diff options
| author | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-12 10:47:17 +0100 |
|---|---|---|
| committer | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-12 10:47:17 +0100 |
| commit | fe92f6a7e33ebc38fc6acf4f1a7e31d8073c6d9f (patch) | |
| tree | d700826dd8d46c1a7b2e5470e06abeb4635bc15b /gopherproxy.go | |
| parent | Use brighter text in location bar for gopher:// (diff) | |
| download | gopherproxy-fe92f6a7e33ebc38fc6acf4f1a7e31d8073c6d9f.tar.gz gopherproxy-fe92f6a7e33ebc38fc6acf4f1a7e31d8073c6d9f.tar.bz2 gopherproxy-fe92f6a7e33ebc38fc6acf4f1a7e31d8073c6d9f.zip | |
Add setting to use proportional font
Diffstat (limited to 'gopherproxy.go')
| -rw-r--r-- | gopherproxy.go | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/gopherproxy.go b/gopherproxy.go index d98ef7c..34e6ff8 100644 --- a/gopherproxy.go +++ b/gopherproxy.go | |||
| @@ -30,10 +30,12 @@ type Item struct { | |||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | type AssetList struct { | 32 | type AssetList struct { |
| 33 | Style string | 33 | Style string |
| 34 | JS string | 34 | JS string |
| 35 | FontW string | 35 | FontW string |
| 36 | FontW2 string | 36 | FontW2 string |
| 37 | PropFontW string | ||
| 38 | PropFontW2 string | ||
| 37 | } | 39 | } |
| 38 | 40 | ||
| 39 | func renderDirectory(w http.ResponseWriter, tpl *template.Template, assetList AssetList, uri string, hostport string, d gopher.Directory) error { | 41 | func renderDirectory(w http.ResponseWriter, tpl *template.Template, assetList AssetList, uri string, hostport string, d gopher.Directory) error { |
| @@ -299,6 +301,18 @@ func ListenAndServe(bind, robotsfile string, robotsdebug bool, vipsconcurrency i | |||
| 299 | } | 301 | } |
| 300 | fontw2Asset := fmt.Sprintf("/iosevka-term-ss03-regular-%x.woff2", md5.Sum(fontdataw2)) | 302 | fontw2Asset := fmt.Sprintf("/iosevka-term-ss03-regular-%x.woff2", md5.Sum(fontdataw2)) |
| 301 | 303 | ||
| 304 | propfontdataw, err := box.Find("iosevka-aile-regular.woff") | ||
| 305 | if err != nil { | ||
| 306 | propfontdataw = []byte{} | ||
| 307 | } | ||
| 308 | propfontwAsset := fmt.Sprintf("/iosevka-aile-regular-%x.woff", md5.Sum(propfontdataw)) | ||
| 309 | |||
| 310 | propfontdataw2, err := box.Find("iosevka-aile-regular.woff2") | ||
| 311 | if err != nil { | ||
| 312 | propfontdataw2 = []byte{} | ||
| 313 | } | ||
| 314 | propfontw2Asset := fmt.Sprintf("/iosevka-aile-regular-%x.woff2", md5.Sum(propfontdataw2)) | ||
| 315 | |||
| 302 | styledata, err := box.Find("style.css") | 316 | styledata, err := box.Find("style.css") |
| 303 | if err != nil { | 317 | if err != nil { |
| 304 | styledata = []byte{} | 318 | styledata = []byte{} |
| @@ -368,13 +382,15 @@ func ListenAndServe(bind, robotsfile string, robotsdebug bool, vipsconcurrency i | |||
| 368 | ConcurrencyLevel: vipsconcurrency, | 382 | ConcurrencyLevel: vipsconcurrency, |
| 369 | }) | 383 | }) |
| 370 | 384 | ||
| 371 | http.HandleFunc("/", GopherHandler(tpl, robotsdata, AssetList{styleAsset, jsAsset, fontwAsset, fontw2Asset}, robotsdebug, uri)) | 385 | http.HandleFunc("/", GopherHandler(tpl, robotsdata, AssetList{styleAsset, jsAsset, fontwAsset, fontw2Asset, propfontwAsset, propfontw2Asset}, robotsdebug, uri)) |
| 372 | http.HandleFunc("/robots.txt", RobotsTxtHandler(robotstxtdata)) | 386 | http.HandleFunc("/robots.txt", RobotsTxtHandler(robotstxtdata)) |
| 373 | http.HandleFunc("/favicon.ico", FaviconHandler(favicondata)) | 387 | http.HandleFunc("/favicon.ico", FaviconHandler(favicondata)) |
| 374 | http.HandleFunc(styleAsset, StyleHandler(styledata)) | 388 | http.HandleFunc(styleAsset, StyleHandler(styledata)) |
| 375 | http.HandleFunc(jsAsset, JavaScriptHandler(jsdata)) | 389 | http.HandleFunc(jsAsset, JavaScriptHandler(jsdata)) |
| 376 | http.HandleFunc(fontwAsset, FontHandler(false, fontdataw)) | 390 | http.HandleFunc(fontwAsset, FontHandler(false, fontdataw)) |
| 377 | http.HandleFunc(fontw2Asset, FontHandler(true, fontdataw2)) | 391 | http.HandleFunc(fontw2Asset, FontHandler(true, fontdataw2)) |
| 392 | http.HandleFunc(propfontwAsset, FontHandler(false, propfontdataw)) | ||
| 393 | http.HandleFunc(propfontw2Asset, FontHandler(true, propfontdataw2)) | ||
| 378 | //http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets/")))) | 394 | //http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets/")))) |
| 379 | 395 | ||
| 380 | return http.ListenAndServe(bind, nil) | 396 | return http.ListenAndServe(bind, nil) |
