summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2023-01-21 19:41:40 +0100
committerBrian Picciano <mediocregopher@gmail.com>2023-01-21 19:41:40 +0100
commitf536b16e170a5efb5b3bdd720e48100d5d0f83ba (patch)
tree1f87f86b6b2d730b448569ad63bcd0f67f710312
parent0d420f70d89281320d95e92db01b240a40c6e2f7 (diff)
Add wtfpl.txt to gemini
-rw-r--r--src/gmi/tpl.go8
-rw-r--r--src/gmi/tpl/wtfpl.txt14
2 files changed, 22 insertions, 0 deletions
diff --git a/src/gmi/tpl.go b/src/gmi/tpl.go
index 8220a49..e448afd 100644
--- a/src/gmi/tpl.go
+++ b/src/gmi/tpl.go
@@ -7,7 +7,9 @@ import (
"fmt"
"io"
"io/fs"
+ "mime"
"net/url"
+ "path"
"path/filepath"
"strconv"
"strings"
@@ -194,10 +196,12 @@ func (a *api) tplHandler() (gemini.Handler, error) {
) {
tplPath := strings.TrimPrefix(r.URL.Path, "/")
+ mimeType := mime.TypeByExtension(path.Ext(r.URL.Path))
ctx = mctx.Annotate(ctx,
"url", r.URL,
"tplPath", tplPath,
+ "mimeType", mimeType,
)
tpl := allTpls.Lookup(tplPath)
@@ -207,6 +211,10 @@ func (a *api) tplHandler() (gemini.Handler, error) {
return
}
+ if mimeType != "" {
+ rw.SetMediaType(mimeType)
+ }
+
buf := new(bytes.Buffer)
err := tpl.Execute(buf, renderer{
diff --git a/src/gmi/tpl/wtfpl.txt b/src/gmi/tpl/wtfpl.txt
new file mode 100644
index 0000000..ee7d6a5
--- /dev/null
+++ b/src/gmi/tpl/wtfpl.txt
@@ -0,0 +1,14 @@
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ Version 2, December 2004
+
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+
+ Everyone is permitted to copy and distribute verbatim or modified
+ copies of this license document, and changing it is allowed as long
+ as the name is changed.
+
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
+