flounder

A simple gemini site builder
git clone git://git.alexwennerberg.com/flounder
Log | Files | Refs | README | LICENSE

commit 50f460905fae3f14da3bfef2043e6239e9854047
parent 64f9da6778b41e22f6d231c9616e0696b06dc00a
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat,  1 Oct 2022 12:25:12 -0700

add inline images

Diffstat:
Mgmi2html.go | 9++++++++-
Mhttp.go | 3++-
Mtemplates/index.html | 1+
3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/gmi2html.go b/gmi2html.go @@ -4,7 +4,9 @@ import ( "fmt" "html" "net/url" + "path/filepath" "strings" + "mime" "git.sr.ht/~adnano/go-gemini" ) @@ -67,7 +69,12 @@ func textToHTML(reqUrl *url.URL, text gemini.Text) ConvertedGmiDoc { if name == "" { name = urlstring } - fmt.Fprintf(&b, "<p><a href='%s'>%s</a></p>\n", urlstring, name) + // embed images + if strings.HasPrefix(mime.TypeByExtension(filepath.Ext(u.Path)), "image") { + fmt.Fprintf(&b, "<p><img src='%s' alt='%s'></p>\n", urlstring, name) + } else { + fmt.Fprintf(&b, "<p><a href='%s'>%s</a></p>\n", urlstring, name) + } case gemini.LinePreformattingToggle: pre = !pre if pre { diff --git a/http.go b/http.go @@ -78,7 +78,8 @@ func rootHandler(w http.ResponseWriter, r *http.Request) { AuthUser AuthUser Files []*File Users []string - }{c, user, indexFiles, allUsers} + IsZoe bool + }{c, user, indexFiles, allUsers, user.Username == "zoe"} err = t.ExecuteTemplate(w, "index.html", data) if err != nil { serverError(w, err) diff --git a/templates/index.html b/templates/index.html @@ -1,5 +1,6 @@ {{template "header" .}} <h1>🐟{{.Config.SiteTitle}}!</h1> +{{ if .IsZoe }} <p><i>hi zoe hope you have a good day :) ✨</i></p> {{ end }} {{template "nav.html" .}} <br> <p>