mirror of
https://gitlab.com/parroquia-san-leandro/cancionero-web.git
synced 2025-04-29 12:56:07 +02:00
Move to less, improved style, fixed bugs
* Redirection wasn't being encoded properly * CSS to LESS transition * Improved Makefile * Explained red color in index * Unified link and button styles
This commit is contained in:
parent
67bedb49e4
commit
c7bca76c8c
14 changed files with 233 additions and 185 deletions
|
@ -3,6 +3,7 @@ from audio_scanner import find_audios
|
|||
from os.path import join
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import urllib.parse
|
||||
import os
|
||||
import re
|
||||
|
||||
|
@ -232,26 +233,28 @@ class SongLoader:
|
|||
|
||||
def print_index(self, index_file="index.html"):
|
||||
self.songs = sorted(self.songs, key=lambda s: s.number)
|
||||
body = index_template % join_list([index_per_song_template %
|
||||
(' class="hasChords"' if not s.chorded() else '',
|
||||
s.get_url(),
|
||||
s.number, s.name,
|
||||
" por %s " % s.author if s.author else "",
|
||||
" basado en %s " % s.origin if s.origin else "")
|
||||
for s in self.songs])
|
||||
song_list = join_list([index_per_song_template.format(
|
||||
url=s.get_url(),
|
||||
li_class=' class="hasChords"' if not s.chorded() else '',
|
||||
number=s.number,
|
||||
name=s.name,
|
||||
author=" por %s " % s.author if s.author else "",
|
||||
origin=" basado en %s " % s.origin if s.origin else "")
|
||||
for s in self.songs])
|
||||
body = index_template.format(list_content=song_list)
|
||||
with open(index_file, 'w') as f:
|
||||
f.write(page_template % (index_css, body))
|
||||
f.write(page_template.format(css=index_css, main=body))
|
||||
|
||||
def print_songs(self, directory="."):
|
||||
for song in self.songs:
|
||||
num_dir = join(directory, "%03d" % (song.number))
|
||||
mkdir(num_dir)
|
||||
with open(join(num_dir, "index.html"), 'w') as f:
|
||||
f.write(song_redir_template.format("../" + song.get_url()))
|
||||
f.write(song_redir_template.format(url=urllib.parse.quote("../" + song.get_url())))
|
||||
song_dir = join(directory, song.get_url())
|
||||
mkdir(song_dir)
|
||||
with open(join(song_dir, "index.html"), 'w') as f:
|
||||
f.write(page_template % (song_css, str(song)))
|
||||
f.write(page_template.format(css=song_css, main=str(song)))
|
||||
|
||||
|
||||
def copy_static(source_dir, target_dir):
|
||||
|
|
|
@ -32,17 +32,17 @@ class Song:
|
|||
self.category = category
|
||||
|
||||
def __str__(self):
|
||||
return song_template % (
|
||||
self.name,
|
||||
"<div>Autor: %s</div>" % self.author if self.author else "",
|
||||
"<div>Basada en: %s</div>" % self.origin if self.origin else "",
|
||||
"""<div *ngIf="song.capo != 0"><span class="capo">Tono original: Cejilla {s.capo}</span>
|
||||
return song_template.format(
|
||||
name=self.name,
|
||||
author="<div>Autor: %s</div>" % self.author if self.author else "",
|
||||
origin="<div>Basada en: %s</div>" % self.origin if self.origin else "",
|
||||
capo_settings="""<div><span class="capo">Tono original: Cejilla {s.capo}</span>
|
||||
<button style="margin-left: 0.5em;" onclick="transpose({s.capo})">Transponer para quitarla</button></div>"""
|
||||
.format(s=self) if self.capo != 0 else "",
|
||||
join_list(self.verses),
|
||||
"<h3>Audios</h3>" if len(self.audios) > 0 else "",
|
||||
join_list(self.audios),
|
||||
self.latex_file)
|
||||
song_html=join_list(self.verses),
|
||||
audios_header="<h3>Audios</h3>" if len(self.audios) > 0 else "",
|
||||
audios_html=join_list(self.audios),
|
||||
latex_file=self.latex_file)
|
||||
|
||||
def set_capo(self, capo):
|
||||
self.capo = capo
|
||||
|
@ -230,7 +230,7 @@ class Audio:
|
|||
def __str__(self):
|
||||
return """
|
||||
<div>
|
||||
Audio del %s (<a href="%s">descarga</a>)
|
||||
Audio del %s <a href="%s"><span>Descargar</span></a>
|
||||
<audio controls style='width: 100%%;'>
|
||||
<source src='%s' type='audio/mpeg'/>
|
||||
</audio>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue