From 81a6f569661422b194b49c83fcae548e8c5cc9a0 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sat, 20 Aug 2016 20:34:08 +0100 Subject: [PATCH] add #19 options to setup --- config/config.go | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 19b59b8a..de6beb52 100644 --- a/config/config.go +++ b/config/config.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "net/http" + "strconv" "strings" "github.com/mholt/caddy" @@ -21,6 +22,10 @@ type Config struct { StyleSheet string // Costum stylesheet FrontMatter string // Default frontmatter to save files in HugoEnabled bool // Enables the Hugo plugin for File Manager + + AllowNew bool + AllowEdit bool + AllowCommands bool } // Parse parses the configuration set by the user so it can @@ -38,6 +43,8 @@ func Parse(c *caddy.Controller) ([]Config, error) { return nil } + var err error + for c.Next() { var cfg = Config{PathScope: ".", BaseURL: "", FrontMatter: "yaml", HugoEnabled: false} for c.NextBlock() { @@ -68,11 +75,36 @@ func Parse(c *caddy.Controller) ([]Config, error) { if !c.NextArg() { return configs, c.ArgErr() } - tplBytes, err := ioutil.ReadFile(c.Val()) + var tplBytes []byte + tplBytes, err = ioutil.ReadFile(c.Val()) if err != nil { return configs, err } cfg.StyleSheet = string(tplBytes) + case "allow_new": + if !c.NextArg() { + return configs, c.ArgErr() + } + cfg.AllowNew, err = strconv.ParseBool(c.Val()) + if err != nil { + return configs, err + } + case "allow_edit": + if !c.NextArg() { + return configs, c.ArgErr() + } + cfg.AllowEdit, err = strconv.ParseBool(c.Val()) + if err != nil { + return configs, err + } + case "allow_comands": + if !c.NextArg() { + return configs, c.ArgErr() + } + cfg.AllowCommands, err = strconv.ParseBool(c.Val()) + if err != nil { + return configs, err + } } }