Compare commits

..

No commits in common. "57f31343debc819decfcb017c46cfd46673c59df" and "a690b76c4256fdeae80ee229f1bf956b3d506a8d" have entirely different histories.

3 changed files with 4 additions and 26 deletions

View file

@ -16,25 +16,17 @@ indir [--host address] [--port port] [--root http_root] directory
--root http_root hosts on the specified subdirectory, i.e. `/files/` --root http_root hosts on the specified subdirectory, i.e. `/files/`
``` ```
## features ## customization
### file serving ### readme
indir has the possibility of automatically serving an `index.html` instead of displaying the directory view!
### customization
#### readme
drop a `README.md` into any directory and indir will render drop a `README.md` into any directory and indir will render
it below the file listing with full markdown support! it below the file listing with full markdown support!
#### custom css
using a 'index.css' file, you can customize the directory view!
--- ---
## to-do: ## to-do:
- [x] use templates instead of hard-coded HTML (i was lazy) - [x] use templates instead of hard-coded HTML (i was lazy)
- [x] directory header from readme file - [x] directory header from readme file
- [x] directory stylesheet overrides - [ ] directory stylesheet overrides
- [x] index.html serving support - [x] index.html serving support
- [x] fix mime-types for browser file view - [x] fix mime-types for browser file view

11
main.go
View file

@ -29,7 +29,6 @@ type (
Root bool Root bool
Files []*File Files []*File
Readme template.HTML Readme template.HTML
CSS template.CSS
} }
File struct { File struct {
@ -182,15 +181,6 @@ func main() {
return return
} }
// load index.css if present
var customCSS template.CSS
cssPath := filepath.Join(fpath, "index.css")
if cssInfo, err := os.Stat(cssPath); err == nil && !cssInfo.IsDir() {
if src, err := os.ReadFile(cssPath); err == nil {
customCSS = template.CSS(src)
}
}
// embeded readme // embeded readme
var readmeHTML template.HTML var readmeHTML template.HTML
entries, err := os.ReadDir(fpath) entries, err := os.ReadDir(fpath)
@ -215,7 +205,6 @@ func main() {
Name: r.URL.Path, Name: r.URL.Path,
Files: []*File{}, Files: []*File{},
Readme: readmeHTML, Readme: readmeHTML,
CSS: customCSS,
} }
fsDir := os.DirFS(fpath) fsDir := os.DirFS(fpath)

View file

@ -142,9 +142,6 @@
} }
} }
</style> </style>
{{if .CSS}}
<style>{{.CSS}}</style>
{{end}}
</head> </head>
<body> <body>
<main> <main>