diff options
Diffstat (limited to 'src/http')
-rw-r--r-- | src/http/http.go | 2 | ||||
-rw-r--r-- | src/http/posts.go | 19 | ||||
-rw-r--r-- | src/http/tpl.go | 15 |
3 files changed, 2 insertions, 34 deletions
diff --git a/src/http/http.go b/src/http/http.go index 93cc043..6458416 100644 --- a/src/http/http.go +++ b/src/http/http.go @@ -149,7 +149,7 @@ func New(params Params) (API, error) { auther: NewAuther(params.AuthUsers, params.AuthRatelimit), } - a.redirectTpl = mustParseTpl(a.emptyTpl(), "redirect.html") + a.redirectTpl = mustParseTpl(template.New(""), "redirect.html") a.srv = &http.Server{Handler: a.handler()} diff --git a/src/http/posts.go b/src/http/posts.go index 42e5b4a..daaaafc 100644 --- a/src/http/posts.go +++ b/src/http/posts.go @@ -65,25 +65,6 @@ func (a *api) postPreprocessFuncImage(args ...string) (string, error) { func (a *api) postPreprocessFuncs() post.PreprocessFunctions { return post.PreprocessFunctions{ - BlogURL: func(path string) string { - return a.blogURL(a.params.PublicURL, path, false) - }, - BlogHTTPURL: func(path string) string { - return a.blogURL(a.params.PublicURL, path, true) - }, - BlogGeminiURL: func(path string) string { - return a.blogURL(a.params.GeminiPublicURL, path, true) - }, - AssetURL: func(id string) string { - return a.assetURL(id, false) - }, - PostURL: func(id string) string { - return a.postURL(id, false) - }, - StaticURL: func(path string) string { - path = filepath.Join("static", path) - return a.blogURL(a.params.PublicURL, path, false) - }, Image: a.postPreprocessFuncImage, } } diff --git a/src/http/tpl.go b/src/http/tpl.go index c4afbdc..57d7cfd 100644 --- a/src/http/tpl.go +++ b/src/http/tpl.go @@ -90,25 +90,12 @@ func (a *api) draftsURL(abs bool) string { return a.blogURL(a.params.PublicURL, "drafts", abs) } -func (a *api) tplFuncs() template.FuncMap { - return template.FuncMap{ - "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(a.postPreprocessFuncs().ToFuncMap()) - return tpl -} - func mustParseTpl(tpl *template.Template, name string) *template.Template { return template.Must(tpl.New(name).Parse(mustReadTplFile(name))) } func (a *api) mustParseBasedTpl(name string) *template.Template { - tpl := a.emptyTpl() + tpl := template.New("") tpl = mustParseTpl(tpl, "gemini-cta.html") tpl = mustParseTpl(tpl, "base.html") tpl = mustParseTpl(tpl, name) |