mirror of
https://gitlab.com/parroquia-san-leandro/cancionero-web.git
synced 2025-04-29 12:56:07 +02:00
Add categories and favicon
* Reorganize resource directories (templates, less, static) * Show categories on index * Add favicon
This commit is contained in:
parent
7e517112f7
commit
3eaed2eaa8
17 changed files with 180 additions and 64 deletions
|
@ -38,9 +38,8 @@ class SongLoader:
|
|||
self.category = None
|
||||
self.categories = []
|
||||
self.songs = []
|
||||
self.scan(latex_file)
|
||||
self.memory = {}
|
||||
self.audio_dir = audio_dir
|
||||
self.scan(latex_file)
|
||||
|
||||
def scan(self, latex_file):
|
||||
main_file = open(latex_file, 'r')
|
||||
|
@ -228,9 +227,16 @@ class SongLoader:
|
|||
continue
|
||||
current_verse.add_line(Line(text, extras))
|
||||
|
||||
def sort_categories(self):
|
||||
result = {}
|
||||
for c in self.categories:
|
||||
result[c] = sorted([s for s in self.songs if s.category == c],
|
||||
key=lambda s: s.number)
|
||||
return result
|
||||
|
||||
def print_index(self, index_file, dj_engine):
|
||||
songs = sorted(self.songs, key=lambda s: s.number)
|
||||
html = dj_engine.get_template("index.html").render(Context({'songs': songs}))
|
||||
context = Context({'sorted_categories': self.sort_categories()})
|
||||
html = dj_engine.get_template("index.html").render(context)
|
||||
with open(index_file, 'w') as f:
|
||||
f.write(html)
|
||||
|
||||
|
@ -264,5 +270,5 @@ if __name__ == '__main__':
|
|||
args = parse_args()
|
||||
loader = SongLoader(args.latex[0], args.audios[0])
|
||||
settings.configure(USE_TZ=False, USE_I18N=False)
|
||||
e = Engine(dirs=["res/html/"])
|
||||
e = Engine(dirs=["res/templates/"])
|
||||
loader.generate_html(args.output_dir[0], e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue