From 5822702590ec03b6d23113014b37929a944b84a7 Mon Sep 17 00:00:00 2001 From: evilchili Date: Sat, 31 Dec 2022 15:16:30 -0800 Subject: [PATCH] adding mastodon meta card, BASE_URL config option. --- groove/cli.py | 3 +++ groove/playlist.py | 6 ++++-- groove/static/themes/blue_train/templates/playlist.tpl | 10 +++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/groove/cli.py b/groove/cli.py index 1907a1e..1c87406 100644 --- a/groove/cli.py +++ b/groove/cli.py @@ -51,6 +51,9 @@ DEFAULT_THEME=blue_train HOST=127.0.0.1 PORT=2323 +# The URL to use when constructing links. Defaults to http://HOST:PORT. +#BASE_URL=http://127.0.0.1:2323 + # Set this to a suitably random string. SECRET_KEY= diff --git a/groove/playlist.py b/groove/playlist.py index 99207b0..4609497 100644 --- a/groove/playlist.py +++ b/groove/playlist.py @@ -73,7 +73,8 @@ class Playlist: @property def url(self) -> str: - return f"http://{os.environ['HOST']}:{os.environ['PORT']}/playlist/{self.slug}" + base = os.environ.get('BASE_URL', f"http://{os.environ['HOST']}:{os.environ['PORT']}") + return f"{base}/playlist/{self.slug}" @property def slug(self) -> str: @@ -127,7 +128,8 @@ class Playlist: playlist = { 'name': self.name, 'slug': self.slug, - 'description': self.description + 'description': self.description, + 'url': self.url } if self.record: playlist.update(dict(self.record)) diff --git a/groove/static/themes/blue_train/templates/playlist.tpl b/groove/static/themes/blue_train/templates/playlist.tpl index c6ea51b..da9ed87 100644 --- a/groove/static/themes/blue_train/templates/playlist.tpl +++ b/groove/static/themes/blue_train/templates/playlist.tpl @@ -1,9 +1,17 @@ + {{playlist['name']}} - Groove On Demand + - Groove On Demand + + + + + + "> +