diff --git a/cahier_des_charges/charges.txt b/cahier_des_charges/charges.txt deleted file mode 100644 index 21d4b611..00000000 --- a/cahier_des_charges/charges.txt +++ /dev/null @@ -1,159 +0,0 @@ -# Index personnalisés - -Je veux être capable de créer mes propres index. Je ne veux pas choisir dans -une liste prédéfinie, mais pouvoir les personnaliser. Je veux pouvoir leur -donner le titre que je veux. - -## Proposition - -Dans le fichier general.sg, définition d'une liste : - -> indexes = [ -> "auteur", -> ("pays", "Index par pays d'origine"), -> ] - -Ceci signifie que j'aurai deux index : - -- l'un utilisant le mot-clef "auteur", ayant pour titre "Index par auteur" ; -- l'autre utilisant le mot-clef "pays", ayant pour titre "Index par pays d'origine". - -Pour chaque index, le mot clef sortas_nom est disponible, si l'on veut que le -nom qui s'affiche ne soit pas le nom par lequel l'entrée est triée. - -Utiliser la commande \newsongkey : http://songs.sourceforge.net/songsdoc/songs.html#mac.newsongkey - -# Découpage du document - -Je veux pouvoir personnaliser le document, à savoir : mettre ma propre page de -titre, choisir l'ordre des éléments (index au début ou à la fin), ajouter des -pages personnalisées, etc. - -## Proposition - -### Préambule - -Dans le fichier general.sg, définition de variables : - -> preambule = "\usepackage{yfonts}" - -Cette variable permet d'ajouter des choses au préambule. Pour intégrer un fichier complet, il suffit de mettre : - -> preambule = "\input{mon_preambule.tex}" - -### Document - -Dans le fichier general.sg, possibilité de définir la variable document : - -> document = [ -> TITLE, -> INDEXES, -> SONGS, -> "appendice.tex", -> ] - -Ceci signifie que mon document comportera la page de titre, l'index, les textes -des chansons par défaut, et à la fin, intégrera mon document "appendice.tex". - -# Emplacement des chansons - -Je veux pouvoir dire à quelles chansons aller chercher. - -## Proposition - -Dans le fichier general.sg, utilisation des variables SONG_ROOT et SONG_FILES. - -> SONG_ROOT = "~/chansons" -> SONG_FILES = "*/*.tex" - -Il est possible de mettre une liste dans SONG_FILES, pour dire de prendre tous -les éléments de la liste. - -# Langue - -Je veux pouvoir dire dans quel langue est chaque chanson, et que ceci soit -ajouté automatiquement à l'appel de Babel. - -# Référence - -Je veux pouvoir faire référence à des chansons (nom, page, etc.). - -## Proposition - -Faire en sorte que la commande \label fonctionne, ou ajouter un mot-clef -"label" à \beginsong. - -Ensuite, avoir à disposition des commandes \songtitle{ref}, \songpage{ref}, -\songkeyword{ref}{keyword}. - -# Chansons de plusieurs auteurs - -Je veux pouvoir choisir l'ordre de mes chansons (classement par auteur par exemple). - -Je veux pouvoir attribuer des chansons à plusieurs auteurs, et décider dans la -partie de quel auteur elle aparaisse, et qu'elle soit référencée dans d'autre. - -Exemple : Les Oiseaux de passage, de Richepin, chantée par Brassens. Je veux -que le texte apparaisse avec les autres textes de Richepin, avec la mention « -Mise en musique par Brassens », et qu'à un endroit dans la « partie » Brassens, -apparaisse le texte « Voir aussi \songtitle{richepin_oiseau}, page -\songpage{richepin_page} ». La chanson apparaitra pour les deux auteurs dans -l'index par auteur. - -## Proposition - -> \beginsong{Chanson des cloches de baptême}[label=richepin_cloches, author=Richepin] -> \comment{Chantée par \songauthor{brassens_philistins} sous le titre \songtitle{brassens_philistins}.} -> ... -> \endsong -> -> \beginchildsong{Philistins}[parent=richepin_cloches, author=Brassens] -> Voir \songtitle{richepin_cloches}, page \pagetitle{richepin_page}. -> \endsong - -# Possibilité d'exporter en LaTeX ou PDF - -Je veux pouvoir, en ligne de commande, dire que je souhaite un export en LaTeX -ou en PDF. - -# Partitions - -Je veux pouvoir placer mes partitions Lilypond dans le même répertoire que les -chansons correspondantes. - -# PDF - -Je veux pouvoir intégrer des PDF comme chansons (partitions scannées). - -# Traductions - -Je pouvoir intégrer des traductions. - -## Proposition - -Dans le fichier general.sg, une variable avec la langue par défaut pour les -traductions. - -> DEFAULT_TRANSLATION_LANGUAGE = "francais" - -Dans un fichier de chanson : - -> \begin[english]{translation} -> Do not use your spoon with your left hand / etc. -> \end{translation} - -# Commentaires - -Je veux pouvoir ajouter des commentaires dans les chansons, qui soient mis en -valeur différement. - -# Langage du fichier de configuration - -Je propose que le fichier de configuration soit du Python : puisqu'un client -texte existe, nous pouvons considérer que quelqu'un modifiant à la main ce -fichier sait faire du Python. - -# Langues - -Pouvoir définir les langues dans le fichier de configuration general.sg, pour -que babel ne soit pas bloqué. diff --git a/songbook-makeindex.py b/songbook-makeindex.py index 8509aa61..f780ecaa 100755 --- a/songbook-makeindex.py +++ b/songbook-makeindex.py @@ -18,7 +18,7 @@ import sortindex import locale # Pattern set to ignore latex command in title prefix -keywordPattern = re.compile(r"^%(\w+)\s?(\w*)") +keywordPattern = re.compile(r"^%(\w+)\s?(.*)$") firstLetterPattern = re.compile(r"^(?:\{?\\\w+\}?)*[^\w]*(\w)") class index: @@ -37,9 +37,17 @@ class index: self.keywords[key].append(word) def compileKeywords(self): - pass + self.prefix_patterns = [] + if 'prefix' in self.keywords: + for prefix in self.keywords['prefix']: + self.prefix_patterns.append(re.compile(r"^(%s)\b\s*(.*)$" % prefix)) def add(self, key, number, link): + for pattern in self.prefix_patterns: + match = pattern.match(key) + if match: + key = "%s (%s)" % (match.group(2), match.group(1)) + break # Only one match per key (first, key) = self.filter(key) if not self.data.has_key(first): self.data[first] = dict() @@ -85,10 +93,11 @@ def processSXD(filename): type = data[0] i = 1 idx = index() - while data[i].startswith('%'): - keywords = keywordPattern.match(data[i]).groups() - idx.keyword(keywords[0],keywords[1]) - i += 1 + if len(data) > 1: + while data[i].startswith('%'): + keywords = keywordPattern.match(data[i]).groups() + idx.keyword(keywords[0],keywords[1]) + i += 1 idx.compileKeywords() for i in range(i,len(data),3): entry = processSXDEntry(data[i:i+3]) diff --git a/songbook.py b/songbook.py index f443947b..db03fba5 100755 --- a/songbook.py +++ b/songbook.py @@ -4,7 +4,6 @@ import getopt, sys import os.path -import glob import re import json import locale @@ -12,6 +11,8 @@ import shutil import locale import platform +from utils.utils import recursiveFind + reTitle = re.compile('(?<=beginsong\\{)(.(? 0: - out.write(formatDefinition('songslist', songslist(library, songs))) + out.write(formatDefinition('songslist', songslist(library, songs, prefixes))) out.write('\\makeatother\n') # output template @@ -184,7 +203,7 @@ def makeDepend(sb, library, output): # check for deps (in sb data) deps = []; if sb["songs"] == "all": - deps += glob.glob(library + 'songs/*/*.sg') + deps += recursiveFind(os.path.join(library, 'songs'), '*.sg') else: deps += map(lambda x: library + "songs/" + x, sb["songs"]) diff --git a/sortindex.py b/sortindex.py index dd3d5d50..4333e5f2 100644 --- a/sortindex.py +++ b/sortindex.py @@ -28,6 +28,7 @@ replacePattern = { '~n' : 'ñ', "c C" : 'Ç', "c c" : 'ç', + "textquoteright" : "'", } def sortkey(value): diff --git a/templates/ancient.tmpl b/templates/ancient.tmpl index 1575f198..9ed78c52 100644 --- a/templates/ancient.tmpl +++ b/templates/ancient.tmpl @@ -88,6 +88,19 @@ \pagestyle{empty} +% +% Customization of the page appearance +% +\RequirePackage[ + a4paper % paper size + ,includeheadfoot % include header and footer into text size + ,hmarginratio=1:1 % ratio between inner and outer margin (default) + ,outer=1.8cm % outer margin (right) + ,vmarginratio=1:1 % ratio between top and bottom margin + ,bmargin=1.3cm % bottom margin +% ,bindingoffset=1.7cm % space reserved to bound pages together + ]{geometry} + \begin{document} \maketitle diff --git a/templates/minimal.tmpl b/templates/minimal.tmpl index 3bdcd58a..f029c988 100644 --- a/templates/minimal.tmpl +++ b/templates/minimal.tmpl @@ -29,7 +29,8 @@ %%: {"name":"lang", "description":"Language", "default":"english"}, %%: {"name":"instruments", "description":"Instruments", "type":"flag", "values":["guitar","ukulele"], "join":",", "mandatory":true, "default":["guitar"]}, %%: {"name":"bookoptions", "description":"Options", "type":"flag", "values":["diagram","importantdiagramonly","lilypond","pictures","tabs","repeatchords","onesongperpage"], "join":",", "mandatory":true, "default":["pictures"]}, -%%: {"name":"mainfontsize", "description":"Font Size", "type":"font", "default":"10"} +%%: {"name":"mainfontsize", "description":"Font Size", "type":"font", "default":"10"}, +%%: {"name":"titleprefixwords", "description":"Ignore some words in the beginning of song titles"} %%:] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % begin document @@ -49,9 +50,24 @@ \fi% } +\gettitleprefixwords + \nosongnumbers \pagestyle{empty} +% +% Customization of the page appearance +% +\RequirePackage[ + a4paper % paper size + ,includeheadfoot % include header and footer into text size + ,hmarginratio=1:1 % ratio between inner and outer margin (default) + ,outer=1.8cm % outer margin (right) + ,vmarginratio=1:1 % ratio between top and bottom margin + ,bmargin=1.3cm % bottom margin +% ,bindingoffset=1.7cm % space reserved to bound pages together + ]{geometry} + \begin{document} \begin{songs}{} diff --git a/templates/patacrep.tmpl b/templates/patacrep.tmpl index 9b78917b..a14d85ca 100644 --- a/templates/patacrep.tmpl +++ b/templates/patacrep.tmpl @@ -42,7 +42,8 @@ %%: {"name":"mainfontsize", "description":"Font Size", "type":"font", "default":"10"}, %%: {"name":"songnumberbgcolor", "description":"Number Shade", "type":"color", "default":"#D1E4AE"}, %%: {"name":"notebgcolor", "description":"Note Shade", "type":"color", "default":"#D1E4AE"}, -%%: {"name":"indexbgcolor", "description":"Index Shade", "type":"color", "default":"#D1E4AE"} +%%: {"name":"indexbgcolor", "description":"Index Shade", "type":"color", "default":"#D1E4AE"}, +%%: {"name":"titleprefixwords", "description":"Ignore some words in the beginning of song titles"} %%:] %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % begin document @@ -84,8 +85,23 @@ \renewcommand{\notebgcolor}{NoteBgColor} \renewcommand{\idxbgcolor}{IndexBgColor} +\gettitleprefixwords + \pagestyle{empty} +% +% Customization of the page appearance +% +\RequirePackage[ + a4paper % paper size + ,includeheadfoot % include header and footer into text size + ,hmarginratio=1:1 % ratio between inner and outer margin (default) + ,outer=1.8cm % outer margin (right) + ,vmarginratio=1:1 % ratio between top and bottom margin + ,bmargin=1.3cm % bottom margin +% ,bindingoffset=1.7cm % space reserved to bound pages together + ]{geometry} + \begin{document} % translate default title diff --git a/tex/crepbook.cls b/tex/crepbook.cls index b61d24ac..7bd8c952 100644 --- a/tex/crepbook.cls +++ b/tex/crepbook.cls @@ -54,7 +54,7 @@ \ProcessOptions % Base class -\LoadClass[a4paper]{article} +\LoadClass{article} % Main packages \RequirePackage{graphicx,xcolor} @@ -335,19 +335,6 @@ \renewcommand{\idxheadfont}{\sffamily\it\LARGE} \renewcommand{\idxrefsfont}{\bfseries} -% -% Customization of the page appearance -% -\RequirePackage[ - a4paper % paper size - ,includeheadfoot % include header and footer into text size - ,hmarginratio=1:1 % ratio between inner and outer margin (default) - ,outer=1.8cm % outer margin (right) - ,vmarginratio=1:1 % ratio between top and bottom margin - ,bmargin=1.3cm % bottom margin -% ,bindingoffset=1.7cm % space reserved to bound pages together - ]{geometry} - % Paragraph indentation space \setlength{\parindent}{0.3cm} diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/utils/resize-cover.py b/utils/resize-cover.py index c7f9daf3..21964487 100755 --- a/utils/resize-cover.py +++ b/utils/resize-cover.py @@ -6,10 +6,11 @@ #Description: Resize all covers to 128,128 thumbnails import Image -import glob + +from utils.utils import recursiveFind # Process song files -covers = glob.glob('songs/*/*.jpg') +covers = recursiveFind(os.path.join(library, 'songs'), '*.jpg') for filename in covers: source = Image.open(filename) diff --git a/utils/rules.py b/utils/rules.py index b1dfbb11..52b6e0b3 100755 --- a/utils/rules.py +++ b/utils/rules.py @@ -8,6 +8,8 @@ import logging import locale re.LOCALE +from utils.utils import recursiveFind + # the dictionary has target_word:replacement_word pairs word_dic = { ##: oe inclusion @@ -236,7 +238,7 @@ def main(): usage() sys.exit(2) - songfiles = glob.glob('songs/*/*.sg') + songfiles = recursiveFind(os.path.join(library, 'songs'), '*.sg') loglevel = "warning" for option, arg in opts: diff --git a/utils/songbook-gtab.py b/utils/songbook-gtab.py index 3a67355c..c89411e8 100755 --- a/utils/songbook-gtab.py +++ b/utils/songbook-gtab.py @@ -2,10 +2,11 @@ # import sys -import glob import re from optparse import OptionParser +from utils.utils import recursiveFind + # Pattern set to ignore latex command in title prefix gtabPattern = re.compile(r"\\gtab\{(.*)\}\{(.*)\}"); @@ -26,7 +27,7 @@ def main(): chords = dict() positions = dict() - songfiles = glob.glob('songs/*/*.sg') + songfiles = recursiveFind(os.path.join(library, 'songs'), '*.sg') for file in songfiles: for line in open(file): diff --git a/utils/utils.py b/utils/utils.py new file mode 100644 index 00000000..576c66b2 --- /dev/null +++ b/utils/utils.py @@ -0,0 +1,13 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# + +import fnmatch +import os + +def recursiveFind(root_directory, pattern): + matches = [] + for root, dirnames, filenames in os.walk(root_directory): + for filename in fnmatch.filter(filenames, pattern): + matches.append(os.path.join(root, filename)) + return matches