diff options
| author | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-16 00:55:25 +0100 |
|---|---|---|
| committer | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-16 00:55:25 +0100 |
| commit | 9bed6157351eea6fdbccff69aba5cc967a0b2a56 (patch) | |
| tree | e7b555078e7a4593f3e3456121dc8b04ae7b10a1 /template.go | |
| parent | Only enable max with if wrapping is enabled (diff) | |
| download | gopherproxy-9bed6157351eea6fdbccff69aba5cc967a0b2a56.tar.gz gopherproxy-9bed6157351eea6fdbccff69aba5cc967a0b2a56.tar.bz2 gopherproxy-9bed6157351eea6fdbccff69aba5cc967a0b2a56.zip | |
Initial Gemini support
Diffstat (limited to 'template.go')
| -rw-r--r-- | template.go | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/template.go b/template.go index 54aa53a..b7d1b1f 100644 --- a/template.go +++ b/template.go | |||
| @@ -27,6 +27,7 @@ var tpltext = `<!doctype html> | |||
| 27 | <body class="{{ if not .Lines }}is-plain{{ end }}"> | 27 | <body class="{{ if not .Lines }}is-plain{{ end }}"> |
| 28 | <header class="header header-base"> | 28 | <header class="header header-base"> |
| 29 | <div class="location"> | 29 | <div class="location"> |
| 30 | {{- $page := . -}} | ||
| 30 | {{- $href := "" -}} | 31 | {{- $href := "" -}} |
| 31 | {{- $uriParts := split .URI "/" -}} | 32 | {{- $uriParts := split .URI "/" -}} |
| 32 | {{- $uriLast := $uriParts | last -}} | 33 | {{- $uriLast := $uriParts | last -}} |
| @@ -35,35 +36,32 @@ var tpltext = `<!doctype html> | |||
| 35 | {{- $uriLast = $uriParts | last -}} | 36 | {{- $uriLast = $uriParts | last -}} |
| 36 | {{- $uriParts = $uriParts | pop -}} | 37 | {{- $uriParts = $uriParts | pop -}} |
| 37 | {{- end -}} | 38 | {{- end -}} |
| 38 | {{- if eq (len $uriParts) 1 -}} | ||
| 39 | {{- $uriLast = $uriParts | last -}} | ||
| 40 | {{- $uriParts = $uriParts | pop -}} | ||
| 41 | {{- end -}} | ||
| 42 | 39 | ||
| 43 | <button class="location__prefix">gopher://</button><button class="location__prefix location__prefix--mobile">://</button> | 40 | <a class="location__prefix">{{ .Protocol }}://</a><a class="location__prefix location__prefix--mobile">://</a> |
| 41 | {{- $href = printf "%s/%s" $href .Protocol -}} | ||
| 44 | {{- range $i, $part := $uriParts -}} | 42 | {{- range $i, $part := $uriParts -}} |
| 45 | {{- if ne $i 1 -}} | 43 | {{- if and (eq $page.Protocol "gopher") (eq $i 1) -}} |
| 46 | {{- $href = printf "%s/%s" $href . -}} | ||
| 47 | {{- if ne $i 0 -}} | ||
| 48 | <span class="location__slash">/</span> | ||
| 49 | {{- end -}} | ||
| 50 | <a href="{{ $href }}" class="location__uripart">{{ . }}</a> | ||
| 51 | {{- else -}} | ||
| 52 | {{- $href = printf "%s/1" $href -}} | 44 | {{- $href = printf "%s/1" $href -}} |
| 53 | {{- $part = $part | trimLeftChar -}} | 45 | {{- $part = $part | trimLeftChar -}} |
| 54 | {{- if not (eq $part "") -}} | 46 | {{- if not (eq $part "") -}} |
| 55 | {{- $href = printf "%s/%s" $href $part -}} | 47 | {{- $href = printf "%s/%s" $href $part -}} |
| 56 | <span class="location__slash">/</span><a href="{{ $href }}" class="location__uripart">{{ $part }}</a> | 48 | <span class="location__slash">/</span><a href="{{ $href }}/" class="location__uripart">{{ $part }}</a> |
| 49 | {{- end -}} | ||
| 50 | {{- else -}} | ||
| 51 | {{- $href = printf "%s/%s" $href . -}} | ||
| 52 | {{- if ne $i 0 -}} | ||
| 53 | <span class="location__slash">/</span> | ||
| 57 | {{- end -}} | 54 | {{- end -}} |
| 55 | <a href="{{ $href }}/" class="location__uripart">{{ . }}</a> | ||
| 58 | {{- end -}} | 56 | {{- end -}} |
| 59 | {{- end -}} | 57 | {{- end -}} |
| 60 | {{- if ne (len $uriParts) 0 -}} | 58 | {{- if ne (len $uriParts) 0 -}} |
| 61 | <span class="location__slash">/</span> | 59 | <span class="location__slash">/</span> |
| 62 | {{- end -}} | 60 | {{- end -}} |
| 63 | <span class="location__uripart">{{ $uriLast -}}</span> | 61 | <span class="location__uripart">{{ $uriLast }}</span> |
| 64 | </div> | 62 | </div> |
| 65 | <div class="actions"> | 63 | <div class="actions"> |
| 66 | {{- if and (not .Lines) (not .Error) -}} | 64 | {{- if and (not .Lines) (not .Error) (eq .Protocol "gopher") -}} |
| 67 | <div class="action"><a href="/{{ .URI | replace "^(.*?)/0" "$1/9" }}">View raw</a></div> | 65 | <div class="action"><a href="/{{ .URI | replace "^(.*?)/0" "$1/9" }}">View raw</a></div> |
| 68 | {{- end -}} | 66 | {{- end -}} |
| 69 | <div class="action"><button class="settings-btn">Settings</button></div> | 67 | <div class="action"><button class="settings-btn">Settings</button></div> |
