adds a placeholder header and footer
This commit is contained in:
parent
f1f6dd6717
commit
df46e34049
84
app.py
84
app.py
@ -5,14 +5,92 @@ app = flask.Flask('songbook')
|
|||||||
|
|
||||||
# BLANK PAGE
|
# BLANK PAGE
|
||||||
|
|
||||||
# @app.route('/album/<int:id>')
|
# @app.route('/')
|
||||||
# def page(id):
|
# def page():
|
||||||
|
|
||||||
# db = sqlite3.connect("file:songbook.sqlite?mode=ro", uri=True)
|
# 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
|
# ALBUM PAGES
|
||||||
|
|
||||||
@app.route('/album/<int:id>')
|
@app.route('/album/<int:id>')
|
||||||
|
|||||||
@ -39,7 +39,7 @@ cur.executemany(
|
|||||||
|
|
||||||
# import motif
|
# import motif
|
||||||
cur.executemany(
|
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:])
|
((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:])
|
((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
|
# import song x album
|
||||||
cur.executemany(
|
cur.executemany(
|
||||||
"insert into song_album(song_id,album_id,track) values (?, ?, ?)",
|
"insert into song_album(song_id,album_id,track) values (?, ?, ?)",
|
||||||
|
|||||||
7
db.sql
7
db.sql
@ -32,7 +32,12 @@ create table credit(
|
|||||||
create table motif(
|
create table motif(
|
||||||
id int primary key,
|
id int primary key,
|
||||||
name text not null,
|
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(
|
create table clip(
|
||||||
|
|||||||
Binary file not shown.
0
static/style.css
Normal file
0
static/style.css
Normal file
@ -1,4 +1,4 @@
|
|||||||
{% extends "base.jinja" %}
|
{% extends "nav.jinja" %}
|
||||||
{% block title %}{{ album_info[0] }}{% endblock %}
|
{% block title %}{{ album_info[0] }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
<!-- List songs -->
|
<!-- List songs -->
|
||||||
<ul>
|
<ul>
|
||||||
{% for id, track, name, name_jp in song_info %}
|
{% for song_id, track, name, name_jp in song_info %}
|
||||||
<li><a href="/song/{{ id }}">#{{ track }}: {{name}} / {{name_jp}}</li></a>
|
<li><a href="{{ url_for('songpage', id=song_id) }}">#{{ track }}: {{name}} / {{name_jp}}</li></a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
<title>{% block title %}{% endblock %} - Eorzea Songbook</title>
|
<title>{% block title %}{% endblock %} - Eorzea Songbook</title>
|
||||||
<link rel="stylesheet" href="style.css">
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=1" />
|
||||||
<script src="script.js"></script>
|
<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>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
{% block content %}{% endblock %}
|
{% block basecontent %}{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
12
templates/home.jinja
Normal file
12
templates/home.jinja
Normal 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 %}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
{% extends "base.jinja" %}
|
{% extends "nav.jinja" %}
|
||||||
|
|
||||||
{% block title %}{{ name }}{% endblock %}
|
{% block title %}{{ name }}{% endblock %}
|
||||||
|
|
||||||
@ -13,7 +13,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<audio
|
<audio
|
||||||
controls
|
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>
|
</audio>
|
||||||
<a href="/song/{{ song_id }}">{{ song }}</a>
|
<a href="/song/{{ song_id }}">{{ song }}</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
22
templates/motifindex.jinja
Normal file
22
templates/motifindex.jinja
Normal 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 %}
|
||||||
@ -1,14 +1,18 @@
|
|||||||
{ % extends "base.jinja" % }
|
{% extends "base.jinja" %}
|
||||||
|
|
||||||
{ % block content % }
|
{% block basecontent %}
|
||||||
|
|
||||||
<header>
|
<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>
|
</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 %}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
{% extends "base.jinja" %}
|
{% extends "nav.jinja" %}
|
||||||
{% block title %}{{ name }}{% endblock %}
|
{% block title %}{{ name }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
<p>Album: </p>
|
<p>Album: </p>
|
||||||
<ul>
|
<ul>
|
||||||
{% for id, track, album_name, album_code in album_info %}
|
{% for album_id, track, album_name, album_code in album_info %}
|
||||||
<li><a href="/album/{{ id }}">{{ album_name }}</a> #{{ track }}</li>
|
<li><a href="{{ url_for('albumpage', id=album_id) }}">{{ album_name }}</a> #{{ track }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -31,9 +31,9 @@
|
|||||||
<li>
|
<li>
|
||||||
<audio
|
<audio
|
||||||
controls
|
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>
|
</audio>
|
||||||
<a href = "/motif/{{ motif_id }}"> {{ motif }} </a>
|
<a href = "{{ url_for('motifpage', id=motif_id) }}"> {{ motif }} </a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|||||||
15
templates/songindex.jinja
Normal file
15
templates/songindex.jinja
Normal 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 %}
|
||||||
Loading…
Reference in New Issue
Block a user