From 6ff7aa2ee035eb81e61b85b28ba2f7cbb55130f5 Mon Sep 17 00:00:00 2001 From: krateng Date: Wed, 24 May 2023 17:44:50 +0200 Subject: [PATCH] Experimental start page redesign --- maloja/pkg_global/conf.py | 3 +- maloja/web/jinja/partials/info_album.jinja | 45 +++++++ maloja/web/jinja/partials/info_artist.jinja | 59 +++++++++ maloja/web/jinja/partials/info_track.jinja | 48 +++++++ maloja/web/jinja/snippets/links.jinja | 2 +- maloja/web/jinja/start.jinja | 121 ++++-------------- .../startpage_modules/charts_albums.jinja | 19 +++ .../startpage_modules/charts_artists.jinja | 19 +++ .../startpage_modules/charts_tracks.jinja | 19 +++ .../jinja/startpage_modules/featured.jinja | 58 +++++++++ .../startpage_modules/lastscrobbles.jinja | 15 +++ .../web/jinja/startpage_modules/pulse.jinja | 17 +++ maloja/web/static/css/maloja.css | 38 +----- maloja/web/static/css/startpage.css | 49 +++++++ maloja/web/static/js/rangeselect.js | 21 +-- 15 files changed, 386 insertions(+), 147 deletions(-) create mode 100644 maloja/web/jinja/partials/info_album.jinja create mode 100644 maloja/web/jinja/partials/info_artist.jinja create mode 100644 maloja/web/jinja/partials/info_track.jinja create mode 100644 maloja/web/jinja/startpage_modules/charts_albums.jinja create mode 100644 maloja/web/jinja/startpage_modules/charts_artists.jinja create mode 100644 maloja/web/jinja/startpage_modules/charts_tracks.jinja create mode 100644 maloja/web/jinja/startpage_modules/featured.jinja create mode 100644 maloja/web/jinja/startpage_modules/lastscrobbles.jinja create mode 100644 maloja/web/jinja/startpage_modules/pulse.jinja create mode 100644 maloja/web/static/css/startpage.css diff --git a/maloja/pkg_global/conf.py b/maloja/pkg_global/conf.py index a9be47b..f8c61f4 100644 --- a/maloja/pkg_global/conf.py +++ b/maloja/pkg_global/conf.py @@ -189,8 +189,7 @@ malojaconfig = Configuration( "parse_remix_artists":(tp.Boolean(), "Parse Remix Artists", False) }, "Web Interface":{ - "default_range_charts_artists":(tp.Choice({'alltime':'All Time','year':'Year','month':"Month",'week':'Week'}), "Default Range Artist Charts", "year"), - "default_range_charts_tracks":(tp.Choice({'alltime':'All Time','year':'Year','month':"Month",'week':'Week'}), "Default Range Track Charts", "year"), + "default_range_startpage":(tp.Choice({'alltime':'All Time','year':'Year','month':"Month",'week':'Week'}), "Default Range for Startpage Stats", "year"), "default_step_pulse":(tp.Choice({'year':'Year','month':"Month",'week':'Week','day':'Day'}), "Default Pulse Step", "month"), "charts_display_tiles":(tp.Boolean(), "Display Chart Tiles", False), "album_showcase":(tp.Boolean(), "Display Album Showcase", True, "Display a graphical album showcase for artist overview pages instead of a chart list"), diff --git a/maloja/web/jinja/partials/info_album.jinja b/maloja/web/jinja/partials/info_album.jinja new file mode 100644 index 0000000..95a9ca9 --- /dev/null +++ b/maloja/web/jinja/partials/info_album.jinja @@ -0,0 +1,45 @@ +{% import 'snippets/links.jinja' as links %} +{% import 'partials/awards_album.jinja' as awards %} + +{% set album = filterkeys.album %} +{% set info = dbc.album_info({'album':album}) %} + +{% set encodedalbum = mlj_uri.uriencode({'album':album}) %} + + + + + + + +
+ {% if adminmode %} +
+ {% else %} +
+
+ {% endif %} +
+ {{ links.links(album.artists) }}
+

{{ info.album.albumtitle | e }}

+ {# awards.certs(album) #} + #{{ info.position }} +
+ +

+ {{ info['scrobbles'] }} Scrobbles +

+ + + + + + {{ awards.medals(info) }} + {{ awards.topweeks(info) }} + + +
diff --git a/maloja/web/jinja/partials/info_artist.jinja b/maloja/web/jinja/partials/info_artist.jinja new file mode 100644 index 0000000..f3308a9 --- /dev/null +++ b/maloja/web/jinja/partials/info_artist.jinja @@ -0,0 +1,59 @@ +{% import 'snippets/links.jinja' as links %} +{% import 'partials/awards_artist.jinja' as awards %} + + +{% set artist = filterkeys.artist %} +{% set info = db.artist_info(artist=artist) %} + +{% set credited = info.get('replace') %} +{% set included = info.get('associated') %} + +{% if credited is not none %} + {% set competes = false %} +{% else %} + {% set credited = artist %} + {% set competes = true %} +{% endif %} + + + + + + + +
+ {% if adminmode %} +
+ {% else %} +
+
+ {% endif %} +
+

{{ info.artist | e }}

+ {% if competes and info['scrobbles']>0 %}#{{ info.position }}{% endif %} +
+ {% if competes and included %} + associated: {{ links.links(included) }} + {% elif not competes %} + Competing under {{ links.link(credited) }} (#{{ info.position }}) + {% endif %} + +

+ {{ info['scrobbles'] }} Scrobbles +

+ + + + + {% if competes %} + {{ awards.medals(info) }} + {{ awards.topweeks(info) }} + {% endif %} + {{ awards.certs(artist) }} + + +
diff --git a/maloja/web/jinja/partials/info_track.jinja b/maloja/web/jinja/partials/info_track.jinja new file mode 100644 index 0000000..f46e342 --- /dev/null +++ b/maloja/web/jinja/partials/info_track.jinja @@ -0,0 +1,48 @@ +{% import 'snippets/links.jinja' as links %} + +{% set track = filterkeys.track %} +{% set info = dbc.track_info({'track':track}) %} + +{% import 'partials/awards_track.jinja' as awards %} + + + + + + + +
+ {% if adminmode %} +
+ {% else %} +
+
+ {% endif %} +
+ {{ links.links(track.artists) }}
+

{{ info.track.title | e }}

+ {{ awards.certs(track) }} + #{{ info.position }} +
+ {% if info.track.album %} + from {{ links.link(info.track.album) }}
+ {% endif %} + +

+ {% if adminmode %}{% endif %} + {{ info['scrobbles'] }} Scrobbles +

+ + + + + + {{ awards.medals(info) }} + {{ awards.topweeks(info) }} + + +
diff --git a/maloja/web/jinja/snippets/links.jinja b/maloja/web/jinja/snippets/links.jinja index 3b5c29d..f90a535 100644 --- a/maloja/web/jinja/snippets/links.jinja +++ b/maloja/web/jinja/snippets/links.jinja @@ -1,5 +1,5 @@ {% macro link(entity) -%} - {% if entity is mapping and 'title' in entity or 'albumtitle' in entity %} + {% if entity is mapping and ('title' in entity or 'albumtitle' in entity) %} {% set name = entity.title or entity.albumtitle %} {% else %} {% set name = entity %} diff --git a/maloja/web/jinja/start.jinja b/maloja/web/jinja/start.jinja index f8240da..eb22b37 100644 --- a/maloja/web/jinja/start.jinja +++ b/maloja/web/jinja/start.jinja @@ -3,109 +3,44 @@ {% block scripts %} - - + + + + {% endblock %} {% block content -%} - - -

Top Artists

- - {% for r in xcurrent -%} - - {{ r.localisation }} - - {{ "|" if not loop.last }} - {%- endfor %} - -

+
- {% for r in xcurrent -%} - - {%- endfor %} + {% for module in ['charts_artists','charts_tracks','charts_albums','pulse','lastscrobbles','featured'] %} +
+ + + {% include 'startpage_modules/' + module + '.jinja' %} + +
+ {% endfor %} +
- -

Top Tracks

- - {% for r in xcurrent -%} - - {{ r.localisation }} - - {{ "|" if not loop.last }} - {%- endfor %} - -

- - - {% for r in xcurrent -%} - - {%- endfor %} - - -
- - -

Last Scrobbles

- - {% for range in xcurrent %} - {{ range.localisation }} - {{ dbc.get_scrobbles_num({'timerange':range.range}) }} - {% endfor %} -

- - - - - {%- with amountkeys = {"perpage":12,"page":0}, shortTimeDesc=True -%} - {% include 'partials/scrobbles.jinja' %} - {%- endwith -%} - - - -
- - - - - -

Pulse

- - {% for range in xranges -%} - - {{ range.localisation }} - - {{ "|" if not loop.last }} - {%- endfor %} -

- - {% for range in xranges -%} - - {%- endfor %} - - -
{%- endblock %} diff --git a/maloja/web/jinja/startpage_modules/charts_albums.jinja b/maloja/web/jinja/startpage_modules/charts_albums.jinja new file mode 100644 index 0000000..671fe10 --- /dev/null +++ b/maloja/web/jinja/startpage_modules/charts_albums.jinja @@ -0,0 +1,19 @@ +

Top Albums

+ +{% for r in xcurrent -%} + + {{ r.localisation }} + + {{ "|" if not loop.last }} +{%- endfor %} + +

+ + +{% for r in xcurrent -%} + +{%- endfor %} diff --git a/maloja/web/jinja/startpage_modules/charts_artists.jinja b/maloja/web/jinja/startpage_modules/charts_artists.jinja new file mode 100644 index 0000000..0c78c89 --- /dev/null +++ b/maloja/web/jinja/startpage_modules/charts_artists.jinja @@ -0,0 +1,19 @@ +

Top Artists

+ +{% for r in xcurrent -%} + + {{ r.localisation }} + + {{ "|" if not loop.last }} +{%- endfor %} + +

+ + +{% for r in xcurrent -%} + +{%- endfor %} diff --git a/maloja/web/jinja/startpage_modules/charts_tracks.jinja b/maloja/web/jinja/startpage_modules/charts_tracks.jinja new file mode 100644 index 0000000..4ae6e4c --- /dev/null +++ b/maloja/web/jinja/startpage_modules/charts_tracks.jinja @@ -0,0 +1,19 @@ +

Top Tracks

+ +{% for r in xcurrent -%} + + {{ r.localisation }} + + {{ "|" if not loop.last }} +{%- endfor %} + +

+ + +{% for r in xcurrent -%} + +{%- endfor %} diff --git a/maloja/web/jinja/startpage_modules/featured.jinja b/maloja/web/jinja/startpage_modules/featured.jinja new file mode 100644 index 0000000..1c96ea2 --- /dev/null +++ b/maloja/web/jinja/startpage_modules/featured.jinja @@ -0,0 +1,58 @@ +

Featured

+ + +{% set entitytypes = [ + {'identifier':'artist','localisation':"Artist", 'template':"info_artist.jinja", 'filterkeys':{"artist":"Blackpink"} }, + {'identifier':'track','localisation':"Track", 'template':"info_track.jinja", 'filterkeys':{"track": {"artists": ["Red Velvet"], "title": "Russian Roulette"}} }, + {'identifier':'album','localisation':"Album", 'template':"info_album.jinja", 'filterkeys':{"album": {"artists": ["TWICE"], "albumtitle": "The Story Begins"}} } +] %} + + +{% for t in entitytypes -%} + + {{ t.localisation }} + + {{ "|" if not loop.last }} +{%- endfor %} + +


+ + +{% for t in entitytypes -%} + +{%- endfor %} + + + + + diff --git a/maloja/web/jinja/startpage_modules/lastscrobbles.jinja b/maloja/web/jinja/startpage_modules/lastscrobbles.jinja new file mode 100644 index 0000000..ae0da70 --- /dev/null +++ b/maloja/web/jinja/startpage_modules/lastscrobbles.jinja @@ -0,0 +1,15 @@ +

Last Scrobbles

+ +{% for range in xcurrent %} + {{ range.localisation }} + {{ dbc.get_scrobbles_num({'timerange':range.range}) }} +{% endfor %} +

+ + + + + {%- with amountkeys = {"perpage":12,"page":0}, shortTimeDesc=True -%} + {% include 'partials/scrobbles.jinja' %} + {%- endwith -%} + diff --git a/maloja/web/jinja/startpage_modules/pulse.jinja b/maloja/web/jinja/startpage_modules/pulse.jinja new file mode 100644 index 0000000..5efdc00 --- /dev/null +++ b/maloja/web/jinja/startpage_modules/pulse.jinja @@ -0,0 +1,17 @@ +

Pulse

+ +{% for range in xranges -%} + + {{ range.localisation }} + + {{ "|" if not loop.last }} +{%- endfor %} +

+ +{% for range in xranges -%} + +{%- endfor %} diff --git a/maloja/web/static/css/maloja.css b/maloja/web/static/css/maloja.css index 3c838db..95c17c1 100644 --- a/maloja/web/static/css/maloja.css +++ b/maloja/web/static/css/maloja.css @@ -802,10 +802,12 @@ table.misc td { div.tiles { display: grid; - grid-template-columns: repeat(18, 50px); - grid-template-rows: repeat(6, 50px); + grid-template-columns: repeat(18, calc(100% / 18)); + grid-template-rows: repeat(6, calc(100% / 6)); grid-auto-flow: row dense; + aspect-ratio: 3 / 1; + } div.tiles div { @@ -982,35 +984,3 @@ span.stat_module_pulse, span.stat_module_topartists, span.stat_module_toptracks display: inline-block; vertical-align: top; } - -/* -** -** -** SIDE LIST ON START PAGE -** -** -*/ - - -@media (min-width: 1600px) { -div.sidelist { - position:absolute; - right:0px; - top:0px; - width:40%; - height:100%; - --current-bg-color: var(--base-color-light); /* drag this information through inheritances */ - background-color: var(--current-bg-color); - padding-left:30px; - padding-right:30px; -} -} - -div.sidelist table { - width:100%; - table-layout:fixed; -} - -div.sidelist table.list td.time { - width:17%; -} diff --git a/maloja/web/static/css/startpage.css b/maloja/web/static/css/startpage.css new file mode 100644 index 0000000..2d3fe9b --- /dev/null +++ b/maloja/web/static/css/startpage.css @@ -0,0 +1,49 @@ +div#startpage { + display: grid; + justify-content: center; + + display: fixed; + grid-column-gap: 25px; + grid-row-gap: 25px; +} + + +@media (min-width: 2201px) { + div#startpage { + grid-template-columns: 30vw 30vw 30vw; + grid-template-rows: 45vh 45vh; + + grid-template-areas: + "charts_artists charts_tracks charts_albums" + "lastscrobbles featured pulse"; + } +} + +@media (min-width: 1401px) and (max-width: 2200px) { + div#startpage { + grid-template-columns: 45vw 45vw; + grid-template-rows: 45vh 45vh 45vh; + + grid-template-areas: + "charts_artists lastscrobbles" + "charts_tracks pulse" + "charts_albums featured"; + } +} + +@media (max-width: 1400px) { + div#startpage { + grid-template-columns: 90vw; + + grid-template-areas: + "charts_artists" + "charts_tracks" + "charts_albums" + "lastscrobbles" + "pulse"; + } + + #start_page_module_featured { + display: none; + } +} diff --git a/maloja/web/static/js/rangeselect.js b/maloja/web/static/js/rangeselect.js index f42d789..2561a69 100644 --- a/maloja/web/static/js/rangeselect.js +++ b/maloja/web/static/js/rangeselect.js @@ -2,7 +2,7 @@ localStorage = window.localStorage; function showRange(identifier,unit) { // Make all modules disappear - modules = document.getElementsByClassName("stat_module_" + identifier); + var modules = document.getElementsByClassName("stat_module_" + identifier); for (var i=0;i