From 4b937d2f1cca5595a74479eab87a8e34d0039bbf Mon Sep 17 00:00:00 2001 From: tjpcc Date: Thu, 7 Sep 2023 15:49:19 -0600 Subject: gophermaps and cgi --- routes.go | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'routes.go') diff --git a/routes.go b/routes.go index 9c330b6..08d2c56 100644 --- a/routes.go +++ b/routes.go @@ -6,6 +6,7 @@ import ( "crypto/x509" "encoding/hex" "os" + "path/filepath" "sort" "strings" @@ -15,7 +16,8 @@ import ( "tildegit.org/tjp/sliderule/contrib/tlsauth" "tildegit.org/tjp/sliderule/finger" "tildegit.org/tjp/sliderule/gemini" - "tildegit.org/tjp/sliderule/gemini/gemtext" + "tildegit.org/tjp/sliderule/gemini/gemtext/atomconv" + "tildegit.org/tjp/sliderule/gopher/gophermap" "tildegit.org/tjp/sliderule/logging" ) @@ -58,32 +60,36 @@ func geminiRouter(conf config) sr.Handler { h := router.Handler() if conf.geminiAutoAtom { - h = gemtext.AutoAtom(h) + h = atomconv.Auto(h) } return h } func gopherRouter(conf config) sr.Handler { - fsys := os.DirFS(conf.gopherRoot) + settings := gophermap.FileSystemSettings{ + ParseExtended: true, + Exec: true, + ListUsers: false, + DirMaps: []string{"gophermap"}, + DirTag: "gophertag", + } router := &sr.Router{} router.Route( "/*", sr.FallthroughHandler( - fs.GopherFileHandler(fsys), - fs.GopherDirectoryDefault(fsys, "index.gophermap"), - fs.GopherDirectoryListing(fsys, nil), + cgi.ExecGopherMaps("/", conf.gopherRoot, &settings), + fs.GopherFileHandler(conf.gopherRoot, &settings), + fs.GopherDirectoryDefault(conf.gopherRoot, &settings), + fs.GopherDirectoryListing(conf.gopherRoot, &settings), ), ) router.Route( "/cgi-bin/*", - cgi.GopherCGIDirectory( - "/cgi-bin/", - strings.Join([]string{".", strings.Trim(conf.gopherRoot, "/"), "cgi-bin"}, "/"), - ), + cgi.GopherCGIDirectory("/cgi-bin/", filepath.Join(conf.gopherRoot, "cgi-bin"), &settings), ) return router.Handler() -- cgit v1.2.3