WIP Redesign
This commit is contained in:
9
main.go
9
main.go
@@ -17,7 +17,7 @@ import (
|
||||
//go:embed assets
|
||||
var assets embed.FS
|
||||
|
||||
var tmpl = template.Must(template.New("page.html").ParseFS(assets, "assets/page.html"))
|
||||
var tmpl = newTemplate("page.html", "assets/page.html")
|
||||
|
||||
// specialPage is the result returned by a pageTypeHandler.
|
||||
// Content is injected into the page after the standard markdown content.
|
||||
@@ -41,8 +41,11 @@ func main() {
|
||||
wikiDir := flag.String("dir", "./wiki", "wiki root directory")
|
||||
user := flag.String("user", "", "basic auth username (empty = no auth)")
|
||||
pass := flag.String("pass", "", "basic auth password")
|
||||
dev := flag.Bool("dev", false, "serve assets from disk (no recompile needed for HTML/CSS changes)")
|
||||
flag.Parse()
|
||||
|
||||
initAssets(*dev)
|
||||
|
||||
root, err := filepath.Abs(*wikiDir)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -53,7 +56,7 @@ func main() {
|
||||
|
||||
h := &handler{root: root, user: *user, pass: *pass}
|
||||
|
||||
staticFS, _ := fs.Sub(assets, "assets")
|
||||
staticFS, _ := fs.Sub(assetFS, "assets")
|
||||
http.Handle("/_/", http.StripPrefix("/_/", http.FileServer(http.FS(staticFS))))
|
||||
http.Handle("/", h)
|
||||
|
||||
@@ -185,7 +188,7 @@ func (h *handler) serveDir(w http.ResponseWriter, r *http.Request, urlPath, fsPa
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
if err := tmpl.Execute(w, data); err != nil {
|
||||
if err := tmpl.get().Execute(w, data); err != nil {
|
||||
log.Printf("template error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user