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

More incomplete jinja templates

This commit is contained in:
Krateng 2020-05-31 18:11:28 +02:00
parent 31585ec646
commit 813dee8400
4 changed files with 117 additions and 7 deletions

View File

@ -0,0 +1,34 @@
{% extends "base.jinja" %}
{% block title %}Maloja - {{ artist }}{% endblock %}
{% block scripts %}
<script src="/datechange.js" async></script>
{% endblock %}
{% set charts = dbp.get_charts_artists(filterkeys,limitkeys) %}
{% block content %}
<table class="top_info">
<tr>
<td class="image">
<div style="background-image:url('{{ img }}')"></div>
</td>
<td class="text">
<h1>Artist Charts</h1><a href="/top_artists"><span>View #1 Artists</span></a><br/>
<span>{{ limitkeys.timerange.desc(prefix=True) }}</span>
<br/><br/>
{{ htmlmodules.module_filterselection(_urikeys) }}
</td>
</tr>
</table>
{% import 'partials/charts_artists.jinja' as charts_artists %}
{{ charts_artists.charts_artists(limitkeys,amountkeys,compare=False) }}
{% endblock %}

View File

@ -0,0 +1,34 @@
{% extends "base.jinja" %}
{% block title %}Maloja - Track Charts{% endblock %}
{% block scripts %}
<script src="/datechange.js" async></script>
{% endblock %}
{% set charts = dbp.get_charts_tracks(filterkeys,limitkeys) %}
{% block content %}
<table class="top_info">
<tr>
<td class="image">
<div style="background-image:url('{{ img }}')"></div>
</td>
<td class="text">
<h1>Track Charts</h1><a href="/top_tracks"><span>View #1 Tracks</span></a><br/>
<span>{{ limitkeys.timerange.desc(prefix=True) }}</span>
<br/><br/>
{{ htmlmodules.module_filterselection(_urikeys) }}
</td>
</tr>
</table>
{% import 'partials/charts_tracks.jinja' as charts_tracks %}
{{ charts_tracks.charts_tracks(filterkeys,limitkeys,amountkeys,charts=charts,compare=false) }}
{% endblock %}

View File

@ -0,0 +1,41 @@
{% macro charts_artists(limitkeys,amountkeys,charts=None,compare=False) %}
{% if charts is none %}
{% set charts = dbp.get_charts_artists(limitkeys) %}
{% endif %}
{% if compare %}
{% endif %}
{% set firstindex = amountkeys.page * amountkeys.perpage %}
{% set lastindex = firstindex + amountkeys.perpage %}
{% set maxbar = charts[0]['scrobbles'] if charts != [] else 0 %}
<table class='list'>
{% for e in charts %}
{% if loop.index0 >= firstindex and loop.index0 < lastindex %}
<tr>
<!-- Rank -->
<td class="rank">{%if loop.changed(e.scrobbles) %}#{{ e.rank }}{% endif %}</td>
<!-- Rank change -->
{% if false %}
{% if e not in prevcharts %}<td class='rankup' title='New'>🆕</td>{% endif %}
{% endif %}
<!-- artist -->
{{ htmlgenerators.entity_column(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>
</tr>
{% endif %}
{% endfor %}
</table>
{%- endmacro %}

View File

@ -1,7 +1,8 @@
{% macro charts_tracks(filterkeys,limitkeys,amountkeys,compare=False) %} {% macro charts_tracks(filterkeys,limitkeys,amountkeys,charts=None,compare=False) %}
{% if charts is none %}
{% set tracks = dbp.get_charts_tracks(filterkeys,limitkeys) %} {% set charts = dbp.get_charts_tracks(filterkeys,limitkeys) %}
{% endif %}
{% if compare %} {% if compare %}
{% if compare is true %} {% if compare is true %}
{% set compare = limitkeys.timerange.next(step=-1) %} {% set compare = limitkeys.timerange.next(step=-1) %}
@ -9,11 +10,11 @@
{% set prevtracks = dbp.get_charts_tracks(filterkeys,{'timerange':compare}) %} {% set prevtracks = dbp.get_charts_tracks(filterkeys,{'timerange':compare}) %}
{% set lastrank = {} %} {% set lastrank = {} %}
{% for t in tracks %} {% for t in charts %}
{% if lastrank.update({(t.track.artists,t.track.title):t.rank}) %}{% endif %} {% if lastrank.update({(t.track.artists,t.track.title):t.rank}) %}{% endif %}
{% endfor %} {% endfor %}
{% for t in tracks %} {% for t in charts %}
{% if (t.track.artists,t.track.title) in lastrank %} {% if (t.track.artists,t.track.title) in lastrank %}
{% if t.update({'lastrank':lastrank[(t.track.artists,t.track.title)]}) %}{% endif %} {% if t.update({'lastrank':lastrank[(t.track.artists,t.track.title)]}) %}{% endif %}
{% endif %} {% endif %}
@ -24,10 +25,10 @@
{% set lastindex = firstindex + amountkeys.perpage %} {% set lastindex = firstindex + amountkeys.perpage %}
{% set maxbar = tracks[0]['scrobbles'] if tracks != [] else 0 %} {% set maxbar = charts[0]['scrobbles'] if charts != [] else 0 %}
<table class='list'> <table class='list'>
{% for e in tracks %} {% for e in charts %}
{% if loop.index0 >= firstindex and loop.index0 < lastindex %} {% if loop.index0 >= firstindex and loop.index0 < lastindex %}
<tr> <tr>
<!-- Rank --> <!-- Rank -->