mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
More PYHP conversion
This commit is contained in:
parent
a6724b9455
commit
33cea26a79
@ -25,8 +25,7 @@ resources = [
|
||||
"web/*",
|
||||
"static/*/*",
|
||||
"data_files/*/*",
|
||||
"data_files/*/*/*",
|
||||
"data_files/.doreah"
|
||||
"data_files/*/*/*"
|
||||
]
|
||||
|
||||
commands = {
|
||||
|
@ -112,9 +112,9 @@
|
||||
|
||||
<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 with="{'amountkeys':{'max_':range[4]},'limitkeys':{'since':range[2]},'delimitkeys':{'step':range[3],'trail':1}}">
|
||||
<pyhp include="partial/pulse.pyhp" />
|
||||
</pyhp>
|
||||
|
||||
<pyhp include="partial/pulse.pyhp" with="{'amountkeys':{'max_':range[4]},'limitkeys':{'since':range[2]},'delimitkeys':{'step':range[3],'trail':1}}" />
|
||||
|
||||
</span>
|
||||
|
||||
</pyhp>
|
||||
@ -133,9 +133,7 @@
|
||||
|
||||
<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 with="{'filterkeys':{'artist':credited},'amountkeys':{'max_':range[4]},'limitkeys':{'since':range[2]},'delimitkeys':{'step':range[3],'trail':1}}">
|
||||
<pyhp include="partial/performance.pyhp" />
|
||||
</pyhp>
|
||||
<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>
|
||||
|
@ -36,7 +36,9 @@
|
||||
</pyhp>
|
||||
</span>
|
||||
|
||||
<pyhp echo="html_charts" />
|
||||
<pyhp include="partial/charts_artists.pyhp" />
|
||||
|
||||
<pyhp include="common/footer.html" />
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
47
maloja/web/charts_tracks.pyhp
Normal file
47
maloja/web/charts_tracks.pyhp
Normal file
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - Track Charts</title>
|
||||
<script src="/datechange.js" async></script>
|
||||
|
||||
<pyhp include="common/header.html" />
|
||||
</head>
|
||||
|
||||
<pyhp>
|
||||
# this is temporary! all modules need to be converted into partials at some point
|
||||
html_charts, rep = htmlmodules.module_trackcharts(**amountkeys,**limitkeys)
|
||||
</pyhp>
|
||||
|
||||
<body>
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('{utilities.getArtistImage(filterkeys.get('artist')) if filterkeys.get('artist') is not None else (utilities.getTrackImage(rep) if rep is not None else 0)}')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>Track Charts</h1><a href="/top_tracks"><span>View #1 Tracks</span></a><br/>
|
||||
<span>
|
||||
<pyhp if="filterkeys.get('artist') is not None">by <pyhp echo="htmlgenerators.artistLink(filterkeys.get('artist'))" /></pyhp>
|
||||
<pyhp echo="limitkeys['timerange'].desc(prefix=True)" />
|
||||
</span>
|
||||
<br/><br/>
|
||||
<pyhp echo="htmlmodules.module_filterselection(_urikeys)" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<span class="stat_module_toptracks">
|
||||
<pyhp if="settings('CHARTS_DISPLAY_TILES')">
|
||||
<pyhp echo="htmlmodules.module_trackcharts_tiles(timerange=limitkeys['timerange'])" />
|
||||
</pyhp>
|
||||
</span>
|
||||
|
||||
<pyhp include="partial/charts_tracks.pyhp" />
|
||||
|
||||
<pyhp include="common/footer.html" />
|
||||
|
||||
</body>
|
||||
</html>
|
@ -63,8 +63,8 @@ else:
|
||||
<pyhp echo="htmlgenerators.entity_column(e['artist'],counting=e['counting'])" />
|
||||
|
||||
<!-- scrobbles -->
|
||||
<td class="amount"><pyhp echo="htmlgenerators.scrobblesArtistLink(e['artist'],limitkeys,amount=e['scrobbles'],**filterkeys,associated=True)" /></td>
|
||||
<td class="bar"><pyhp echo="htmlgenerators.scrobblesArtistLink(e['artist'],limitkeys,percent=e['scrobbles']*100/maxbar,**filterkeys,associated=True)" /></td>
|
||||
<td class="amount"><pyhp echo="htmlgenerators.scrobblesArtistLink(e['artist'],urihandler.internal_to_uri(limitkeys),amount=e['scrobbles'],associated=True)" /></td>
|
||||
<td class="bar"><pyhp echo="htmlgenerators.scrobblesArtistLink(e['artist'],urihandler.internal_to_uri(limitkeys),percent=e['scrobbles']*100/maxbar,associated=True)" /></td>
|
||||
</tr>
|
||||
<pyhp save="e" as="prev" />
|
||||
</pyhp>
|
||||
|
70
maloja/web/partial/charts_tracks.pyhp
Normal file
70
maloja/web/partial/charts_tracks.pyhp
Normal file
@ -0,0 +1,70 @@
|
||||
|
||||
<pyhp>
|
||||
if amountkeys.get("max_") is not None: amountkeys["perpage"],amountkeys["page"] = amountkeys["max_"],0
|
||||
firstindex = amountkeys["page"] * amountkeys["perpage"]
|
||||
lastindex = firstindex + amountkeys["perpage"]
|
||||
</pyhp>
|
||||
|
||||
<pyhp import="math" />
|
||||
|
||||
<pyhp save="db.get_charts_tracks(**filterkeys,**limitkeys)" as="tracks" />
|
||||
<pyhp save="math.ceil(len(tracks) / amountkeys['perpage'])" as="pages" />
|
||||
|
||||
|
||||
<pyhp>
|
||||
try:
|
||||
trackslast = db.get_charts_tracks(**kwargs_filter,timerange=kwargs_time["timerange"].next(step=-1))
|
||||
# create rank association
|
||||
lastrank = {}
|
||||
for tl in trackslast:
|
||||
lastrank[(*tl["track"]["artists"],tl["track"]["title"])] = tl["rank"]
|
||||
for t in tracks:
|
||||
try:
|
||||
t["delta"] = lastrank[(*t["track"]["artists"],t["track"]["title"])] - t["rank"]
|
||||
except:
|
||||
t["delta"] = math.inf
|
||||
except:
|
||||
pass
|
||||
</pyhp>
|
||||
|
||||
|
||||
<pyhp save="tracks[0]['scrobbles'] if tracks != [] else 0" as="maxbar" />
|
||||
|
||||
<table class='list'>
|
||||
<pyhp save="True" as="first" />
|
||||
<pyhp for="e" in="tracks[firstindex:lastindex]">
|
||||
<tr>
|
||||
<!-- Rank -->
|
||||
<td class="rank"><pyhp if="first or e['scrobbles'] < prev['scrobbles']">#<pyhp echo="e['rank']"/></pyhp></td>
|
||||
<pyhp save="False" as="first" />
|
||||
<!-- Rank change -->
|
||||
<pyhp if="e.get('delta') is not None">
|
||||
<pyhp if="e.get('delta') is math.inf">
|
||||
<td class='rankup' title='New'>🆕</td>
|
||||
</pyhp>
|
||||
<pyhp if="e.get('delta') > 0 and e.get('delta') is not math.inf">
|
||||
<td class='rankup' title="up from #{e['rank']+e['delta']}">↗</td>
|
||||
</pyhp>
|
||||
<pyhp if="e.get('delta') < 0">
|
||||
<td class='rankdown' title="down from #{e['rank']+e['delta']}">↘</td>
|
||||
</pyhp>
|
||||
<pyhp if="e.get('delta') == 0">
|
||||
<td class='ranksame' title="Unchanged">➡</td>
|
||||
</pyhp>
|
||||
</pyhp>
|
||||
|
||||
<!-- artist -->
|
||||
<pyhp echo="htmlgenerators.entity_column(e['track'])" />
|
||||
|
||||
<!-- scrobbles -->
|
||||
<td class="amount"><pyhp echo="htmlgenerators.scrobblesTrackLink(e['track'],urihandler.internal_to_uri(limitkeys),amount=e['scrobbles'])" /></td>
|
||||
<td class="bar"><pyhp echo="htmlgenerators.scrobblesTrackLink(e['track'],urihandler.internal_to_uri(limitkeys),percent=e['scrobbles']*100/maxbar)" /></td>
|
||||
</tr>
|
||||
<pyhp save="e" as="prev" />
|
||||
</pyhp>
|
||||
</table>
|
||||
|
||||
|
||||
<pyhp if="amountkeys.get('max_') is None">
|
||||
<pyhp include="pagination.pyhp" />
|
||||
</pyhp>
|
8
maloja/web/partial/link_track_scrobbles.pyhp
Normal file
8
maloja/web/partial/link_track_scrobbles.pyhp
Normal file
@ -0,0 +1,8 @@
|
||||
<a href='/scrobbles?{uri_query(track)}&{compose_querystring(timekeys)}'>
|
||||
<pyhp if="amount is not None">
|
||||
<pyhp echo="amount" />
|
||||
</pyhp>
|
||||
<pyhp if="amount is None">
|
||||
<div style='width:{percent}%;'></div>
|
||||
</pyhp>
|
||||
</a>
|
@ -1,5 +1,4 @@
|
||||
<pyhp save="{k:amountkeys[k] for k in amountkeys if k in ['perpage','pages']}" as="unchangedamountkeys" />
|
||||
<pyhp save="{**unchangedamountkeys,**filterkeys,**limitkeys,**delimitkeys}" as="unchanged" />
|
||||
<pyhp save="{'perpage':amountkeys['perpage'],**filterkeys,**limitkeys,**delimitkeys}" as="unchanged" />
|
||||
|
||||
<pyhp save="amountkeys['page']" as="page" />
|
||||
|
||||
@ -8,52 +7,54 @@
|
||||
|
||||
<div class='paginate'>
|
||||
|
||||
<pyhp if="page > 1">
|
||||
<a href='?{compose(touri(dict(**unchanged,page=0)))}'>
|
||||
<span class='stat_selector'>
|
||||
1
|
||||
</span>
|
||||
</a>
|
||||
|
|
||||
</pyhp>
|
||||
<pyhp if="pages > 1">
|
||||
<pyhp if="page > 1">
|
||||
<a href='?{compose(touri(dict(**unchanged,page=0)))}'>
|
||||
<span class='stat_selector'>
|
||||
1
|
||||
</span>
|
||||
</a>
|
||||
|
|
||||
</pyhp>
|
||||
|
||||
<pyhp if="page > 2">
|
||||
... |
|
||||
</pyhp>
|
||||
<pyhp if="page > 2">
|
||||
... |
|
||||
</pyhp>
|
||||
|
||||
<pyhp if="page > 0">
|
||||
<a href='?{compose(touri(dict(**unchanged,page=page-1)))}'>
|
||||
<span class='stat_selector'>
|
||||
<pyhp echo="page" />
|
||||
</span>
|
||||
</a>
|
||||
«
|
||||
</pyhp>
|
||||
<pyhp if="page > 0">
|
||||
<a href='?{compose(touri(dict(**unchanged,page=page-1)))}'>
|
||||
<span class='stat_selector'>
|
||||
<pyhp echo="page" />
|
||||
</span>
|
||||
</a>
|
||||
«
|
||||
</pyhp>
|
||||
|
||||
<span style='opacity:0.5;' class='stat_selector'>
|
||||
<pyhp echo="page+1" />
|
||||
</span>
|
||||
<span style='opacity:0.5;' class='stat_selector'>
|
||||
<pyhp echo="page+1" />
|
||||
</span>
|
||||
|
||||
<pyhp if="page < pages - 1">
|
||||
»
|
||||
<a href='?{compose(touri(dict(**unchanged,page=page+1)))}'>
|
||||
<span class='stat_selector'>
|
||||
<pyhp echo="page+2" />
|
||||
</span>
|
||||
</a>
|
||||
</pyhp>
|
||||
<pyhp if="page < pages - 1">
|
||||
»
|
||||
<a href='?{compose(touri(dict(**unchanged,page=page+1)))}'>
|
||||
<span class='stat_selector'>
|
||||
<pyhp echo="page+2" />
|
||||
</span>
|
||||
</a>
|
||||
</pyhp>
|
||||
|
||||
<pyhp if="page < pages - 3">
|
||||
| ...
|
||||
</pyhp>
|
||||
<pyhp if="page < pages - 3">
|
||||
| ...
|
||||
</pyhp>
|
||||
|
||||
<pyhp if="page < pages - 2">
|
||||
|
|
||||
<a href='?{compose(touri(dict(**unchanged,page=pages-1)))}'>
|
||||
<span class='stat_selector'>
|
||||
<pyhp echo="pages" />
|
||||
</span>
|
||||
</a>
|
||||
<pyhp if="page < pages - 2">
|
||||
|
|
||||
<a href='?{compose(touri(dict(**unchanged,page=pages-1)))}'>
|
||||
<span class='stat_selector'>
|
||||
<pyhp echo="pages" />
|
||||
</span>
|
||||
</a>
|
||||
</pyhp>
|
||||
</pyhp>
|
||||
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<pyhp>
|
||||
if amountkeys["max_"] is not None: amountkeys["perpage"],amountkeys["page"] = amountkeys["max_"],0
|
||||
if amountkeys.get("max_") is not None: amountkeys["perpage"],amountkeys["page"] = amountkeys["max_"],0
|
||||
firstindex = amountkeys["page"] * amountkeys["perpage"]
|
||||
lastindex = firstindex + amountkeys["perpage"]
|
||||
|
||||
@ -23,3 +23,9 @@
|
||||
</tr>
|
||||
</pyhp>
|
||||
</table>
|
||||
|
||||
|
||||
<pyhp if="amountkeys.get('max_') is None">
|
||||
<pyhp include="pagination.pyhp" />
|
||||
<!-- <pyhp echo="htmlmodules.module_paginate(page=amountkeys['page'],pages=pages,perpage=amountkeys['perpage'],**_urikeys)" />-->
|
||||
</pyhp>
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user