summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/http/tpl.go18
-rw-r--r--src/http/tpl/base.html5
-rw-r--r--src/http/tpl/gemini-cta.html2
-rw-r--r--src/http/tpl/post.html2
-rw-r--r--src/render/methods.go4
5 files changed, 10 insertions, 21 deletions
diff --git a/src/http/tpl.go b/src/http/tpl.go
index afd4c8e..2711259 100644
--- a/src/http/tpl.go
+++ b/src/http/tpl.go
@@ -12,7 +12,6 @@ import (
"net/url"
"path/filepath"
"strings"
- "time"
"dev.mediocregopher.com/mediocre-blog.git/src/http/apiutil"
"dev.mediocregopher.com/mediocre-blog.git/src/post"
@@ -93,27 +92,14 @@ func (a *api) draftsURL(abs bool) string {
func (a *api) tplFuncs() template.FuncMap {
return template.FuncMap{
- "StaticInlineCSS": func(path string) (template.CSS, error) {
- path = filepath.Join("static", path)
- b, err := staticFS.ReadFile(path)
- return template.CSS(b), err
- },
- "DraftURL": func(id string) string {
- return a.draftPostURL(id, false)
- },
- "DateTimeFormat": func(t time.Time) string {
- return t.Format("2006-01-02")
- },
- "SafeURL": func(u string) template.URL {
- return template.URL(u)
- },
+ "DraftURL": func(id string) string { return a.draftPostURL(id, false) },
}
}
func (a *api) emptyTpl() *template.Template {
tpl := template.New("")
tpl = tpl.Funcs(a.tplFuncs())
- tpl = tpl.Funcs(template.FuncMap(a.postPreprocessFuncs().ToFuncMap()))
+ tpl = tpl.Funcs(a.postPreprocessFuncs().ToFuncMap())
return tpl
}
diff --git a/src/http/tpl/base.html b/src/http/tpl/base.html
index 7e7a4a9..47644f7 100644
--- a/src/http/tpl/base.html
+++ b/src/http/tpl/base.html
@@ -3,9 +3,8 @@
<head>
<title>{{ .Title }}</title>
- <style>{{ StaticInlineCSS "new.css" }}</style>
- <style>{{ StaticInlineCSS "mediocre.css" }}</style>
-
+ <link rel="stylesheet" type="text/css" href="{{ StaticURL "new.css" }}" />
+ <link rel="stylesheet" type="text/css" href="{{ StaticURL "mediocre.css" }}" />
<link rel="apple-touch-icon" sizes="180x180" href="{{ StaticURL "favicon/apple-touch-icon.png" }}">
<link rel="icon" type="image/png" sizes="32x32" href="{{ StaticURL "favicon/favicon-32x32.png" }}">
<link rel="icon" type="image/png" sizes="16x16" href="{{ StaticURL "favicon/favicon-16x16.png" }}">
diff --git a/src/http/tpl/gemini-cta.html b/src/http/tpl/gemini-cta.html
index 06e3a22..89b8e8b 100644
--- a/src/http/tpl/gemini-cta.html
+++ b/src/http/tpl/gemini-cta.html
@@ -2,7 +2,7 @@
<p>
This site can also be accessed via the gemini protocol:
- <a href="{{ BlogGeminiURL "/" | SafeURL }}">
+ <a href="{{ BlogGeminiURL "/" | .URLIsSafe }}">
{{ BlogGeminiURL "/" }}
</a>
</p>
diff --git a/src/http/tpl/post.html b/src/http/tpl/post.html
index 0cf3622..46a24fc 100644
--- a/src/http/tpl/post.html
+++ b/src/http/tpl/post.html
@@ -16,7 +16,7 @@
{{ .PostHTMLBody $post }}
<p><em>
- Published {{ DateTimeFormat $post.PublishedAt }}
+ Published {{ $post.PublishedAt.Format "2006-01-02" }}
</em></p>
{{- if $post.Series }}
diff --git a/src/render/methods.go b/src/render/methods.go
index 5b2c0b1..9b5a41e 100644
--- a/src/render/methods.go
+++ b/src/render/methods.go
@@ -263,3 +263,7 @@ func (m *Methods) GetPath() (string, error) {
}
func (m *Methods) Add(a, b int) int { return a + b }
+
+func (m *Methods) URLIsSafe(s string) template.URL {
+ return template.URL(s)
+}