mirror of
https://github.com/krateng/maloja.git
synced 2025-07-31 14:33:50 -04:00
Completed artist and track jinja templates
This commit is contained in:
parent
b3f4fc1246
commit
2cd5472751
@ -19,7 +19,8 @@ requires = [
|
|||||||
"nimrodel>=0.6.3",
|
"nimrodel>=0.6.3",
|
||||||
"setproctitle>=1.1.10",
|
"setproctitle>=1.1.10",
|
||||||
"wand>=0.5.4",
|
"wand>=0.5.4",
|
||||||
"lesscpy>=0.13"
|
"lesscpy>=0.13",
|
||||||
|
"jinja2">2.11
|
||||||
]
|
]
|
||||||
resources = [
|
resources = [
|
||||||
"web/*/*",
|
"web/*/*",
|
||||||
|
@ -600,6 +600,7 @@ def artistInfo(artist):
|
|||||||
position = c["rank"]
|
position = c["rank"]
|
||||||
performance = get_performance(artist=artist,step="week")
|
performance = get_performance(artist=artist,step="week")
|
||||||
return {
|
return {
|
||||||
|
"artist":artist,
|
||||||
"scrobbles":scrobbles,
|
"scrobbles":scrobbles,
|
||||||
"position":position,
|
"position":position,
|
||||||
"associated":others,
|
"associated":others,
|
||||||
@ -645,6 +646,7 @@ def trackInfo(track):
|
|||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
"track":track,
|
||||||
"scrobbles":scrobbles,
|
"scrobbles":scrobbles,
|
||||||
"position":position,
|
"position":position,
|
||||||
"medals":{"gold":[],"silver":[],"bronze":[],**MEDALS_TRACKS.get((frozenset(track["artists"]),track["title"]),{})},
|
"medals":{"gold":[],"silver":[],"bronze":[],**MEDALS_TRACKS.get((frozenset(track["artists"]),track["title"]),{})},
|
||||||
|
@ -6,6 +6,8 @@ from .globalconf import datadir, DATA_DIR
|
|||||||
# server stuff
|
# server stuff
|
||||||
from bottle import Bottle, route, get, post, error, run, template, static_file, request, response, FormsDict, redirect, template, HTTPResponse, BaseRequest
|
from bottle import Bottle, route, get, post, error, run, template, static_file, request, response, FormsDict, redirect, template, HTTPResponse, BaseRequest
|
||||||
import waitress
|
import waitress
|
||||||
|
# templating
|
||||||
|
from jinja2 import Environment, PackageLoader, select_autoescape
|
||||||
# monkey patching
|
# monkey patching
|
||||||
from . import monkey
|
from . import monkey
|
||||||
# rest of the project
|
# rest of the project
|
||||||
@ -206,7 +208,7 @@ JINJA_CONTEXT = {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
|
||||||
jinjaenv = Environment(
|
jinjaenv = Environment(
|
||||||
loader=PackageLoader('maloja', 'web/jinja'),
|
loader=PackageLoader('maloja', 'web/jinja'),
|
||||||
autoescape=select_autoescape(['html', 'xml'])
|
autoescape=select_autoescape(['html', 'xml'])
|
||||||
|
@ -290,6 +290,17 @@ span.stat_selector_pulse,span.stat_selector_topartists,span.stat_selector_toptra
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
display:inline-block;
|
||||||
|
padding-right:5px;
|
||||||
|
margin-bottom:10px;
|
||||||
|
margin-top:15px;
|
||||||
|
}
|
||||||
|
h2+span.afterheader {
|
||||||
|
color:@TEXT_COLOR_TERTIARY;
|
||||||
|
}
|
||||||
|
|
||||||
/* SHINY*/
|
/* SHINY*/
|
||||||
.medal {
|
.medal {
|
||||||
top:5px;
|
top:5px;
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
|
{% import 'partials/awards_artist.jinja' as awards %}
|
||||||
|
|
||||||
|
|
||||||
<table class="top_info">
|
<table class="top_info">
|
||||||
@ -45,18 +46,18 @@
|
|||||||
</td>
|
</td>
|
||||||
<td class="text">
|
<td class="text">
|
||||||
<h1>{{ artist }}</h1>
|
<h1>{{ artist }}</h1>
|
||||||
{% if competes %}<span class="rank"><a href="/charts_artists?max=100">{{ positionstring }}</a></span>{% endif %}
|
{% if competes %}<span class="rank"><a href="/charts_artists?max=100">#{{ info.position }}</a></span>{% endif %}
|
||||||
<br/>
|
<br/>
|
||||||
{% if competes and included %}
|
{% if competes and included %}
|
||||||
<span>associated: {{ htmlgenerators.artistLinks(included) }}</span>
|
<span>associated: {{ htmlgenerators.artistLinks(included) }}</span>
|
||||||
{% elif not competes %}
|
{% elif not competes %}
|
||||||
<span>Competing under {{ htmlgenerators.artistLink(credited) }} ({{ positionstring }})</span>
|
<span>Competing under {{ htmlgenerators.artistLink(credited) }} (#{{ info.position }})</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<p class="stats"><a href="/scrobbles?{{ encodedartist }}">{{ info['scrobbles'] }} Scrobbles</a></p>
|
<p class="stats"><a href="/scrobbles?{{ encodedartist }}">{{ info['scrobbles'] }} Scrobbles</a></p>
|
||||||
|
|
||||||
|
|
||||||
{% import 'partials/awards.jinja' as awards %}
|
|
||||||
|
|
||||||
{% if competes %}
|
{% if competes %}
|
||||||
{{ awards.medals(info) }}
|
{{ awards.medals(info) }}
|
||||||
@ -74,7 +75,7 @@
|
|||||||
{# htmlmodules.module_trackcharts(**filterkeys,max_=15)[0] #}
|
{# htmlmodules.module_trackcharts(**filterkeys,max_=15)[0] #}
|
||||||
{% import 'partials/charts_tracks.jinja' as charts_tracks %}
|
{% import 'partials/charts_tracks.jinja' as charts_tracks %}
|
||||||
|
|
||||||
{{ charts_tracks.charts_tracks(filterkeys,limitkeys,amountkeys,compare=false) }}
|
{{ charts_tracks.charts_tracks(filterkeys,limitkeys,{"perpage":15,"page":0},compare=false) }}
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@ -83,7 +84,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<h2><a href='/pulse?{{ encodedartist }}&step=year&trail=1'>Pulse</a></h2>
|
<h2><a href='/pulse?{{ encodedartist }}&step=year&trail=1'>Pulse</a></h2>
|
||||||
|
<br/>
|
||||||
{% for range in xranges %}
|
{% for range in xranges %}
|
||||||
<span
|
<span
|
||||||
onclick="showRangeManual('pulse','{{ range.identifier }}')"
|
onclick="showRangeManual('pulse','{{ range.identifier }}')"
|
||||||
@ -112,6 +113,9 @@
|
|||||||
<td>
|
<td>
|
||||||
<!-- We use the same classes / function calls here because we want it to switch together with pulse -->
|
<!-- We use the same classes / function calls here because we want it to switch together with pulse -->
|
||||||
<h2><a href='/performance?{{ encodedcredited }}&step=year&trail=1'>Performance</a></h2>
|
<h2><a href='/performance?{{ encodedcredited }}&step=year&trail=1'>Performance</a></h2>
|
||||||
|
{% if not competes %}<span class="afterheader">of {{ htmlgenerators.artistLink(credited) }}</span>
|
||||||
|
{% endif %}
|
||||||
|
<br/>
|
||||||
|
|
||||||
{% for range in xranges %}
|
{% for range in xranges %}
|
||||||
<span
|
<span
|
||||||
@ -133,7 +137,7 @@
|
|||||||
style="{{ 'display:none;' if initialrange==range.identifier else '' }}"
|
style="{{ 'display:none;' if initialrange==range.identifier else '' }}"
|
||||||
>
|
>
|
||||||
|
|
||||||
{{ performance.performance(filterkeys,{'since':range.firstrange},{'step':range.identifier,'trail':1},amountkeys) }}
|
{{ performance.performance({'artist':credited},{'since':range.firstrange},{'step':range.identifier,'trail':1},amountkeys) }}
|
||||||
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@ -144,7 +148,7 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
<h2><a href='/scrobbles?{encodedartist}'>Last Scrobbles</a></h2>
|
<h2><a href='/scrobbles?{{ encodedartist }}'>Last Scrobbles</a></h2>
|
||||||
|
|
||||||
{% import 'partials/scrobbles.jinja' as scrobbles %}
|
{% import 'partials/scrobbles.jinja' as scrobbles %}
|
||||||
{{ scrobbles.scrobbles(filterkeys,limitkeys,{"perpage":15,"page":0}) }}
|
{{ scrobbles.scrobbles(filterkeys,limitkeys,{"perpage":15,"page":0}) }}
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
{% macro topweeks(info) %}
|
{% macro topweeks(info) %}
|
||||||
|
|
||||||
|
{% set encodedartist = urihandler.compose_querystring(urihandler.internal_to_uri({'artist':info.artist})) %}
|
||||||
|
|
||||||
|
|
||||||
<!-- TOPWEEKS -->
|
<!-- TOPWEEKS -->
|
||||||
<span>
|
<span>
|
||||||
@ -51,15 +53,14 @@
|
|||||||
{% macro certs(artist) %}
|
{% macro certs(artist) %}
|
||||||
|
|
||||||
<!-- CERTS -->
|
<!-- CERTS -->
|
||||||
{% for track in db.get_tracks(artist=artist) %}
|
{% for track in db.get_tracks(artist=artist) -%}
|
||||||
{% set info = db.trackInfo(track) %}
|
{% set info = db.trackInfo(track) %}
|
||||||
{% if info.certification is not none %}
|
{% if info.certification is not none -%}
|
||||||
<a href='{{ htmlgenerators.link_address(track) }}'>
|
<a href='{{ htmlgenerators.link_address(track) }}'>
|
||||||
<img class="certrecord_small"
|
<img class="certrecord_small"
|
||||||
src="/media/record_{{ info.certification }}.png"
|
src="/media/record_{{ info.certification }}.png"
|
||||||
title="{{ track.title }} has reached {{ info.certification.capitalize() }} status" />
|
title="{{ track.title }} has reached {{ info.certification.capitalize() }} status" /></a>
|
||||||
</a>
|
{%- endif %}
|
||||||
{% endif %}
|
{%- endfor %}
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
63
maloja/web/jinja/partials/awards_track.jinja
Normal file
63
maloja/web/jinja/partials/awards_track.jinja
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
{% macro medals(info) %}
|
||||||
|
|
||||||
|
<!-- MEDALS -->
|
||||||
|
{% for year in info.medals.gold -%}
|
||||||
|
<a title="Best Track in {{ year }}" class="hidelink medal shiny gold" href='/charts_tracks?max=50&in={{ year }}'>
|
||||||
|
<span>{{ year }}</span>
|
||||||
|
</a>
|
||||||
|
{%- endfor %}
|
||||||
|
{% for year in info.medals.silver -%}
|
||||||
|
<a title="Second best Track in {{ year }}" class="hidelink medal shiny silver" href='/charts_tracks?max=50&in={{ year }}'>
|
||||||
|
<span>{{ year }}</span>
|
||||||
|
</a>
|
||||||
|
{%- endfor %}
|
||||||
|
{% for year in info.medals.bronze -%}
|
||||||
|
<a title="Third best Track in {{ year }}" class="hidelink medal shiny bronze" href='/charts_tracks?max=50&in={{ year }}'>
|
||||||
|
<span>{{ year }}</span>
|
||||||
|
</a>
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
|
{%- endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% macro topweeks(info) %}
|
||||||
|
|
||||||
|
{% set encodedtrack = urihandler.compose_querystring(urihandler.internal_to_uri({'track':info.track})) %}
|
||||||
|
|
||||||
|
<!-- TOPWEEKS -->
|
||||||
|
<span>
|
||||||
|
{% if info.topweeks is not none %}
|
||||||
|
<a title="{{ info.topweeks }} weeks on #1" href="/performance?{{ encodedtrack }}&step=week">
|
||||||
|
<img class="star" src="/media/star.png" />{{ info.topweeks }}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{%- endmacro %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% macro certs(track) %}
|
||||||
|
|
||||||
|
<!-- CERTS -->
|
||||||
|
|
||||||
|
{% set info = db.trackInfo(track) %}
|
||||||
|
{% if info.certification is not none %}
|
||||||
|
<img class="certrecord"
|
||||||
|
src="/media/record_{{ info.certification }}.png"
|
||||||
|
title="This track has reached {{ info.certification.capitalize() }} status" />
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{%- endmacro %}
|
@ -20,11 +20,15 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% set firstindex = amountkeys.page * amountkeys.perpage %}
|
||||||
|
{% set lastindex = firstindex + amountkeys.perpage %}
|
||||||
|
|
||||||
|
|
||||||
{% set maxbar = tracks[0]['scrobbles'] if tracks != [] else 0 %}
|
{% set maxbar = tracks[0]['scrobbles'] if tracks != [] else 0 %}
|
||||||
|
|
||||||
<table class='list'>
|
<table class='list'>
|
||||||
{% for e in tracks %}
|
{% for e in tracks %}
|
||||||
|
{% if loop.index0 >= firstindex and loop.index0 < lastindex %}
|
||||||
<tr>
|
<tr>
|
||||||
<!-- Rank -->
|
<!-- Rank -->
|
||||||
<td class="rank">{%if loop.changed(e.scrobbles) %}#{{ e.rank }}{% endif %}</td>
|
<td class="rank">{%if loop.changed(e.scrobbles) %}#{{ e.rank }}{% endif %}</td>
|
||||||
@ -41,6 +45,7 @@
|
|||||||
<td class="amount">{{ htmlgenerators.scrobblesTrackLink(e['track'],urihandler.internal_to_uri(limitkeys),amount=e['scrobbles']) }}</td>
|
<td class="amount">{{ htmlgenerators.scrobblesTrackLink(e['track'],urihandler.internal_to_uri(limitkeys),amount=e['scrobbles']) }}</td>
|
||||||
<td class="bar">{{ htmlgenerators.scrobblesTrackLink(e['track'],urihandler.internal_to_uri(limitkeys),percent=e['scrobbles']*100/maxbar) }}</td>
|
<td class="bar">{{ htmlgenerators.scrobblesTrackLink(e['track'],urihandler.internal_to_uri(limitkeys),percent=e['scrobbles']*100/maxbar) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{% macro scrobbles(filterkeys,limitkeys,amountkeys) %}
|
{% macro scrobbles(filterkeys,limitkeys,amountkeys,shortTimeDesc=False) %}
|
||||||
|
|
||||||
{% set scrobbles = dbp.get_scrobbles(filterkeys,limitkeys,amountkeys) %}
|
{% set scrobbles = dbp.get_scrobbles(filterkeys,limitkeys,amountkeys) %}
|
||||||
|
|
||||||
@ -10,11 +10,9 @@
|
|||||||
|
|
||||||
<table class='list'>
|
<table class='list'>
|
||||||
{% for s in scrobbles %}
|
{% for s in scrobbles %}
|
||||||
{% if loop.index0 > firstindex and loop.index0 < lastindex %}
|
{% if loop.index0 >= firstindex and loop.index0 < lastindex %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class='time'>
|
<td class='time'>{{ malojatime.timestamp_desc(s["time"],short=shortTimeDesc) }}</td>
|
||||||
|
|
||||||
</td>
|
|
||||||
{{ entityrow.row(s) }}
|
{{ entityrow.row(s) }}
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
135
maloja/web/jinja/track.jinja
Normal file
135
maloja/web/jinja/track.jinja
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
{% extends "base.jinja" %}
|
||||||
|
{% block title %}Maloja - {{ track.title }}{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="/rangeselect.js"></script>
|
||||||
|
<script>
|
||||||
|
function scrobble(encodedtrack,apikey) {
|
||||||
|
neo.xhttprequest('/api/newscrobble?' + encodedtrack + "key=" + apikey).then(response=>{window.location.reload()});
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% set track = filterkeys.track %}
|
||||||
|
{% set info = db.trackInfo(track) %}
|
||||||
|
|
||||||
|
{% set initialrange ='month' %}
|
||||||
|
|
||||||
|
|
||||||
|
{% set encodedtrack = urihandler.compose_querystring(urihandler.internal_to_uri({'track':track})) %}
|
||||||
|
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
|
{% import 'partials/awards_track.jinja' as awards %}
|
||||||
|
|
||||||
|
|
||||||
|
<table class="top_info">
|
||||||
|
<tr>
|
||||||
|
<td class="image">
|
||||||
|
{% if adminmode %}
|
||||||
|
<div
|
||||||
|
class="changeable-image" data-uploader="b64=>upload('{encodedartist}','{apikey}',b64)"
|
||||||
|
style="background-image:url('{{ utilities.getTrackImage(artists=track.artists,title=track.title,fast=True) }}');"
|
||||||
|
></div>
|
||||||
|
{% else %}
|
||||||
|
<div style="background-image:url('{{ utilities.getTrackImage(artists=track.artists,title=track.title,fast=True) }}');">
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td class="text">
|
||||||
|
<span>{{ htmlgenerators.artistLinks(track.artists) }}</span><br/>
|
||||||
|
<h1>{{ track.title }}</h1>
|
||||||
|
{{ awards.certs(track) }}
|
||||||
|
<span class="rank"><a href="/charts_tracks?max=100">#{{ info.position }}</a></span>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
<p class="stats"><a href="/scrobbles?{{ encodedtrack }}">{{ info['scrobbles'] }} Scrobbles</a></p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{{ awards.medals(info) }}
|
||||||
|
{{ awards.topweeks(info) }}
|
||||||
|
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<table class="twopart">
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<h2><a href='/pulse?{{ encodedtrack }}&step=year&trail=1'>Pulse</a></h2>
|
||||||
|
<br/>
|
||||||
|
{% for range in xranges %}
|
||||||
|
<span
|
||||||
|
onclick="showRangeManual('pulse','{{ range.identifier }}')"
|
||||||
|
class="stat_selector_pulse selector_pulse_{{ range.identifier }}"
|
||||||
|
style="{{ 'opacity:0.5;' if initialrange==range.identifier else '' }}">
|
||||||
|
{{ range.localisation }}
|
||||||
|
</span>
|
||||||
|
{% if not loop.last %}|{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
{% import 'partials/pulse.jinja' as pulse %}
|
||||||
|
{% for range in xranges %}
|
||||||
|
|
||||||
|
<span
|
||||||
|
class="stat_module_pulse pulse_{{ range.identifier }}"
|
||||||
|
style="{{ 'display:none;' if initialrange==range.identifier else '' }}"
|
||||||
|
>
|
||||||
|
|
||||||
|
{{ pulse.pulse(filterkeys,{'since':range.firstrange},{'step':range.identifier,'trail':1},amountkeys) }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<!-- We use the same classes / function calls here because we want it to switch together with pulse -->
|
||||||
|
<h2><a href='/performance?{{ encodedtrack }}&step=year&trail=1'>Performance</a></h2>
|
||||||
|
<br/>
|
||||||
|
{% for range in xranges %}
|
||||||
|
<span
|
||||||
|
onclick="showRangeManual('pulse','{{ range.identifier }}')"
|
||||||
|
class="stat_selector_pulse selector_pulse_{{ range.identifier }}"
|
||||||
|
style="{{ 'opacity:0.5;' if initialrange==range.identifier else '' }}">
|
||||||
|
{{ range.localisation }}
|
||||||
|
</span>
|
||||||
|
{% if not loop.last %}|{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
<br/><br/>
|
||||||
|
|
||||||
|
{% import 'partials/performance.jinja' as performance %}
|
||||||
|
{% for range in xranges %}
|
||||||
|
|
||||||
|
<span
|
||||||
|
class="stat_module_pulse pulse_{{ range.identifier }}"
|
||||||
|
style="{{ 'display:none;' if initialrange==range.identifier else '' }}"
|
||||||
|
>
|
||||||
|
|
||||||
|
{{ performance.performance(filterkeys,{'since':range.firstrange},{'step':range.identifier,'trail':1},amountkeys) }}
|
||||||
|
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a href='/scrobbles?{{ encodedtrack }}'>Last Scrobbles</a></h2>
|
||||||
|
|
||||||
|
{% import 'partials/scrobbles.jinja' as scrobbles %}
|
||||||
|
{{ scrobbles.scrobbles(filterkeys,limitkeys,{"perpage":15,"page":0}) }}
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user