diff options
author | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-26 13:13:02 +0100 |
---|---|---|
committer | Feuerfuchs <git@feuerfuchs.dev> | 2019-11-26 13:13:02 +0100 |
commit | 93115f804220c31c2aa10f123560fb11135f06d8 (patch) | |
tree | a3c12f68c4263f3e34b1e03f12e7962aab9cfbf5 /template.go | |
parent | Fix title on startpage (diff) | |
download | gopherproxy-93115f804220c31c2aa10f123560fb11135f06d8.tar.gz gopherproxy-93115f804220c31c2aa10f123560fb11135f06d8.tar.bz2 gopherproxy-93115f804220c31c2aa10f123560fb11135f06d8.zip |
Add IPv6 support, general restructuring
Diffstat (limited to 'template.go')
-rw-r--r-- | template.go | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/template.go b/template.go deleted file mode 100644 index 6b90cc0..0000000 --- a/template.go +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | package gopherproxy | ||
2 | |||
3 | var tpltext = `<!doctype html> | ||
4 | <html> | ||
5 | <head> | ||
6 | <meta charset="utf-8"> | ||
7 | <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
8 | <title>{{ .Title }}{{ if ne .Protocol "startpage" }} - {{ .Protocol | title }} proxy{{ end }}</title> | ||
9 | <link rel="stylesheet" href="{{ .Assets.Style }}" /> | ||
10 | <style> | ||
11 | @font-face { | ||
12 | font-family: 'Iosevka Term SS03'; | ||
13 | font-style: normal; | ||
14 | font-weight: normal; | ||
15 | src: url('{{ .Assets.FontW2 }}') format('woff2'), | ||
16 | url('{{ .Assets.FontW }}') format('woff'); | ||
17 | } | ||
18 | @font-face { | ||
19 | font-family: 'Iosevka Aile'; | ||
20 | font-style: normal; | ||
21 | font-weight: normal; | ||
22 | src: url('{{ .Assets.PropFontW2 }}') format('woff2'), | ||
23 | url('{{ .Assets.PropFontW }}') format('woff'); | ||
24 | } | ||
25 | </style> | ||
26 | </head> | ||
27 | <body class="{{ if not .Lines }}is-plain{{ end }}"> | ||
28 | <header class="header header-base"> | ||
29 | <div class="location"> | ||
30 | <a class="location__prefix">{{ .Protocol }}://</a><a class="location__prefix location__prefix--mobile">://</a> | ||
31 | |||
32 | {{- if .URI -}} | ||
33 | {{- $page := . -}} | ||
34 | {{- $href := printf "/%s" .Protocol -}} | ||
35 | {{- $uriParts := split .URI "/" -}} | ||
36 | |||
37 | {{- $uriLast := $uriParts | last -}} | ||
38 | {{- $uriParts = $uriParts | pop -}} | ||
39 | {{- if eq $uriLast "" -}} | ||
40 | {{- $uriLast = $uriParts | last -}} | ||
41 | {{- $uriParts = $uriParts | pop -}} | ||
42 | {{- end -}} | ||
43 | |||
44 | {{- range $i, $part := $uriParts -}} | ||
45 | {{- if and (eq $page.Protocol "gopher") (eq $i 1) -}} | ||
46 | {{- $href = printf "%s/1" $href -}} | ||
47 | {{- $part = $part | trimLeftChar -}} | ||
48 | {{- if not (eq $part "") -}} | ||
49 | {{- $href = printf "%s/%s" $href $part -}} | ||
50 | <span class="location__slash">/</span><a href="{{ $href }}/" class="location__uripart">{{ $part }}</a> | ||
51 | {{- end -}} | ||
52 | {{- else -}} | ||
53 | {{- $href = printf "%s/%s" $href . -}} | ||
54 | {{- if ne $i 0 -}} | ||
55 | <span class="location__slash">/</span> | ||
56 | {{- end -}} | ||
57 | <a href="{{ $href }}/" class="location__uripart">{{ . }}</a> | ||
58 | {{- end -}} | ||
59 | {{- end -}} | ||
60 | {{- if ne (len $uriParts) 0 -}} | ||
61 | <span class="location__slash">/</span> | ||
62 | {{- end -}} | ||
63 | {{- if and (eq $page.Protocol "gopher") (eq (len $uriParts) 1) -}} | ||
64 | {{- $uriLast = $uriLast | trimLeftChar -}} | ||
65 | {{- end -}} | ||
66 | <span class="location__uripart">{{ $uriLast }}</span> | ||
67 | {{- end -}} | ||
68 | </div> | ||
69 | <div class="actions"> | ||
70 | {{- if and (not .Lines) (not .Error) (eq .Protocol "gopher") -}} | ||
71 | <div class="action"><a href="/gopher/{{ .URI | replace "^([^/]*)/0" "$1/9" }}">View raw</a></div> | ||
72 | {{- end -}} | ||
73 | <div class="action"><button class="settings-btn">Settings</button></div> | ||
74 | </div> | ||
75 | </header> | ||
76 | <main class="wrap"> | ||
77 | <pre class="content content--has-monospace-font{{ if .Lines }} content--has-type-annotations{{ end }}"> | ||
78 | {{- if .Lines -}} | ||
79 | {{- $content := "" -}} | ||
80 | {{- range .Lines -}} | ||
81 | {{- if ne $content "" -}} | ||
82 | {{- $content = printf "%s\n" $content -}} | ||
83 | {{- end -}} | ||
84 | {{- if .Link -}} | ||
85 | {{- $content = printf "%s%s" $content (printf "<span class=\"type-annotation\">%s </span><a class=\"link link--%s\" href=\"%s\">%s</a>" .Type .Type .Link (.Text | HTMLEscape)) -}} | ||
86 | {{- else -}} | ||
87 | {{- $content = printf "%s%s" $content (printf "<span class=\"type-annotation\"> </span>%s" (.Text | HTMLEscape)) -}} | ||
88 | {{- end -}} | ||
89 | {{- end -}} | ||
90 | {{- $content | safeHtml -}} | ||
91 | {{- else -}} | ||
92 | {{- .RawText -}} | ||
93 | {{- end -}} | ||
94 | </pre> | ||
95 | </main> | ||
96 | <aside class="modal modal--settings"> | ||
97 | <div class="modal__content"> | ||
98 | <header class="modal__head header-base"> | ||
99 | <h1 class="modal__title">Settings</h1> | ||
100 | <button class="modal__close-btn">Close</button> | ||
101 | </header> | ||
102 | <div class="setting setting--word-wrap"> | ||
103 | <strong class="setting__label">Wrap wide content</strong> | ||
104 | <button class="setting__value">[N/A]</button> | ||
105 | </div> | ||
106 | <div class="setting setting--monospace-font"> | ||
107 | <strong class="setting__label">Monospace font</strong> | ||
108 | <button class="setting__value">[N/A]</button> | ||
109 | </div> | ||
110 | <div class="setting setting--image-previews"> | ||
111 | <strong class="setting__label">Image thumbnails</strong> | ||
112 | <button class="setting__value">[N/A]</button> | ||
113 | </div> | ||
114 | <div class="setting setting--clickable-plain-links"> | ||
115 | <strong class="setting__label">Clickable links in text files</strong> | ||
116 | <button class="setting__value">[N/A]</button> | ||
117 | </div> | ||
118 | </div> | ||
119 | </aside> | ||
120 | <script src="{{ .Assets.JS }}"></script> | ||
121 | </body> | ||
122 | </html>` | ||