Skip to content

Commit

Permalink
add #19 options to setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Aug 20, 2016
1 parent ab9f022 commit 81a6f56
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"strconv"
"strings"

"github.com/mholt/caddy"
Expand All @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -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
}
}
}

Expand Down

0 comments on commit 81a6f56

Please sign in to comment.