From b2f6f95916e940820a95b56c023748c9b407ffbd Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 29 Jul 2017 18:08:27 +0100 Subject: [PATCH] Fix Hugo error Former-commit-id: 22a3e0ab7462efcf920a14a8f45da27c0fd683dd [formerly c393472665da880feee876ca3c24e474660c1f44] [formerly b83bf6b70a23c6522a9896ef47819f0442c5d2c8 [formerly c0b60d5928efc1d684afad67f29cc8656d89ee32]] Former-commit-id: d3b03bb09b509b29781c0f585b2f44401f1f37cf [formerly e40c32c1eb119d2ccfa681b62310642534b71b79] Former-commit-id: 1e643026d4fde9e223dbb29c108acfb530963624 --- caddy/hugo/setup.go | 2 ++ cmd/filemanager/main.go | 2 ++ plugins/hugo.go | 12 ++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/caddy/hugo/setup.go b/caddy/hugo/setup.go index 7da39d58..df28c921 100644 --- a/caddy/hugo/setup.go +++ b/caddy/hugo/setup.go @@ -18,6 +18,8 @@ import ( // setup configures a new FileManager middleware instance. func setup(c *caddy.Controller) error { + plugins.RegisterHugo() + configs, err := parse(c) if err != nil { return err diff --git a/cmd/filemanager/main.go b/cmd/filemanager/main.go index 6848c36a..51fd93e9 100644 --- a/cmd/filemanager/main.go +++ b/cmd/filemanager/main.go @@ -76,6 +76,8 @@ func setupViper() { } func main() { + plugins.RegisterHugo() + setupViper() flag.Parse() diff --git a/plugins/hugo.go b/plugins/hugo.go index af837c50..340626bf 100644 --- a/plugins/hugo.go +++ b/plugins/hugo.go @@ -16,7 +16,12 @@ import ( "github.com/robfig/cron" ) -func init() { +var ( + ErrHugoNotFound = errors.New("It seems that tou don't have 'hugo' on your PATH") + ErrUnsupportedFileType = errors.New("The type of the provided file isn't supported for this action") +) + +func RegisterHugo() { filemanager.RegisterPlugin("hugo", filemanager.Plugin{ JavaScript: rice.MustFindBox("./assets/").MustString("hugo.js"), CommandEvents: []string{"before_publish", "after_publish"}, @@ -30,11 +35,6 @@ func init() { }) } -var ( - ErrHugoNotFound = errors.New("It seems that tou don't have 'hugo' on your PATH") - ErrUnsupportedFileType = errors.New("The type of the provided file isn't supported for this action") -) - // Hugo is a hugo (https://gohugo.io) plugin. type Hugo struct { // Website root