all repos — honk @ 757bb4cea44f69d71dbd6b6c6e857bd00569e211

my fork of honk

pwa patch

thanks ptd
Anirudh Oppiliappan x@icyphox.sh
Tue, 29 Nov 2022 11:38:28 +0530
commit

757bb4cea44f69d71dbd6b6c6e857bd00569e211

parent

891717ddf4b402c6707ba3e2047cbbeb1ad77195

4 files changed, 38 insertions(+), 10 deletions(-)

jump to
M views/header.htmlviews/header.html

@@ -1,18 +1,22 @@

<!doctype html> <html> <head> - <title>honk</title> - <link href="/style.css{{ .StyleParam }}" rel="stylesheet"> + <title>honk</title> + <link href="/style.css{{ .StyleParam }}" rel="stylesheet"> {{ if .LocalStyleParam }} - <link href="/local.css{{ .LocalStyleParam }}" rel="stylesheet"> + <link href="/local.css{{ .LocalStyleParam }}" rel="stylesheet"> {{ end }} - <style> - {{ .UserStyle }} - </style> - <link href="/icon.png" rel="icon"> - <meta name="theme-color" media="(prefers-color-scheme: light) "content="#F72585"> - <meta name="theme-color" media="(prefers-color-scheme: dark) "content="#509c93"> - <meta name="viewport" content="width=device-width"> + <style> + {{ .UserStyle }} + </style> + <link rel="manifest" href="/manifest.webmanifest"> + <link href="/icon.png" rel="icon"> + <meta name="theme-color" media="(prefers-color-scheme: light) "content="#F72585"> + <meta name="theme-color" media="(prefers-color-scheme: dark) "content="#509c93"> + <meta name="viewport" content="width=device-width"> + <script> + if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js') } + </script> </head> <body> <header>
A views/manifest.webmanifest

@@ -0,0 +1,16 @@

+{ + "background_color": "#F5EFFF", + "description": "undermine the vole", + "display": "standalone", + "icons": [ + { + "src": "icon.png", + "sizes": "128x128", + "type": "image/png" + } + ], + "name": "honk", + "short_name": "honk", + "start_url": "/" +} +
A views/sw.js

@@ -0,0 +1,4 @@

+self.addEventListener('install', function (event) { + console.log('service worker installed') +}) +
M web.goweb.go

@@ -2703,6 +2703,8 @@ viewDir + "/views/style.css",

dataDir + "/views/local.css", viewDir + "/views/honkpage.js", dataDir + "/views/local.js", + viewDir + "/views/manifest.webmanifest", + viewDir + "/views/sw.js", } for _, s := range assets { savedassetparams[s] = getassetparam(s)

@@ -2754,12 +2756,14 @@

posters.HandleFunc("/csp-violation", fiveoh) getters.HandleFunc("/style.css", serveviewasset) + getters.HandleFunc("/sw.js", serveviewasset) getters.HandleFunc("/honkpage.js", serveviewasset) getters.HandleFunc("/misc.js", serveviewasset) getters.HandleFunc("/local.css", servedataasset) getters.HandleFunc("/local.js", servedataasset) getters.HandleFunc("/icon.png", servedataasset) getters.HandleFunc("/favicon.ico", servedataasset) + getters.HandleFunc("/manifest.webmanifest", serveviewasset) getters.HandleFunc("/about", servehtml) getters.HandleFunc("/login", servehtml)