adds a placeholder header and footer

This commit is contained in:
Effie 2023-06-06 18:46:12 +10:00
parent f1f6dd6717
commit df46e34049
13 changed files with 168 additions and 23 deletions

84
app.py
View File

@ -5,14 +5,92 @@ app = flask.Flask('songbook')
# BLANK PAGE
# @app.route('/album/<int:id>')
# 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/<int:id>')

View File

@ -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 (?, ?, ?)",

7
db.sql
View File

@ -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(

Binary file not shown.

0
static/style.css Normal file
View File

View File

@ -1,4 +1,4 @@
{% extends "base.jinja" %}
{% extends "nav.jinja" %}
{% block title %}{{ album_info[0] }}{% endblock %}
{% block content %}
@ -8,8 +8,8 @@
<!-- List songs -->
<ul>
{% for id, track, name, name_jp in song_info %}
<li><a href="/song/{{ id }}">#{{ track }}: {{name}} / {{name_jp}}</li></a>
{% for song_id, track, name, name_jp in song_info %}
<li><a href="{{ url_for('songpage', id=song_id) }}">#{{ track }}: {{name}} / {{name_jp}}</li></a>
{% endfor %}
</ul>

View File

@ -1,13 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>{% block title %}{% endblock %} - Eorzea Songbook</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=1" />
<meta name="description" content="Listen to the motifs of Final Fantasy XIV's soundtrack." />
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}" />
<link rel="icon" sizes="16x16 32x32 48x48" type="image/png" href="" />
</head>
<body>
{% block content %}{% endblock %}
{% block basecontent %}{% endblock %}
</body>

12
templates/home.jinja Normal file
View File

@ -0,0 +1,12 @@
{% extends "base.jinja" %}
{% block title %}Home{% endblock %}
{% block basecontent %}
<h1>The Eorzea Songbook</h1>
<a href="{{ url_for('songindex') }}">View Songs</a>
<a href="{{ url_for('motifindex') }}">View Motifs</a>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "base.jinja" %}
{% extends "nav.jinja" %}
{% block title %}{{ name }}{% endblock %}
@ -13,7 +13,7 @@
<li>
<audio
controls
src = "/static/clip/{{ '%04d' % song_id }}-{{ '%03d' % motif_id }}.flac">
src = "{{ url_for('static', filename='clip/') }}{{ '%04d' % song_id }}-{{ '%03d' % motif_id }}.flac">
</audio>
<a href="/song/{{ song_id }}">{{ song }}</a>
</li>

View File

@ -0,0 +1,22 @@
{% extends "nav.jinja" %}
{% block title %}Motif Index{% endblock %}
{% block content %}
{% for category_id, name in category_info %}
<h2>{{ name }}</h2>
<ul>
{% for motif_id, motif, category in motif_info if category == category_id %}
<li><a href="{{ url_for('motifpage', id=motif_id) }}">{{ motif }}</a></li>
{% endfor %}
</ul>
{% endfor %}
<h2>Misc.</h2>
<ul>
{% for motif_id, motif, category in motif_info if category == '' %}
<li><a href="{{ url_for('motifpage', id=motif_id) }}">{{ motif }}</a></li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -1,14 +1,18 @@
{ % extends "base.jinja" % }
{% extends "base.jinja" %}
{ % block content % }
{% block basecontent %}
<header>
<p> The header will be in here. For now, click <a href="{{ url_for('homepage') }}">here</a> to go back to the home page.</p>
</header>
{ % block basecontent % }{ % endblock % }
{% block content %}{% endblock %}
<footer>
<p> The footer will be in here, when it's ready. </p>
{ % endblock content %}
</footer>
{% endblock basecontent %}

View File

@ -1,4 +1,4 @@
{% extends "base.jinja" %}
{% extends "nav.jinja" %}
{% block title %}{{ name }}{% endblock %}
{% block content %}
@ -18,8 +18,8 @@
<p>Album: </p>
<ul>
{% for id, track, album_name, album_code in album_info %}
<li><a href="/album/{{ id }}">{{ album_name }}</a> #{{ track }}</li>
{% for album_id, track, album_name, album_code in album_info %}
<li><a href="{{ url_for('albumpage', id=album_id) }}">{{ album_name }}</a> #{{ track }}</li>
{% endfor %}
</ul>
@ -31,9 +31,9 @@
<li>
<audio
controls
src = "/static/clip/{{ '%04d' % song_id }}-{{ '%03d' % motif_id }}.flac">
src = "{{ url_for('static', filename='clip/') }}{{ '%04d' % song_id }}-{{ '%03d' % motif_id }}.flac">
</audio>
<a href = "/motif/{{ motif_id }}"> {{ motif }} </a>
<a href = "{{ url_for('motifpage', id=motif_id) }}"> {{ motif }} </a>
</li>
{% endfor %}

15
templates/songindex.jinja Normal file
View File

@ -0,0 +1,15 @@
{% extends "nav.jinja" %}
{% block title %}Song Index{% endblock %}
{% block content %}
{% for album_id, name, date in album_info %}
<h2>{{ name }}</h2>
<ul>
{% for song_id, album, track, name, name_jp in song_info if album_id == album %}
<li><a href="{{ url_for('songpage', id=song_id) }}">#{{ track }}: {{name}} / {{name_jp}}</li></a>
{% endfor %}
</ul>
{% endfor %}
{% endblock %}