From e58fabd89f9708aaeb10e52f731759712034833f Mon Sep 17 00:00:00 2001 From: Feuerfuchs Date: Mon, 18 May 2020 18:02:20 +0200 Subject: WIP: Refactoring --- internal/port/tpl/_fonts.html | 12 ++++---- internal/port/tpl/_header.html | 48 -------------------------------- internal/port/tpl/_modals.html | 2 +- internal/port/tpl/gemini.html | 62 ++++++++++++++++++++++++++++-------------- internal/port/tpl/gopher.html | 19 ++++--------- 5 files changed, 54 insertions(+), 89 deletions(-) delete mode 100644 internal/port/tpl/_header.html (limited to 'internal/port/tpl') 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 @@ font-family: 'Iosevka Term SS03'; font-style: normal; font-weight: normal; - src: url('{{ .Assets.FontW2 }}') format('woff2'), - url('{{ .Assets.FontW }}') format('woff'); + src: url('{{ .Assets.FontRegularW2 }}') format('woff2'), + url('{{ .Assets.FontRegularW }}') format('woff'); } @font-face { - font-family: 'Iosevka Aile'; + font-family: 'Iosevka Term SS03'; font-style: normal; - font-weight: normal; - src: url('{{ .Assets.PropFontW2 }}') format('woff2'), - url('{{ .Assets.PropFontW }}') format('woff'); + font-weight: bold; + src: url('{{ .Assets.FontBoldW2 }}') format('woff2'), + url('{{ .Assets.FontBoldW }}') format('woff'); } 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 @@ -
-
- {{ .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 -}} -
-
-
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 @@
- Monospace font + Gemini: Monospace font
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 @@ {{- template "_fonts.html" . -}} - - {{- template "_header.html" . -}} + +
+
+ gemini://:// + {{- range $i, $item := .Nav -}} + {{- if ne $i 0 -}} + / + {{- end -}} + {{- if .Current -}} + {{ .Label }} + {{- else -}} + {{ .Label }} + {{- end -}} + {{- end -}} +
+
+
+
+
-
-				{{- if .Lines -}}
-					{{- $content := "" -}}
-					{{- range .Lines -}}
-						{{- if ne $content "" -}}
-							{{- $content = printf "%s\n" $content -}}
-						{{- end -}}
-						{{- if .Link -}}
-							{{- $content = printf "%s%s" $content (printf "%s  %s" .Type .Type .Link (.Text | HTMLEscape)) -}}
-						{{- else -}}
-							{{- $content = printf "%s%s" $content (printf "     %s" (.Text | HTMLEscape)) -}}
-						{{- end -}}
-					{{- end -}}
-					{{- $content | safeHtml -}}
-				{{- else -}}
-					{{- .RawText -}}
-				{{- end -}}
-			
+
+ {{- range .Sections -}} + {{- if eq .Type "RAW_TEXT" -}} +
```
{{- .Text -}}
+ {{- else if eq .Type "REFLOW_TEXT" -}} +

{{- .Text -}}

+ {{- else if eq .Type "LINK" -}} + + {{- else if eq .Type "HEADING_1" -}} +
#

{{- .Text -}}

+ {{- else if eq .Type "HEADING_2" -}} +
##

{{- .Text -}}

+ {{- else if eq .Type "HEADING_3" -}} +
###

{{- .Text -}}

+ {{- else if eq .Type "LIST" -}} +
    + {{- range .Items -}} +
  • {{- . -}}
  • + {{- end -}} +
+ {{- end -}} + {{- end -}} +
{{- 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 @@
-
-        {{- $content := "" -}}
+      
{{- $page := . -}} {{- range .Lines -}} - {{- if ne $content "" -}} - {{- $content = printf "%s\n" $content -}} - {{- end -}} - {{- if $page.IsPlain -}} - {{- $content = printf "%s%s" $content (.Text | HTMLEscape) -}} + {{- if .Link -}} +
{{- .Type -}}{{- .Text -}}
{{- else -}} - {{- if .Link -}} - {{- $content = printf "%s%s" $content (printf "%s %s" .Type .Type .Link (.Text | HTMLEscape)) -}} - {{- else -}} - {{- $content = printf "%s%s" $content (printf " %s" (.Text | HTMLEscape)) -}} - {{- end -}} +
{{- .Text -}}
{{- end -}} {{- end -}} - {{- $content | safeHtml -}} -
+
{{- template "_modals.html" . -}} -- cgit v1.2.3-70-g09d2