diff --git a/makefile b/makefile index c2496e10..92c28e4a 100644 --- a/makefile +++ b/makefile @@ -82,10 +82,10 @@ $(PDF): %.pdf: %.tex %.aux $(MAKE_INDEX) --library=$(LIBRARY) $< > $@ %.tex: $(BOOKS_DIR)/%.sb - $(MAKE_SONGBOOK) --cache --library=$(LIBRARY) -s $< -o $@ + $(MAKE_SONGBOOK) --library=$(LIBRARY) -s $< -o $@ %.d: $(BOOKS_DIR)/%.sb - $(MAKE_SONGBOOK) --cache --library=$(LIBRARY) -s $< -d -o $@ + $(MAKE_SONGBOOK) --library=$(LIBRARY) -s $< -d -o $@ %.pdf: %.ly @$(LILYPOND) --format=pdf -e '(define-public songbookstaff "$(SONGBOOKSTAFF)")' --output=$(@:%.pdf=%) $< diff --git a/songbook.py b/songbook.py index f3422c9a..d8741a08 100755 --- a/songbook.py +++ b/songbook.py @@ -25,16 +25,9 @@ class Song: return repr((self.title, self.artist, self.album, self.path)) from xdg.BaseDirectory import * +cachePath = os.path.join(xdg_cache_home, 'songbook') -print 'xdg_data_home: %s' % xdg_data_home -print 'xdg_data_dirs: %s' % xdg_data_dirs -print 'xdg_config_home: %s' % xdg_config_home -print 'xdg_config_dirs: %s' % xdg_config_dirs -print 'xdg_cache_home: %s' % xdg_cache_home - -songbook_cache_home = os.path.join(xdg_cache_home, 'songbook') - -def makeCoverCache(library, cachePath): +def makeCoverCache(library): ''' Copy all pictures found in the libraries into a unique cache folder. @@ -157,13 +150,16 @@ def makeTexFile(sb, library, output): out.write(formatDefinition('songslist', songslist(library, songs))) out.write('\\makeatother\n') - # output grapihcs path - #out.write('\\graphicspath{ {img/}, {' + songbook_cache_home + '/images/} }\n') - # output template commentPattern = re.compile(r"^\s*%") f = open("templates/"+template) content = [ line for line in f if not commentPattern.match(line) ] + + for index, line in enumerate(content): + if re.compile("getcachedirectory").search(line): + line = line.replace("\\getcachedirectory", cachePath + "/") + content[index] = line + f.close() out.write(''.join(content)) @@ -215,7 +211,7 @@ def main(): try: opts, args = getopt.getopt(sys.argv[1:], "hs:o:d:l", - ["help","songbook=","output=","depend","cache","library="]) + ["help","songbook=","output=","depend","library="]) except getopt.GetoptError, err: # print help and exit print str(err) @@ -225,15 +221,12 @@ def main(): songbook = None depend = False output = None - cache = False library = './' for o, a in opts: if o in ("-h", "--help"): usage() sys.exit() - elif o in ("--cache"): - cache = True elif o in ("-s", "--songbook"): songbook = a elif o in ("-d", "--depend"): @@ -245,7 +238,7 @@ def main(): else: assert False, "unhandled option" - makeCoverCache(library, os.path.join(songbook_cache_home, 'images')) + makeCoverCache(library) if songbook and output: f = open(songbook) sb = json.load(f) diff --git a/templates/ancient.tmpl b/templates/ancient.tmpl index 28a080f6..76edaeab 100644 --- a/templates/ancient.tmpl +++ b/templates/ancient.tmpl @@ -68,7 +68,7 @@ \newindex{titleidx}{\getname_title} \newauthorindex{authidx}{\getname_auth} -\graphicspath{ {covers/}, {img/} } +\graphicspath{ {img/}, {\getcachedirectory} } \definecolor{SongNumberBgColor}{HTML}{\getsongnumberbgcolor} \definecolor{NoteBgColor}{HTML}{\getnotebgcolor} diff --git a/templates/minimal.tmpl b/templates/minimal.tmpl index fdbfffa3..e9033363 100644 --- a/templates/minimal.tmpl +++ b/templates/minimal.tmpl @@ -41,7 +41,7 @@ \usepackage[italian,portuguese,spanish,english,french]{babel} \lang{\getlang} -\graphicspath{ {covers/}, {img/} } +\graphicspath{ {img/}, {\getcachedirectory} } \nosongnumbers \pagestyle{empty} diff --git a/templates/patacrep.tmpl b/templates/patacrep.tmpl index 1a226c9c..3ce21261 100644 --- a/templates/patacrep.tmpl +++ b/templates/patacrep.tmpl @@ -68,7 +68,7 @@ \newindex{titleidx}{\getname_title} \newauthorindex{authidx}{\getname_auth} -\graphicspath{ {covers/}, {img/} } +\graphicspath{ {img/}, {\getcachedirectory} } \definecolor{SongNumberBgColor}{HTML}{\getsongnumberbgcolor} \definecolor{NoteBgColor}{HTML}{\getnotebgcolor}