one more thing
This commit is contained in:
parent
d5306b594f
commit
7ed515dba8
|
@ -16,6 +16,7 @@ type Config struct {
|
||||||
Root http.FileSystem
|
Root http.FileSystem
|
||||||
BaseURL string
|
BaseURL string
|
||||||
AbsoluteURL string
|
AbsoluteURL string
|
||||||
|
AddrPath string
|
||||||
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
|
||||||
|
@ -77,7 +78,7 @@ func Parse(c *caddy.Controller) ([]Config, error) {
|
||||||
caddyConf := httpserver.GetConfig(c)
|
caddyConf := httpserver.GetConfig(c)
|
||||||
cfg.AbsoluteURL = caddyConf.Addr.Path + "/" + cfg.BaseURL
|
cfg.AbsoluteURL = caddyConf.Addr.Path + "/" + cfg.BaseURL
|
||||||
cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)
|
cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)
|
||||||
|
cfg.AddrPath = strings.TrimSuffix(caddyConf.Addr.Path, "/")
|
||||||
cfg.Root = http.Dir(cfg.PathScope)
|
cfg.Root = http.Dir(cfg.PathScope)
|
||||||
if err := appendConfig(cfg); err != nil {
|
if err := appendConfig(cfg); err != nil {
|
||||||
return configs, err
|
return configs, err
|
||||||
|
|
|
@ -54,7 +54,7 @@ func (f FileManager) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.IsDir && !strings.HasSuffix(r.URL.Path, "/") {
|
if fi.IsDir && !strings.HasSuffix(r.URL.Path, "/") {
|
||||||
http.Redirect(w, r, r.URL.Path+"/", http.StatusTemporaryRedirect)
|
http.Redirect(w, r, c.AddrPath+r.URL.Path+"/", http.StatusTemporaryRedirect)
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue