Update to work with Caddy sub directories

This commit is contained in:
Henrique Dias
2016-07-01 15:46:06 +01:00
parent e0a3c6cb22
commit d5306b594f
4 changed files with 16 additions and 10 deletions

View File

@@ -7,6 +7,7 @@ import (
"strings"
"github.com/mholt/caddy"
"github.com/mholt/caddy/caddyhttp/httpserver"
)
// Config is a configuration for browsing in a particualr path.
@@ -14,6 +15,7 @@ type Config struct {
PathScope string
Root http.FileSystem
BaseURL string
AbsoluteURL string
StyleSheet string // Costum stylesheet
FrontMatter string // Default frontmatter to save files in
HugoEnabled bool // Enables the Hugo plugin for File Manager
@@ -72,6 +74,10 @@ func Parse(c *caddy.Controller) ([]Config, error) {
}
}
caddyConf := httpserver.GetConfig(c)
cfg.AbsoluteURL = caddyConf.Addr.Path + "/" + cfg.BaseURL
cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)
cfg.Root = http.Dir(cfg.PathScope)
if err := appendConfig(cfg); err != nil {
return configs, err