From 72d238b05d66e20ab8c910ffd2a404981b518951 Mon Sep 17 00:00:00 2001 From: Karl Date: Thu, 17 Jul 2025 07:43:00 +0100 Subject: [PATCH] share on android --- app.py | 6 ++++++ static/site.webmanifest | 12 +++++++++++- templates/add_account.html | 3 +-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 3cf67c2..f378348 100644 --- a/app.py +++ b/app.py @@ -159,6 +159,12 @@ def user_accounts() -> Union[Response, str]: auth=session["auth_credentials"], ) +@app.route("/share", methods=["GET"]) +def share() -> Response: + """Handles shared text from PWA.""" + shared_text = request.args.get("text") + return redirect(url_for("add_account", shared_text=shared_text)) + @app.route("/accounts/add", methods=["GET", "POST"]) def add_account() -> Union[Response, str]: """Handles adding a new user account.""" diff --git a/static/site.webmanifest b/static/site.webmanifest index 1d83a02..2805a46 100644 --- a/static/site.webmanifest +++ b/static/site.webmanifest @@ -1,6 +1,7 @@ { "short_name": "kTv", "name": "kTvManager", + "description": "KTVManager PWA", "icons": [ { "src": "/web-app-manifest-192x192.png", @@ -16,5 +17,14 @@ "start_url": "/", "background_color": "#ffffff", "display": "standalone", - "theme_color": "#ffffff" + "theme_color": "#ffffff", + "share_target": { + "action": "/share", + "method": "GET", + "params": { + "title": "title", + "text": "text", + "url": "url" + } + } } \ No newline at end of file diff --git a/templates/add_account.html b/templates/add_account.html index f20e056..cdebc96 100644 --- a/templates/add_account.html +++ b/templates/add_account.html @@ -131,8 +131,7 @@ } }); - const sharedTextJson = '{{ shared_text|tojson|safe }}'; - const sharedText = JSON.parse(sharedTextJson); + const sharedText = '{{ shared_text|safe }}'; if (sharedText) { const accountDetailsTextarea = document.getElementById('accountDetails');