improve (404): SVG artwork from pixeltrue.com

This commit is contained in:
Mickael Kerjean
2020-08-05 11:48:25 +10:00
parent 8fcb721c13
commit f2fa1f489e
2 changed files with 10 additions and 7 deletions

View File

@ -100,7 +100,7 @@ func Page(stuff string) string {
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<style>
html { background: #f4f4f4; color: #455164; font-size: 16px; font-family: -apple-system,system-ui,BlinkMacSystemFont,Roboto,"Helvetica Neue",Arial,sans-serif; }
body { text-align: center; padding-top: 50px; text-align: center; }
body { text-align: center; padding-top: 50px; text-align: center; margin: 0; }
h1 { font-weight: 200; line-height: 1em; font-size: 40px; }
p { opacity: 0.8; font-size: 1.05em; }
</style>

View File

@ -28,8 +28,7 @@ func IndexHandler(_path string) func(App, http.ResponseWriter, *http.Request) {
return func(ctx App, res http.ResponseWriter, req *http.Request) {
urlObj, err := URL.Parse(req.URL.String())
if err != nil {
res.WriteHeader(http.StatusInternalServerError)
res.Write([]byte(Page("<h1>404 - Not Found</h1>")))
NotFoundHandler(ctx, res, req)
return
}
url := urlObj.Path
@ -40,8 +39,7 @@ func IndexHandler(_path string) func(App, http.ResponseWriter, *http.Request) {
} else if url != "/" && strings.HasPrefix(url, "/s/") == false &&
strings.HasPrefix(url, "/view/") == false && strings.HasPrefix(url, "/files/") == false &&
url != "/login" && url != "/logout" && strings.HasPrefix(url, "/admin") == false {
res.WriteHeader(http.StatusNotFound)
res.Write([]byte(Page("<h1>404 - Not Found</h1>")))
NotFoundHandler(ctx, res, req)
return
}
ua := req.Header.Get("User-Agent");
@ -65,6 +63,11 @@ func IndexHandler(_path string) func(App, http.ResponseWriter, *http.Request) {
}
}
func NotFoundHandler(ctx App, res http.ResponseWriter, req *http.Request) {
res.WriteHeader(http.StatusNotFound)
res.Write([]byte(Page(`<img style="max-width:800px" src="/assets/icons/404.svg" />`)))
}
func AboutHandler(ctx App, res http.ResponseWriter, req *http.Request) {
t, _ := template.New("about").Parse(Page(`
<h1> {{index .App 0}} </h1>