mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added web pages for albums
This commit is contained in:
parent
99cb8f4c64
commit
27a2bc705a
154
maloja/web/jinja/album.jinja
Normal file
154
maloja/web/jinja/album.jinja
Normal file
@ -0,0 +1,154 @@
|
||||
{% extends "abstracts/base.jinja" %}
|
||||
{% block title %}Maloja - {{ info.album.albumtitle }}{% endblock %}
|
||||
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="/rangeselect.js"></script>
|
||||
<script src="/edit.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% set album = filterkeys.album %}
|
||||
{% set info = dbc.album_info({'album':album}) %}
|
||||
|
||||
{% set initialrange ='month' %}
|
||||
|
||||
|
||||
{% set encodedalbum = mlj_uri.uriencode({'album':album}) %}
|
||||
|
||||
|
||||
{% block icon_bar %}
|
||||
{% if adminmode %}
|
||||
{% include 'icons/edit.jinja' %}
|
||||
{% include 'icons/merge.jinja' %}
|
||||
{% include 'icons/merge_mark.jinja' %}
|
||||
{% include 'icons/merge_cancel.jinja' %}
|
||||
<script>showValidMergeIcons();</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<script>
|
||||
const entity_id = {{ info.id }};
|
||||
const entity_type = 'album';
|
||||
const entity_name = {{ album.albumtitle | tojson }};
|
||||
</script>
|
||||
|
||||
|
||||
{% import 'partials/awards_album.jinja' as awards %}
|
||||
|
||||
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
{% if adminmode %}
|
||||
<div
|
||||
class="changeable-image" data-uploader="b64=>upload('{{ encodedalbum }}',b64)"
|
||||
style="background-image:url('{{ images.get_album_image(album) }}');"
|
||||
title="Drag & Drop to upload new image"
|
||||
></div>
|
||||
{% else %}
|
||||
<div style="background-image:url('{{ images.get_album_image(album) }}');">
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text">
|
||||
<span>{{ links.links(album.artists) }}</span><br/>
|
||||
<h1 id="main_entity_name" class="headerwithextra">{{ info.album.albumtitle | e }}</h1>
|
||||
{# awards.certs(album) #}
|
||||
<span class="rank"><a href="/charts_albums?max=100">#{{ info.position }}</a></span>
|
||||
<br/>
|
||||
|
||||
<p class="stats">
|
||||
<a href="{{ mlj_uri.create_uri("/scrobbles",filterkeys) }}">{{ info['scrobbles'] }} Scrobbles</a>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{{ awards.medals(info) }}
|
||||
{{ awards.topweeks(info) }}
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<table class="twopart">
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<h2 class="headerwithextra"><a href='{{ mlj_uri.create_uri("/pulse",filterkeys) }}'>Pulse</a></h2>
|
||||
<br/>
|
||||
{% for r in xranges %}
|
||||
<span
|
||||
onclick="showRangeManual('pulse','{{ r.identifier }}')"
|
||||
class="stat_selector_pulse selector_pulse_{{ r.identifier }}"
|
||||
style="{{ 'opacity:0.5;' if initialrange==r.identifier else '' }}">
|
||||
{{ r.localisation }}
|
||||
</span>
|
||||
{% if not loop.last %}|{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<br/><br/>
|
||||
|
||||
{% for r in xranges %}
|
||||
|
||||
<span
|
||||
class="stat_module_pulse pulse_{{ r.identifier }}"
|
||||
style="{{ 'display:none;' if initialrange!=r.identifier else '' }}"
|
||||
>
|
||||
|
||||
{% with limitkeys={"since":r.firstrange},delimitkeys={'step':r.identifier,'trail':1} %}
|
||||
{% include 'partials/pulse.jinja' %}
|
||||
{% endwith %}
|
||||
</span>
|
||||
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>
|
||||
<!-- We use the same classes / function calls here because we want it to switch together with pulse -->
|
||||
<h2 class="headerwithextra"><a href='{{ mlj_uri.create_uri("/performance",filterkeys) }}'>Performance</a></h2>
|
||||
<br/>
|
||||
{% for r in xranges %}
|
||||
<span
|
||||
onclick="showRangeManual('pulse','{{ r.identifier }}')"
|
||||
class="stat_selector_pulse selector_pulse_{{ r.identifier }}"
|
||||
style="{{ 'opacity:0.5;' if initialrange==r.identifier else '' }}">
|
||||
{{ r.localisation }}
|
||||
</span>
|
||||
{% if not loop.last %}|{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<br/><br/>
|
||||
|
||||
{% for r in xranges %}
|
||||
|
||||
<span
|
||||
class="stat_module_pulse pulse_{{ r.identifier }}"
|
||||
style="{{ 'display:none;' if initialrange!=r.identifier else '' }}"
|
||||
>
|
||||
|
||||
{% with limitkeys={"since":r.firstrange},delimitkeys={'step':r.identifier,'trail':1} %}
|
||||
{% include 'partials/performance.jinja' %}
|
||||
{% endwith %}
|
||||
</span>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h2><a href='{{ mlj_uri.create_uri("/scrobbles",filterkeys) }}'>Last Scrobbles</a></h2>
|
||||
|
||||
{% with amountkeys = {"perpage":15,"page":0} %}
|
||||
{% include 'partials/scrobbles.jinja' %}
|
||||
{% endwith %}
|
||||
|
||||
|
||||
{% endblock %}
|
52
maloja/web/jinja/charts_albums.jinja
Normal file
52
maloja/web/jinja/charts_albums.jinja
Normal file
@ -0,0 +1,52 @@
|
||||
{% extends "abstracts/base.jinja" %}
|
||||
{% block title %}Maloja - Album Charts{% endblock %}
|
||||
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="/datechange.js" async></script>
|
||||
{% endblock %}
|
||||
|
||||
{% set charts = dbc.get_charts_albums(filterkeys,limitkeys) %}
|
||||
{% set pages = math.ceil(charts.__len__() / amountkeys.perpage) %}
|
||||
{% if charts[0] is defined %}
|
||||
{% set topalbum = charts[0].album %}
|
||||
{% set img = images.get_album_image(topalbum) %}
|
||||
{% else %}
|
||||
{% set img = "/favicon.png" %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('{{ img }}')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>Album Charts</h1><a href="/top_albums"><span>View #1 Albums</span></a><br/>
|
||||
{% if filterkeys.get('artist') is not none %}by {{ links.link(filterkeys.get('artist')) }}{% endif %}
|
||||
<span>{{ limitkeys.timerange.desc(prefix=True) }}</span>
|
||||
<br/><br/>
|
||||
{% with delimitkeys = {} %}
|
||||
{% include 'snippets/timeselection.jinja' %}
|
||||
{% endwith %}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{% if settings['CHARTS_DISPLAY_TILES'] %}
|
||||
{% include 'partials/charts_albums_tiles.jinja' %}
|
||||
<br/><br/>
|
||||
{% endif %}
|
||||
|
||||
{% with compare=true %}
|
||||
{% include 'partials/charts_albums.jinja' %}
|
||||
{% endwith %}
|
||||
|
||||
{% import 'snippets/pagination.jinja' as pagination %}
|
||||
{{ pagination.pagination(filterkeys,limitkeys,delimitkeys,amountkeys,pages) }}
|
||||
|
||||
{% endblock %}
|
42
maloja/web/jinja/partials/awards_album.jinja
Normal file
42
maloja/web/jinja/partials/awards_album.jinja
Normal file
@ -0,0 +1,42 @@
|
||||
{% macro medals(info) %}
|
||||
|
||||
<!-- MEDALS -->
|
||||
{% for year in info.medals.gold -%}
|
||||
<a title="Best Album in {{ year }}" class="hidelink medal shiny gold" href='/charts_albums?max=50&in={{ year }}'>
|
||||
<span>{{ year }}</span>
|
||||
</a>
|
||||
{%- endfor %}
|
||||
{% for year in info.medals.silver -%}
|
||||
<a title="Second best Album in {{ year }}" class="hidelink medal shiny silver" href='/charts_albums?max=50&in={{ year }}'>
|
||||
<span>{{ year }}</span>
|
||||
</a>
|
||||
{%- endfor %}
|
||||
{% for year in info.medals.bronze -%}
|
||||
<a title="Third best Album in {{ year }}" class="hidelink medal shiny bronze" href='/charts_albums?max=50&in={{ year }}'>
|
||||
<span>{{ year }}</span>
|
||||
</a>
|
||||
{%- endfor %}
|
||||
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{% macro topweeks(info) %}
|
||||
|
||||
{% set encodedtrack = mlj_uri.uriencode({'album':info.album}) %}
|
||||
|
||||
<!-- TOPWEEKS -->
|
||||
<span>
|
||||
{% if info.topweeks > 0 %}
|
||||
<a title="{{ info.topweeks }} weeks on #1" href="/performance?{{ encodedalbum }}&step=week">
|
||||
<img class="star" src="/media/star.png" />{{ info.topweeks }}
|
||||
</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
|
||||
{%- endmacro %}
|
56
maloja/web/jinja/partials/charts_albums.jinja
Normal file
56
maloja/web/jinja/partials/charts_albums.jinja
Normal file
@ -0,0 +1,56 @@
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
{% import 'snippets/entityrow.jinja' as entityrow %}
|
||||
|
||||
{% if charts is undefined %}
|
||||
{% set charts = dbc.get_charts_albums(filterkeys,limitkeys) %}
|
||||
{% endif %}
|
||||
{% if compare %}
|
||||
{% if compare is true %}
|
||||
{% set compare = limitkeys.timerange.next(step=-1) %}
|
||||
{% if compare is none %}{% set compare = False %}{% endif %}
|
||||
{% endif %}
|
||||
{% if compare %}
|
||||
{% set prevalbums = dbc.get_charts_albums(filterkeys,{'timerange':compare}) %}
|
||||
|
||||
{% set lastranks = {} %}
|
||||
{% for t in prevalbums %}
|
||||
{% if lastranks.update({"|".join(t.album.artists)+"||"+t.album.albumtitle:t.rank}) %}{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% for t in charts %}
|
||||
{% if "|".join(t.album.artists)+"||"+t.album.albumtitle in lastranks %}
|
||||
{% if t.update({'last_rank':lastranks["|".join(t.album.artists)+"||"+t.album.albumtitle]}) %}{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% 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 compare %}
|
||||
{% if e.last_rank is undefined %}<td class='rankup' title='New'>🆕</td>
|
||||
{% elif e.last_rank < e.rank %}<td class='rankdown' title='Down from #{{ e.last_rank }}'>↘</td>
|
||||
{% elif e.last_rank > e.rank %}<td class='rankup' title='Up from #{{ e.last_rank }}'>↗</td>
|
||||
{% elif e.last_rank == e.rank %}<td class='ranksame' title='Unchanged'>➡</td>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
<!-- artist -->
|
||||
{{ entityrow.row(e['album']) }}
|
||||
|
||||
<!-- scrobbles -->
|
||||
<td class="amount">{{ links.link_scrobbles([{'album':e.album,'timerange':limitkeys.timerange}],amount=e['scrobbles']) }}</td>
|
||||
<td class="bar">{{ links.link_scrobbles([{'album':e.album,'timerange':limitkeys.timerange}],percent=e['scrobbles']*100/maxbar) }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</table>
|
45
maloja/web/jinja/partials/charts_albums_tiles.jinja
Normal file
45
maloja/web/jinja/partials/charts_albums_tiles.jinja
Normal file
@ -0,0 +1,45 @@
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
|
||||
|
||||
{% if charts is undefined %}
|
||||
{% set charts = dbc.get_charts_albums(limitkeys) %}
|
||||
{% endif %}
|
||||
|
||||
{% set charts_14 = charts | fixlength(14) %}
|
||||
{% set charts_cycler = cycler(*charts_14) %}
|
||||
|
||||
|
||||
|
||||
<table class="tiles_top"><tr>
|
||||
{% for segment in range(3) %}
|
||||
{% if charts_14[0] is none and loop.first %}
|
||||
{% include 'icons/nodata.jinja' %}
|
||||
{% else %}
|
||||
<td>
|
||||
{% set segmentsize = segment+1 %}
|
||||
<table class="tiles_{{ segmentsize }}x{{ segmentsize }} tiles_sub">
|
||||
{% for row in range(segmentsize) -%}
|
||||
<tr>
|
||||
{% for col in range(segmentsize) %}
|
||||
{% set entry = charts_cycler.next() %}
|
||||
{% if entry is not none %}
|
||||
{% set album = entry.album %}
|
||||
{% set rank = entry.rank %}
|
||||
<td>
|
||||
<a href="{{ links.url(album) }}">
|
||||
<div class="lazy" data-bg="{{ images.get_album_image(album) }}"'>
|
||||
<span class='stats'>#{{ rank }}</span> <span>{{ album.title }}</span>
|
||||
</div>
|
||||
</a>
|
||||
</td>
|
||||
{% else -%}
|
||||
<td></td>
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
</tr>
|
||||
{%- endfor -%}
|
||||
</table>
|
||||
</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr></table>
|
30
maloja/web/jinja/partials/top_albums.jinja
Normal file
30
maloja/web/jinja/partials/top_albums.jinja
Normal file
@ -0,0 +1,30 @@
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
{% import 'snippets/entityrow.jinja' as entityrow %}
|
||||
|
||||
{% set ranges = dbc.get_top_albums(filterkeys,limitkeys,delimitkeys) %}
|
||||
|
||||
{% set maxbar = ranges|map(attribute="scrobbles")|max|default(1) %}
|
||||
{% if maxbar < 1 %}{% set maxbar = 1 %}{% endif %}
|
||||
|
||||
<table class="list">
|
||||
{% for e in ranges %}
|
||||
|
||||
{% set thisrange = e.range %}
|
||||
{% set album = e.album %}
|
||||
<tr>
|
||||
<td>{{ thisrange.desc() }}</td>
|
||||
|
||||
{% if album is none %}
|
||||
<td><div></div></td>
|
||||
<td class='stats'>n/a</td>
|
||||
<td class='amount'>0</td>
|
||||
<td class='bar'></td>
|
||||
{% else %}
|
||||
{{ entityrow.row(album) }}
|
||||
<td class='amount'>{{ links.link_scrobbles([{'album':album,'timerange':thisrange}],amount=e.scrobbles) }}</td>
|
||||
<td class='bar'> {{ links.link_scrobbles([{'album':album,'timerange':thisrange}],percent=e.scrobbles*100/maxbar) }}</td>
|
||||
{% endif %}
|
||||
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
@ -2,8 +2,10 @@
|
||||
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
|
||||
{% if entity is mapping and 'artists' in entity %}
|
||||
{% if entity is mapping and 'title' in entity %}
|
||||
{% set img = images.get_track_image(entity) %}
|
||||
{% elif entity is mapping and 'albumtitle' in entity %}
|
||||
{% set img = images.get_album_image(entity) %}
|
||||
{% else %}
|
||||
{% set img = images.get_artist_image(entity) %}
|
||||
{% endif %}
|
||||
@ -20,6 +22,10 @@
|
||||
<td class='track'>
|
||||
<span class='artist_in_trackcolumn'>{{ links.links(entity.artists) }}</span> – {{ links.link(entity) }}
|
||||
</td>
|
||||
{% elif entity is mapping and 'albumtitle' in entity %}
|
||||
<td class='album'>
|
||||
<span class='artist_in_trackcolumn'>{{ links.links(entity.artists) }}</span> – {{ links.link(entity) }}
|
||||
</td>
|
||||
{% else %}
|
||||
<td class='artist'>{{ links.link(entity) }}
|
||||
{% if counting != [] %}
|
||||
|
@ -7,6 +7,9 @@
|
||||
{% elif filterkeys.get('track') is not none %}
|
||||
of {{ links.link(filterkeys.get('track')) }}
|
||||
by {{ links.links(filterkeys["track"]["artists"]) }}
|
||||
{% elif filterkeys.get('album') is not none %}
|
||||
of {{ links.link(filterkeys.get('album')) }}
|
||||
by {{ links.links(filterkeys["album"]["artists"]) }}
|
||||
{% endif %}
|
||||
{{ limitkeys.timerange.desc(prefix=True) }}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% macro link(entity) -%}
|
||||
{% if entity is mapping and 'artists' in entity %}
|
||||
{% set name = entity.title %}
|
||||
{% set name = entity.title or entity.albumtitle %}
|
||||
{% else %}
|
||||
{% set name = entity %}
|
||||
{% endif %}
|
||||
@ -17,7 +17,9 @@
|
||||
|
||||
|
||||
{% macro url(entity) %}
|
||||
{% if entity is mapping and 'artists' in entity -%}
|
||||
{% if entity is mapping and 'albumtitle' in entity -%}
|
||||
{{ mlj_uri.create_uri("/album",{'album':entity}) }}
|
||||
{% elif entity is mapping and 'artists' in entity -%}
|
||||
{{ mlj_uri.create_uri("/track",{'track':entity}) }}
|
||||
{%- else -%}
|
||||
{{ mlj_uri.create_uri("/artist",{'artist':entity}) }}
|
||||
@ -43,6 +45,8 @@
|
||||
|
||||
{% if 'track' in filterkeys %}
|
||||
{% set url = mlj_uri.create_uri("/charts_tracks",{'timerange':timerange}) %}
|
||||
{% elif 'album' in filterkeys %}
|
||||
{% set url = mlj_uri.create_uri("/charts_albums",{'timerange':timerange}) %}
|
||||
{% elif 'artist' in filterkeys %}
|
||||
{% set url = mlj_uri.create_uri("/charts_artists",{'timerange':timerange}) %}
|
||||
{% endif %}
|
||||
|
30
maloja/web/jinja/top_albums.jinja
Normal file
30
maloja/web/jinja/top_albums.jinja
Normal file
@ -0,0 +1,30 @@
|
||||
{% extends "abstracts/base.jinja" %}
|
||||
{% block title %}Maloja - #1 Albums{% endblock %}
|
||||
|
||||
|
||||
<!-- find representative -->
|
||||
|
||||
{% set entries = dbc.get_top_albums(filterkeys,limitkeys,delimitkeys) %}
|
||||
{% set repr = entries | find_representative('album','scrobbles') %}
|
||||
{% set img = "/favicon.png" if repr is none else images.get_album_image(repr.album) %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('{{ img }}')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>#1 Albums</h1><br/>
|
||||
<span>{{ limitkeys.timerange.desc(prefix=True) }}</span>
|
||||
|
||||
<br/><br/>
|
||||
{% include 'snippets/timeselection.jinja' %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{% include 'partials/top_albums.jinja' %}
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user