mirror of https://github.com/jlelse/GoBlog
Add old content warning
This commit is contained in:
parent
f300c3d498
commit
11c4467caa
22
render.go
22
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{} {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{ define "header" }}
|
||||
<header>
|
||||
<h1><a href="{{ blogRelative .Blog "/" }}" rel="home" title="{{ .Blog.Title }}">{{ .Blog.Title }}</a></h1>
|
||||
<h1><a href="{{ blogrelative .Blog "/" }}" rel="home" title="{{ .Blog.Title }}">{{ .Blog.Title }}</a></h1>
|
||||
{{ with .Blog.Description }}<p><i>{{ . }}</i></p>{{ end }}
|
||||
<nav>
|
||||
{{ with menu .Blog "main" }}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{{ define "oldcontentwarning" }}
|
||||
{{ if .Data.Published }}
|
||||
{{ if (datebefore (dateadd .Data.Published 1 0 0) now) }}
|
||||
<strong class="p border-top border-bottom">{{ string .Blog.Lang "oldcontent" }}</strong>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
|
@ -11,9 +11,10 @@
|
|||
{{ include "postmeta" . }}
|
||||
{{ include "postactions" . }}
|
||||
{{ if .Data.Content }}
|
||||
{{ include "oldcontentwarning" . }}
|
||||
<div class=e-content>
|
||||
{{ with p .Data "audio" }}
|
||||
<audio controls preload="metadata" class="fw"><source src="{{ . }}"/></audio>
|
||||
<audio controls preload="none" class="fw"><source src="{{ . }}"/></audio>
|
||||
{{ end }}
|
||||
{{ content .Data }}
|
||||
{{ with p .Data "link" }}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{{ define "postmeta" }}
|
||||
<div class="p">
|
||||
{{ $section := (index .Blog.Sections .Data.Section) }}
|
||||
{{ if .Data.Published }}<div>{{ string .Blog.Lang "publishedon" }} <time class="dt-published" datetime="{{ dateformat .Data.Published "2006-01-02T15:04:05Z07:00"}}">{{ longDate .Data.Published .Blog.TimeLang }}</time>{{ if $section }} in <a href="{{ blogRelative .Blog $section.Name }}">{{ $section.Title }}</a>{{ end }}</div>{{ end }}
|
||||
{{ if .Data.Updated }}<div>{{ string .Blog.Lang "updatedon" }} <time class="dt-updated" datetime="{{ dateformat .Data.Updated "2006-01-02T15:04:05Z07:00"}}">{{ longDate .Data.Updated .Blog.TimeLang }}</time></div>{{ end }}
|
||||
{{ if .Data.Published }}<div>{{ string .Blog.Lang "publishedon" }} <time class="dt-published" datetime="{{ dateformat .Data.Published "2006-01-02T15:04:05Z07:00"}}">{{ longdate .Data.Published .Blog.TimeLang }}</time>{{ if $section }} in <a href="{{ blogrelative .Blog $section.Name }}">{{ $section.Title }}</a>{{ end }}</div>{{ end }}
|
||||
{{ if .Data.Updated }}<div>{{ string .Blog.Lang "updatedon" }} <time class="dt-updated" datetime="{{ dateformat .Data.Updated "2006-01-02T15:04:05Z07:00"}}">{{ longdate .Data.Updated .Blog.TimeLang }}</time></div>{{ end }}
|
||||
{{ if p .Data "replylink" }}
|
||||
<div>{{ string .Blog.Lang "replyto" }}: <a class="u-in-reply-to" href="{{ p .Data "replylink" }}" target="_blank" rel="noopener">{{ p .Data "replytitle" | default (p .Data "replylink") }}</a></div>
|
||||
{{ end }}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
{{ if gt (len $tvs) 0 }}
|
||||
<p><b>{{ $tax.Title }}</b>:
|
||||
{{ range $j, $tv := $tvs }}
|
||||
<a class="p-category" rel="tag" href="{{ blogRelative $blog ( printf "/%s/%s" $tax.Name (urlize $tv) ) }}">{{ $tv }}</a>
|
||||
<a class="p-category" rel="tag" href="{{ blogrelative $blog ( printf "/%s/%s" $tax.Name (urlize $tv) ) }}">{{ $tv }}</a>
|
||||
{{ end }}
|
||||
</p>
|
||||
{{ end }}
|
||||
|
|
|
@ -8,4 +8,5 @@ likeof: "Gefällt mir von"
|
|||
translations: "Übersetzungen"
|
||||
share: "Teilen"
|
||||
speak: "Lies mir bitte vor."
|
||||
stopspeak: "Hör auf zu sprechen!"
|
||||
stopspeak: "Hör auf zu sprechen!"
|
||||
oldcontent: "⚠️ Dieser Eintrag ist bereits über ein Jahr alt. Er ist möglicherweise nicht mehr aktuell. Meinungen können sich geändert haben."
|
|
@ -11,4 +11,5 @@ likeof: "Like of"
|
|||
translations: "Translations"
|
||||
share: "Share"
|
||||
speak: "Read to me, please."
|
||||
stopspeak: "Stop speaking!"
|
||||
stopspeak: "Stop speaking!"
|
||||
oldcontent: "⚠️ This entry is already over one year old. It may no longer be up to date. Opinions may have changed."
|
|
@ -10,7 +10,7 @@
|
|||
{{ $blog := .Blog }}
|
||||
{{ $taxonomy := .Data.Taxonomy.Name }}
|
||||
{{ range $i, $value := (sort .Data.TaxonomyValues) }}
|
||||
<li><a href="{{ blogRelative $blog ( printf "/%s/%s" $taxonomy (urlize .) ) }}">{{ . }}</a></li>
|
||||
<li><a href="{{ blogrelative $blog ( printf "/%s/%s" $taxonomy (urlize .) ) }}">{{ . }}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</main>
|
||||
|
|
Loading…
Reference in New Issue