diff --git a/build_pages.py b/build_pages.py index b74da2c..dc240fd 100644 --- a/build_pages.py +++ b/build_pages.py @@ -1,11 +1,12 @@ import sqlite3 import jinja2 import os +import shutil for dirname in [ "public/song", "public/motif", - "public/album", + "public/album" ]: os.makedirs(dirname, exist_ok=True) @@ -14,21 +15,40 @@ songplate = environment.get_template("songpage.jinja") db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True) +# generate song pages -for song in db.execute("SELECT name FROM song"): - filename = f"public/song/{song[0]}" +for id, name, name_jp in db.execute(''' + select + id, name, name_jp + from + song + '''): + + # query album info + + album_info = db.execute(''' + select + album_id, track, album.name, album.code + from + song_album + join + album + on + song_album.album_id=album.id + where + song_id = ? + ''', + (id,) + ).fetchall() + + print(album_info) + + filename = f"public/song/{id:04}" content = songplate.render( - songname=song[0], - clips=() + name=name, + id=id, + album_info=album_info ) with open(filename, mode="w") as file: file.write(content) - print(f"... wrote {filename}") - -# template = environment.from_string("Now Playing: {{ song }}") -# for songname in songnames: -# print( -# template.render( -# song=songname[0] -# ) -# ) \ No newline at end of file + print(f"... wrote {filename}") \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..cb529ce --- /dev/null +++ b/deploy.sh @@ -0,0 +1,2 @@ +sudo rm -r /var/www/eorzea-songbook +sudo cp -r public/ /var/www/eorzea-songbook \ No newline at end of file diff --git a/templates/songpage.jinja b/templates/songpage.jinja index 55f3a42..5cbbeed 100644 --- a/templates/songpage.jinja +++ b/templates/songpage.jinja @@ -7,7 +7,15 @@ -

Now Playing: {{ songname }}

- +

Now Playing: {{ id }}. {{ name }} ({% for _, _, _, album_code in album_info %}{{ album_code }}{% if not loop.last %}, {% endif %}{% endfor %}) +

+

Artist:

+

Album:

+ +

Clips: