sessions / 4468e68110dcec93d63b91e773a914cb5ba163c2

/home/powellc/src/code.unbl.ink/secstate/vrobbler

This commit has no recorded session.

diff

ignore whitespace

commit 4468e68110dcec93d63b91e773a914cb5ba163c2Author: Colin Powell <colin@unbl.ink>Date:   Tue Jun 30 16:29:56 2026 -0400    [charts] Split maloja charts out from tablesdiff --git a/PROJECT.org b/PROJECT.orgindex ba10636..ea9b720 100644--- a/PROJECT.org+++ b/PROJECT.org@@ -88,7 +88,7 @@ fetching and simple saving. *** Metadata sources **** Scraper -* Backlog [1/24] :vrobbler:project:personal:+* Backlog [2/25] :vrobbler:project:personal: ** TODO [#C] After transition to linux add curl_cffi as webpage scrapper again :webpages:metadata: ** TODO [#C] Create small utility to clean up tracks scrobbled with wonky playback times :bug:music:scrobbles: :PROPERTIES:@@ -605,6 +605,10 @@ independent of the email flow it was originally creatdd for  ** TODO [#B] Is there way to create unique slugs for media instances :media_types: +** DONE [#B] Split up chart page between tables and maloja :charts:templates:+:PROPERTIES:+:ID:       103ab084-2016-cfa4-c677-3c5fdc54cce0+:END: ** DONE [#A] Fix CI so we don't double run deploys and builds :ci: :PROPERTIES: :ID:       1a93e7cb-b883-aae5-2bd5-fcdd6e16f8abdiff --git a/vrobbler/apps/charts/urls.py b/vrobbler/apps/charts/urls.pyindex fe05a7b..22c45b5 100644--- a/vrobbler/apps/charts/urls.py+++ b/vrobbler/apps/charts/urls.py@@ -3,6 +3,7 @@ from charts.views import (     BirdsChartView,     ChartDetailView,     ChartRecordView,+    MalojaChartsView,     SpotifyTracksView, ) from django.urls import path@@ -11,6 +12,7 @@ app_name = "charts"  urlpatterns = [     path("charts/", ChartRecordView.as_view(), name="charts-home"),+    path("charts/maloja/", MalojaChartsView.as_view(), name="maloja-charts"),     path("charts/spotify/", SpotifyTracksView.as_view(), name="spotify-tracks"),     path("charts/bandcamp/", BandcampTracksView.as_view(), name="bandcamp-tracks"),     path("charts/birds/", BirdsChartView.as_view(), name="birds-chart"),diff --git a/vrobbler/apps/charts/views.py b/vrobbler/apps/charts/views.pyindex d5882eb..9a88541 100644--- a/vrobbler/apps/charts/views.py+++ b/vrobbler/apps/charts/views.py@@ -159,80 +159,6 @@ class ChartRecordView(TemplateView):             context["week"] = current_week             context["day"] = current_day -        context["chart_keys"] = {-            "today": "Today",-            "week": "This Week",-            "month": "This Month",-            "year": "This Year",-            "all": "All Time",-        }--        context["maloja_charts"] = {-            "artist": {-                "today": list(-                    self.get_charts_for_period(-                        user, "artist", year=year, month=month, day=day,-                    )-                ),-                "week": list(-                    self.get_charts_for_period(-                        user, "artist", year=year, week=week,-                    )-                ),-                "month": list(-                    self.get_charts_for_period(-                        user, "artist", year=year, month=month,-                    )-                ),-                "year": list(-                    self.get_charts_for_period(user, "artist", year=year)-                ),-                "all": list(self.get_charts_for_period(user, "artist")),-            },-            "album": {-                "today": list(-                    self.get_charts_for_period(-                        user, "album", year=year, month=month, day=day,-                    )-                ),-                "week": list(-                    self.get_charts_for_period(-                        user, "album", year=year, week=week,-                    )-                ),-                "month": list(-                    self.get_charts_for_period(-                        user, "album", year=year, month=month,-                    )-                ),-                "year": list(-                    self.get_charts_for_period(user, "album", year=year)-                ),-                "all": list(self.get_charts_for_period(user, "album")),-            },-            "tv_series": {-                "today": list(-                    self.get_charts_for_period(-                        user, "tv_series", year=year, month=month, day=day,-                    )-                ),-                "week": list(-                    self.get_charts_for_period(-                        user, "tv_series", year=year, week=week,-                    )-                ),-                "month": list(-                    self.get_charts_for_period(-                        user, "tv_series", year=year, month=month,-                    )-                ),-                "year": list(-                    self.get_charts_for_period(user, "tv_series", year=year)-                ),-                "all": list(self.get_charts_for_period(user, "tv_series")),-            },-        }-         # List-group tables default to week-level when no date param (matches active tab)         if not date_param:             list_year = current_year@@ -510,6 +436,53 @@ class ChartRecordView(TemplateView):         }  +class MalojaChartsView(ChartRecordView):+    """Three maloja-themed image grid widgets (artists, albums, TV series)+    with Today/Week/Month/Year/All tabs. Each tab computes its own period+    from the current date โ€” no query param needed."""++    template_name = "charts/maloja_charts.html"++    def get_context_data(self, **kwargs):+        context = super(ChartRecordView, self).get_context_data(**kwargs)+        user = self.request.user++        now = timezone.now()+        if user.is_authenticated:+            now = now_user_timezone(user.profile)+        today = now.date()++        context["chart_keys"] = {+            "today": "Today",+            "week": "This Week",+            "month": "This Month",+            "year": "This Year",+            "all": "All Time",+        }++        tab_params = {+            "today": {"year": today.year, "month": today.month, "day": today.day},+            "week": {"year": today.year, "week": today.isocalendar()[1]},+            "month": {"year": today.year, "month": today.month},+            "year": {"year": today.year},+        }++        maloja_charts = {}+        for media_type in ("artist", "album", "tv_series"):+            tabs = {}+            for key in ("today", "week", "month", "year"):+                tabs[key] = list(+                    self.get_charts_for_period(user, media_type, **tab_params[key])+                )+            tabs["all"] = list(+                self.get_charts_for_period(user, media_type)+            )+            maloja_charts[media_type] = tabs++        context["maloja_charts"] = maloja_charts+        return context++ MEDIA_TYPE_LABELS = {     "artist": ("๐ŸŽค", "Top Artists"),     "album": ("๐Ÿ’ฟ", "Top Albums"),diff --git a/vrobbler/templates/charts/chart_index.html b/vrobbler/templates/charts/chart_index.htmlindex ddffe3e..bacca6e 100644--- a/vrobbler/templates/charts/chart_index.html+++ b/vrobbler/templates/charts/chart_index.html@@ -120,7 +120,11 @@ </div> {% endif %} -{% include "scrobbles/_top_charts.html" %}+<div class="row mb-3">+    <div class="col-12">+        <a href="{% url 'charts:maloja-charts' %}" class="btn btn-sm btn-outline-secondary">๐ŸŽจ Maloja Widgets</a>+    </div>+</div>  <div class="row mt-4">     {% if charts.artist %}diff --git a/vrobbler/templates/charts/maloja_charts.html b/vrobbler/templates/charts/maloja_charts.htmlnew file mode 100644index 0000000..a3c320c--- /dev/null+++ b/vrobbler/templates/charts/maloja_charts.html@@ -0,0 +1,45 @@+{% extends "base_list.html" %}+{% load static %}++{% block title %}Maloja Widgets{% endblock %}++{% block head_extra %}+<style>+    .container { margin-bottom: 100px; }+    h2 { padding-top: 20px; }+    .nav-tabs { cursor: pointer; }+    .image-wrapper { contain: content; }+    .image-wrapper :hover { background: rgba(0,0,0,0.3); }+    .caption {+        position: fixed; top: 5px; left: 5px;+        padding: 3px; font-size: 90%;+        color: white; background: rgba(0,0,0,0.4);+    }+    .caption-medium {+        position: fixed; top: 5px; left: 5px;+        padding: 3px; font-size: 75%;+        color: white; background: rgba(0,0,0,0.4);+    }+    .caption-small {+        position: fixed; top: 5px; left: 5px;+        padding: 3px; font-size: 60%;+        color: white; background: rgba(0,0,0,0.4);+    }+</style>+{% endblock %}++{% block lists %}++{% block grid_view_button %}{% endblock %}++<div class="row mb-3">+    <div class="col-12">+        <a href="{% url 'charts:charts-home' %}" class="btn btn-sm btn-outline-secondary">&larr; Full Charts</a>+        <a href="{% url 'charts:spotify-tracks' %}" class="btn btn-sm btn-outline-secondary">๐ŸŽต Spotify Tracks</a>+        <a href="{% url 'charts:bandcamp-tracks' %}" class="btn btn-sm btn-outline-secondary">๐ŸŽต Bandcamp Tracks</a>+    </div>+</div>++{% include "scrobbles/_top_charts.html" %}++{% endblock %}