diff --git a/caddy/parser/parser.go b/caddy/parser/parser.go index cf06e9fd..241903b3 100644 --- a/caddy/parser/parser.go +++ b/caddy/parser/parser.go @@ -146,6 +146,15 @@ func Parse(c *caddy.Controller, plugin string) ([]*filemanager.FileManager, erro } u.CSS = string(css) + case "view_mode": + if !c.NextArg() { + return nil, c.ArgErr() + } + + u.ViewMode = c.Val() + if u.ViewMode != "mosaic" && u.ViewMode != "list" { + return nil, c.ArgErr() + } case "no_auth": if !c.NextArg() { noAuth = true diff --git a/cmd/filemanager/main.go b/cmd/filemanager/main.go index 5a14afc7..0344e250 100644 --- a/cmd/filemanager/main.go +++ b/cmd/filemanager/main.go @@ -34,6 +34,7 @@ var ( locale string baseurl string prefixurl string + viewMode string port int noAuth bool allowCommands bool @@ -53,6 +54,7 @@ func init() { flag.StringVarP(&baseurl, "baseurl", "b", "", "Base URL") flag.StringVar(&commands, "commands", "git svn hg", "Default commands option for new users") flag.StringVar(&prefixurl, "prefixurl", "", "Prefix URL") + flag.StringVar(&viewMode, "view-mode", "mosaic", "Default view mode for new users") flag.BoolVar(&allowCommands, "allow-commands", true, "Default allow commands option for new users") flag.BoolVar(&allowEdit, "allow-edit", true, "Default allow edit option for new users") flag.BoolVar(&allowPublish, "allow-publish", true, "Default allow publish option for new users") @@ -79,6 +81,7 @@ func setupViper() { viper.SetDefault("NoAuth", false) viper.SetDefault("BaseURL", "") viper.SetDefault("PrefixURL", "") + viper.SetDefault("ViewMode", "mosaic") viper.BindPFlag("Port", flag.Lookup("port")) viper.BindPFlag("Address", flag.Lookup("address")) @@ -95,6 +98,7 @@ func setupViper() { viper.BindPFlag("NoAuth", flag.Lookup("no-auth")) viper.BindPFlag("BaseURL", flag.Lookup("baseurl")) viper.BindPFlag("PrefixURL", flag.Lookup("prefixurl")) + viper.BindPFlag("ViewMode", flag.Lookup("view-mode")) viper.SetConfigName("filemanager") viper.AddConfigPath(".") @@ -189,6 +193,7 @@ func handler() http.Handler { CSS: "", Scope: viper.GetString("Scope"), FileSystem: fileutils.Dir(viper.GetString("Scope")), + ViewMode: viper.GetString("ViewMode"), }, Store: &filemanager.Store{ Config: bolt.ConfigStore{DB: db},