From 79fd699ceeb80bec1305907fc81817894b8536cb Mon Sep 17 00:00:00 2001 From: Pablo Ferreiro Date: Fri, 4 Nov 2022 17:25:14 +0100 Subject: [PATCH] revert auto register sw --- app/Controllers/SettingsController.php | 8 ++++++++ app/Helpers/UrlBuilder.php | 1 + components/head.latte | 4 +++- components/settings/misc.latte | 18 ++++++++++++++++++ components/sw.latte | 3 +++ views/settings.latte | 5 +++++ 6 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 components/settings/misc.latte create mode 100644 components/sw.latte diff --git a/app/Controllers/SettingsController.php b/app/Controllers/SettingsController.php index f3fb979..68707d9 100644 --- a/app/Controllers/SettingsController.php +++ b/app/Controllers/SettingsController.php @@ -34,6 +34,14 @@ class SettingsController { self::redirect(); } + static public function misc() { + if (isset($_POST['misc-sw'])) { + $sw = $_POST['misc-sw']; + Cookies::set("misc-sw", $sw); + } + self::redirect(); + } + static private function redirect() { $url = Misc::url('/settings'); header("Location: {$url}"); diff --git a/app/Helpers/UrlBuilder.php b/app/Helpers/UrlBuilder.php index 5a36ca3..62bff30 100644 --- a/app/Helpers/UrlBuilder.php +++ b/app/Helpers/UrlBuilder.php @@ -7,6 +7,7 @@ class UrlBuilder { } static public function download(string $url, string $username, string $id, bool $watermark): string { + // {path('/download?url=' . urlencode($playAddr) . '&id=' . $id . '&user=' . $uniqueId) . '&watermark=1'} $down_url = Misc::url('/download?url=' . urlencode($url) . '&id=' . $id . '&user=' . $username); if ($watermark) $down_url .= '&watermark=1'; return $down_url; diff --git a/components/head.latte b/components/head.latte index ef6a9dc..cce56a1 100644 --- a/components/head.latte +++ b/components/head.latte @@ -16,6 +16,8 @@ {$title} - ProxiTok - {*/ Handles Service Worker /*} + {*/ Handles optional Service Worker /*} + {if \App\Helpers\Cookies::check('misc-sw', 'yes')} + {/if} diff --git a/components/settings/misc.latte b/components/settings/misc.latte new file mode 100644 index 0000000..4ba494e --- /dev/null +++ b/components/settings/misc.latte @@ -0,0 +1,18 @@ +{embed '../form.latte', path: '/settings/misc', method: 'POST', submit: true} +{block fields} +
+ +
+ + +
+

This can be used to install the PWA version of ProxiTok

+
+{/block} +{/embed} diff --git a/components/sw.latte b/components/sw.latte new file mode 100644 index 0000000..43eaa3a --- /dev/null +++ b/components/sw.latte @@ -0,0 +1,3 @@ +{if \App\Helpers\Cookies::check('misc-sw', 'yes')} + +{/if} diff --git a/views/settings.latte b/views/settings.latte index c578cd0..b6e1c01 100644 --- a/views/settings.latte +++ b/views/settings.latte @@ -14,4 +14,9 @@

Api

{include '../components/settings/api.latte'} +
+
+

Misc

+ {include '../components/settings/misc.latte'} +
{/block}