parent
81a6f56966
commit
9e8601085a
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -13,19 +14,32 @@ import (
|
||||||
|
|
||||||
// Config is a configuration for browsing in a particualr path.
|
// Config is a configuration for browsing in a particualr path.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
PathScope string
|
*UserConfig
|
||||||
Root http.FileSystem
|
|
||||||
BaseURL string
|
BaseURL string
|
||||||
AbsoluteURL string
|
AbsoluteURL string
|
||||||
AddrPath string
|
AddrPath string
|
||||||
Token string // Anti CSRF token
|
Token string // Anti CSRF token
|
||||||
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
|
// UserConfig contains the configuration for each user
|
||||||
AllowEdit bool
|
type UserConfig struct {
|
||||||
AllowCommands bool
|
PathScope string
|
||||||
|
Root http.FileSystem
|
||||||
|
StyleSheet string // Costum stylesheet
|
||||||
|
FrontMatter string // Default frontmatter to save files in
|
||||||
|
AllowNew bool // Can create files and folders
|
||||||
|
AllowEdit bool // Can edit/rename files
|
||||||
|
|
||||||
|
Allow []string // Allowed browse directories/files
|
||||||
|
AllowRegex []*regexp.Regexp // Regex of the previous
|
||||||
|
Block []string // Blocked browse directories/files
|
||||||
|
BlockRegex []*regexp.Regexp // Regex of the previous
|
||||||
|
|
||||||
|
AllowCommands bool // Can execute commands
|
||||||
|
AllowedCommands []string // Allowed commands
|
||||||
|
BlockedCommands []string // Blocked Commands
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse parses the configuration set by the user so it can
|
// Parse parses the configuration set by the user so it can
|
||||||
|
@ -46,7 +60,12 @@ func Parse(c *caddy.Controller) ([]Config, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
for c.Next() {
|
for c.Next() {
|
||||||
var cfg = Config{PathScope: ".", BaseURL: "", FrontMatter: "yaml", HugoEnabled: false}
|
var cfg = Config{}
|
||||||
|
cfg.PathScope = "."
|
||||||
|
cfg.BaseURL = ""
|
||||||
|
cfg.FrontMatter = "yaml"
|
||||||
|
cfg.HugoEnabled = false
|
||||||
|
|
||||||
for c.NextBlock() {
|
for c.NextBlock() {
|
||||||
switch c.Val() {
|
switch c.Val() {
|
||||||
case "show":
|
case "show":
|
||||||
|
|
Loading…
Reference in New Issue