aboutsummaryrefslogtreecommitdiffstats
path: root/internal/port/tpl/_header.html
blob: 5bcd2544a12ae184d77275118232f4c3a860639c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<header class="header header-base">
  <div class="location">
            <a class="location__prefix">{{ .Protocol }}://</a><a class="location__prefix location__prefix--mobile">://</a>
            
    {{- 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 -}}
            <span class="location__slash">/</span><a href="{{ $href }}/" class="location__uripart">{{ $part }}</a>
          {{- end -}}
        {{- else -}}
          {{- $href = printf "%s/%s" $href . -}}
          {{- if ne $i 0 -}}
            <span class="location__slash">/</span>
          {{- end -}}
          <a href="{{ $href }}/" class="location__uripart">{{ . }}</a>
        {{- end -}}
      {{- end -}}
      {{- if ne (len $uriParts) 0 -}}
        <span class="location__slash">/</span>
      {{- end -}}
      {{- if and (eq $page.Protocol "gopher") (eq (len $uriParts) 1) -}}
        {{- $uriLast = $uriLast | trimLeftChar -}}
      {{- end -}}
      <span class="location__uripart">{{ $uriLast }}</span>
            {{- end -}}
  </div>
  <div class="actions">
    {{- if and (not .Lines) (not .Error) (eq .Protocol "gopher") -}}
      <div class="action"><a href="/gopher/{{ .URL | replace "^([^/]*)/0" "$1/9" }}">View raw</a></div>
    {{- end -}}
    <div class="action"><button class="settings-btn">Settings</button></div>
  </div>
</header>