diff --git a/config.go b/config.go index a758903..4eb6dbc 100644 --- a/config.go +++ b/config.go @@ -24,6 +24,8 @@ type config struct { privilegedUsers []string fingerResponses map[string]string + + geminiAutoAtom bool } func configure() config { @@ -38,6 +40,11 @@ func configure() config { fingers[strings.ToLower(key[7:])] = val } + autoatom, err := strconv.ParseBool(os.Getenv("GEMINI_AUTOATOM")) + if err != nil { + autoatom = false + } + return config{ hostname: os.Getenv("HOST_NAME"), geminiRoot: os.Getenv("GEMINI_ROOT"), @@ -48,6 +55,8 @@ func configure() config { privilegedUsers: privileged, fingerResponses: fingers, + + geminiAutoAtom: autoatom, } } diff --git a/go.mod b/go.mod index cd0335b..2625ca9 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,9 @@ module tildegit.org/tjp/sr-71 go 1.19 -require tildegit.org/tjp/sliderule v1.0.1-0.20230509200833-d7ffcc43d12c +require tildegit.org/tjp/sliderule v1.2.0 require ( github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect + github.com/go-logfmt/logfmt v0.6.0 // indirect ) diff --git a/go.sum b/go.sum index 2e29525..d150099 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,12 @@ github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= +github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= tildegit.org/tjp/sliderule v1.0.1-0.20230509200833-d7ffcc43d12c h1:SNZW29TADL5Kl+ysr8mUg8GNf6ftKaaVEkp8gI6kHfc= tildegit.org/tjp/sliderule v1.0.1-0.20230509200833-d7ffcc43d12c/go.mod h1:opdo8E25iS9X9pNismM8U7pCH8XO0PdRIIhdADn8Uik= +tildegit.org/tjp/sliderule v1.2.0 h1:DsULRA+FTSoyMmA488rNfdYJa5iX8eUrSmlNSHKggfI= +tildegit.org/tjp/sliderule v1.2.0/go.mod h1:opdo8E25iS9X9pNismM8U7pCH8XO0PdRIIhdADn8Uik= diff --git a/routes.go b/routes.go index c4c9df0..9c330b6 100644 --- a/routes.go +++ b/routes.go @@ -15,6 +15,7 @@ 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/logging" ) @@ -55,7 +56,12 @@ func geminiRouter(conf config) sr.Handler { )), ) - return router.Handler() + h := router.Handler() + if conf.geminiAutoAtom { + h = gemtext.AutoAtom(h) + } + + return h } func gopherRouter(conf config) sr.Handler {