diff options
author | Feuerfuchs <git@feuerfuchs.dev> | 2020-05-18 18:02:20 +0200 |
---|---|---|
committer | Feuerfuchs <git@feuerfuchs.dev> | 2020-05-18 18:02:20 +0200 |
commit | e58fabd89f9708aaeb10e52f731759712034833f (patch) | |
tree | b845d41df1e91f01e4d66fb0a40fa9dc76c24dcd /internal/port/tpl | |
parent | WIP: Refactoring (diff) | |
download | gopherproxy-e58fabd89f9708aaeb10e52f731759712034833f.tar.gz gopherproxy-e58fabd89f9708aaeb10e52f731759712034833f.tar.bz2 gopherproxy-e58fabd89f9708aaeb10e52f731759712034833f.zip |
WIP: Refactoring
Diffstat (limited to 'internal/port/tpl')
-rw-r--r-- | internal/port/tpl/_fonts.html | 12 | ||||
-rw-r--r-- | internal/port/tpl/_header.html | 48 | ||||
-rw-r--r-- | internal/port/tpl/_modals.html | 2 | ||||
-rw-r--r-- | internal/port/tpl/gemini.html | 62 | ||||
-rw-r--r-- | internal/port/tpl/gopher.html | 19 |
5 files changed, 54 insertions, 89 deletions
diff --git a/internal/port/tpl/_fonts.html b/internal/port/tpl/_fonts.html index b56aa22..a947222 100644 --- a/internal/port/tpl/_fonts.html +++ b/internal/port/tpl/_fonts.html | |||
@@ -3,14 +3,14 @@ | |||
3 | font-family: 'Iosevka Term SS03'; | 3 | font-family: 'Iosevka Term SS03'; |
4 | font-style: normal; | 4 | font-style: normal; |
5 | font-weight: normal; | 5 | font-weight: normal; |
6 | src: url('{{ .Assets.FontW2 }}') format('woff2'), | 6 | src: url('{{ .Assets.FontRegularW2 }}') format('woff2'), |
7 | url('{{ .Assets.FontW }}') format('woff'); | 7 | url('{{ .Assets.FontRegularW }}') format('woff'); |
8 | } | 8 | } |
9 | @font-face { | 9 | @font-face { |
10 | font-family: 'Iosevka Aile'; | 10 | font-family: 'Iosevka Term SS03'; |
11 | font-style: normal; | 11 | font-style: normal; |
12 | font-weight: normal; | 12 | font-weight: bold; |
13 | src: url('{{ .Assets.PropFontW2 }}') format('woff2'), | 13 | src: url('{{ .Assets.FontBoldW2 }}') format('woff2'), |
14 | url('{{ .Assets.PropFontW }}') format('woff'); | 14 | url('{{ .Assets.FontBoldW }}') format('woff'); |
15 | } | 15 | } |
16 | </style> | 16 | </style> |
diff --git a/internal/port/tpl/_header.html b/internal/port/tpl/_header.html deleted file mode 100644 index 5bcd254..0000000 --- a/internal/port/tpl/_header.html +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | <header class="header header-base"> | ||
2 | <div class="location"> | ||
3 | <a class="location__prefix">{{ .Protocol }}://</a><a class="location__prefix location__prefix--mobile">://</a> | ||
4 | |||
5 | {{- if .URL -}} | ||
6 | {{- $page := . -}} | ||
7 | {{- $href := printf "/%s" .Protocol -}} | ||
8 | {{- $uriParts := split .URL "/" -}} | ||
9 | |||
10 | {{- $uriLast := $uriParts | last -}} | ||
11 | {{- $uriParts = $uriParts | pop -}} | ||
12 | {{- if eq $uriLast "" -}} | ||
13 | {{- $uriLast = $uriParts | last -}} | ||
14 | {{- $uriParts = $uriParts | pop -}} | ||
15 | {{- end -}} | ||
16 | |||
17 | {{- range $i, $part := $uriParts -}} | ||
18 | {{- if and (eq $page.Protocol "gopher") (eq $i 1) -}} | ||
19 | {{- $href = printf "%s/1" $href -}} | ||
20 | {{- $part = $part | trimLeftChar -}} | ||
21 | {{- if not (eq $part "") -}} | ||
22 | {{- $href = printf "%s/%s" $href $part -}} | ||
23 | <span class="location__slash">/</span><a href="{{ $href }}/" class="location__uripart">{{ $part }}</a> | ||
24 | {{- end -}} | ||
25 | {{- else -}} | ||
26 | {{- $href = printf "%s/%s" $href . -}} | ||
27 | {{- if ne $i 0 -}} | ||
28 | <span class="location__slash">/</span> | ||
29 | {{- end -}} | ||
30 | <a href="{{ $href }}/" class="location__uripart">{{ . }}</a> | ||
31 | {{- end -}} | ||
32 | {{- end -}} | ||
33 | {{- if ne (len $uriParts) 0 -}} | ||
34 | <span class="location__slash">/</span> | ||
35 | {{- end -}} | ||
36 | {{- if and (eq $page.Protocol "gopher") (eq (len $uriParts) 1) -}} | ||
37 | {{- $uriLast = $uriLast | trimLeftChar -}} | ||
38 | {{- end -}} | ||
39 | <span class="location__uripart">{{ $uriLast }}</span> | ||
40 | {{- end -}} | ||
41 | </div> | ||
42 | <div class="actions"> | ||
43 | {{- if and (not .Lines) (not .Error) (eq .Protocol "gopher") -}} | ||
44 | <div class="action"><a href="/gopher/{{ .URL | replace "^([^/]*)/0" "$1/9" }}">View raw</a></div> | ||
45 | {{- end -}} | ||
46 | <div class="action"><button class="settings-btn">Settings</button></div> | ||
47 | </div> | ||
48 | </header> | ||
diff --git a/internal/port/tpl/_modals.html b/internal/port/tpl/_modals.html index 3c08d9a..3bbdef2 100644 --- a/internal/port/tpl/_modals.html +++ b/internal/port/tpl/_modals.html | |||
@@ -9,7 +9,7 @@ | |||
9 | <button class="setting__value">[N/A]</button> | 9 | <button class="setting__value">[N/A]</button> |
10 | </div> | 10 | </div> |
11 | <div class="setting setting--monospace-font"> | 11 | <div class="setting setting--monospace-font"> |
12 | <strong class="setting__label">Monospace font</strong> | 12 | <strong class="setting__label">Gemini: Monospace font</strong> |
13 | <button class="setting__value">[N/A]</button> | 13 | <button class="setting__value">[N/A]</button> |
14 | </div> | 14 | </div> |
15 | <div class="setting setting--image-previews"> | 15 | <div class="setting setting--image-previews"> |
diff --git a/internal/port/tpl/gemini.html b/internal/port/tpl/gemini.html index 08f1b8e..df50d50 100644 --- a/internal/port/tpl/gemini.html +++ b/internal/port/tpl/gemini.html | |||
@@ -7,28 +7,50 @@ | |||
7 | <link rel="stylesheet" href="{{ .Assets.Style }}" /> | 7 | <link rel="stylesheet" href="{{ .Assets.Style }}" /> |
8 | {{- template "_fonts.html" . -}} | 8 | {{- template "_fonts.html" . -}} |
9 | </head> | 9 | </head> |
10 | <body class="{{ if not .Lines }}is-plain{{ end }}"> | 10 | <body class="{{ if .IsPlain }}is-plain{{ end }}"> |
11 | {{- template "_header.html" . -}} | 11 | <header class="header header-base"> |
12 | <div class="location"> | ||
13 | <a class="location__prefix">gemini://</a><a class="location__prefix location__prefix--mobile">://</a> | ||
14 | {{- range $i, $item := .Nav -}} | ||
15 | {{- if ne $i 0 -}} | ||
16 | <span class="location__slash">/</span> | ||
17 | {{- end -}} | ||
18 | {{- if .Current -}} | ||
19 | <span class="location__uripart">{{ .Label }}</span> | ||
20 | {{- else -}} | ||
21 | <a href="{{ .URL }}/" class="location__uripart">{{ .Label }}</a> | ||
22 | {{- end -}} | ||
23 | {{- end -}} | ||
24 | </div> | ||
25 | <div class="actions"> | ||
26 | <div class="action"><button class="settings-btn">Settings</button></div> | ||
27 | </div> | ||
28 | </header> | ||
12 | 29 | ||
13 | <main class="wrap"> | 30 | <main class="wrap"> |
14 | <pre class="content content--has-monospace-font{{ if .Lines }} content--has-type-annotations{{ end }}"> | 31 | <div class="content{{ if not .IsPlain }} content--has-type-annotations{{ end }}"> |
15 | {{- if .Lines -}} | 32 | {{- range .Sections -}} |
16 | {{- $content := "" -}} | 33 | {{- if eq .Type "RAW_TEXT" -}} |
17 | {{- range .Lines -}} | 34 | <div class="section"><span class="section__type">```</span><pre class="section__content">{{- .Text -}}</pre></div> |
18 | {{- if ne $content "" -}} | 35 | {{- else if eq .Type "REFLOW_TEXT" -}} |
19 | {{- $content = printf "%s\n" $content -}} | 36 | <div class="section"><p class="section__content">{{- .Text -}}</p></div> |
20 | {{- end -}} | 37 | {{- else if eq .Type "LINK" -}} |
21 | {{- if .Link -}} | 38 | <div class="section"><span class="section__type">=></span><a class="section__content" href="{{ .URL }}">{{- .Text -}}</a></div> |
22 | {{- $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)) -}} | 39 | {{- else if eq .Type "HEADING_1" -}} |
23 | {{- else -}} | 40 | <div class="section"><span class="section__type">#</span><h1 class="section__content">{{- .Text -}}</h1></div> |
24 | {{- $content = printf "%s%s" $content (printf "<span class=\"type-annotation\"> </span>%s" (.Text | HTMLEscape)) -}} | 41 | {{- else if eq .Type "HEADING_2" -}} |
25 | {{- end -}} | 42 | <div class="section"><span class="section__type">##</span><h2 class="section__content">{{- .Text -}}</h2></div> |
26 | {{- end -}} | 43 | {{- else if eq .Type "HEADING_3" -}} |
27 | {{- $content | safeHtml -}} | 44 | <div class="section"><span class="section__type">###</span><h3 class="section__content">{{- .Text -}}</h3></div> |
28 | {{- else -}} | 45 | {{- else if eq .Type "LIST" -}} |
29 | {{- .RawText -}} | 46 | <div class="section"><ul class="section__content"> |
30 | {{- end -}} | 47 | {{- range .Items -}} |
31 | </pre> | 48 | <li>{{- . -}}</li> |
49 | {{- end -}} | ||
50 | </ul></div> | ||
51 | {{- end -}} | ||
52 | {{- end -}} | ||
53 | </div> | ||
32 | </main> | 54 | </main> |
33 | 55 | ||
34 | {{- template "_modals.html" . -}} | 56 | {{- template "_modals.html" . -}} |
diff --git a/internal/port/tpl/gopher.html b/internal/port/tpl/gopher.html index c971847..5436123 100644 --- a/internal/port/tpl/gopher.html +++ b/internal/port/tpl/gopher.html | |||
@@ -31,25 +31,16 @@ | |||
31 | </header> | 31 | </header> |
32 | 32 | ||
33 | <main class="wrap"> | 33 | <main class="wrap"> |
34 | <pre class="content content--has-monospace-font{{ if not .IsPlain }} content--has-type-annotations{{ end }}"> | 34 | <div class="content content--monospace{{ if not .IsPlain }} content--has-type-annotations{{ end }}"> |
35 | {{- $content := "" -}} | ||
36 | {{- $page := . -}} | 35 | {{- $page := . -}} |
37 | {{- range .Lines -}} | 36 | {{- range .Lines -}} |
38 | {{- if ne $content "" -}} | 37 | {{- if .Link -}} |
39 | {{- $content = printf "%s\n" $content -}} | 38 | <div class="section"><span class="section__type">{{- .Type -}}</span><a class="section__content" href="{{ .Link }}">{{- .Text -}}</a></div> |
40 | {{- end -}} | ||
41 | {{- if $page.IsPlain -}} | ||
42 | {{- $content = printf "%s%s" $content (.Text | HTMLEscape) -}} | ||
43 | {{- else -}} | 39 | {{- else -}} |
44 | {{- if .Link -}} | 40 | <div class="section"><span class="section__type"></span><pre class="section__content">{{- .Text -}}</pre></div> |
45 | {{- $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)) -}} | ||
46 | {{- else -}} | ||
47 | {{- $content = printf "%s%s" $content (printf "<span class=\"type-annotation\"> </span>%s" (.Text | HTMLEscape)) -}} | ||
48 | {{- end -}} | ||
49 | {{- end -}} | 41 | {{- end -}} |
50 | {{- end -}} | 42 | {{- end -}} |
51 | {{- $content | safeHtml -}} | 43 | </div> |
52 | </pre> | ||
53 | </main> | 44 | </main> |
54 | 45 | ||
55 | {{- template "_modals.html" . -}} | 46 | {{- template "_modals.html" . -}} |