diff --git a/config/config.go b/config/config.go index 829fc95c..61b400ef 100644 --- a/config/config.go +++ b/config/config.go @@ -9,15 +9,17 @@ import ( // Config is the add-on configuration set on Caddyfile type Config struct { - Styles string + Styles string + Args []string + Hugo bool - Args []string Command string + Content string } // ParseCMS parses the configuration file func ParseCMS(c *setup.Controller) (*Config, error) { - conf := &Config{Hugo: true} + conf := &Config{Hugo: true, Content: "content"} for c.Next() { for c.NextBlock() { @@ -40,6 +42,13 @@ func ParseCMS(c *setup.Controller) (*Config, error) { if err != nil { return conf, err } + case "content": + if !c.NextArg() { + return nil, c.ArgErr() + } + conf.Content = c.Val() + conf.Content = strings.TrimPrefix(conf.Content, "/") + conf.Content = strings.TrimSuffix(conf.Content, "/") case "command": if !c.NextArg() { return nil, c.ArgErr() diff --git a/editor/editor.go b/editor/editor.go index 5af99e77..00904f25 100644 --- a/editor/editor.go +++ b/editor/editor.go @@ -7,16 +7,6 @@ import ( "github.com/hacdias/staticmin/config" ) -type editor struct { - Name string - Class string - IsPost bool - Mode string - Content string - FrontMatter interface{} - Config *config.Config -} - // ServeHTTP serves the editor page func ServeHTTP(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) { filename := strings.Replace(r.URL.Path, "/admin/edit/", "", 1) diff --git a/editor/get.go b/editor/get.go index 91a9fbe9..4f413642 100644 --- a/editor/get.go +++ b/editor/get.go @@ -16,6 +16,16 @@ import ( "github.com/spf13/hugo/parser" ) +type editor struct { + Name string + Class string + IsPost bool + Mode string + Content string + FrontMatter interface{} + Config *config.Config +} + // GET handles the GET method on editor page func GET(w http.ResponseWriter, r *http.Request, c *config.Config, filename string) (int, error) { // Check if the file format is supported. If not, send a "Not Acceptable" diff --git a/templates/base_full.tmpl b/templates/base_full.tmpl index 4e448e9f..6064d667 100644 --- a/templates/base_full.tmpl +++ b/templates/base_full.tmpl @@ -20,7 +20,8 @@