From ac770231436f8a17d348a6a0ab934429df3c57d0 Mon Sep 17 00:00:00 2001 From: Feuerfuchs Date: Mon, 18 May 2020 16:12:43 +0200 Subject: WIP: Refactoring --- internal/port/tpl/_header.html | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 internal/port/tpl/_header.html (limited to 'internal/port/tpl/_header.html') diff --git a/internal/port/tpl/_header.html b/internal/port/tpl/_header.html new file mode 100644 index 0000000..5bcd254 --- /dev/null +++ b/internal/port/tpl/_header.html @@ -0,0 +1,48 @@ +
+
+ {{ .Protocol }}://:// + + {{- if .URL -}} + {{- $page := . -}} + {{- $href := printf "/%s" .Protocol -}} + {{- $uriParts := split .URL "/" -}} + + {{- $uriLast := $uriParts | last -}} + {{- $uriParts = $uriParts | pop -}} + {{- if eq $uriLast "" -}} + {{- $uriLast = $uriParts | last -}} + {{- $uriParts = $uriParts | pop -}} + {{- end -}} + + {{- range $i, $part := $uriParts -}} + {{- if and (eq $page.Protocol "gopher") (eq $i 1) -}} + {{- $href = printf "%s/1" $href -}} + {{- $part = $part | trimLeftChar -}} + {{- if not (eq $part "") -}} + {{- $href = printf "%s/%s" $href $part -}} + /{{ $part }} + {{- end -}} + {{- else -}} + {{- $href = printf "%s/%s" $href . -}} + {{- if ne $i 0 -}} + / + {{- end -}} + {{ . }} + {{- end -}} + {{- end -}} + {{- if ne (len $uriParts) 0 -}} + / + {{- end -}} + {{- if and (eq $page.Protocol "gopher") (eq (len $uriParts) 1) -}} + {{- $uriLast = $uriLast | trimLeftChar -}} + {{- end -}} + {{ $uriLast }} + {{- end -}} +
+
+ {{- if and (not .Lines) (not .Error) (eq .Protocol "gopher") -}} + + {{- end -}} +
+
+
-- cgit v1.2.3-70-g09d2