From f7858cd719b74afacb1a6b15c5ea03dc10d4e3ad Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 7 Sep 2017 10:41:01 +0100 Subject: [PATCH] Default view mode Former-commit-id: 9212e217514046246a2bde10319763b05998b223 [formerly 8643e0ba3b4246ac0320b5d96dee4ba95e74a346] [formerly 77adb69159dce9cc89b631107340812916a2e279 [formerly 5daacf029887f4c5ba18940555f1bb434c78bfc8]] Former-commit-id: 1a264e8a297e2a5146db53cd6cc40b8baba778de [formerly 607685afb5b6c89703c0b6d82b3dcec07eb22bef] Former-commit-id: 1732f02d1641236402976ae182ee03f7b936d0c1 --- caddy/parser/parser.go | 9 +++++++++ cmd/filemanager/main.go | 5 +++++ 2 files changed, 14 insertions(+) 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},