update
This commit is contained in:
parent
f95059d897
commit
34d72cbbc9
|
@ -1,7 +1,6 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mholt/caddy/config/setup"
|
"github.com/mholt/caddy/config/setup"
|
||||||
|
@ -11,15 +10,13 @@ import (
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Styles string
|
Styles string
|
||||||
Args []string
|
Args []string
|
||||||
|
|
||||||
Hugo bool
|
|
||||||
Command string
|
Command string
|
||||||
Content string
|
Content string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseCMS parses the configuration file
|
// ParseCMS parses the configuration file
|
||||||
func ParseCMS(c *setup.Controller) (*Config, error) {
|
func ParseCMS(c *setup.Controller) (*Config, error) {
|
||||||
conf := &Config{Hugo: true, Content: "content"}
|
conf := &Config{Content: "content"}
|
||||||
|
|
||||||
for c.Next() {
|
for c.Next() {
|
||||||
for c.NextBlock() {
|
for c.NextBlock() {
|
||||||
|
@ -33,15 +30,6 @@ func ParseCMS(c *setup.Controller) (*Config, error) {
|
||||||
conf.Styles = strings.TrimPrefix(conf.Styles, "/")
|
conf.Styles = strings.TrimPrefix(conf.Styles, "/")
|
||||||
// Add a beginning slash to make a
|
// Add a beginning slash to make a
|
||||||
conf.Styles = "/" + conf.Styles
|
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":
|
case "content":
|
||||||
if !c.NextArg() {
|
if !c.NextArg() {
|
||||||
return nil, c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
|
|
|
@ -161,7 +161,7 @@ func ParseComponents(r *http.Request) []string {
|
||||||
|
|
||||||
// Run is used to run the static website generator
|
// Run is used to run the static website generator
|
||||||
func Run(c *config.Config) {
|
func Run(c *config.Config) {
|
||||||
if !c.Hugo {
|
if c.Command != "" {
|
||||||
out, err := exec.Command(c.Command, c.Args...).Output()
|
out, err := exec.Command(c.Command, c.Args...).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic("Can't execute the commands defined on Caddyfile.")
|
log.Panic("Can't execute the commands defined on Caddyfile.")
|
||||||
|
|
Loading…
Reference in New Issue