aboutsummaryrefslogtreecommitdiffstats
path: root/template.go
diff options
context:
space:
mode:
authorFeuerfuchs <git@feuerfuchs.dev>2019-06-23 17:29:07 +0200
committerFeuerfuchs <git@feuerfuchs.dev>2019-06-23 17:29:07 +0200
commitc448abd99a470e1ec541027077dcdef0745270d8 (patch)
tree433def56b6f0e81457cbe39fc85f402a9e4e18a8 /template.go
parentCheck type instead of file ext to render text via tpl (diff)
downloadgopherproxy-c448abd99a470e1ec541027077dcdef0745270d8.tar.gz
gopherproxy-c448abd99a470e1ec541027077dcdef0745270d8.tar.bz2
gopherproxy-c448abd99a470e1ec541027077dcdef0745270d8.zip
Show expandable thumbnails for images
Diffstat (limited to 'template.go')
-rw-r--r--template.go16
1 files changed, 5 insertions, 11 deletions
diff --git a/template.go b/template.go
index 33486d5..f5f4f2b 100644
--- a/template.go
+++ b/template.go
@@ -47,7 +47,10 @@ var tpltext = `<!doctype html>
47 {{- $content = printf "%s\n" $content -}} 47 {{- $content = printf "%s\n" $content -}}
48 {{- end -}} 48 {{- end -}}
49 {{- if .Link -}} 49 {{- if .Link -}}
50 {{- $content = printf "%s%s" $content (printf "<span class=\"link-type\">%s </span><a class=\"link link--%s\" href=\"%s\">%s</a>" .Type .Type .Link (.Text | HTMLEscape)) -}} 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)) -}}
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 -}}
51 {{- else -}} 54 {{- else -}}
52 {{- $content = printf "%s%s" $content (printf " %s" (.Text | HTMLEscape)) -}} 55 {{- $content = printf "%s%s" $content (printf " %s" (.Text | HTMLEscape)) -}}
53 {{- end -}} 56 {{- end -}}
@@ -59,16 +62,7 @@ var tpltext = `<!doctype html>
59 </pre> 62 </pre>
60 </main> 63 </main>
61 <script type="text/javascript"> 64 <script type="text/javascript">
62 var qry=document.getElementsByClassName('link--QRY') 65 {{ .Script | safeJs }}
63 var i=qry.length
64 while (i--) {
65 qry[i].addEventListener('click', function(e) {
66 e.preventDefault();
67 var resp=prompt("Please enter required input: ", "")
68 if (resp !== null && resp !== "") window.location = e.target.href + "?" + resp
69 return false;
70 })
71 }
72 </script> 66 </script>
73 </body> 67 </body>
74</html>` 68</html>`