organizes the motif index and starts work on search bar

This commit is contained in:
Effie 2023-06-13 18:22:08 +10:00
parent 50752c32fd
commit 90a4e3c8f3
8 changed files with 67 additions and 14 deletions

48
app.py
View File

@ -25,6 +25,47 @@ def homepage():
return flask.render_template('home.html') return flask.render_template('home.html')
# SEARCH RESULTS
@app.route('/search')
def searchpage():
db = openbook()
searchargs = flask.request.args['q']
searchresult = db.execute('''
select
'song', id, name
from
song
where
name
like
'%' || ? || '%'
union all
select
'album', id, name
from
album
where
name
like
'%' || ? || '%'
''',
(searchargs,searchargs)
).fetchall()
return flask.render_template('',
album_info=album_info,
song_info=song_info
)
# SONG INDEX # SONG INDEX
@app.route('/song') @app.route('/song')
@ -87,7 +128,7 @@ def motifindex():
group by group by
category.id, category.name category.id, category.name
order by order by
count(category.id) desc category.id
''').fetchall() ''').fetchall()
motif_info = db.execute(''' motif_info = db.execute('''
@ -102,7 +143,7 @@ def motifindex():
group by group by
id, name, category id, name, category
order by order by
id clip.song_id
''').fetchall() ''').fetchall()
return flask.render_template('motifindex.html', return flask.render_template('motifindex.html',
@ -270,8 +311,7 @@ def songpage(id):
where where
song_id = ? song_id = ?
order by order by
feature desc, start_ms
song_id
''', ''',
(id,) (id,)
).fetchall() ).fetchall()

Binary file not shown.

Binary file not shown.

View File

@ -153,7 +153,7 @@ a{
background: lch(25% 40 45); background: lch(25% 40 45);
display: flex; display: flex;
flex: auto; flex: auto;
justify-content: right; justify-content: center;
} }
.motif-box span{ .motif-box span{
@ -162,10 +162,19 @@ a{
} }
.motif-name::before{
content: "T";
margin-right: 2rem;
visibility: hidden;
}
.motif-name{ .motif-name{
text-align: center;
margin: auto; margin: auto;
} }
.motif-count{ .motif-count{
position: absolute, right;
text-align: right;
width: 2rem;
} }

View File

@ -7,6 +7,7 @@
<meta name="description" content="Listen to the motifs of Final Fantasy XIV's soundtrack." /> <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="stylesheet" href="{{ url_for('static', filename='style.css') }}" />
<link rel="icon" sizes="16x16 32x32 48x48" type="image/png" href="" /> <link rel="icon" sizes="16x16 32x32 48x48" type="image/png" href="" />
<script src="https://unpkg.com/htmx.org@1.9.2" integrity="sha384-L6OqL9pRWyyFU3+/bjdSri+iIphTN/bvYyM37tICVyOJkWZLpP2vGn6VUEXgzg6h" crossorigin="anonymous"></script>
</head> </head>
<body> <body>

View File

@ -1,9 +1,5 @@
{% block footer %}
<footer> <footer>
<p> The footer will be in here, when it's ready. </p> <p> The footer will be in here, when it's ready. </p>
</footer> </footer>
{% endblock footer %}

View File

@ -1,5 +1,3 @@
{% block navheader %}
<header> <header>
<nav> <nav>
<ul class="top-buttons"> <ul class="top-buttons">
@ -8,6 +6,15 @@
<li><a href="{{ url_for('motifindex') }}">Motifs</a></li> <li><a href="{{ url_for('motifindex') }}">Motifs</a></li>
</ul> </ul>
</nav> </nav>
<input
type="search"
name="q"
placeholder="Search..."
hx-get="/search"
hx-trigger="search"
hx-target="#search-results"
/>
<div id="search-results"></div>
</header> </header>
{% endblock %}

View File