share to and pwa
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 4m21s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 4m21s
This commit is contained in:
parent
629ef4e975
commit
d67c4dd94b
8
app.py
8
app.py
@ -156,7 +156,9 @@ def user_accounts():
|
|||||||
|
|
||||||
@app.route("/accounts/add", methods=["GET", "POST"])
|
@app.route("/accounts/add", methods=["GET", "POST"])
|
||||||
def add_account():
|
def add_account():
|
||||||
base_url = app.config["BASE_URL"] # Access base_url from the config
|
base_url = app.config["BASE_URL"]
|
||||||
|
shared_text = request.args.get('shared_text')
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
username = request.form["username"]
|
username = request.form["username"]
|
||||||
password = request.form["password"]
|
password = request.form["password"]
|
||||||
@ -167,9 +169,9 @@ def add_account():
|
|||||||
):
|
):
|
||||||
cache.clear()
|
cache.clear()
|
||||||
return redirect(url_for("user_accounts"))
|
return redirect(url_for("user_accounts"))
|
||||||
return render_template("add_account.html", ocr_enabled=app.config.get("OCR_ENABLED"), text_input_enabled=app.config.get("TEXT_INPUT_ENABLED"))
|
return render_template("add_account.html", ocr_enabled=app.config.get("OCR_ENABLED"), text_input_enabled=app.config.get("TEXT_INPUT_ENABLED"), shared_text=shared_text)
|
||||||
|
|
||||||
return render_template("add_account.html", ocr_enabled=app.config.get("OCR_ENABLED"), text_input_enabled=app.config.get("TEXT_INPUT_ENABLED"))
|
return render_template("add_account.html", ocr_enabled=app.config.get("OCR_ENABLED"), text_input_enabled=app.config.get("TEXT_INPUT_ENABLED"), shared_text=shared_text)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/accounts/delete", methods=["POST"])
|
@app.route("/accounts/delete", methods=["POST"])
|
||||||
|
@ -6,10 +6,14 @@ self.addEventListener('activate', e => {
|
|||||||
// console.log('[Service Worker] Activated');
|
// console.log('[Service Worker] Activated');
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('fetch', e => {
|
self.addEventListener('fetch', (event) => {
|
||||||
// e.respondWith(
|
if (event.request.method === 'POST' && event.request.url.endsWith('/accounts/add/')) {
|
||||||
// caches.match(e.request).then(res => {
|
event.respondWith(
|
||||||
// return res || fetch(e.request);
|
(async () => {
|
||||||
// })
|
const formData = await event.request.formData();
|
||||||
// );
|
const text = formData.get('text') || '';
|
||||||
|
return Response.redirect(`/accounts/add?shared_text=${encodeURIComponent(text)}`, 303);
|
||||||
|
})()
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
@ -24,5 +24,14 @@
|
|||||||
],
|
],
|
||||||
"theme_color": "#ffffff",
|
"theme_color": "#ffffff",
|
||||||
"background_color": "#ffffff",
|
"background_color": "#ffffff",
|
||||||
"display": "standalone"
|
"display": "standalone",
|
||||||
|
"share_target": {
|
||||||
|
"action": "/accounts/add/",
|
||||||
|
"method": "GET",
|
||||||
|
"params": {
|
||||||
|
"title": "title",
|
||||||
|
"text": "text",
|
||||||
|
"url": "url"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@
|
|||||||
<title>Add Account - KTVManager</title>
|
<title>Add Account - KTVManager</title>
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
|
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
|
||||||
|
<link rel="manifest" href="{{ url_for('static', filename='site.webmanifest') }}" />
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.css" />
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/awesomplete/1.1.5/awesomplete.min.css" />
|
||||||
<style>
|
<style>
|
||||||
/* Hide the spinner by default */
|
/* Hide the spinner by default */
|
||||||
@ -156,6 +157,21 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const sharedTextJson = '{{ shared_text|tojson|safe }}';
|
||||||
|
const sharedText = JSON.parse(sharedTextJson);
|
||||||
|
|
||||||
|
if (sharedText) {
|
||||||
|
const accountDetailsTextarea = document.getElementById('accountDetails');
|
||||||
|
if (accountDetailsTextarea) {
|
||||||
|
accountDetailsTextarea.value = sharedText;
|
||||||
|
const event = new Event('input', {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
});
|
||||||
|
accountDetailsTextarea.dispatchEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -5,10 +5,15 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>KTVManager</title>
|
<title>KTVManager</title>
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
|
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
|
||||||
|
<link rel="manifest" href="{{ url_for('static', filename='site.webmanifest') }}" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<script>
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.register('{{ url_for("static", filename="service-worker.js") }}')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<!-- Navbar -->
|
<!-- Navbar -->
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
<a class="navbar-brand" href="/">KTVManager</a>
|
<a class="navbar-brand" href="/">KTVManager</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user