add conf.DirlistEnable and modify readme
This commit is contained in:
parent
33b0be1065
commit
6c71b360ac
14
README.md
14
README.md
|
@ -1,5 +1,13 @@
|
|||
# spsrv
|
||||
WIP!
|
||||
|
||||
A static spartan server with many features:
|
||||
|
||||
* folder redirects
|
||||
* /~user directories
|
||||
* directory listing
|
||||
* CONF or TOML config file
|
||||
* directory listing options
|
||||
* user directory feature and userdir path
|
||||
|
||||
## todo
|
||||
- [x] /folder to /folder/ redirects
|
||||
|
@ -9,7 +17,9 @@ WIP!
|
|||
- [x] refactor working dir part
|
||||
- [x] config
|
||||
- [ ] status meta
|
||||
- [ ] user homedir
|
||||
- [x] user homedir
|
||||
- [x] hostname, port
|
||||
- [x] public dir
|
||||
- [ ] dirlist title
|
||||
- [ ] userdir slug
|
||||
- [ ] /echo /guestbook (configurable)
|
||||
|
|
13
config.go
13
config.go
|
@ -8,12 +8,12 @@ import (
|
|||
)
|
||||
|
||||
type Config struct {
|
||||
Port int
|
||||
Hostname string
|
||||
RootDir string
|
||||
UserDirEnable bool
|
||||
UserDir string
|
||||
// UserSlug string
|
||||
Port int
|
||||
Hostname string
|
||||
RootDir string
|
||||
UserDirEnable bool
|
||||
UserDir string
|
||||
DirlistEnable bool
|
||||
DirlistReverse bool
|
||||
DirlistSort string
|
||||
DirlistTitles bool
|
||||
|
@ -23,6 +23,7 @@ var defaultConf = &Config{
|
|||
Port: 300,
|
||||
Hostname: "localhost",
|
||||
RootDir: "/var/spartan/",
|
||||
DirlistEnable: true,
|
||||
DirlistReverse: false,
|
||||
DirlistSort: "name",
|
||||
DirlistTitles: true,
|
||||
|
|
2
spsrv.go
2
spsrv.go
|
@ -151,7 +151,7 @@ func serveFile(conn io.ReadWriteCloser, reqPath, path string, conf *Config) {
|
|||
// not putting the /folder to /folder/ redirect here because folder can still
|
||||
// be opened without errors
|
||||
// Directory listing
|
||||
if strings.HasSuffix(path, "index.gmi") {
|
||||
if conf.DirlistEnable && strings.HasSuffix(path, "index.gmi") {
|
||||
// fullPath := filepath.Join(fmt.Sprint(rootDir), path)
|
||||
fullPath := path
|
||||
if _, err := os.Stat(fullPath); os.IsNotExist(err) {
|
||||
|
|
Loading…
Reference in New Issue