diff options
| author | Feuerfuchs <git@feuerfuchs.dev> | 2019-06-24 21:54:39 +0200 |
|---|---|---|
| committer | Feuerfuchs <git@feuerfuchs.dev> | 2019-06-24 21:54:39 +0200 |
| commit | 3ec9264deb436af8fd6f5efc5efc3c7872127b05 (patch) | |
| tree | 0906868494c3656ec3fba9f3824671a887e55b28 /template.go | |
| parent | Show expandable thumbnails for images (diff) | |
| download | gopherproxy-3ec9264deb436af8fd6f5efc5efc3c7872127b05.tar.gz gopherproxy-3ec9264deb436af8fd6f5efc5efc3c7872127b05.tar.bz2 gopherproxy-3ec9264deb436af8fd6f5efc5efc3c7872127b05.zip | |
Improved design, add setting for image previews, add prompt for new location
Diffstat (limited to 'template.go')
| -rw-r--r-- | template.go | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/template.go b/template.go index f5f4f2b..dfda36d 100644 --- a/template.go +++ b/template.go | |||
| @@ -12,31 +12,38 @@ var tpltext = `<!doctype html> | |||
| 12 | </style> | 12 | </style> |
| 13 | </head> | 13 | </head> |
| 14 | <body> | 14 | <body> |
| 15 | <header class="header"> | 15 | <header class="header header-base"> |
| 16 | {{- $href := "" -}} | 16 | <div class="location"> |
| 17 | {{- $uriParts := split .URI "/" -}} | 17 | {{- $href := "" -}} |
| 18 | {{- $uriLast := $uriParts | last -}} | 18 | {{- $uriParts := split .URI "/" -}} |
| 19 | {{- $uriParts = $uriParts | pop -}} | 19 | {{- $uriLast := $uriParts | last -}} |
| 20 | {{- if eq $uriLast "" -}} | 20 | {{- $uriParts = $uriParts | pop -}} |
| 21 | {{- $uriLast = $uriParts | last -}} | 21 | {{- if eq $uriLast "" -}} |
| 22 | {{- $uriParts = $uriParts | pop -}} | 22 | {{- $uriLast = $uriParts | last -}} |
| 23 | {{- end -}} | 23 | {{- $uriParts = $uriParts | pop -}} |
| 24 | {{- if eq (len $uriParts) 1 -}} | 24 | {{- end -}} |
| 25 | {{- $uriLast = $uriParts | last -}} | 25 | {{- if eq (len $uriParts) 1 -}} |
| 26 | {{- $uriParts = $uriParts | pop -}} | 26 | {{- $uriLast = $uriParts | last -}} |
| 27 | {{- end -}} | 27 | {{- $uriParts = $uriParts | pop -}} |
| 28 | {{- end -}} | ||
| 28 | 29 | ||
| 29 | {{- range $i, $part := $uriParts -}} | 30 | <button class="location__prefix">gopher://</button> {{ range $i, $part := $uriParts -}} |
| 30 | {{- if ne $i 1 -}} | 31 | {{- if ne $i 1 -}} |
| 31 | {{- $href = printf "%s/%s" $href . -}} | 32 | {{- $href = printf "%s/%s" $href . -}} |
| 32 | {{- if ne $i 0 }} / {{ end -}} | 33 | {{- if ne $i 0 -}} |
| 33 | <a href="{{ $href }}" class="header__uripart">{{ . }}</a> | 34 | <span class="location__slash"> / </span> |
| 34 | {{- else -}} | 35 | {{- end -}} |
| 35 | {{- $href = printf "%s/1" $href -}} | 36 | <a href="{{ $href }}" class="location__uripart">{{ . }}</a> |
| 37 | {{- else -}} | ||
| 38 | {{- $href = printf "%s/1" $href -}} | ||
| 39 | {{- end -}} | ||
| 40 | {{- end -}} | ||
| 41 | {{- if ne (len $uriParts) 0 -}} | ||
| 42 | <span class="location__slash"> / </span> | ||
| 36 | {{- end -}} | 43 | {{- end -}} |
| 37 | {{- end -}} | 44 | <span class="location__uripart">{{ $uriLast -}}</span> |
| 38 | {{- if ne (len $uriParts) 0 }} / {{ end -}} | 45 | </div> |
| 39 | <span class="header__uripart header__uripart--last">{{ $uriLast -}}</span> | 46 | <button class="settings-btn">Settings</button> |
| 40 | </header> | 47 | </header> |
| 41 | <main class="wrap"> | 48 | <main class="wrap"> |
| 42 | <pre class="content"> | 49 | <pre class="content"> |
| @@ -48,9 +55,6 @@ var tpltext = `<!doctype html> | |||
| 48 | {{- end -}} | 55 | {{- end -}} |
| 49 | {{- if .Link -}} | 56 | {{- if .Link -}} |
| 50 | {{- $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)) -}} | 57 | {{- $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)) -}} |
| 51 | {{- if or (eq .Type "IMG") (eq .Type "GIF") -}} | ||
| 52 | {{- $content = printf "%s\n%s" $content (printf "<span class=\"type-annotation\"> -> </span><a class=\"img-preview\" href=\"%s\"><img src=\"%s\" /></a>" .Link (.Link | replace "^/(.*?)/I" "/$1/T")) -}} | ||
| 53 | {{- end -}} | ||
| 54 | {{- else -}} | 58 | {{- else -}} |
| 55 | {{- $content = printf "%s%s" $content (printf " %s" (.Text | HTMLEscape)) -}} | 59 | {{- $content = printf "%s%s" $content (printf " %s" (.Text | HTMLEscape)) -}} |
| 56 | {{- end -}} | 60 | {{- end -}} |
| @@ -61,6 +65,18 @@ var tpltext = `<!doctype html> | |||
| 61 | {{- end -}} | 65 | {{- end -}} |
| 62 | </pre> | 66 | </pre> |
| 63 | </main> | 67 | </main> |
| 68 | <aside class="modal modal--settings"> | ||
| 69 | <div class="modal__content"> | ||
| 70 | <header class="modal__head header-base"> | ||
| 71 | <h1 class="modal__title">Settings</h1> | ||
| 72 | <button class="modal__close-btn">Close</button> | ||
| 73 | </header> | ||
| 74 | <div class="setting setting--image-previews"> | ||
| 75 | <strong class="setting__label">Image thumbnails</strong> | ||
| 76 | <button class="setting__value">[N/A]</button> | ||
| 77 | </div> | ||
| 78 | </div> | ||
| 79 | </aside> | ||
| 64 | <script type="text/javascript"> | 80 | <script type="text/javascript"> |
| 65 | {{ .Script | safeJs }} | 81 | {{ .Script | safeJs }} |
| 66 | </script> | 82 | </script> |
