mirror of
https://gitlab.com/parroquia-san-leandro/cancionero-web.git
synced 2024-12-22 08:43:33 +01:00
Small fixes
* data format * replace js link to a tag * css fixes * changed link structure to /{number}/{name}/
This commit is contained in:
parent
9f4e8b89fc
commit
ae5e6b6cf0
5 changed files with 34 additions and 11 deletions
|
@ -15,6 +15,11 @@
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.songs li a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
.songs li:hover {
|
.songs li:hover {
|
||||||
color: #607D8B;
|
color: #607D8B;
|
||||||
background-color: #DDD;
|
background-color: #DDD;
|
||||||
|
@ -54,4 +59,4 @@
|
||||||
min-height: 1.8em;
|
min-height: 1.8em;
|
||||||
margin-right: .8em;
|
margin-right: .8em;
|
||||||
border-radius: 4px 0 0 4px;
|
border-radius: 4px 0 0 4px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
<li onclick="window.location = '%s'"%s>
|
<li%s>
|
||||||
<span class="numberBadge">%d. </span>
|
<a href="%s">
|
||||||
%s%s%s
|
<span class="numberBadge">%d. </span>
|
||||||
|
%s%s%s
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
9
res/song_redir.html
Normal file
9
res/song_redir.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="refresh" content="0; url = {0}">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a href="{0}">Redirigiendo a la canción, haz click aquí si no sucede de forma automática.</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -7,6 +7,10 @@ import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def mkdir(path):
|
||||||
|
if not os.path.exists(path):
|
||||||
|
os.mkdir(path)
|
||||||
|
|
||||||
# Note that re.match prepends ^ to the pattern, whereas re.search doesn't
|
# Note that re.match prepends ^ to the pattern, whereas re.search doesn't
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +31,7 @@ def extra_put(extra, index, the_type, data=None):
|
||||||
page_template = readfile("res/page.html")
|
page_template = readfile("res/page.html")
|
||||||
index_template = readfile("res/index.html")
|
index_template = readfile("res/index.html")
|
||||||
index_per_song_template = readfile("res/song_li.html")
|
index_per_song_template = readfile("res/song_li.html")
|
||||||
|
song_redir_template = readfile("res/song_redir.html")
|
||||||
index_css = '<link rel="stylesheet" href="main.css">\n\t<link rel="stylesheet" href="index.css">'
|
index_css = '<link rel="stylesheet" href="main.css">\n\t<link rel="stylesheet" href="index.css">'
|
||||||
song_css = '<link rel="stylesheet" href="../song.css">\n\t<link rel="stylesheet" href="../main.css">'
|
song_css = '<link rel="stylesheet" href="../song.css">\n\t<link rel="stylesheet" href="../main.css">'
|
||||||
|
|
||||||
|
@ -220,8 +225,8 @@ class SongLoader:
|
||||||
def print_index(self, index_file="index.html"):
|
def print_index(self, index_file="index.html"):
|
||||||
self.songs = sorted(self.songs, key=lambda s: s.number)
|
self.songs = sorted(self.songs, key=lambda s: s.number)
|
||||||
body = index_template % join_list([index_per_song_template %
|
body = index_template % join_list([index_per_song_template %
|
||||||
(s.get_url(),
|
(' class="hasChords"' if not s.chorded() else '',
|
||||||
' class="hasChords"' if not s.chorded() else '',
|
s.get_url(),
|
||||||
s.number, s.name,
|
s.number, s.name,
|
||||||
" por %s " % s.author if s.author else "",
|
" por %s " % s.author if s.author else "",
|
||||||
" basado en %s " % s.origin if s.origin else "")
|
" basado en %s " % s.origin if s.origin else "")
|
||||||
|
@ -231,9 +236,12 @@ class SongLoader:
|
||||||
|
|
||||||
def print_songs(self, directory="."):
|
def print_songs(self, directory="."):
|
||||||
for song in self.songs:
|
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()))
|
||||||
song_dir = join(directory, song.get_url())
|
song_dir = join(directory, song.get_url())
|
||||||
if not os.path.exists(song_dir):
|
mkdir(song_dir)
|
||||||
os.mkdir(song_dir)
|
|
||||||
with open(join(song_dir, "index.html"), 'w') as f:
|
with open(join(song_dir, "index.html"), 'w') as f:
|
||||||
f.write(page_template % (song_css, str(song)))
|
f.write(page_template % (song_css, str(song)))
|
||||||
|
|
||||||
|
@ -247,8 +255,7 @@ def copy_static(source_dir, target_dir):
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
loader = SongLoader("latex/cancionero.tex")
|
loader = SongLoader("latex/cancionero.tex")
|
||||||
target_dir = "public/"
|
target_dir = "public/"
|
||||||
if not os.path.exists(target_dir):
|
mkdir(target_dir)
|
||||||
os.mkdir(target_dir)
|
|
||||||
loader.print_songs(target_dir)
|
loader.print_songs(target_dir)
|
||||||
loader.print_index(target_dir + "index.html")
|
loader.print_index(target_dir + "index.html")
|
||||||
copy_static("res", target_dir)
|
copy_static("res", target_dir)
|
||||||
|
|
|
@ -224,7 +224,7 @@ class Audio:
|
||||||
def __init__(self, date, audio_file):
|
def __init__(self, date, audio_file):
|
||||||
assert isinstance(date, datetime)
|
assert isinstance(date, datetime)
|
||||||
self.date = date
|
self.date = date
|
||||||
self.date_text = date.strftime("%A %d de %B del %Y")
|
self.date_text = date.strftime("%A %-d de %B del %Y")
|
||||||
self.audio_file = audio_file
|
self.audio_file = audio_file
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
Loading…
Reference in a new issue