diff --git a/app.py b/app.py index bbdc625..b60900f 100644 --- a/app.py +++ b/app.py @@ -5,14 +5,92 @@ app = flask.Flask('songbook') # BLANK PAGE -# @app.route('/album/') -# def page(id): +# @app.route('/') +# def page(): # db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True) -# return flask.render_template('motif.jinja', +# return flask.render_template('.jinja', # ) +# HOMEPAGE + +@app.route('/') +def homepage(): + + + + return flask.render_template('home.jinja') + +# SONG INDEX + +@app.route('/song') +def song_redirect(): + return flask.redirect("/index", code=308) + +@app.route('/index') +def songindex(): + + db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True) + + album_info = db.execute(''' + select + id, name, date + from + album + order by + id + ''').fetchall() + + song_info = db.execute(''' + select + song_id, album_id, track, song.name, song.name_jp + from + song_album + join + song + on + song_album.song_id=song.id + order by + album_id, + track + ''').fetchall() + + return flask.render_template('songindex.jinja', + album_info=album_info, + song_info=song_info + ) + +# MOTIF INDEX + +@app.route('/motif') +def motifindex(): + + db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True) + + category_info = db.execute(''' + select + id, name + from + category + order by + id + ''').fetchall() + + motif_info = db.execute(''' + select + id, name, category + from + motif + order by + id + ''').fetchall() + + return flask.render_template('motifindex.jinja', + category_info = category_info, + motif_info = motif_info + ) + # ALBUM PAGES @app.route('/album/') diff --git a/build_db.py b/build_db.py index 517b43d..dc0951c 100644 --- a/build_db.py +++ b/build_db.py @@ -39,7 +39,7 @@ cur.executemany( # import motif cur.executemany( - 'insert into motif(id,name,type) values(?, ?, ?)', + 'insert into motif(id,name,category) values(?, ?, ?)', ((row[0],row[1],'' if len(row)<3 else row[2]) for row in clipdata['Motif'][1:]) ) @@ -49,6 +49,12 @@ cur.executemany( ((row[0],row[1],row[2],row[3],0 if len(row)<5 else row[4]) for row in clipdata['Clip'][1:]) ) +# import category +cur.executemany( + 'insert into category(id,name) values (?, ?)', + clipdata['Category'][1:] +) + # import song x album cur.executemany( "insert into song_album(song_id,album_id,track) values (?, ?, ?)", diff --git a/db.sql b/db.sql index f636c68..ccf6219 100644 --- a/db.sql +++ b/db.sql @@ -32,7 +32,12 @@ create table credit( create table motif( id int primary key, name text not null, - type int not null + category int not null +); + +create table category( + id int primary key, + name text not null ); create table clip( diff --git a/reference_clips.ods b/reference_clips.ods index 0b3983c..69fca46 100644 Binary files a/reference_clips.ods and b/reference_clips.ods differ diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..e69de29 diff --git a/templates/album.jinja b/templates/album.jinja index a25df5a..c6bb87a 100644 --- a/templates/album.jinja +++ b/templates/album.jinja @@ -1,4 +1,4 @@ -{% extends "base.jinja" %} +{% extends "nav.jinja" %} {% block title %}{{ album_info[0] }}{% endblock %} {% block content %} @@ -8,8 +8,8 @@ diff --git a/templates/base.jinja b/templates/base.jinja index 0f422f8..39999e7 100644 --- a/templates/base.jinja +++ b/templates/base.jinja @@ -1,13 +1,16 @@ + {% block title %}{% endblock %} - Eorzea Songbook - - + + + + - {% block content %}{% endblock %} + {% block basecontent %}{% endblock %} diff --git a/templates/home.jinja b/templates/home.jinja new file mode 100644 index 0000000..8c27b95 --- /dev/null +++ b/templates/home.jinja @@ -0,0 +1,12 @@ +{% extends "base.jinja" %} +{% block title %}Home{% endblock %} + +{% block basecontent %} + +

The Eorzea Songbook

+ +View Songs + +View Motifs + +{% endblock %} \ No newline at end of file diff --git a/templates/motif.jinja b/templates/motif.jinja index 8f67cbe..e592fc7 100644 --- a/templates/motif.jinja +++ b/templates/motif.jinja @@ -1,4 +1,4 @@ -{% extends "base.jinja" %} +{% extends "nav.jinja" %} {% block title %}{{ name }}{% endblock %} @@ -13,7 +13,7 @@
  • {{ song }}
  • diff --git a/templates/motifindex.jinja b/templates/motifindex.jinja new file mode 100644 index 0000000..c865406 --- /dev/null +++ b/templates/motifindex.jinja @@ -0,0 +1,22 @@ +{% extends "nav.jinja" %} +{% block title %}Motif Index{% endblock %} + +{% block content %} + +{% for category_id, name in category_info %} +

    {{ name }}

    + +{% endfor %} + +

    Misc.

    + + +{% endblock %} \ No newline at end of file diff --git a/templates/nav.jinja b/templates/nav.jinja index 232375e..044fe5b 100644 --- a/templates/nav.jinja +++ b/templates/nav.jinja @@ -1,14 +1,18 @@ -{ % extends "base.jinja" % } +{% extends "base.jinja" %} -{ % block content % } +{% block basecontent %}
    - +

    The header will be in here. For now, click here to go back to the home page.

    -{ % block basecontent % }{ % endblock % } +{% block content %}{% endblock %} +
    +

    The footer will be in here, when it's ready.

    -{ % endblock content %} \ No newline at end of file +
    + +{% endblock basecontent %} \ No newline at end of file diff --git a/templates/song.jinja b/templates/song.jinja index 0a88605..243c2d5 100644 --- a/templates/song.jinja +++ b/templates/song.jinja @@ -1,4 +1,4 @@ -{% extends "base.jinja" %} +{% extends "nav.jinja" %} {% block title %}{{ name }}{% endblock %} {% block content %} @@ -18,8 +18,8 @@

    Album:

    @@ -31,9 +31,9 @@
  • - {{ motif }} + {{ motif }}
  • {% endfor %} diff --git a/templates/songindex.jinja b/templates/songindex.jinja new file mode 100644 index 0000000..2467ffe --- /dev/null +++ b/templates/songindex.jinja @@ -0,0 +1,15 @@ +{% extends "nav.jinja" %} +{% block title %}Song Index{% endblock %} + +{% block content %} + +{% for album_id, name, date in album_info %} +

    {{ name }}

    + +{% endfor %} + +{% endblock %} \ No newline at end of file