Browse Source

Improvements for short urls

master
Jan-Lukas Else 1 month ago
parent
commit
34807582dd
7 changed files with 25 additions and 13 deletions
  1. +1
    -1
      shortPath.go
  2. +3
    -9
      templates/postmeta.gohtml
  3. +2
    -1
      templates/strings/de.yaml
  4. +2
    -1
      templates/strings/default.yaml
  5. +1
    -1
      templates/summary.gohtml
  6. +11
    -0
      templates/summaryandpostmeta.gohtml
  7. +5
    -0
      templates/summarymeta.gohtml

+ 1
- 1
shortPath.go View File

@ -60,5 +60,5 @@ func redirectToLongPath(rw http.ResponseWriter, r *http.Request) {
serve404(rw, r)
return
}
http.Redirect(rw, r, path, http.StatusFound)
http.Redirect(rw, r, path, http.StatusMovedPermanently)
}

+ 3
- 9
templates/postmeta.gohtml View File

@ -1,17 +1,11 @@
{{ 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 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 }}
{{ if p .Data "likelink" }}
<div>{{ string .Blog.Lang "likeof" }}: <a class="u-like-of" href="{{ p .Data "likelink" }}" target="_blank" rel="noopener">{{ p .Data "liketitle" | default (p .Data "likelink") }}</a></div>
{{ end }}
{{ include "summaryandpostmeta" . }}
{{ $translations := (translations .Data) }}
{{ if gt (len $translations) 0 }}
<div>{{ string .Blog.Lang "translations" }}: {{ $delimiter := "" }}{{ range $i, $t := $translations }}{{ $delimiter }}<a href="{{ $t.Path }}">{{ title $t }}</a>{{ $delimiter = ", " }}{{ end }}</div>
{{ end }}
{{ $short := shorturl .Data }}
{{ if $short }}<div>{{ string .Blog.Lang "shorturl" }} <a href="{{ $short }}" rel="shortlink">{{ $short }}</a></div>{{ end }}
</div>
{{ end }}

+ 2
- 1
templates/strings/de.yaml View File

@ -10,4 +10,5 @@ share: "Teilen"
speak: "Lies mir bitte vor."
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."
search: "Suchen"
search: "Suchen"
shorturl: "Kurz-URL:"

+ 2
- 1
templates/strings/default.yaml View File

@ -29,4 +29,5 @@ update: "Update"
upload: "Upload"
login: "Login"
username: "Username"
password: "Password"
password: "Password"
shorturl: "Short URL:"

+ 1
- 1
templates/summary.gohtml View File

@ -7,7 +7,7 @@
</a>
</h2>
{{ end }}
{{ include "postmeta" . }}
{{ include "summarymeta" . }}
<p class="p-summary">{{ summary .Data }}</p>
<p>{{ if (hasp .Data "images") }}🖼️ {{ end }}<a class="u-url" href="{{ .Data.Path }}">{{ string .Blog.Lang "view" }}</a></p>
</article>

+ 11
- 0
templates/summaryandpostmeta.gohtml View File

@ -0,0 +1,11 @@
{{ define "summaryandpostmeta" }}
{{ $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 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 }}
{{ if p .Data "likelink" }}
<div>{{ string .Blog.Lang "likeof" }}: <a class="u-like-of" href="{{ p .Data "likelink" }}" target="_blank" rel="noopener">{{ p .Data "liketitle" | default (p .Data "likelink") }}</a></div>
{{ end }}
{{ end }}

+ 5
- 0
templates/summarymeta.gohtml View File

@ -0,0 +1,5 @@
{{ define "summarymeta" }}
<div class="p">
{{ include "summaryandpostmeta" . }}
</div>
{{ end }}

Loading…
Cancel
Save