From 11c4467caa10cfb51767e1dfd6dedc1ca14d3eda Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Tue, 3 Nov 2020 18:00:03 +0100 Subject: [PATCH] Add old content warning --- render.go | 22 ++++++++++++++++++++-- templates/header.gohtml | 2 +- templates/oldcontentwarning.gohtml | 7 +++++++ templates/post.gohtml | 3 ++- templates/postmeta.gohtml | 4 ++-- templates/posttax.gohtml | 2 +- templates/strings/de.yaml | 3 ++- templates/strings/default.yaml | 3 ++- templates/taxonomy.gohtml | 2 +- 9 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 templates/oldcontentwarning.gohtml diff --git a/render.go b/render.go index 852a695..9dd0b4e 100644 --- a/render.go +++ b/render.go @@ -82,7 +82,7 @@ func initRendering() error { } return d.Format(format) }, - "longDate": func(date string, localeString string) string { + "longdate": func(date string, localeString string) string { d, err := dateparse.ParseIn(date, time.Local) if err != nil { return "" @@ -93,6 +93,24 @@ func initRendering() error { "now": func() string { return time.Now().String() }, + "dateadd": func(date string, years, months, days int) string { + d, err := dateparse.ParseIn(date, time.Local) + if err != nil { + return "" + } + return d.AddDate(years, months, days).String() + }, + "datebefore": func(date string, before string) bool { + d, err := dateparse.ParseIn(date, time.Local) + if err != nil { + return false + } + b, err := dateparse.ParseIn(before, time.Local) + if err != nil { + return false + } + return d.Before(b) + }, "asset": assetFile, "string": getTemplateStringVariant, "include": func(templateName string, data ...interface{}) (template.HTML, error) { @@ -145,7 +163,7 @@ func initRendering() error { "absolute": func(path string) string { return appConfig.Server.PublicAddress + path }, - "blogRelative": func(blog *configBlog, path string) string { + "blogrelative": func(blog *configBlog, path string) string { return blog.getRelativePath(path) }, "jsonFile": func(filename string) *map[string]interface{} { diff --git a/templates/header.gohtml b/templates/header.gohtml index 2a1e1b4..8757b13 100644 --- a/templates/header.gohtml +++ b/templates/header.gohtml @@ -1,6 +1,6 @@ {{ define "header" }}
-

{{ .Blog.Title }}

+

{{ .Blog.Title }}

{{ with .Blog.Description }}

{{ . }}

{{ end }}