This commit is contained in:
Henrique Dias 2017-01-18 18:21:04 +00:00
parent 022891e51e
commit 91a6848586
2 changed files with 3 additions and 10 deletions

View File

@ -21,7 +21,6 @@ import (
"github.com/hacdias/caddy-filemanager" "github.com/hacdias/caddy-filemanager"
"github.com/hacdias/caddy-filemanager/assets" "github.com/hacdias/caddy-filemanager/assets"
"github.com/hacdias/caddy-filemanager/frontmatter" "github.com/hacdias/caddy-filemanager/frontmatter"
"github.com/hacdias/caddy-filemanager/handlers"
"github.com/hacdias/caddy-filemanager/utils/variables" "github.com/hacdias/caddy-filemanager/utils/variables"
"github.com/hacdias/caddy-hugo/utils/commands" "github.com/hacdias/caddy-hugo/utils/commands"
"github.com/mholt/caddy/caddyhttp/httpserver" "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 return http.StatusInternalServerError, err
} }
format := rune(r.Header.Get("Rune")[0])
scheduler := cron.New() scheduler := cron.New()
scheduler.AddFunc(t.Format("05 04 15 02 01 *"), func() { scheduler.AddFunc(t.Format("05 04 15 02 01 *"), func() {
filename := r.URL.Path 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") 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 { if err != nil {
log.Println(err) log.Println(err)

View File

@ -158,15 +158,8 @@ func parse(c *caddy.Controller, root string) (*Config, *filemanager.FileManager,
fm = &filemanager.FileManager{Configs: fmConfig} fm = &filemanager.FileManager{Configs: fmConfig}
fm.Configs[0].HugoEnabled = true fm.Configs[0].HugoEnabled = true
format := getFrontMatter(cfg)
cfg.WebDavURL = fm.Configs[0].WebDavURL cfg.WebDavURL = fm.Configs[0].WebDavURL
for _, user := range fm.Configs[0].Users {
user.FrontMatter = format
}
if err != nil { if err != nil {
return cfg, fm, err return cfg, fm, err
} }
@ -210,7 +203,7 @@ func getFrontMatter(conf *Config) string {
log.Println(err) log.Println(err)
fmt.Printf("Can't get the default frontmatter from the configuration. %s will be used.\n", format) fmt.Printf("Can't get the default frontmatter from the configuration. %s will be used.\n", format)
} else { } else {
bytes = frontmatter.AppendRune(bytes, format) bytes = frontmatter.AppendRune(bytes, frontmatter.StringFormatToRune(format))
f, err := frontmatter.Unmarshal(bytes) f, err := frontmatter.Unmarshal(bytes)
if err != nil { if err != nil {