This commit is contained in:
Henrique Dias 2015-09-27 20:33:36 +01:00
parent f95059d897
commit 34d72cbbc9
2 changed files with 4 additions and 16 deletions

View File

@ -1,7 +1,6 @@
package config
import (
"strconv"
"strings"
"github.com/mholt/caddy/config/setup"
@ -9,17 +8,15 @@ import (
// Config is the add-on configuration set on Caddyfile
type Config struct {
Styles string
Args []string
Hugo bool
Styles string
Args []string
Command string
Content string
}
// ParseCMS parses the configuration file
func ParseCMS(c *setup.Controller) (*Config, error) {
conf := &Config{Hugo: true, Content: "content"}
conf := &Config{Content: "content"}
for c.Next() {
for c.NextBlock() {
@ -33,15 +30,6 @@ func ParseCMS(c *setup.Controller) (*Config, error) {
conf.Styles = strings.TrimPrefix(conf.Styles, "/")
// Add a beginning slash to make a
conf.Styles = "/" + conf.Styles
case "hugo":
if !c.NextArg() {
return nil, c.ArgErr()
}
var err error
conf.Hugo, err = strconv.ParseBool(c.Val())
if err != nil {
return conf, err
}
case "content":
if !c.NextArg() {
return nil, c.ArgErr()

View File

@ -161,7 +161,7 @@ func ParseComponents(r *http.Request) []string {
// Run is used to run the static website generator
func Run(c *config.Config) {
if !c.Hugo {
if c.Command != "" {
out, err := exec.Command(c.Command, c.Args...).Output()
if err != nil {
log.Panic("Can't execute the commands defined on Caddyfile.")