From e57a3d5ecf30762eded942d6779d7357f8d25f38 Mon Sep 17 00:00:00 2001 From: Solderpunk Date: Thu, 11 Jun 2020 22:43:13 +0200 Subject: [PATCH] Read header for directory listings from .mollyhead. --- handler.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/handler.go b/handler.go index ff478ec..852e4ff 100644 --- a/handler.go +++ b/handler.go @@ -270,6 +270,15 @@ func generateDirectoryListing(URL *url.URL, path string) string { log.Fatal(err) } listing = "# Directory listing\n\n" + // Override with .mollyhead file + header_path := filepath.Join(path, ".mollyhead") + _, err = os.Stat(header_path) + if err == nil { + header, err := ioutil.ReadFile(header_path) + if err == nil { + listing = string(header) + } + } // Do "up" link first if URL.Path != "/" { if strings.HasSuffix(URL.Path, "/") {