share on android

This commit is contained in:
Karl 2025-07-17 07:43:00 +01:00
parent ef9804da72
commit 72d238b05d
3 changed files with 18 additions and 3 deletions

6
app.py
View File

@ -159,6 +159,12 @@ def user_accounts() -> Union[Response, str]:
auth=session["auth_credentials"], 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"]) @app.route("/accounts/add", methods=["GET", "POST"])
def add_account() -> Union[Response, str]: def add_account() -> Union[Response, str]:
"""Handles adding a new user account.""" """Handles adding a new user account."""

View File

@ -1,6 +1,7 @@
{ {
"short_name": "kTv", "short_name": "kTv",
"name": "kTvManager", "name": "kTvManager",
"description": "KTVManager PWA",
"icons": [ "icons": [
{ {
"src": "/web-app-manifest-192x192.png", "src": "/web-app-manifest-192x192.png",
@ -16,5 +17,14 @@
"start_url": "/", "start_url": "/",
"background_color": "#ffffff", "background_color": "#ffffff",
"display": "standalone", "display": "standalone",
"theme_color": "#ffffff" "theme_color": "#ffffff",
"share_target": {
"action": "/share",
"method": "GET",
"params": {
"title": "title",
"text": "text",
"url": "url"
}
}
} }

View File

@ -131,8 +131,7 @@
} }
}); });
const sharedTextJson = '{{ shared_text|tojson|safe }}'; const sharedText = '{{ shared_text|safe }}';
const sharedText = JSON.parse(sharedTextJson);
if (sharedText) { if (sharedText) {
const accountDetailsTextarea = document.getElementById('accountDetails'); const accountDetailsTextarea = document.getElementById('accountDetails');