mirror of
https://github.com/filebrowser/filebrowser.git
synced 2024-06-07 23:00:43 +00:00
add #19 options to setup
This commit is contained in:
parent
ab9f02256e
commit
81a6f56966
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mholt/caddy"
|
"github.com/mholt/caddy"
|
||||||
@ -21,6 +22,10 @@ type Config struct {
|
|||||||
StyleSheet string // Costum stylesheet
|
StyleSheet string // Costum stylesheet
|
||||||
FrontMatter string // Default frontmatter to save files in
|
FrontMatter string // Default frontmatter to save files in
|
||||||
HugoEnabled bool // Enables the Hugo plugin for File Manager
|
HugoEnabled bool // Enables the Hugo plugin for File Manager
|
||||||
|
|
||||||
|
AllowNew bool
|
||||||
|
AllowEdit bool
|
||||||
|
AllowCommands bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse parses the configuration set by the user so it can
|
// Parse parses the configuration set by the user so it can
|
||||||
@ -38,6 +43,8 @@ func Parse(c *caddy.Controller) ([]Config, error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
for c.Next() {
|
for c.Next() {
|
||||||
var cfg = Config{PathScope: ".", BaseURL: "", FrontMatter: "yaml", HugoEnabled: false}
|
var cfg = Config{PathScope: ".", BaseURL: "", FrontMatter: "yaml", HugoEnabled: false}
|
||||||
for c.NextBlock() {
|
for c.NextBlock() {
|
||||||
@ -68,11 +75,36 @@ func Parse(c *caddy.Controller) ([]Config, error) {
|
|||||||
if !c.NextArg() {
|
if !c.NextArg() {
|
||||||
return configs, c.ArgErr()
|
return configs, c.ArgErr()
|
||||||
}
|
}
|
||||||
tplBytes, err := ioutil.ReadFile(c.Val())
|
var tplBytes []byte
|
||||||
|
tplBytes, err = ioutil.ReadFile(c.Val())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return configs, err
|
return configs, err
|
||||||
}
|
}
|
||||||
cfg.StyleSheet = string(tplBytes)
|
cfg.StyleSheet = string(tplBytes)
|
||||||
|
case "allow_new":
|
||||||
|
if !c.NextArg() {
|
||||||
|
return configs, c.ArgErr()
|
||||||
|
}
|
||||||
|
cfg.AllowNew, err = strconv.ParseBool(c.Val())
|
||||||
|
if err != nil {
|
||||||
|
return configs, err
|
||||||
|
}
|
||||||
|
case "allow_edit":
|
||||||
|
if !c.NextArg() {
|
||||||
|
return configs, c.ArgErr()
|
||||||
|
}
|
||||||
|
cfg.AllowEdit, err = strconv.ParseBool(c.Val())
|
||||||
|
if err != nil {
|
||||||
|
return configs, err
|
||||||
|
}
|
||||||
|
case "allow_comands":
|
||||||
|
if !c.NextArg() {
|
||||||
|
return configs, c.ArgErr()
|
||||||
|
}
|
||||||
|
cfg.AllowCommands, err = strconv.ParseBool(c.Val())
|
||||||
|
if err != nil {
|
||||||
|
return configs, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user