tagpic

posix tagging gallery
git clone git://kloet.net/tagpic
Download | Log | Files | Refs | LICENSE

commit d0666f6f822608c8339a9f94835b254c29ac8d7a
parent 679e87d4fc5b55d8fa9c5a418e86bc153bc2c2fc
Author: Andrew Kloet <andrew@kloet.net>
Date:   Thu, 17 Sep 2026 15:00:53 -0400

tagpicd: xhtml

Diffstat:
Mtagpicd.go | 36+++++++++++++++++++++++-------------
1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/tagpicd.go b/tagpicd.go @@ -34,22 +34,30 @@ var ( port string ) -var tmpl = template.Must(template.New("").Parse(`<!DOCTYPE html> -<html> -<head><style>body{font-family:monospace;max-width:700px;margin:auto;padding:1em}img{max-width:100%;height:auto}</style></head> +var tmpl = template.Must(template.New("").Parse(`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> +<head> +<title>tagpic</title> +<style type="text/css"> + body{font-family:monospace;max-width:700px;margin:auto;padding:1em} + img{max-width:100%;height:auto} +</style> +</head> <body> <h3>/{{.Tag}}/</h3> <p>{{range .Tags}}<a href="/{{.}}/">{{.}}</a> {{end}}</p> -<hr> -{{range .Imgs}} +<hr/> +{{range .Imgs -}} <div> - <small>{{.Date}} | {{range .Tags}}<a href="/{{.}}/">{{.}}</a> {{end}}</small><br> - <a href="{{.URL}}" target="_blank"><img src="{{.URL}}"></a> -</div><br> -{{else}}<p>No images.</p>{{end}} -<hr> -{{if gt .Prev 0}}<a href="?page={{.Prev}}">prev</a>{{end}} -{{if .Next}}<a href="?page={{.Next}}">next</a>{{end}} + <small>{{.Date}} | {{range .Tags}}<a href="/{{.}}/">{{.}}</a> {{end}}</small> + <a href="{{.URL}}"><img src="{{.URL}}" alt="" /></a> +</div> +{{else}}<p>No images.</p>{{- end -}} +<hr/> +<div> +{{if gt .Prev 0}}<a href="?page={{.Prev}}">prev</a>{{end -}} +{{- if .Next}}<a href="?page={{.Next}}">next</a>{{end}} +</div> </body></html>`)) func main() { @@ -57,7 +65,7 @@ func main() { flag.Parse() port = *portFlag - /* $TAGPIC_IMGDIR -> $HOME/imgdir -> ./imgdir */ + /* $TAGPIC_IMGDIR ->$HOME/imgdir -> ./imgdir */ imgDir = os.Getenv("TAGPIC_IMGDIR") if imgDir == "" { if home, err := os.UserHomeDir(); err == nil { @@ -146,6 +154,8 @@ func gallery(w http.ResponseWriter, r *http.Request) { next = page + 1 } + // xhtml is the reasonable choice + w.Header().Set("Content-Type", "application/xhtml+xml; charset=utf-8") tmpl.Execute(w, map[string]any{ "Tag": tag, "Tags": tags,