From da3c29209fb9519913f5eb4fcc1b1a4986464f03 Mon Sep 17 00:00:00 2001 From: James Mills Date: Mon, 26 Jun 2017 01:48:07 -0700 Subject: Bump --- Dockerfile | 2 +- gopherproxy.go | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index bf5cab6..ddba3aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM golang:alpine EXPOSE 80/tcp ENTRYPOINT ["gopherproxy"] -CMD [] +CMD ["-bind", "0.0.0.0:80", "-uri", "floodgap.com"] RUN \ apk add --update git && \ diff --git a/gopherproxy.go b/gopherproxy.go index 8c85448..fcce1ee 100644 --- a/gopherproxy.go +++ b/gopherproxy.go @@ -23,9 +23,16 @@ type tplRow struct { type Handler func(w http.ResponseWriter, req *http.Request) func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport string, d gopher.Directory) error { - out := make([]tplRow, len(d)) + var title string + + out := make([]tplRow, len(d.Items)) + + for i, x := range d.Items { + if x.Type == gopher.INFO && x.Selector == "TITLE" { + title = x.Description + continue + } - for i, x := range d { tr := tplRow{ Text: x.Description, Type: x.Type.String(), @@ -60,10 +67,14 @@ func renderDirectory(w http.ResponseWriter, tpl *template.Template, hostport str out[i] = tr } + if title == "" { + title = hostport + } + return tpl.Execute(w, struct { Title string Lines []tplRow - }{hostport, out}) + }{title, out}) } // MakeGopherProxyHandler returns a Handler that proxies requests -- cgit v1.2.3-70-g09d2