all repos — legit @ 856f66808b913baff13c815daec3cdde7121e3bd

web frontend for git

routes/template.go (view raw)

 1package routes
 2
 3import (
 4	"html/template"
 5	"net/http"
 6	"os"
 7	"path/filepath"
 8
 9	"icyphox.sh/legit/config"
10)
11
12func Write404(w http.ResponseWriter, c config.Config) {
13	w.WriteHeader(404)
14	tpath := filepath.Join(c.Template.Dir, "404.html")
15	t := template.Must(template.ParseFiles(tpath))
16	t.Execute(w, nil)
17}
18
19func Write500(w http.ResponseWriter, c config.Config) {
20	w.WriteHeader(500)
21	tpath := filepath.Join(c.Template.Dir, "500.html")
22	t := template.Must(template.ParseFiles(tpath))
23	t.Execute(w, nil)
24}
25
26func funcMap() template.FuncMap {
27	return template.FuncMap{
28		"prettyMode": func(mode uint32) string {
29			return os.FileMode(mode).String()
30		},
31	}
32}