|
|
@ -69,7 +69,7 @@ func (ch *CaddyHugo) ServeHTTPWithNext(next httpserver.Handler, c *caddy.Control |
|
|
|
return 404, nil |
|
|
|
return 404, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ch CaddyHugo) ServeNewContent(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
func (ch *CaddyHugo) ServeNewContent(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
name := r.FormValue("name") |
|
|
|
name := r.FormValue("name") |
|
|
|
ctype := r.FormValue("type") |
|
|
|
ctype := r.FormValue("type") |
|
|
|
|
|
|
|
|
|
|
@ -83,7 +83,7 @@ func (ch CaddyHugo) ServeNewContent(w http.ResponseWriter, r *http.Request) (int |
|
|
|
http.Redirect(w, r, filepath.Join("/hugo/edit/", "content", filename), http.StatusFound) |
|
|
|
http.Redirect(w, r, filepath.Join("/hugo/edit/", "content", filename), http.StatusFound) |
|
|
|
return http.StatusFound, nil |
|
|
|
return http.StatusFound, nil |
|
|
|
} |
|
|
|
} |
|
|
|
func (ch CaddyHugo) Middleware(c *caddy.Controller) httpserver.Middleware { |
|
|
|
func (ch *CaddyHugo) Middleware(c *caddy.Controller) httpserver.Middleware { |
|
|
|
return func(next httpserver.Handler) httpserver.Handler { |
|
|
|
return func(next httpserver.Handler) httpserver.Handler { |
|
|
|
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
return ch.ServeHTTPWithNext(next, c, w, r) |
|
|
|
return ch.ServeHTTPWithNext(next, c, w, r) |
|
|
@ -91,11 +91,11 @@ func (ch CaddyHugo) Middleware(c *caddy.Controller) httpserver.Middleware { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ch CaddyHugo) Auth(r *http.Request) bool { |
|
|
|
func (ch *CaddyHugo) Auth(r *http.Request) bool { |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ch CaddyHugo) Match(r *http.Request) bool { |
|
|
|
func (ch *CaddyHugo) Match(r *http.Request) bool { |
|
|
|
if strings.HasPrefix(r.URL.Path, "/media/") { |
|
|
|
if strings.HasPrefix(r.URL.Path, "/media/") { |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
@ -107,7 +107,7 @@ func (ch CaddyHugo) Match(r *http.Request) bool { |
|
|
|
return strings.HasPrefix(r.URL.Path, "/hugo/") |
|
|
|
return strings.HasPrefix(r.URL.Path, "/hugo/") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ch CaddyHugo) Admin() httpserver.Handler { |
|
|
|
func (ch *CaddyHugo) Admin() httpserver.Handler { |
|
|
|
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
err := ch.adminTmpl.Execute(w, ch.TmplData(r, nil)) |
|
|
|
err := ch.adminTmpl.Execute(w, ch.TmplData(r, nil)) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -120,7 +120,7 @@ func (ch CaddyHugo) Admin() httpserver.Handler { |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ch CaddyHugo) AuthorHome() httpserver.Handler { |
|
|
|
func (ch *CaddyHugo) AuthorHome() httpserver.Handler { |
|
|
|
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { |
|
|
|
td := ch.TmplData(r, nil) |
|
|
|
td := ch.TmplData(r, nil) |
|
|
|
err := ch.authorTmpl.Execute(w, td) |
|
|
|
err := ch.authorTmpl.Execute(w, td) |
|
|
|