From 44a2739a3b6e58cb90b7f7dfca2197834cf30464 Mon Sep 17 00:00:00 2001 From: Krateng Date: Sun, 30 Aug 2020 03:08:45 +0200 Subject: [PATCH] Implemented pulse and performance in jinja --- maloja/__pkginfo__.py | 2 +- maloja/malojatime.py | 3 +- maloja/web/jinja/performance.jinja | 38 +++++++++++++++++++ maloja/web/jinja/pulse.jinja | 38 +++++++++++++++++++ maloja/web/jinja/scrobbles.jinja | 20 +++++----- .../jinja/snippets/filterdescription.jinja | 11 ++++++ 6 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 maloja/web/jinja/performance.jinja create mode 100644 maloja/web/jinja/pulse.jinja create mode 100644 maloja/web/jinja/snippets/filterdescription.jinja diff --git a/maloja/__pkginfo__.py b/maloja/__pkginfo__.py index 0e225c5..911db6d 100644 --- a/maloja/__pkginfo__.py +++ b/maloja/__pkginfo__.py @@ -5,7 +5,7 @@ author = { "email":"maloja@krateng.dev", "github": "krateng" } -version = 2,7,10 +version = 2,7,11 versionstr = ".".join(str(n) for n in version) links = { "pypi":"malojaserver", diff --git a/maloja/malojatime.py b/maloja/malojatime.py index 7c8fd81..99bae93 100644 --- a/maloja/malojatime.py +++ b/maloja/malojatime.py @@ -542,7 +542,8 @@ def time_stamps(since=None,to=None,within=None,range=None): # return (stamp1,stamp2-1) - +def delimit_desc_p(d): + return delimit_desc(**d) def delimit_desc(step="month",stepn=1,trail=1): txt = "" diff --git a/maloja/web/jinja/performance.jinja b/maloja/web/jinja/performance.jinja new file mode 100644 index 0000000..3fd7262 --- /dev/null +++ b/maloja/web/jinja/performance.jinja @@ -0,0 +1,38 @@ +{% extends "abstracts/base.jinja" %} +{% block title %}Maloja - {{ malojatime.delimit_desc_p(delimitkeys) }} Performance{% endblock %} + +{% import 'snippets/filterdescription.jinja' as filterdesc %} +{% import 'partials/performance.jinja' as performance %} + +{% if filterkeys.get('track') is not none %} + {% set img = utilities.getTrackImage(artists=filterkeys.track.artists,title=filterkeys.track.title,fast=True) %} +{% elif filterkeys.get('artist') is not none %} + {% set img = utilities.getArtistImage(filterkeys.artist,fast=True) %} +{% else %} + {% set img = "/favicon.png" %} +{% endif %} + +{% block content %} + + + + + +
+
+
+

{{ malojatime.delimit_desc_p(delimitkeys) }} Performance

+ {% if limitkeys != {} %} + View Pulse + {% endif %} +
+ {{ filterdesc.desc(filterkeys,limitkeys,prefix='of') }} +

+ {{ htmlmodules.module_filterselection(_urikeys,delimit=True) }} + +
+ + + {{ performance.performance(filterkeys,limitkeys,delimitkeys,amountkeys) }} + +{% endblock %} diff --git a/maloja/web/jinja/pulse.jinja b/maloja/web/jinja/pulse.jinja new file mode 100644 index 0000000..775788e --- /dev/null +++ b/maloja/web/jinja/pulse.jinja @@ -0,0 +1,38 @@ +{% extends "abstracts/base.jinja" %} +{% block title %}Maloja - {{ malojatime.delimit_desc_p(delimitkeys) }} Pulse{% endblock %} + +{% import 'snippets/filterdescription.jinja' as filterdesc %} +{% import 'partials/pulse.jinja' as pulse %} + +{% if filterkeys.get('track') is not none %} + {% set img = utilities.getTrackImage(artists=filterkeys.track.artists,title=filterkeys.track.title,fast=True) %} +{% elif filterkeys.get('artist') is not none %} + {% set img = utilities.getArtistImage(filterkeys.artist,fast=True) %} +{% else %} + {% set img = "/favicon.png" %} +{% endif %} + +{% block content %} + + + + + +
+
+
+

{{ malojatime.delimit_desc_p(delimitkeys) }} Pulse

+ {% if filterkeys != {} %} + View Rankings + {% endif %} +
+ {{ filterdesc.desc(filterkeys,limitkeys,prefix='of') }} +

+ {{ htmlmodules.module_filterselection(_urikeys,delimit=True) }} + +
+ + + {{ pulse.pulse(filterkeys,limitkeys,delimitkeys,amountkeys) }} + +{% endblock %} diff --git a/maloja/web/jinja/scrobbles.jinja b/maloja/web/jinja/scrobbles.jinja index c5098a8..078f7b6 100644 --- a/maloja/web/jinja/scrobbles.jinja +++ b/maloja/web/jinja/scrobbles.jinja @@ -1,7 +1,12 @@ {% extends "abstracts/base.jinja" %} {% block title %}Maloja - Scrobbles{% endblock %} +{% import 'snippets/filterdescription.jinja' as filterdesc %} +{% import 'partials/scrobbles.jinja' as scrobblemodule %} +{% import 'snippets/pagination.jinja' as pagination %} + {% set scrobbles = dbp.get_scrobbles(filterkeys,limitkeys,amountkeys) %} +{% set pages = math.ceil(scrobbles.__len__() / amountkeys.perpage) %} {% if filterkeys.get('track') is not none %} {% set img = utilities.getTrackImage(artists=filterkeys.track.artists,title=filterkeys.track.title,fast=True) %} @@ -23,13 +28,8 @@

Scrobbles


- {% if filterkeys.get('artist') is not none %} - by {{ htmlgenerators.artistLink(filterkeys.get('artist')) }} - {% elif filterkeys.get('track') is not none %} - of {{ htmlgenerators.trackLink(filterkeys.get('track')) }} - by {{ htmlgenerators.artistLinks(filterkeys["track"]["artists"]) }} - {% endif %} - {{ limitkeys.timerange.desc(prefix=True) }}
+ {{ filterdesc.desc(filterkeys,limitkeys) }} +

{{ scrobbles.__len__() }} Scrobbles


{{ htmlmodules.module_filterselection(_urikeys) }} @@ -38,8 +38,10 @@ - {% import 'partials/scrobbles.jinja' as scrobbles %} - {{ scrobbles.scrobbles(filterkeys,limitkeys,amountkeys) }} + + {{ scrobblemodule.scrobbles(filterkeys,limitkeys,amountkeys) }} + + {{ pagination.pagination(filterkeys,limitkeys,delimitkeys,amountkeys,pages) }} {% endblock %} diff --git a/maloja/web/jinja/snippets/filterdescription.jinja b/maloja/web/jinja/snippets/filterdescription.jinja new file mode 100644 index 0000000..af83c08 --- /dev/null +++ b/maloja/web/jinja/snippets/filterdescription.jinja @@ -0,0 +1,11 @@ +{% macro desc(filterkeys,limitkeys,prefix="by") %} + + {% if filterkeys.get('artist') is not none %} + {{ prefix }} {{ htmlgenerators.artistLink(filterkeys.get('artist')) }} + {% elif filterkeys.get('track') is not none %} + of {{ htmlgenerators.trackLink(filterkeys.get('track')) }} + by {{ htmlgenerators.artistLinks(filterkeys["track"]["artists"]) }} + {% endif %} + {{ limitkeys.timerange.desc(prefix=True) }} + +{% endmacro %}