added preloads page

This commit is contained in:
ston1th 2022-03-23 01:09:12 +01:00
commit 333d5cb149
6 changed files with 235 additions and 75 deletions

View file

@ -56,10 +56,11 @@ type dirs []dir
func (dirs) Less(i, j dir) bool { return i.Name < j.Name }
type file struct {
Name template.HTML
URI template.HTML
Anchor string
Status int
Name template.HTML
URI template.HTML
Anchor string
Status int
Running bool
}
type files []file
@ -128,6 +129,20 @@ func (r *responseInterceptor) GetPaths(path string, fs *fs.FS, relative bool) (d
return
}
func getPreloads(path string, fs *fs.FS) (dc dirContents) {
dc.Base = path
for _, p := range fs.Preloads() {
dc.Files = append(dc.Files, file{
Name: template.HTML(p.Name),
URI: template.HTML(p.Name),
Status: p.Status,
Running: p.Running,
})
}
slices.SortFunc(dc.Files, dc.Files.Less)
return
}
func anchor(s string) string {
if i := strings.LastIndex(s, "/"); i > 0 && i+1 < len(s) {
s = s[i+1:]