1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Improved jinja pages

This commit is contained in:
Krateng 2020-08-21 18:20:51 +02:00
parent 4113d1761e
commit 1563a15abd
5 changed files with 16 additions and 274 deletions

View File

@ -5,7 +5,7 @@ author = {
"email":"maloja@krateng.dev",
"github": "krateng"
}
version = 2,7,2
version = 2,7,3
versionstr = ".".join(str(n) for n in version)
links = {
"pypi":"malojaserver",

View File

@ -1,11 +1,18 @@
{% extends "abstracts/base.jinja" %}
{% block title %}Maloja - {{ artist }}{% endblock %}
{% block title %}Maloja - Artist Charts{% endblock %}
{% block scripts %}
<script src="/datechange.js" async></script>
{% endblock %}
{% set charts = dbp.get_charts_artists(filterkeys,limitkeys) %}
{% if charts[0] is defined %}
{% set topartist = charts[0].artist %}
{% set img = utilities.getArtistImage(artist=topartist,fast=True) %}
{% else %}
{% set img = "/favicon.png" %}
{% endif %}
{% block content %}

View File

@ -6,6 +6,12 @@
{% endblock %}
{% set charts = dbp.get_charts_tracks(filterkeys,limitkeys) %}
{% if charts[0] is defined %}
{% set toptrack = charts[0].track %}
{% set img = utilities.getTrackImage(artists=toptrack.artists,title=toptrack.title,fast=True) %}
{% else %}
{% set img = "/favicon.png" %}
{% endif %}
{% block content %}
@ -17,6 +23,7 @@
</td>
<td class="text">
<h1>Track Charts</h1><a href="/top_tracks"><span>View #1 Tracks</span></a><br/>
{% if filterkeys.get('artist') is not none %}by {{ htmlgenerators.artistLink(filterkeys.get('artist')) }}{% endif %}
<span>{{ limitkeys.timerange.desc(prefix=True) }}</span>
<br/><br/>
{{ htmlmodules.module_filterselection(_urikeys) }}

View File

@ -1,151 +0,0 @@
<!DOCTYPE html>
<html>
<!-- query keys -->
<pyhp save="filterkeys.get('artist')" as="artist" />
<!-- DB calls -->
<pyhp save="db.artistInfo(artist)" as="info" />
<!-- preprocessing -->
<pyhp save="info.get('replace')" as="credited" />
<pyhp save="info.get('associated')" as="included" />
<pyhp save="'#' + str(info.get('position'))" as="positionstring" />
<pyhp save="'month'" as="initialrange" />
<!-- includestring -->
<pyhp save="''" as="includestring" />
<pyhp if="credited is not None">
<pyhp save="'Competing under ' + htmlgenerators.artistLink(credited) + ' (' + positionstring + ')'" as="includestring" />
<pyhp save="''" as="positionstring" /> <!-- clear positionstring so it's not shown next to the artist -->
</pyhp>
<pyhp if="credited is None">
<pyhp save="artist" as="credited" />
</pyhp>
<pyhp if="included is not None and included != []">
<pyhp save="'associated: ' + htmlgenerators.artistLinks(included)" as="includestring" />
</pyhp>
<!-- url encode -->
<pyhp save="urihandler.compose_querystring(urihandler.internal_to_uri({'artist':artist}))" as="encodedartist" />
<pyhp save="urihandler.compose_querystring(urihandler.internal_to_uri({'artist':credited}))" as="encodedcredited" />
<head>
<meta charset="UTF-8" />
<title>Maloja - <pyhp echo="artist" /></title>
<pyhp include="common/header.html" />
<script src="/rangeselect.js"></script>
</head>
<body>
<table class="top_info">
<tr>
<td class="image">
<pyhp if="adminmode"><div class="changeable-image" data-uploader="b64=>upload('{encodedartist}','{apikey}',b64)" style="background-image:url('{utilities.getArtistImage(artist=artist,fast=True)}');"></div></pyhp>
<pyhp if="not adminmode"><div style="background-image:url('{utilities.getArtistImage(artist=artist,fast=True)}');"></div></pyhp>
</td>
<td class="text">
<h1><pyhp echo="artist" /></h1>
<span class="rank"><a href="/charts_artists?max=100"><pyhp echo="positionstring" /></a></span>
<br/>
<span><pyhp echo="includestring" /></span>
<p class="stats"><a href="/scrobbles?{encodedartist}"><pyhp echo="info['scrobbles']" /> Scrobbles</a></p>
<!-- MEDALS -->
<pyhp for="year" in="info['medals']['gold']"><a title="Best Artist in {year}" class="hidelink medal shiny gold" href='/charts_artists?max=50&amp;in={str(year)}'><span><pyhp echo="year" /></span></a></pyhp>
<pyhp for="year" in="info['medals']['silver']"><a title="Second best Artist in {year}" class="hidelink medal shiny silver" href='/charts_artists?max=50&amp;in={str(year)}'><span><pyhp echo="year" /></span></a></pyhp>
<pyhp for="year" in="info['medals']['bronze']"><a title="Third best Artist in {year}" class="hidelink medal shiny bronze" href='/charts_artists?max=50&amp;in={str(year)}'><span><pyhp echo="year" /></span></a></pyhp>
<!-- TOPWEEKS -->
<span><pyhp if="info.get('topweeks') not in [0,None]">
<a title="{str(info['topweeks'])} weeks on #1" href="/performance?{encodedartist}&step=week">
<img class="star" src="/media/star.png" /><pyhp echo="info['topweeks']" />
</a>
</pyhp></span>
<!-- CERTS -->
<pyhp for="track" in="db.get_tracks(artist=artist)"><pyhp save="db.trackInfo(track)" as="info" /><pyhp if="info.get('certification') is not None"><a href='{htmlgenerators.link_address(track)}'><img class="certrecord_small"
src="/media/record_{info['certification']}.png"
title="{track['title']} has reached {info['certification'].capitalize()} status"
/></a></pyhp></pyhp>
</td>
</tr>
</table>
<h2><a href='/charts_tracks?{encodedartist}'>Top Tracks</a></h2>
<pyhp echo="htmlmodules.module_trackcharts(**filterkeys,max_=15)[0]" />
<br/>
<table class="twopart">
<pyhp save="[
('day','7 days',malojatime.today().next(-6),'day',7),
('week','12 weeks',malojatime.thisweek().next(-11),'week',12),
('month','12 months',malojatime.thismonth().next(-11),'month',12),
('year','10 years',malojatime.thisyear().next(-9),'year',12)
]" as="ranges" />
<tr>
<td>
<h2><a href='/pulse?{encodedartist}&amp;step=year&amp;trail=1'>Pulse</a></h2>
<pyhp for="range" in="ranges" separator = " | ">
<span onclick="showRangeManual('pulse','{range[0]}')" class="stat_selector_pulse selector_pulse_{range[0]}" style="{'opacity:0.5;' if initialrange==range[0] else ''}"><pyhp echo="range[1]" /></span>
</pyhp>
<br/><br/>
<pyhp for="range" in="ranges">
<span class="stat_module_pulse pulse_{range[0]}" style="{'display:none;' if initialrange==range[0] else ''}">
<!--<pyhp echo="htmlmodules.module_pulse(artist=artist,max_=range[4],since=range[2],step=range[3],trail=1)" />-->
<pyhp include="partial/pulse.pyhp" with="{'amountkeys':{'max_':range[4]},'limitkeys':{'since':range[2]},'delimitkeys':{'step':range[3],'trail':1}}" />
</span>
</pyhp>
</td>
<td>
<!-- We use the same classes / function calls here because we want it to switch together with pulse -->
<h2><a href='/performance?{encodedcredited}&amp;step=year&amp;trail=1'>Performance</a></h2>
<pyhp for="range" in="ranges" separator = " | ">
<span onclick="showRangeManual('pulse','{range[0]}')" class="stat_selector_pulse selector_pulse_{range[0]}" style="{'opacity:0.5;' if initialrange==range[0] else ''}"><pyhp echo="range[1]" /></span>
</pyhp>
<br/><br/>
<pyhp for="range" in="ranges">
<span class="stat_module_pulse pulse_{range[0]}" style="{'display:none;' if initialrange==range[0] else ''}">
<!--<pyhp echo="htmlmodules.module_performance(artist=credited,max_=range[4],since=range[2],step=range[3],trail=1)" />-->
<pyhp include="partial/performance.pyhp" with="{'filterkeys':{'artist':credited},'amountkeys':{'max_':range[4]},'limitkeys':{'since':range[2]},'delimitkeys':{'step':range[3],'trail':1}}" />
</span>
</pyhp>
</td>
</tr>
</table>
<h2><a href='/scrobbles?{encodedartist}'>Last Scrobbles</a></h2>
<pyhp echo="htmlmodules.module_scrobblelist(**filterkeys,max_=10,earlystop=True)[0]" />
<pyhp include="common/footer.html" />
</body>
</html>

View File

@ -1,121 +0,0 @@
<!DOCTYPE html>
<html>
<!-- query keys -->
<pyhp save="filterkeys.get('track')" as="track" />
<!-- DB calls -->
<pyhp save="db.trackInfo(track)" as="info" />
<!-- preprocessing -->
<pyhp save="'#' + str(info.get('position'))" as="positionstring" />
<pyhp save="'month'" as="initialrange" />
<!-- url encode -->
<pyhp save="urihandler.compose_querystring(urihandler.internal_to_uri({'track':track}))" as="encodedtrack" />
<head>
<meta charset="UTF-8" />
<title>Maloja - <pyhp echo="track['title']" /></title>
<pyhp include="common/header.html" />
<script src="/rangeselect.js"></script>
<script>
function scrobble(encodedtrack,apikey) {
neo.xhttprequest('/api/newscrobble?' + encodedtrack + "key=" + apikey).then(response=>{window.location.reload()});
}
</script>
</head>
<body>
<table class="top_info">
<tr>
<td class="image">
<pyhp if="adminmode"><div class="changeable-image" data-uploader="b64=>upload('{encodedtrack}','{apikey}',b64)" style="background-image:url('{utilities.getTrackImage(track['artists'],track['title'],fast=True)}')"></div></pyhp>
<pyhp if="not adminmode"><div style="background-image:url('{utilities.getTrackImage(track['artists'],track['title'],fast=True)}')"></div></pyhp>
</td>
<td class="text">
<span><pyhp echo="htmlgenerators.artistLinks(track['artists'])" /></span><br/>
<h1><pyhp echo="track['title']" /></h1> <pyhp if="info['certification'] is not None"><img class="certrecord" src="/media/record_{info['certification']}.png" title="This track has reached {info['certification'].capitalize()} status" /></pyhp> <span class="rank"><a href="/charts_tracks?max=100"><pyhp echo="positionstring" /></a></span>
<p class="stats"><pyhp if="adminmode"><span onclick="scrobble('{encodedtrack}','{apikey}')" class="button">Scrobble now</span> </pyhp><a href="/scrobbles?{encodedtrack}"><pyhp echo="info['scrobbles']" /> Scrobbles</a></p>
<pyhp for="year" in="info['medals']['gold']"><a title="Best Track in {year}" class="hidelink medal shiny gold" href='/charts_tracks?max=50&amp;in={str(year)}'><span><pyhp echo="year" /></span></a></pyhp>
<pyhp for="year" in="info['medals']['silver']"><a title="Second best Track in {year}" class="hidelink medal shiny silver" href='/charts_tracks?max=50&amp;in={str(year)}'><span><pyhp echo="year" /></span></a></pyhp>
<pyhp for="year" in="info['medals']['bronze']"><a title="Third best Track in {year}" class="hidelink medal shiny bronze" href='/charts_tracks?max=50&amp;in={str(year)}'><span><pyhp echo="year" /></span></a></pyhp>
<span><pyhp if="info.get('topweeks') not in [0,None]">
<a title="{str(info['topweeks'])} weeks on #1" href="/performance?{encodedtrack}&step=week">
<img class="star" src="/media/star.png" /><pyhp echo="info['topweeks']" />
</a>
</pyhp></span>
</td>
</tr>
</table>
<table class="twopart">
<pyhp save="[
('day','7 days',malojatime.today().next(-6),'day',7),
('week','12 weeks',malojatime.thisweek().next(-11),'week',12),
('month','12 months',malojatime.thismonth().next(-11),'month',12),
('year','10 years',malojatime.thisyear().next(-9),'year',12)
]" as="ranges" />
<tr>
<td>
<h2><a href='/pulse?{encodedtrack}&amp;step=year&amp;trail=1'>Pulse</a></h2>
<pyhp for="range" in="ranges" separator = " | ">
<span onclick="showRangeManual('pulse','{range[0]}')" class="stat_selector_pulse selector_pulse_{range[0]}" style="{'opacity:0.5;' if initialrange==range[0] else ''}"><pyhp echo="range[1]" /></span>
</pyhp>
<br/><br/>
<pyhp for="range" in="ranges">
<span class="stat_module_pulse pulse_{range[0]}" style="{'display:none;' if initialrange==range[0] else ''}">
<pyhp with="{'amountkeys':{'max_':range[4]},'limitkeys':{'since':range[2]},'delimitkeys':{'step':range[3],'trail':1}}">
<pyhp include="partial/pulse.pyhp" />
</pyhp>
</span>
</pyhp>
</td>
<td>
<!-- We use the same classes / function calls here because we want it to switch together with pulse -->
<h2><a href='/performance?{encodedtrack}&amp;step=year&amp;trail=1'>Performance</a></h2>
<pyhp for="range" in="ranges" separator = " | ">
<span onclick="showRangeManual('pulse','{range[0]}')" class="stat_selector_pulse selector_pulse_{range[0]}" style="{'opacity:0.5;' if initialrange==range[0] else ''}"><pyhp echo="range[1]" /></span>
</pyhp>
<br/><br/>
<pyhp for="range" in="ranges">
<span class="stat_module_pulse pulse_{range[0]}" style="{'display:none;' if initialrange==range[0] else ''}">
<pyhp with="{'amountkeys':{'max_':range[4]},'limitkeys':{'since':range[2]},'delimitkeys':{'step':range[3],'trail':1}}">
<pyhp include="partial/performance.pyhp" />
</pyhp>
</span>
</pyhp>
</td>
</tr>
</table>
<h2><a href='/scrobbles?{encodedtrack}'>Last Scrobbles</a></h2>
<pyhp echo="htmlmodules.module_scrobblelist(**filterkeys,max_=10,earlystop=True)[0]" />
<pyhp include="common/footer.html" />
</body>
</html>