Small fixes

* data format
* replace js link to a tag
* css fixes
* changed link structure to /{number}/{name}/
This commit is contained in:
Carlos Galindo 2020-12-07 18:18:47 +01:00
parent 9f4e8b89fc
commit ae5e6b6cf0
5 changed files with 34 additions and 11 deletions

View file

@ -15,6 +15,11 @@
border-radius: 4px;
}
.songs li a {
color: inherit;
text-decoration: inherit;
}
.songs li:hover {
color: #607D8B;
background-color: #DDD;

View file

@ -1,4 +1,6 @@
<li onclick="window.location = '%s'"%s>
<span class="numberBadge">%d. </span>
%s%s%s
<li%s>
<a href="%s">
<span class="numberBadge">%d. </span>
%s%s%s
</a>
</li>

9
res/song_redir.html Normal file
View 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>

View file

@ -7,6 +7,10 @@ import os
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
@ -27,6 +31,7 @@ def extra_put(extra, index, the_type, data=None):
page_template = readfile("res/page.html")
index_template = readfile("res/index.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">'
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"):
self.songs = sorted(self.songs, key=lambda s: s.number)
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,
" por %s " % s.author if s.author else "",
" basado en %s " % s.origin if s.origin else "")
@ -231,9 +236,12 @@ class SongLoader:
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()))
song_dir = join(directory, song.get_url())
if not os.path.exists(song_dir):
os.mkdir(song_dir)
mkdir(song_dir)
with open(join(song_dir, "index.html"), 'w') as f:
f.write(page_template % (song_css, str(song)))
@ -247,8 +255,7 @@ def copy_static(source_dir, target_dir):
if __name__ == '__main__':
loader = SongLoader("latex/cancionero.tex")
target_dir = "public/"
if not os.path.exists(target_dir):
os.mkdir(target_dir)
mkdir(target_dir)
loader.print_songs(target_dir)
loader.print_index(target_dir + "index.html")
copy_static("res", target_dir)

View file

@ -224,7 +224,7 @@ class Audio:
def __init__(self, date, audio_file):
assert isinstance(date, datetime)
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
def __str__(self):