diff --git a/res/index.css b/res/index.css
index 7389f52..5c71a9c 100644
--- a/res/index.css
+++ b/res/index.css
@@ -15,6 +15,11 @@
border-radius: 4px;
}
+.songs li a {
+ color: inherit;
+ text-decoration: inherit;
+}
+
.songs li:hover {
color: #607D8B;
background-color: #DDD;
@@ -54,4 +59,4 @@
min-height: 1.8em;
margin-right: .8em;
border-radius: 4px 0 0 4px;
-}
\ No newline at end of file
+}
diff --git a/res/song_li.html b/res/song_li.html
index 02c689e..d771c9b 100644
--- a/res/song_li.html
+++ b/res/song_li.html
@@ -1,4 +1,6 @@
-
- %d.
- %s%s%s
+
+
+ %d.
+ %s%s%s
+
diff --git a/res/song_redir.html b/res/song_redir.html
new file mode 100644
index 0000000..ad1be43
--- /dev/null
+++ b/res/song_redir.html
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+ Redirigiendo a la canción, haz click aquí si no sucede de forma automática.
+
+
diff --git a/src/latex_scanner.py b/src/latex_scanner.py
index e2bdd33..57b2e0f 100644
--- a/src/latex_scanner.py
+++ b/src/latex_scanner.py
@@ -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 = '\n\t'
song_css = '\n\t'
@@ -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)
diff --git a/src/song_types.py b/src/song_types.py
index 8082c61..cd80148 100644
--- a/src/song_types.py
+++ b/src/song_types.py
@@ -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):