mirror of
https://gitlab.com/parroquia-san-leandro/cancionero-web.git
synced 2025-04-27 23:55:57 +02: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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue