mirror of
https://gitlab.com/parroquia-san-leandro/cancionero-web.git
synced 2026-01-28 13:07:58 +01:00
Rediseño de la interfaz y arreglos menores
- ¡Ahora con tema oscuro! Se activa según el navegador del usuario. - URL de audios simplificada. - Nuevos iconos para canciones con acordes/audios. - Enlaces de la cabecera actualizados. - Siempre mostramos los ajustes. - Insertar espacio forzoso para separar algunas palabras que se juntaban. - Soporte para canciones con dos líneas de acordes (e.g. Engrandece).
This commit is contained in:
parent
e838b066de
commit
03522304fa
15 changed files with 203 additions and 83 deletions
38
src/model.py
38
src/model.py
|
|
@ -40,7 +40,7 @@ class Song:
|
|||
self.verses.append(verse)
|
||||
|
||||
def url(self):
|
||||
return "%03d %s" % (self.number, self.name.replace("¿", "").replace("?", ""))
|
||||
return "%03d %s/" % (self.number, self.name.replace("¿", "").replace("?", ""))
|
||||
|
||||
def chorded(self):
|
||||
for v in self.verses:
|
||||
|
|
@ -48,6 +48,9 @@ class Song:
|
|||
return True
|
||||
return False
|
||||
|
||||
def has_audios(self):
|
||||
return len(self.audios) > 0
|
||||
|
||||
|
||||
class Verse:
|
||||
def __init__(self, is_chorus=False):
|
||||
|
|
@ -149,6 +152,7 @@ class Line:
|
|||
self.lyric_arr.append(Line.ECHO_BEGIN if inside_echo else '')
|
||||
mid = True
|
||||
self.lyric_arr[-1] += self.text[i]
|
||||
self.lyric_arr = [re.sub(r'^ | $', ' ', l) for l in self.lyric_arr]
|
||||
self.lyric_arr = [l if l != "" else " " for l in self.lyric_arr]
|
||||
|
||||
def remove_brackets(self):
|
||||
|
|
@ -162,8 +166,8 @@ class Line:
|
|||
return False
|
||||
|
||||
|
||||
def chord_eng2lat(text):
|
||||
return Chord.CHORDS_LAT[Chord.ENG_INDEX[text]]
|
||||
def chord_eng2lat(text, transpose = 0):
|
||||
return Chord.CHORDS_LAT[(Chord.ENG_INDEX[text] + transpose + len(Chord.CHORDS_LAT)) % len(Chord.CHORDS_LAT)]
|
||||
|
||||
|
||||
class Chord:
|
||||
|
|
@ -172,28 +176,34 @@ class Chord:
|
|||
CHORDS_ENG = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'B&', 'B']
|
||||
ENG_INDEX = {'C': 0, 'C#': 1, 'D&': 1, 'D': 2, 'D#': 3, 'E&': 3, 'E': 4, 'F&': 4, 'F': 5, 'E#': 5, 'F#': 6, 'G&': 6, 'G': 7, 'G#': 8, 'A&': 8, 'A': 9, 'A#': 10, 'B&': 10, 'B': 11, 'C&': 11, 'B#': 0}
|
||||
|
||||
def __init__(self, text, base_transpose=0):
|
||||
def __init__(self, text, transpose = 0, trfmt = "normal"):
|
||||
self.text = text + " "
|
||||
self.items = []
|
||||
self.base_transpose = base_transpose
|
||||
self.items_n = [] # normal version
|
||||
self.items_t = [] # transposed version
|
||||
self.transpose = transpose
|
||||
self.trfmt = trfmt
|
||||
ignore = False
|
||||
for i, char in enumerate(text):
|
||||
if ignore:
|
||||
ignore = False
|
||||
continue
|
||||
if "A" <= char <= "G":
|
||||
if len(self.items) > 0 and not self.items[-1]['text'].endswith(" "):
|
||||
self.items[-1]['text'] += " "
|
||||
if len(self.items_n) > 0 and not self.items_n[-1]['text'].endswith(" "):
|
||||
self.items_n[-1]['text'] += " "
|
||||
self.items_t[-1]['text'] += " "
|
||||
if len(text) > i + 1 and (text[i + 1] == "#" or text[i + 1] == "&"):
|
||||
self.items.append({'text': chord_eng2lat(char + text[i + 1]), 'chord': True})
|
||||
self.items_n.append({'text': chord_eng2lat(char + text[i + 1]), 'chord': True})
|
||||
self.items_t.append({'text': chord_eng2lat(char + text[i + 1], transpose), 'chord': True})
|
||||
ignore = True
|
||||
else:
|
||||
self.items.append({'text': chord_eng2lat(char), 'chord': True})
|
||||
self.items_n.append({'text': chord_eng2lat(char), 'chord': True})
|
||||
self.items_t.append({'text': chord_eng2lat(char, transpose), 'chord': True})
|
||||
else:
|
||||
self.items.append({'text': char, 'chord': False})
|
||||
if len(self.items) > 0 and not self.items[-1]['text'].endswith(" "):
|
||||
self.items[-1]['text'] += " "
|
||||
|
||||
self.items_n.append({'text': char, 'chord': False})
|
||||
self.items_t.append({'text': char, 'chord': False})
|
||||
if len(self.items_n) > 0 and not self.items_n[-1]['text'].endswith(" "):
|
||||
self.items_n[-1]['text'] += " "
|
||||
self.items_t[-1]['text'] += " "
|
||||
|
||||
def __str__(self):
|
||||
return self.text
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue