Spaces:
Sleeping
Sleeping
Brunwo
commited on
Commit
•
48414d2
1
Parent(s):
0e9d836
attempt pwa share target
Browse files- manifest.json +7 -11
- share-target.html +12 -0
- share-target.js +16 -0
manifest.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{
|
2 |
-
"name": "
|
3 |
-
"short_name": "
|
4 |
"start_url": "/index.html",
|
5 |
"display": "standalone",
|
6 |
"background_color": "#ffffff",
|
@@ -23,17 +23,13 @@
|
|
23 |
"purpose": "maskable"
|
24 |
}
|
25 |
],
|
26 |
-
|
27 |
-
|
28 |
"share_target": {
|
29 |
-
"action": "/
|
30 |
"method": "GET",
|
31 |
"params": {
|
32 |
-
"title": "
|
33 |
-
"text": "
|
34 |
-
"url": "
|
35 |
}
|
36 |
}
|
37 |
-
|
38 |
-
|
39 |
-
}
|
|
|
1 |
{
|
2 |
+
"name": "Web listener",
|
3 |
+
"short_name": "WebPodcast",
|
4 |
"start_url": "/index.html",
|
5 |
"display": "standalone",
|
6 |
"background_color": "#ffffff",
|
|
|
23 |
"purpose": "maskable"
|
24 |
}
|
25 |
],
|
|
|
|
|
26 |
"share_target": {
|
27 |
+
"action": "/share-target/",
|
28 |
"method": "GET",
|
29 |
"params": {
|
30 |
+
"title": "title",
|
31 |
+
"text": "text",
|
32 |
+
"url": "url"
|
33 |
}
|
34 |
}
|
35 |
+
}
|
|
|
|
share-target.html
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Handling Share...</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<p>Handling shared content...</p>
|
10 |
+
<script src="/share-target.js"></script>
|
11 |
+
</body>
|
12 |
+
</html>
|
share-target.js
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This function will be called when the PWA receives a share
|
2 |
+
function handleShareTarget() {
|
3 |
+
const urlParams = new URLSearchParams(window.location.search);
|
4 |
+
const sharedUrl = urlParams.get('url') || urlParams.get('text');
|
5 |
+
|
6 |
+
if (sharedUrl) {
|
7 |
+
// Redirect to the main page with the shared URL as a parameter
|
8 |
+
window.location.href = `/index.html?url=${encodeURIComponent(sharedUrl)}`;
|
9 |
+
} else {
|
10 |
+
// If no URL is shared, just go to the main page
|
11 |
+
window.location.href = '/index.html';
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
// Call the function when the page loads
|
16 |
+
handleShareTarget();
|