From: Christian Heller Date: Tue, 10 Dec 2024 15:57:51 +0000 (+0100) Subject: In all-pages player control, link playing title to file page. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/todo?a=commitdiff_plain;h=eeffb6b6e21ce4abe1194e6ed0b4e1d263b77a65;p=ytplom In all-pages player control, link playing title to file page. --- diff --git a/src/templates/_base.tmpl b/src/templates/_base.tmpl index 9f19af6..2161f8f 100644 --- a/src/templates/_base.tmpl +++ b/src/templates/_base.tmpl @@ -8,6 +8,8 @@ const RETRY_INTERVAL_S = 5; const PATH_EVENTS = '/{{page_names.events}}'; const PATH_PLAYER = '/{{page_names.player}}'; +const PATH_PLAYLIST = '/{{page_names.playlist}}'; +const PATH_PREFIX_FILE = '/{{page_names.file}}/'; var event_handlers = []; var events_params = ''; @@ -42,11 +44,12 @@ function player_command(command) { send_to({command: [command]}, PATH_PLAYER); } event_handlers.push(function(data) { // update player state - const state_desc = data.running ? (data.paused ? 'paused' : 'playing') : 'stopped'; - for (const [id, text] of [['player_state', `${state_desc}: ${data.title}`], + for (const [id, text] of [['player_state', data.running ? (data.paused ? 'paused' : 'playing') : 'stopped'], + ['a_playing', data.title], ['btn_pause', data.paused ? 'resume' : 'pause'], - ['btn_stop', data.running? 'stop' : 'play']]) { - document.getElementById(id).textContent = text; }}); + ['btn_stop', data.running ? 'stop' : 'play']]) { + document.getElementById(id).textContent = text; } + document.getElementById('a_playing').href = data.title_digest ? `${PATH_PREFIX_FILE}${data.title_digest}` : PATH_PLAYLIST ; }) {% block script %} {% endblock %} @@ -65,11 +68,12 @@ td, th { vertical-align: top; text-align: left; } {{ macros.link_if("playlist" != selected, page_names.playlist) }} · {{ macros.link_if("files" != selected, page_names.files) }} · {{ macros.link_if("yt_queries" != selected, page_names.yt_queries, "queries") }} -| +
+ - - - + + +· :
{% block body %} {% endblock %} diff --git a/src/ytplom/http.py b/src/ytplom/http.py index 90c3ef0..4535361 100644 --- a/src/ytplom/http.py +++ b/src/ytplom/http.py @@ -381,6 +381,7 @@ class _TaskHandler(BaseHTTPRequestHandler): 'last_update': self.server.player.last_update, 'running': self.server.player.is_running, 'paused': self.server.player.is_paused, + 'title_digest': playing.digest.b64 if playing else '', 'title': str(playing.rel_path) if playing else 'none'} if 'playlist' in params.as_dict: data['playlist_files'] = [