From 91a6848586ca7052390326ca537bbdb3bfd90a8a Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 18 Jan 2017 18:21:04 +0000 Subject: [PATCH] fix hacdias/caddy-hugo#105 --- hugo.go | 4 ++-- setup.go | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/hugo.go b/hugo.go index e99c712c..b635758a 100644 --- a/hugo.go +++ b/hugo.go @@ -21,7 +21,6 @@ import ( "github.com/hacdias/caddy-filemanager" "github.com/hacdias/caddy-filemanager/assets" "github.com/hacdias/caddy-filemanager/frontmatter" - "github.com/hacdias/caddy-filemanager/handlers" "github.com/hacdias/caddy-filemanager/utils/variables" "github.com/hacdias/caddy-hugo/utils/commands" "github.com/mholt/caddy/caddyhttp/httpserver" @@ -161,6 +160,7 @@ func (h Hugo) Schedule(w http.ResponseWriter, r *http.Request) (int, error) { return http.StatusInternalServerError, err } + format := rune(r.Header.Get("Rune")[0]) scheduler := cron.New() scheduler.AddFunc(t.Format("05 04 15 02 01 *"), func() { filename := r.URL.Path @@ -199,7 +199,7 @@ func (h Hugo) Schedule(w http.ResponseWriter, r *http.Request) (int, error) { delete(front.(map[string]interface{}), "Draft") } - fm, err := handlers.ParseFrontMatter(front, h.FileManager.Configs[0].FrontMatter) + fm, err := frontmatter.Marshal(front, format) if err != nil { log.Println(err) diff --git a/setup.go b/setup.go index bf7873f4..c514b326 100644 --- a/setup.go +++ b/setup.go @@ -158,15 +158,8 @@ func parse(c *caddy.Controller, root string) (*Config, *filemanager.FileManager, fm = &filemanager.FileManager{Configs: fmConfig} fm.Configs[0].HugoEnabled = true - - format := getFrontMatter(cfg) - cfg.WebDavURL = fm.Configs[0].WebDavURL - for _, user := range fm.Configs[0].Users { - user.FrontMatter = format - } - if err != nil { return cfg, fm, err } @@ -210,7 +203,7 @@ func getFrontMatter(conf *Config) string { log.Println(err) fmt.Printf("Can't get the default frontmatter from the configuration. %s will be used.\n", format) } else { - bytes = frontmatter.AppendRune(bytes, format) + bytes = frontmatter.AppendRune(bytes, frontmatter.StringFormatToRune(format)) f, err := frontmatter.Unmarshal(bytes) if err != nil {