small bug fixes
parent
1df11145a8
commit
de984c3037
21
README.md
21
README.md
|
@ -8,15 +8,26 @@
|
||||||
|
|
||||||
This package is a plugin for Caddy server that provides an online file manager (based on browse middleware) that is able to: rename files, delete files and upload files. Some new features that can be implemented in the future can be seen at [issues](https://github.com/hacdias/caddy-filemanager/issues).
|
This package is a plugin for Caddy server that provides an online file manager (based on browse middleware) that is able to: rename files, delete files and upload files. Some new features that can be implemented in the future can be seen at [issues](https://github.com/hacdias/caddy-filemanager/issues).
|
||||||
|
|
||||||
|
### Syntax
|
||||||
|
|
||||||
```
|
```
|
||||||
filemanager {
|
filemanager url {
|
||||||
show path
|
show path
|
||||||
on url
|
styles filepath
|
||||||
styles filepath
|
frontmatter type
|
||||||
frontmatter type
|
allow_new [true|false]
|
||||||
|
allow_edit [true|false]
|
||||||
|
allow_commands [true|false]
|
||||||
|
allow_command command
|
||||||
|
block_command command
|
||||||
|
allow [path|dotfiles]
|
||||||
|
allow_r path regex
|
||||||
|
block [path|dotfiles]
|
||||||
|
block_r path regex
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## NOTE FOR DEVELOPERS
|
## NOTE FOR DEVELOPERS
|
||||||
|
|
||||||
You need to run `go generate` on `$GOPATH/src/github.com/hacdias/caddy-filemanager` before building any binary. Otherwise, you will receive an `undefined: Asset` error.
|
You need to run `go generate` on `$GOPATH/src/github.com/hacdias/caddy-filemanager` before building any binary. Otherwise, you will receive an `undefined: Asset` error.
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// BaseURL is the url of the assets
|
// BaseURL is the url of the assets
|
||||||
const BaseURL = "_filemanagerinternal"
|
const BaseURL = "/_filemanagerinternal"
|
||||||
|
|
||||||
// Serve provides the needed assets for the front-end
|
// Serve provides the needed assets for the front-end
|
||||||
func Serve(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
|
func Serve(w http.ResponseWriter, r *http.Request, c *config.Config) (int, error) {
|
||||||
|
|
|
@ -70,12 +70,20 @@ func Parse(c *caddy.Controller) ([]Config, error) {
|
||||||
Regexp: regexp.MustCompile("\\/\\..+"),
|
Regexp: regexp.MustCompile("\\/\\..+"),
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
// Get the baseURL
|
||||||
|
args := c.RemainingArgs()
|
||||||
|
|
||||||
|
if len(args) > 0 {
|
||||||
|
cfg.BaseURL = args[0]
|
||||||
|
}
|
||||||
|
|
||||||
// Set the first user, the global user
|
// Set the first user, the global user
|
||||||
user = cfg.User
|
user = cfg.User
|
||||||
|
|
||||||
for c.NextBlock() {
|
for c.NextBlock() {
|
||||||
switch c.Val() {
|
switch c.Val() {
|
||||||
case "on":
|
case "on":
|
||||||
|
// NOTE: DEPRECATED
|
||||||
if !c.NextArg() {
|
if !c.NextArg() {
|
||||||
return configs, c.ArgErr()
|
return configs, c.ArgErr()
|
||||||
}
|
}
|
||||||
|
@ -212,6 +220,10 @@ func Parse(c *caddy.Controller) ([]Config, error) {
|
||||||
cfg.BaseURL = strings.TrimSuffix(cfg.BaseURL, "/")
|
cfg.BaseURL = strings.TrimSuffix(cfg.BaseURL, "/")
|
||||||
cfg.BaseURL = "/" + cfg.BaseURL
|
cfg.BaseURL = "/" + cfg.BaseURL
|
||||||
|
|
||||||
|
if cfg.BaseURL == "/" {
|
||||||
|
cfg.BaseURL = ""
|
||||||
|
}
|
||||||
|
|
||||||
caddyConf := httpserver.GetConfig(c)
|
caddyConf := httpserver.GetConfig(c)
|
||||||
cfg.AbsoluteURL = strings.TrimSuffix(caddyConf.Addr.Path, "/") + "/" + cfg.BaseURL
|
cfg.AbsoluteURL = strings.TrimSuffix(caddyConf.Addr.Path, "/") + "/" + cfg.BaseURL
|
||||||
cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)
|
cfg.AbsoluteURL = strings.Replace(cfg.AbsoluteURL, "//", "/", -1)
|
||||||
|
|
Loading…
Reference in New Issue