flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 3d63a8ce4b80ae8cd81bff62ef03e4d4ea8b436f
parent ade0a38005835f48624cd3c356465f7456c79a2f
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat,  5 Dec 2020 17:46:08 -0800

Allow admin to view hidden files on TL

Diffstat:
Madmin.go | 1+
Mgemini.go | 2+-
Mhttp.go | 2+-
Mmain.go | 4++--
4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/admin.go b/admin.go @@ -47,6 +47,7 @@ func makeAdmin(username string) error { if err != nil { return err } + log.Println("Made admin user", username) return nil } diff --git a/gemini.go b/gemini.go @@ -18,7 +18,7 @@ func gmiIndex(w *gmi.ResponseWriter, r *gmi.Request) { if err != nil { log.Fatal(err) } - files, err := getIndexFiles() + files, err := getIndexFiles(false) users, err := getActiveUserNames() if err != nil { log.Println(err) diff --git a/http.go b/http.go @@ -57,7 +57,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) { } authd, _, isAdmin := getAuthUser(r) - indexFiles, err := getIndexFiles() + indexFiles, err := getIndexFiles(isAdmin) if err != nil { log.Println(err) renderDefaultError(w, http.StatusInternalServerError) diff --git a/main.go b/main.go @@ -97,14 +97,14 @@ func getCreator(filePath string) string { return r } -func getIndexFiles() ([]*File, error) { // cache this function +func getIndexFiles(admin bool) ([]*File, error) { // cache this function result := []*File{} err := filepath.Walk(c.FilesDirectory, func(thepath string, info os.FileInfo, err error) error { if err != nil { log.Printf("Failure accessing a path %q: %v\n", thepath, err) return err // think about } - if info.IsDir() && info.Name() == HIDDEN_FOLDER { + if !admin && info.IsDir() && info.Name() == HIDDEN_FOLDER { return filepath.SkipDir } // make this do what it should