mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Replaced remaining htmlgenerator calls
This commit is contained in:
parent
f7ca7b0dc9
commit
6ca88685bf
@ -1,7 +1,7 @@
|
||||
from .. import database_packed
|
||||
from . import filters
|
||||
|
||||
from .. import database, database_packed, htmlgenerators, malojatime, utilities, urihandler, malojauri
|
||||
from .. import database, database_packed, malojatime, utilities, urihandler, malojauri
|
||||
from doreah import settings
|
||||
|
||||
import urllib
|
||||
@ -16,7 +16,6 @@ JINJA_CONTEXT = {
|
||||
# maloja
|
||||
"db": database,
|
||||
"dbp":dbp,
|
||||
"htmlgenerators": htmlgenerators,
|
||||
"malojatime": malojatime,
|
||||
"utilities": utilities,
|
||||
"urihandler": urihandler,
|
||||
|
@ -11,7 +11,6 @@ import waitress
|
||||
from . import monkey
|
||||
# rest of the project
|
||||
from . import database
|
||||
from . import htmlgenerators
|
||||
from . import malojatime
|
||||
from . import utilities
|
||||
from . import malojauri
|
||||
|
@ -19,7 +19,9 @@
|
||||
{% if adminmode %}
|
||||
You are only seeing this information because you are in admin mode:
|
||||
<br/><br/>
|
||||
<div style="white-space: pre-wrap; font-family: monospace;">{{ traceback }}</div>
|
||||
<div style="white-space: pre-wrap; font-family: monospace;">{% autoescape true -%}
|
||||
{{ traceback }}
|
||||
{%- endautoescape %}</div>
|
||||
{% else %}
|
||||
A team of Korean schoolgirls with katanas has been dispatched to deal with this situation.
|
||||
{% endif %}
|
||||
|
@ -53,8 +53,8 @@
|
||||
{{ entityrow.row(e['artist']) }}
|
||||
|
||||
<!-- scrobbles -->
|
||||
<td class="amount">{{ htmlgenerators.scrobblesArtistLink(e['artist'],urihandler.internal_to_uri(limitkeys),amount=e['scrobbles']) }}</td>
|
||||
<td class="bar">{{ htmlgenerators.scrobblesArtistLink(e['artist'],urihandler.internal_to_uri(limitkeys),percent=e['scrobbles']*100/maxbar) }}</td>
|
||||
<td class="amount">{{ links.link_scrobbles([{'artist':e['artist'],'timerange':limitkeys.timerange}],amount=e['scrobbles']) }}</td>
|
||||
<td class="bar">{{ links.link_scrobbles([{'artist':e['artist'],'timerange':limitkeys.timerange}],percent=e['scrobbles']*100/maxbar) }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
@ -50,8 +50,8 @@
|
||||
{{ entityrow.row(e['track']) }}
|
||||
|
||||
<!-- scrobbles -->
|
||||
<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="amount">{{ links.link_scrobbles([{'track':e.track,'timerange':limitkeys.timerange}],amount=e['scrobbles']) }}</td>
|
||||
<td class="bar">{{ links.link_scrobbles([{'track':e.track,'timerange':limitkeys.timerange}],percent=e['scrobbles']*100/maxbar) }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
@ -13,11 +13,11 @@
|
||||
<tr>
|
||||
<td>{{ thisrange.desc() }}</td>
|
||||
<td class="rank">
|
||||
{{ '#' + t.rank.__str__() if t.rank is not none else 'n/a' }}
|
||||
{{ links.link_rank(filterkeys,thisrange,rank=t.rank) }}
|
||||
</td>
|
||||
<td class="chart">
|
||||
{% set prct = ((minrank+1-t.rank)*100/minrank if t.rank is not none else 0) %}
|
||||
{{ htmlgenerators.rankLink(thisrange.urikeys(),percent=prct,medal=t.rank,**filterkeys) }}
|
||||
{{ links.link_rank(filterkeys,thisrange,percent=prct,rank=t.rank) }}
|
||||
</td>
|
||||
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
|
||||
{% set ranges = dbp.get_pulse(filterkeys,limitkeys,delimitkeys) %}
|
||||
|
||||
{% set maxbar = ranges|map(attribute="scrobbles")|max|default(1) %}
|
||||
@ -10,10 +12,10 @@
|
||||
<tr>
|
||||
<td>{{ thisrange.desc() }}</td>
|
||||
<td class="amount">
|
||||
{{ htmlgenerators.scrobblesLink(thisrange.urikeys(),amount=t.scrobbles,**filterkeys) }}
|
||||
{{ links.link_scrobbles([filterkeys,{'timerange':thisrange}],amount=t.scrobbles) }}
|
||||
</td>
|
||||
<td class="bar">
|
||||
{{ htmlgenerators.scrobblesLink(thisrange.urikeys(),percent=t.scrobbles*100/maxbar,**filterkeys) }}
|
||||
{{ links.link_scrobbles([filterkeys,{'timerange':thisrange}],percent=t.scrobbles*100/maxbar) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -1,3 +1,6 @@
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
{% import 'snippets/entityrow.jinja' as entityrow %}
|
||||
|
||||
{% set ranges = dbp.get_top_artists(limitkeys,delimitkeys) %}
|
||||
|
||||
{% set maxbar = ranges|map(attribute="scrobbles")|max|default(1) %}
|
||||
@ -17,9 +20,9 @@
|
||||
<td class='amount'>0</td>
|
||||
<td class='bar'></td>
|
||||
{% else %}
|
||||
{{ htmlgenerators.entity_column(artist,image=utilities.getArtistImage(artist,fast=True)) }}
|
||||
<td class='amount'>{{ htmlgenerators.scrobblesArtistLink(artist,thisrange.urikeys(),amount=e.scrobbles) }}</td>
|
||||
<td class='bar'> {{ htmlgenerators.scrobblesArtistLink(artist,thisrange.urikeys(),percent=e.scrobbles*100/maxbar) }}</td>
|
||||
{{ entityrow.row(artist) }}
|
||||
<td class='amount'>{{ links.link_scrobbles([{'artist':artist,'timerange':thisrange}],amount=e.scrobbles) }}</td>
|
||||
<td class='bar'> {{ links.link_scrobbles([{'artist':artist,'timerange':thisrange}],percent=e.scrobbles*100/maxbar) }}</td>
|
||||
{% endif %}
|
||||
|
||||
</tr>
|
||||
|
@ -1,3 +1,6 @@
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
{% import 'snippets/entityrow.jinja' as entityrow %}
|
||||
|
||||
{% set ranges = dbp.get_top_tracks(filterkeys,limitkeys,delimitkeys) %}
|
||||
|
||||
{% set maxbar = ranges|map(attribute="scrobbles")|max|default(1) %}
|
||||
@ -17,9 +20,9 @@
|
||||
<td class='amount'>0</td>
|
||||
<td class='bar'></td>
|
||||
{% else %}
|
||||
{{ htmlgenerators.entity_column(track,image=utilities.getTrackImage(track.artists,track.title,fast=True)) }}
|
||||
<td class='amount'>{{ htmlgenerators.scrobblesTrackLink(track,thisrange.urikeys(),amount=e.scrobbles) }}</td>
|
||||
<td class='bar'> {{ htmlgenerators.scrobblesTrackLink(track,thisrange.urikeys(),percent=e.scrobbles*100/maxbar) }}</td>
|
||||
{{ entityrow.row(track) }}
|
||||
<td class='amount'>{{ links.link_scrobbles([{'track':track,'timerange':thisrange}],amount=e.scrobbles) }}</td>
|
||||
<td class='bar'> {{ links.link_scrobbles([{'track':track,'timerange':thisrange}],percent=e.scrobbles*100/maxbar) }}</td>
|
||||
{% endif %}
|
||||
|
||||
</tr>
|
||||
|
@ -23,3 +23,37 @@
|
||||
{{ mlj_uri.create_uri("/artist",{'artist':entity}) }}
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
|
||||
{% macro link_scrobbles(keydicts,amount=None,percent=None) %}
|
||||
|
||||
<a href='{{ mlj_uri.create_uri("/scrobbles",*keydicts) }}'>
|
||||
{% if percent is not none %}
|
||||
<div style='width:{{ percent }}%;'></div>
|
||||
{% elif amount is not none %}
|
||||
{{ amount }}
|
||||
{% endif %}
|
||||
|
||||
</a>
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% macro link_rank(filterkeys,timerange,rank=None,percent=None) %}
|
||||
|
||||
{% if 'track' in filterkeys %}
|
||||
{% set url = mlj_uri.create_uri("/charts_track",{'timerange':timerange}) %}
|
||||
{% elif 'artist' in filterkeys %}
|
||||
{% set url = mlj_uri.create_uri("/charts_artists",{'timerange':timerange}) %}
|
||||
{% endif %}
|
||||
|
||||
{% set rankclass = {1:'gold',2:'silver',3:'bronze'}[rank] or "" %}
|
||||
|
||||
<a href='{{ url }}'>
|
||||
{% if percent is not none %}
|
||||
<div class=" {{ rankclass }}" style='width: {{ percent }}%;'></div>
|
||||
{% else %}
|
||||
{% if rank is not none %}#{{ rank }}{% else %}n/a{% endif %}
|
||||
{% endif %}
|
||||
</a>
|
||||
{%- endmacro %}
|
||||
|
Loading…
Reference in New Issue
Block a user