Skip to content

Commit

Permalink
Add configs #19 #21 #23 #24
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Aug 20, 2016
1 parent 81a6f56 commit 9e86010
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"regexp"
"strconv"
"strings"

Expand All @@ -13,19 +14,32 @@ import (

// Config is a configuration for browsing in a particualr path.
type Config struct {
PathScope string
Root http.FileSystem
*UserConfig
BaseURL string
AbsoluteURL string
AddrPath string
Token string // Anti CSRF token
StyleSheet string // Costum stylesheet
FrontMatter string // Default frontmatter to save files in
HugoEnabled bool // Enables the Hugo plugin for File Manager
}

AllowNew bool
AllowEdit bool
AllowCommands bool
// UserConfig contains the configuration for each user
type UserConfig struct {
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
Expand All @@ -46,7 +60,12 @@ func Parse(c *caddy.Controller) ([]Config, error) {
var err error

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() {
switch c.Val() {
case "show":
Expand Down

0 comments on commit 9e86010

Please sign in to comment.