mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
add option for #106
This commit is contained in:
parent
55f4b75529
commit
6ef2cf88e0
4
hugo.go
4
hugo.go
@ -133,7 +133,9 @@ func (h Hugo) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
|
|||||||
|
|
||||||
// RunHugo is used to run the static website generator
|
// RunHugo is used to run the static website generator
|
||||||
func RunHugo(c *Config, force bool) {
|
func RunHugo(c *Config, force bool) {
|
||||||
os.RemoveAll(c.Root + "public")
|
if c.CleanPublic {
|
||||||
|
os.RemoveAll(c.Root + "public")
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent running if watching is enabled
|
// Prevent running if watching is enabled
|
||||||
if b, pos := variables.StringInSlice("--watch", c.Args); b && !force {
|
if b, pos := variables.StringInSlice("--watch", c.Args); b && !force {
|
||||||
|
12
setup.go
12
setup.go
@ -10,6 +10,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hacdias/caddy-filemanager"
|
"github.com/hacdias/caddy-filemanager"
|
||||||
@ -70,6 +71,7 @@ type Config struct {
|
|||||||
Args []string // Hugo arguments
|
Args []string // Hugo arguments
|
||||||
BaseURL string // BaseURL of admin interface
|
BaseURL string // BaseURL of admin interface
|
||||||
WebDavURL string
|
WebDavURL string
|
||||||
|
CleanPublic bool
|
||||||
BeforePublish config.CommandFunc
|
BeforePublish config.CommandFunc
|
||||||
AfterPublish config.CommandFunc
|
AfterPublish config.CommandFunc
|
||||||
}
|
}
|
||||||
@ -127,6 +129,16 @@ func parse(c *caddy.Controller, root string) (*Config, *filemanager.FileManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg.Args = append(cfg.Args, "--"+flag+"="+value)
|
cfg.Args = append(cfg.Args, "--"+flag+"="+value)
|
||||||
|
case "clean_public":
|
||||||
|
if !c.NextArg() {
|
||||||
|
return cfg, &filemanager.FileManager{}, c.ArgErr()
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.CleanPublic, err = strconv.ParseBool(c.Val())
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return cfg, &filemanager.FileManager{}, c.ArgErr()
|
||||||
|
}
|
||||||
case "before_publish":
|
case "before_publish":
|
||||||
if cfg.BeforePublish, err = config.CommandRunner(c); err != nil {
|
if cfg.BeforePublish, err = config.CommandRunner(c); err != nil {
|
||||||
return cfg, &filemanager.FileManager{}, err
|
return cfg, &filemanager.FileManager{}, err
|
||||||
|
Loading…
Reference in New Issue
Block a user