From 04fc620e1deab6b12e7fad43e924e0ee9dde83a9 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Sat, 9 Oct 2021 16:00:59 +0200 Subject: [PATCH] Added play buttons for invoking desktop-client --- server/app.py | 10 +++++++++- server/templates/media_element.htm | 3 +++ server/templates/media_list.htm | 16 ++++++++++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/server/app.py b/server/app.py index 17b4812..5c35786 100644 --- a/server/app.py +++ b/server/app.py @@ -7,7 +7,7 @@ from __future__ import annotations from functools import partial import logging import os -from pathlib import Path +from urllib.parse import urlencode, quote_plus from typing import Any, Callable, Dict, Iterable, Optional, Union from flask import Flask, jsonify, make_response, request @@ -137,6 +137,14 @@ def as_link(uri: str): uri = Markup.escape(uri) return Markup(f'{uri}') +@flask_app.template_filter() +def as_play_link(video_uri: str): + opts = { + "video_uri": video_uri, + } + play_uri = "entertainment-decider:///player/play?" + urlencode(opts, quote_via=quote_plus) + return Markup(f'Play') + @flask_app.template_filter() def tenary(b: bool, true_str: str, false_str: str) -> str: return true_str if b else false_str diff --git a/server/templates/media_element.htm b/server/templates/media_element.htm index a391be3..f2b3c14 100644 --- a/server/templates/media_element.htm +++ b/server/templates/media_element.htm @@ -19,6 +19,9 @@
{{ element.notes or "" }}

Properties

Part of Collections

diff --git a/server/templates/media_list.htm b/server/templates/media_list.htm index 5ed4e59..c22b64f 100644 --- a/server/templates/media_list.htm +++ b/server/templates/media_list.htm @@ -10,6 +10,16 @@ padding: .2em; border: solid black 1px; } + a:link { text-decoration: none; } + a:visited { text-decoration: none; } + a:hover { text-decoration: none; } + a:active { text-decoration: none; } + .button { + padding: .1rem .2rem; + margin: 0 .1rem; + background-color: lightcoral; + border-radius: .3rem; + } @@ -28,7 +38,7 @@ Progress Length Consider - Link + Actions {% for media in media_list %} @@ -45,7 +55,9 @@ {{ media.length }} s {{ media.can_considered | tenary("Yes", "no") }} - link + + {{ media.uri | as_play_link }} + {% endfor %}