|
|
@ -19,13 +19,13 @@ import ( |
|
|
|
"git.stephensearles.com/stephen/acedoc" |
|
|
|
"git.stephensearles.com/stephen/acedoc" |
|
|
|
"git.stephensearles.com/stephen/caddy-hugo2/assets" |
|
|
|
"git.stephensearles.com/stephen/caddy-hugo2/assets" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/gohugoio/hugo/deps" |
|
|
|
|
|
|
|
"github.com/gohugoio/hugo/hugofs" |
|
|
|
|
|
|
|
"github.com/gohugoio/hugo/hugolib" |
|
|
|
"github.com/gorilla/websocket" |
|
|
|
"github.com/gorilla/websocket" |
|
|
|
"github.com/mholt/caddy" |
|
|
|
"github.com/mholt/caddy" |
|
|
|
"github.com/mholt/caddy/caddyhttp/httpserver" |
|
|
|
"github.com/mholt/caddy/caddyhttp/httpserver" |
|
|
|
"github.com/spf13/afero" |
|
|
|
"github.com/spf13/afero" |
|
|
|
"github.com/spf13/hugo/deps" |
|
|
|
|
|
|
|
"github.com/spf13/hugo/hugofs" |
|
|
|
|
|
|
|
"github.com/spf13/hugo/hugolib" |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const ( |
|
|
|
const ( |
|
|
@ -321,7 +321,15 @@ func (ch *CaddyHugo) serveDraft(w http.ResponseWriter, r *http.Request) (int, er |
|
|
|
prefix := "/hugo/draft/" + encoded |
|
|
|
prefix := "/hugo/draft/" + encoded |
|
|
|
r.URL.Path = r.URL.Path[len(prefix):] |
|
|
|
r.URL.Path = r.URL.Path[len(prefix):] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
page := ch.HugoSites.GetContentPage(name) |
|
|
|
|
|
|
|
if page == nil { |
|
|
|
|
|
|
|
fmt.Fprintf(w, "can't find %q to display a draft", name) |
|
|
|
|
|
|
|
return 404, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r.URL.Path = page.RelPermalink() |
|
|
|
http.FileServer(http.Dir(docref.tmpdir)).ServeHTTP(w, r) |
|
|
|
http.FileServer(http.Dir(docref.tmpdir)).ServeHTTP(w, r) |
|
|
|
|
|
|
|
|
|
|
|
return 200, nil |
|
|
|
return 200, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -512,11 +520,9 @@ func (ch CaddyHugo) NewContent(w http.ResponseWriter, r *http.Request) (int, err |
|
|
|
name += ".md" |
|
|
|
name += ".md" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
name = strings.ToLower(name) |
|
|
|
filename := path.Join(ctype, strings.ToLower(name)) |
|
|
|
|
|
|
|
|
|
|
|
filename := path.Join(ctype, name) |
|
|
|
|
|
|
|
if ctype == "default" { |
|
|
|
if ctype == "default" { |
|
|
|
filename = name |
|
|
|
filename = strings.ToLower(name) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_, err := os.Stat(path.Join(ch.Site.Root, "content", filename)) |
|
|
|
_, err := os.Stat(path.Join(ch.Site.Root, "content", filename)) |
|
|
|