mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
before publish and after publish commands
This commit is contained in:
parent
76c91576cf
commit
af8dbc2180
16
hugo.go
16
hugo.go
@ -101,7 +101,23 @@ func (h Hugo) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if r.Header.Get("Regenerate") == "true" {
|
if r.Header.Get("Regenerate") == "true" {
|
||||||
|
if err = h.Config.BeforePublish(
|
||||||
|
r,
|
||||||
|
&h.FileManager.Configs[0],
|
||||||
|
h.FileManager.Configs[0].User,
|
||||||
|
); err != nil {
|
||||||
|
return http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
|
|
||||||
RunHugo(h.Config, false)
|
RunHugo(h.Config, false)
|
||||||
|
|
||||||
|
if err = h.Config.AfterPublish(
|
||||||
|
r,
|
||||||
|
&h.FileManager.Configs[0],
|
||||||
|
h.FileManager.Configs[0].User,
|
||||||
|
); err != nil {
|
||||||
|
return http.StatusInternalServerError, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Header.Get("Schedule") != "" {
|
if r.Header.Get("Schedule") != "" {
|
||||||
|
10
setup.go
10
setup.go
@ -69,6 +69,8 @@ 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
|
||||||
|
BeforePublish config.CommandFunc
|
||||||
|
AfterPublish config.CommandFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse parses the configuration set by the user so it can be
|
// Parse parses the configuration set by the user so it can be
|
||||||
@ -127,6 +129,14 @@ func parse(c *caddy.Controller, root string) (*Config, *filemanager.FileManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg.Args = append(cfg.Args, "--"+values[0]+"="+value)
|
cfg.Args = append(cfg.Args, "--"+values[0]+"="+value)
|
||||||
|
case "before_publish":
|
||||||
|
if cfg.BeforePublish, err = config.CommandRunner(c); err != nil {
|
||||||
|
return cfg, &filemanager.FileManager{}, err
|
||||||
|
}
|
||||||
|
case "after_publish":
|
||||||
|
if cfg.AfterPublish, err = config.CommandRunner(c); err != nil {
|
||||||
|
return cfg, &filemanager.FileManager{}, err
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
line := "\n\t" + c.Val()
|
line := "\n\t" + c.Val()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user