flounder

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

commit 904a619b566e69eac12b9d7e2822b24dc4f74263
parent 7c81f713a773d2463dc971fcb7981abfaf3ad08f
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat, 21 Nov 2020 14:03:32 -0800

add hidden folder

Diffstat:
Mgemini.go | 3+++
Mgo.sum | 2++
Mhttp.go | 3+++
Mmain.go | 5+++++
4 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/gemini.go b/gemini.go @@ -43,6 +43,9 @@ func gmiPage(w *gmi.ResponseWriter, r *gmi.Request) { fileName := filepath.Clean(r.URL.Path) if fileName == "/" { fileName = "index.gmi" + } else if strings.HasPrefix(fileName, ".hidden") { + w.WriteStatus(gmi.StatusNotFound) + return } log.Println("Request for gemini file", fileName, "for user", userName) diff --git a/go.sum b/go.sum @@ -25,7 +25,9 @@ github.com/mattn/go-sqlite3 v1.14.4/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGw golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d h1:2+ZP7EfsZV7Vvmx3TIqSlSzATMkTAKqM14YGFPoSKjI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/http.go b/http.go @@ -434,6 +434,9 @@ func userFile(w http.ResponseWriter, r *http.Request) { p := filepath.Clean(r.URL.Path) if p == "/" { p = "index.gmi" + } else if strings.HasPrefix(p, "/.hidden") { + renderError(w, "404: file not found", 404) + return } fileName := path.Join(c.FilesDirectory, userName, p) extension := path.Ext(fileName) diff --git a/main.go b/main.go @@ -22,6 +22,8 @@ import ( var c Config // global var to hold static configuration +const HIDDEN_FOLDER = ".hidden" + type File struct { // also folders Creator string Name string // includes folder @@ -101,6 +103,9 @@ func getIndexFiles() ([]*File, error) { // cache this function log.Printf("Failure accessing a path %q: %v\n", thepath, err) return err // think about } + if info.IsDir() && info.Name() == HIDDEN_FOLDER { + return filepath.SkipDir + } // make this do what it should if !info.IsDir() { creatorFolder := getCreator(thepath)