1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Reworked landing page

This commit is contained in:
Alban 2012-11-17 21:36:28 +01:00
parent e40bc11f30
commit 15a9722325
2 changed files with 23 additions and 19 deletions

View File

@ -1,21 +1,21 @@
{% extends "layout.html" %}
{% block body %}
{% if admin %}
<p><a href="{{ url_for('user_index') }}">Users</a> | <a href="{{ url_for('folder_index') }}">Folders</a></p>
{% endif %}
<h2>Artists</h2>
<table>
<tr><th>Id</th><th>Name</th></tr>
{% for artist in artists %}
<tr><td>{{ artist.id }}</td><td>{{ artist.name }}</td></tr>
{% endfor %}
</table>
<h2>Albums</h2>
<table>
<tr><th>Artist</th><th>Album</th></tr>
{% for album in albums %}
<tr><td>{{ album.artist.name }}</td><td>{{ album.name }}</td></tr>
{% endfor %}
</table>
<h2>Hi!</h2>
<p>There's nothing much to see here.</p>
<p>
If you want to listen to some music, you'll have to use one of the available clients. See the <a href="http://www.subsonic.org/pages/apps.jsp">Subsonic website</a>
for a list of compatible clients.<br />
For now, this server has been tested on <em>MiniSub</em> and <em>Perisonic</em>.
</p>
<h2>Stats</h2>
<ul>
<li>{{ stats.artists }} artists</li>
<li>{{ stats.albums }} albums</li>
<li>{{ stats.tracks }} tracks</li>
</ul>
{% endblock %}

10
web.py
View File

@ -36,12 +36,16 @@ def teardown(exception):
@app.route('/')
def index():
return render_template('home.html',
artists = db.Artist.query.order_by(db.Artist.name).all(),
albums = db.Album.query.join(db.Album.artist).order_by(db.Artist.name, db.Album.name).all())
stats = {
'artists': db.Artist.query.count(),
'albums': db.Album.query.count(),
'tracks': db.Track.query.count()
}
return render_template('home.html', stats = stats, admin = UserManager.get(session.get('userid'))[1].admin)
@app.route('/resetdb')
def reset_db():
if UserManager.get(session.get('userid'))[1].admin:
db.recreate_db()
return redirect(url_for('index'))