Merge pull request #1 from reeseovine/main increase mobile-friendliness
j3s j3s@c3f.net
Thu, 25 May 2023 16:39:13 -0700
12 files changed,
164 insertions(+),
1 deletions(-)
jump to
M
files/head.tmpl.html
→
files/head.tmpl.html
@@ -4,6 +4,19 @@ <html lang="en">
<head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> + + <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> + <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png"> + <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"> + <link rel='shortcut icon' href='/favicon.ico'> + <link rel="manifest" href="/manifest.json"> + + <script> + if ('serviceWorker' in navigator) { + navigator.serviceWorker.register("/serviceworker.js"); + } + </script> + <title>{{ .Title }}</title> <style> {{ .StyleSheet }}
A
files/static/manifest.json
@@ -0,0 +1,22 @@
+{ + "name": "vore", + "short_name": "vore", + "start_url": "https://vore.website", + "display": "standalone", + "icons": [ + { + "src": "/android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any maskable monochrome" + }, + { + "src": "/android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any maskable monochrome" + } + ], + "theme_color": "#ffffff", + "background_color": "#ffffff" +}
A
logo/original.svg
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="300" + height="300" + viewBox="0 0 300 300" + version="1.1" + id="svg5" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + sodipodi:docname="original.svg" + inkscape:export-filename="../files/static/apple-touch-icon.png" + inkscape:export-xdpi="57.599998" + inkscape:export-ydpi="57.599998" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview7" + pagecolor="#ffffff" + bordercolor="#ffffff" + borderopacity="1" + inkscape:showpageshadow="0" + inkscape:pageopacity="0" + inkscape:pagecheckerboard="1" + inkscape:deskcolor="#505050" + inkscape:document-units="mm" + showgrid="false" + showborder="false" + inkscape:zoom="2.7433333" + inkscape:cx="150" + inkscape:cy="150" + inkscape:current-layer="layer1" /> + <defs + id="defs2" /> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(-88.429247,-252.219)"> + <rect + style="fill:#ffffff;stroke:none;stroke-width:32;stroke-linecap:round;paint-order:stroke fill markers" + id="rect1062" + width="300" + height="300" + x="88.429245" + y="252.21899" /> + <ellipse + style="display:none;fill:#ffffff;stroke:none;stroke-width:177.123;stroke-linecap:round;paint-order:stroke fill markers" + id="path1008" + cx="238.42923" + cy="402.21899" + rx="120.00002" + ry="120" /> + <path + style="color:#000000;fill:#000000;stroke:none;stroke-width:22.4;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" + d="m 199.67882,390.54935 a 5.60056,5.60056 0 0 0 -3.34414,2.13145 l -20.49961,27.45996 c -13.20644,-7.14236 -20.24258,-14.0123 -20.24258,-14.0123 a 5.6,5.6 0 0 0 -7.92012,0.0328 5.6,5.6 0 0 0 0.0342,7.92011 c 0,0 9.2309,9.00163 26.40586,17.62441 a 5.6,5.6 0 0 0 0.0342,0.0574 5.6,5.6 0 0 0 0.16953,0.0423 c 15.75889,7.88039 38.13726,15.41504 66.43438,15.41504 29.63099,0 51.71276,-7.75469 66.36602,-15.59961 14.65325,-7.84491 22.2373,-16.1082 22.2373,-16.1082 a 5.6,5.6 0 0 0 -0.38008,-7.91055 5.6,5.6 0 0 0 -7.90918,0.37871 c 0,0 -5.9871,6.67444 -19.23359,13.76621 -13.24649,7.09178 -33.39531,14.27344 -61.08047,14.27344 -7.42782,0 -14.35756,-0.57039 -20.85781,-1.50528 l -13.77032,-40.29511 a 5.60056,5.60056 0 0 0 -6.44355,-3.6709 z m -0.72051,17.34005 8.26191,24.17734 c -7.92572,-1.90722 -14.97001,-4.32617 -21.11894,-6.95625 z" + id="path734" /> + </g> +</svg>
A
logo/small.svg
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="300" + height="300" + viewBox="0 0 300 300" + version="1.1" + id="svg5" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + sodipodi:docname="small.svg" + inkscape:export-filename="../files/static/favicon-16x16.png" + inkscape:export-xdpi="5.1199999" + inkscape:export-ydpi="5.1199999" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview7" + pagecolor="#ffffff" + bordercolor="#ffffff" + borderopacity="1" + inkscape:showpageshadow="0" + inkscape:pageopacity="0" + inkscape:pagecheckerboard="1" + inkscape:deskcolor="#505050" + inkscape:document-units="mm" + showgrid="false" + showborder="false" + inkscape:zoom="2.351237" + inkscape:cx="75.492178" + inkscape:cy="99.309428" + inkscape:current-layer="layer1" /> + <defs + id="defs2" /> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(-88.429247,-252.219)"> + <g + id="g3911" + transform="translate(2.1288773,110.05368)"> + <ellipse + style="display:none;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:16;stroke-linecap:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" + id="path1933" + cx="177.51703" + cy="312.58838" + rx="10.493162" + ry="11.11914" /> + <path + style="color:#000000;fill:#000000;stroke:#ffffff;stroke-width:32;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers" + d="m 180.94284,268.37715 a 8.0008,8.0008 0 0 0 -4.77735,3.04492 l -29.28515,39.22852 c -18.86635,-10.20337 -28.91797,-20.01758 -28.91797,-20.01758 a 8,8 0 0 0 -11.31446,0.0469 8,8 0 0 0 0.0488,11.31445 c 0,0 13.187,12.85947 37.72266,25.17773 a 8,8 0 0 0 0.0488,0.082 8,8 0 0 0 0.24218,0.0605 c 22.5127,11.2577 54.4818,22.02149 94.90625,22.02149 42.32999,0 73.87538,-11.07814 94.8086,-22.28516 20.93322,-11.20702 31.76758,-23.01172 31.76758,-23.01172 a 8,8 0 0 0 -0.54297,-11.30078 8,8 0 0 0 -11.29883,0.54101 c 0,0 -8.553,9.53491 -27.47656,19.66602 -18.92356,10.13111 -47.70758,20.39063 -87.25782,20.39063 -10.61116,0 -20.51079,-0.81485 -29.79687,-2.1504 l -19.67188,-57.56445 a 8.0008,8.0008 0 0 0 -9.20507,-5.24414 z m -1.0293,24.77149 11.80273,34.53906 c -11.32247,-2.7246 -21.38574,-6.18024 -30.16992,-9.9375 z" + id="path734" /> + </g> + </g> +</svg>
M
site.go
→
site.go
@@ -1,12 +1,14 @@
package main import ( + "errors" "fmt" "io/ioutil" "log" "math/rand" "net/http" "net/url" + "os" "path/filepath" "strings" "text/template"@@ -45,7 +47,7 @@
// rootHandler is our "wildcard handler", so in addition to // serving /, it also acts as a router for a few arbitrary // patterns that can't be registered at starttime -// this includes /<username> and 404 +// this includes /<username>, static files, and 404 func (s *Site) rootHandler(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/" { s.indexHandler(w, r)@@ -56,6 +58,13 @@ if s.db.UserExists(strings.TrimPrefix(r.URL.Path, "/")) {
s.userHandler(w, r) return } + // handles static files + file := filepath.Join("files", "static", strings.TrimPrefix(r.URL.Path, "/")) + if _, err := os.Stat(file); !errors.Is(err, os.ErrNotExist) { + http.ServeFile(w, r, file) + return + } + // 404 http.NotFound(w, r) }