Skip to content

Commit

Permalink
Enhancement: manage handler.lua as in issue xyproto#95
Browse files Browse the repository at this point in the history
handler.lua files work as index.lua,
but "cover" also the subtree
until "shadowed" by an index.* file,
or by another handler.lua
  • Loading branch information
giuliolunati committed Mar 22, 2023
1 parent 1383628 commit 186b70b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions engine/dirhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ func (ac *Config) DirPage(w http.ResponseWriter, req *http.Request, rootdir, dir
}
}

// Serve handler.lua, if found in ancestors
var ancestor string
ancestor = filepath.Dir(dirname)
for true {
filename= filepath.Join(ancestor, "handler.lua")
if ac.fs.Exists(filename) {
ac.FilePage(w, req, filename, ac.defaultLuaDataFilename)
return
}
if ancestor == "." { break }
ancestor= filepath.Dir(ancestor)
}


// Serve a directory listing if no index file is found
ac.DirectoryListing(w, req, rootdir, dirname, theme)
}

0 comments on commit 186b70b

Please sign in to comment.