allow / or regular for dir

Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
Sam Therapy 2022-10-13 16:42:04 +02:00
parent a9ac7145f6
commit d5ea2009a9
Signed by: sam
GPG key ID: 4D8B07C18F31ACBD
3 changed files with 12 additions and 12 deletions

21
main.go
View file

@ -147,9 +147,9 @@ func (werc *Werc) genmenu(site, dir string) MenuEntries {
_, current := path.Split(dir)
if current != "" {
spl = spl[:len(spl)-1]
}
// if current != "" {
// spl = spl[:len(spl)-1]
// }
//log.Printf("base %s path %s spl %+v", base, dir, spl)
@ -178,7 +178,7 @@ func (werc *Werc) genmenu(site, dir string) MenuEntries {
me.Name = me.Name + "/"
}
// if browing a file, mark it as current
if me.Name == current {
if me.Name == current || me.Name == current+"/" {
me.This = true
}
//log.Printf("me %+v", me)
@ -381,13 +381,14 @@ again:
for suf, handler := range sufferring {
var tryfiles []string
if strings.HasSuffix(route, "/") {
for _, index := range indexFiles {
tryfiles = append(tryfiles, path.Join(base, route, index+"."+suf))
}
} else {
tryfiles = append(tryfiles, path.Join(base, route+"."+suf))
// if strings.HasSuffix(route, "/") {
for _, index := range indexFiles {
tryfiles = append(tryfiles, path.Join(base, route, index+"."+suf))
}
// } else {
tryfiles = append(tryfiles, path.Join(base, route+"."+suf))
// }
fmt.Println("Files:", tryfiles)
for _, f := range tryfiles {
fh, err := werc.fs.Open(f)

View file

@ -1,7 +1,6 @@
<nav>
<div class='left'>
<!-- <a href="/sitemap">site map</a> | -->
<a href='https://status.froth.zone/'>status page</a> |
<a href='https://git.froth.zone/sam'>git</a>
</div>

@ -1 +1 @@
Subproject commit ccbb39bbea9aa7c2975b5bb5794ae26d2013337b
Subproject commit 8c70232b4b7cf9a64726fa3930c9640a2b424cd1