diff --git a/cahier_des_charges/charges.txt b/cahier_des_charges/charges.txt new file mode 100644 index 00000000..21d4b611 --- /dev/null +++ b/cahier_des_charges/charges.txt @@ -0,0 +1,159 @@ +# 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 41b4b3df..db03fba5 100755 --- a/songbook.py +++ b/songbook.py @@ -50,7 +50,17 @@ def makeCoverCache(library): def matchRegexp(reg, iterable): return [ m.group(1) for m in (reg.match(l) for l in iterable) if m ] -def songslist(library, songs): +def unprefixed(title, prefixes): + """Remove the first prefix of the list in the beginning of title (if any). + """ + for prefix in prefixes: + match = re.compile(r"^(%s)\b\s*(.*)$" % prefix).match(title) + if match: + return match.group(2) + return title + + +def songslist(library, songs, prefixes): song_objects = [] for s in songs: path = library + 'songs/' + s @@ -65,7 +75,7 @@ def songslist(library, songs): album = '' song_objects.append(Song(title, artist, album, path)) - song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(x.title)) + song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(unprefixed(x.title, prefixes))) song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(x.album)) song_objects = sorted(song_objects, key=lambda x: locale.strxfrm(x.artist)) @@ -122,6 +132,8 @@ def makeTexFile(sb, library, output): # default value template = "patacrep.tmpl" songs = [] + titleprefixwords = "" + prefixes = [] # parse the songbook data if "template" in sb: @@ -130,6 +142,12 @@ def makeTexFile(sb, library, output): if "songs" in sb: songs = sb["songs"] del sb["songs"] + if "titleprefixwords" in sb: + prefixes = sb["titleprefixwords"] + for prefix in sb["titleprefixwords"]: + titleprefixwords += "\\titleprefixword{%s}\n" % prefix + sb["titleprefixwords"] = titleprefixwords + parameters = parseTemplate("templates/"+template) @@ -152,7 +170,7 @@ def makeTexFile(sb, library, output): songs = map(lambda x: x[len(library) + 6:], recursiveFind(os.path.join(library, 'songs'), '*.sg')) if len(songs) > 0: - out.write(formatDefinition('songslist', songslist(library, songs))) + out.write(formatDefinition('songslist', songslist(library, songs, prefixes))) out.write('\\makeatother\n') # output template 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}