From 74933687c1005d40ca7ee5449d956cc49706d88e Mon Sep 17 00:00:00 2001 From: Ricardo Date: Sun, 22 Feb 2026 00:13:41 +0100 Subject: [PATCH] feat: unify listening widget with Funkwhale + Last.fm sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show 2 recent tracks from each source (4 total) instead of only Funkwhale. Removed stats section — users can visit /listening/ for full statistics. Now Playing indicator works from either source. --- _includes/components/widgets/funkwhale.njk | 118 ++++++++++++++------- 1 file changed, 79 insertions(+), 39 deletions(-) diff --git a/_includes/components/widgets/funkwhale.njk b/_includes/components/widgets/funkwhale.njk index 36aba11..5ac286a 100644 --- a/_includes/components/widgets/funkwhale.njk +++ b/_includes/components/widgets/funkwhale.njk @@ -1,6 +1,6 @@ -{# Funkwhale Now Playing Widget #} -{% if funkwhaleActivity and (funkwhaleActivity.nowPlaying or funkwhaleActivity.stats) %} - +{# Listening Widget — combined Funkwhale + Last.fm recent tracks #} +{% set hasListening = (funkwhaleActivity and (funkwhaleActivity.nowPlaying or funkwhaleActivity.listenings.length)) or (lastfmActivity and (lastfmActivity.nowPlaying or lastfmActivity.scrobbles.length)) %} +{% if hasListening %}

@@ -9,10 +9,15 @@ Listening

- {# Now Playing / Recently Played #} - {% if funkwhaleActivity.nowPlaying and funkwhaleActivity.nowPlaying.track %} -
- {% if funkwhaleActivity.nowPlaying.status == 'now-playing' %} + {# Now Playing — show if either source is actively playing #} + {% set fwNow = funkwhaleActivity.nowPlaying if funkwhaleActivity and funkwhaleActivity.nowPlaying and funkwhaleActivity.nowPlaying.status == 'now-playing' else null %} + {% set lfmNow = lastfmActivity.nowPlaying if lastfmActivity and lastfmActivity.nowPlaying and lastfmActivity.nowPlaying.status == 'now-playing' else null %} + + {% if fwNow or lfmNow %} + {% set np = fwNow or lfmNow %} + {% set npSource = "Funkwhale" if fwNow else "Last.fm" %} + {% set npColor = "purple" if fwNow else "red" %} +
@@ -20,54 +25,89 @@ Now Playing + ({{ npSource }})
- {% elif funkwhaleActivity.nowPlaying.status == 'recently-played' %} -
Recently Played
- {% endif %} -
- {% if funkwhaleActivity.nowPlaying.coverUrl %} - + {% if np.coverUrl %} + {% endif %}

- {% if funkwhaleActivity.nowPlaying.trackUrl %} - - {{ funkwhaleActivity.nowPlaying.track }} - + {% if np.trackUrl %} + {{ np.track }} {% else %} - {{ funkwhaleActivity.nowPlaying.track }} + {{ np.track }} {% endif %}

-

{{ funkwhaleActivity.nowPlaying.artist }}

+

{{ np.artist }}

{% endif %} - {# Quick Stats #} - {% if funkwhaleActivity.stats and funkwhaleActivity.stats.summary %} - {% set stats = funkwhaleActivity.stats.summary.all %} -
-
- {{ stats.totalPlays or 0 }} - plays -
-
- {{ stats.uniqueArtists or 0 }} - artists -
-
- {{ stats.totalDurationFormatted or '0m' }} - listened -
-
- {% endif %} + {# Recent tracks — 2 from each source #} + + + View full listening history
- {% endif %}