From 9bed6157351eea6fdbccff69aba5cc967a0b2a56 Mon Sep 17 00:00:00 2001 From: Feuerfuchs Date: Sat, 16 Nov 2019 00:55:25 +0100 Subject: Initial Gemini support --- template.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'template.go') diff --git a/template.go b/template.go index 54aa53a..b7d1b1f 100644 --- a/template.go +++ b/template.go @@ -27,6 +27,7 @@ var tpltext = `
+ {{- $page := . -}} {{- $href := "" -}} {{- $uriParts := split .URI "/" -}} {{- $uriLast := $uriParts | last -}} @@ -35,35 +36,32 @@ var tpltext = ` {{- $uriLast = $uriParts | last -}} {{- $uriParts = $uriParts | pop -}} {{- end -}} - {{- if eq (len $uriParts) 1 -}} - {{- $uriLast = $uriParts | last -}} - {{- $uriParts = $uriParts | pop -}} - {{- end -}} - + {{ .Protocol }}://:// + {{- $href = printf "%s/%s" $href .Protocol -}} {{- range $i, $part := $uriParts -}} - {{- if ne $i 1 -}} - {{- $href = printf "%s/%s" $href . -}} - {{- if ne $i 0 -}} - / - {{- end -}} - {{ . }} - {{- else -}} + {{- 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 }} + /{{ $part }} + {{- end -}} + {{- else -}} + {{- $href = printf "%s/%s" $href . -}} + {{- if ne $i 0 -}} + / {{- end -}} + {{ . }} {{- end -}} {{- end -}} {{- if ne (len $uriParts) 0 -}} / {{- end -}} - {{ $uriLast -}} + {{ $uriLast }}
- {{- if and (not .Lines) (not .Error) -}} + {{- if and (not .Lines) (not .Error) (eq .Protocol "gopher") -}} {{- end -}}
-- cgit v1.2.3-54-g00ecf