Recompressed favicons to save space, and replaced multiple favicon handler functions with a single catchall
After Width: | Height: | Size: 7.4 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 6.7 KiB |
|
@ -2,7 +2,7 @@
|
||||||
<browserconfig>
|
<browserconfig>
|
||||||
<msapplication>
|
<msapplication>
|
||||||
<tile>
|
<tile>
|
||||||
<square150x150logo src="/mstile-150x150.png"/>
|
<square150x150logo src="/favicons/mstile-150x150.png"/>
|
||||||
<TileColor>#da532c</TileColor>
|
<TileColor>#da532c</TileColor>
|
||||||
</tile>
|
</tile>
|
||||||
</msapplication>
|
</msapplication>
|
After Width: | Height: | Size: 605 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 5.6 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 3.8 KiB |
|
@ -3,12 +3,12 @@
|
||||||
"short_name": "",
|
"short_name": "",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "/android-chrome-192x192.png",
|
"src": "/favicons/android-chrome-192x192.png",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "/android-chrome-512x512.png",
|
"src": "/favicons/android-chrome-512x512.png",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
}
|
}
|
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 12 KiB |
|
@ -1,28 +0,0 @@
|
||||||
<?xml version="1.0" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
|
||||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
|
||||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="700.000000pt" height="700.000000pt" viewBox="0 0 700.000000 700.000000"
|
|
||||||
preserveAspectRatio="xMidYMid meet">
|
|
||||||
<metadata>
|
|
||||||
Created by potrace 1.14, written by Peter Selinger 2001-2017
|
|
||||||
</metadata>
|
|
||||||
<g transform="translate(0.000000,700.000000) scale(0.100000,-0.100000)"
|
|
||||||
fill="#000000" stroke="none">
|
|
||||||
<path d="M3278 6995 c-2 -1 -42 -5 -89 -9 -47 -4 -95 -8 -105 -10 -10 -2 -41
|
|
||||||
-7 -69 -10 -335 -44 -715 -158 -1030 -312 -180 -87 -448 -247 -555 -331 -8 -6
|
|
||||||
-51 -40 -95 -74 -340 -264 -650 -624 -875 -1014 -47 -83 -170 -327 -170 -340
|
|
||||||
0 -3 -9 -24 -20 -48 -57 -123 -157 -435 -186 -582 -2 -11 -10 -54 -19 -95 -29
|
|
||||||
-147 -36 -200 -52 -370 -15 -165 -8 -592 12 -711 2 -13 6 -46 9 -74 9 -78 22
|
|
||||||
-152 51 -285 21 -96 91 -339 114 -395 5 -11 25 -65 46 -120 49 -130 168 -373
|
|
||||||
244 -500 391 -648 952 -1139 1640 -1435 269 -115 598 -207 880 -246 25 -3 57
|
|
||||||
-8 71 -10 163 -25 682 -25 842 1 13 2 46 7 73 10 71 10 87 13 115 18 14 3 43
|
|
||||||
8 65 12 115 21 314 74 455 122 188 64 473 192 614 278 32 19 62 35 67 35 5 0
|
|
||||||
9 5 9 10 0 6 5 10 10 10 15 0 220 141 330 227 152 118 324 280 450 422 36 41
|
|
||||||
70 79 76 85 6 6 48 61 94 121 150 197 277 405 383 628 26 53 47 99 47 102 0 2
|
|
||||||
11 28 24 57 57 127 151 421 182 573 17 81 54 301 59 350 4 33 9 71 11 85 9 47
|
|
||||||
11 525 4 605 -15 157 -21 210 -25 225 -2 8 -7 35 -10 60 -17 129 -80 384 -136
|
|
||||||
552 -348 1036 -1168 1857 -2204 2206 -163 55 -429 121 -555 137 -19 3 -46 7
|
|
||||||
-60 10 -13 2 -52 7 -86 11 -33 3 -74 8 -90 10 -32 5 -540 14 -546 9z"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 1.6 KiB |
|
@ -76,5 +76,5 @@ func init() {
|
||||||
})
|
})
|
||||||
|
|
||||||
rootCmd.SetVersionTemplate("roulette v{{.Version}}\n")
|
rootCmd.SetVersionTemplate("roulette v{{.Version}}\n")
|
||||||
rootCmd.Version = "0.47.0"
|
rootCmd.Version = "0.47.1"
|
||||||
}
|
}
|
||||||
|
|
73
cmd/web.go
|
@ -33,7 +33,7 @@ import (
|
||||||
"github.com/yosssi/gohtml"
|
"github.com/yosssi/gohtml"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed img/*
|
//go:embed favicons/*
|
||||||
var favicons embed.FS
|
var favicons embed.FS
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -870,11 +870,11 @@ func serveMedia(paths []string, Regexes *Regexes, index *Index) http.HandlerFunc
|
||||||
|
|
||||||
var htmlBody strings.Builder
|
var htmlBody strings.Builder
|
||||||
htmlBody.WriteString(`<!DOCTYPE html><html lang="en"><head>`)
|
htmlBody.WriteString(`<!DOCTYPE html><html lang="en"><head>`)
|
||||||
htmlBody.WriteString(`<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">`)
|
htmlBody.WriteString(`<link rel="apple-touch-icon" sizes="180x180" href="/favicons/apple-touch-icon.png">`)
|
||||||
htmlBody.WriteString(`<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">`)
|
htmlBody.WriteString(`<link rel="icon" type="image/png" sizes="32x32" href="/favicons/favicon-32x32.png">`)
|
||||||
htmlBody.WriteString(`<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">`)
|
htmlBody.WriteString(`<link rel="icon" type="image/png" sizes="16x16" href="/favicons/favicon-16x16.png">`)
|
||||||
htmlBody.WriteString(`<link rel="manifest" href="/site.webmanifest">`)
|
htmlBody.WriteString(`<link rel="manifest" href="/favicons/site.webmanifest">`)
|
||||||
htmlBody.WriteString(`<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">`)
|
htmlBody.WriteString(`<link rel="mask-icon" href="/favicons/safari-pinned-tab.svg" color="#5bbad5">`)
|
||||||
htmlBody.WriteString(`<meta name="msapplication-TileColor" content="#da532c">`)
|
htmlBody.WriteString(`<meta name="msapplication-TileColor" content="#da532c">`)
|
||||||
htmlBody.WriteString(`<meta name="theme-color" content="#ffffff">`)
|
htmlBody.WriteString(`<meta name="theme-color" content="#ffffff">`)
|
||||||
htmlBody.WriteString(`<style>html,body{margin:0;padding:0;height:100%;}`)
|
htmlBody.WriteString(`<style>html,body{margin:0;padding:0;height:100%;}`)
|
||||||
|
@ -921,67 +921,18 @@ func serveMedia(paths []string, Regexes *Regexes, index *Index) http.HandlerFunc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func serveFavicons() http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
fname := strings.TrimPrefix(r.URL.Path, "/")
|
||||||
|
|
||||||
func registerIcoHandlers(router *chi.Mux) {
|
data, err := favicons.ReadFile(fname)
|
||||||
router.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
data, err := favicons.ReadFile("img/favicon.ico")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Type: image/x-icon"))
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data))))
|
|
||||||
w.Write(data)
|
|
||||||
})
|
|
||||||
|
|
||||||
router.HandleFunc("/apple-touch-icon.png", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
data, err := favicons.ReadFile("img/apple-touch-icon.png")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Type: image/png"))
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data))))
|
w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data))))
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
})
|
}
|
||||||
|
|
||||||
router.HandleFunc("/favicon-32x32.png", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
data, err := favicons.ReadFile("img/favicon-32x32.png")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Type: image/png"))
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data))))
|
|
||||||
w.Write(data)
|
|
||||||
})
|
|
||||||
|
|
||||||
router.HandleFunc("/favicon-16x16.png", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
data, err := favicons.ReadFile("img/favicon-16x16.png")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Type: image/png"))
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data))))
|
|
||||||
w.Write(data)
|
|
||||||
})
|
|
||||||
|
|
||||||
router.HandleFunc("/site.webmanifest", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
data, err := favicons.ReadFile("img/site.webmanifest")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Type: application/json"))
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data))))
|
|
||||||
w.Write(data)
|
|
||||||
})
|
|
||||||
|
|
||||||
router.HandleFunc("/safari-pinned-tab.svg", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
data, err := favicons.ReadFile("img/safari-pinned-tab.svg")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Type: image/svg+xml"))
|
|
||||||
w.Header().Write(bytes.NewBufferString("Content-Length: " + strconv.Itoa(len(data))))
|
|
||||||
w.Write(data)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ServePage(args []string) error {
|
func ServePage(args []string) error {
|
||||||
|
@ -1021,7 +972,7 @@ func ServePage(args []string) error {
|
||||||
|
|
||||||
router := chi.NewRouter()
|
router := chi.NewRouter()
|
||||||
|
|
||||||
registerIcoHandlers(router)
|
router.Handle("/favicons/*", serveFavicons())
|
||||||
|
|
||||||
if cache {
|
if cache {
|
||||||
skipIndex := false
|
skipIndex := false
|
||||||
|
|