hswaw/site: basic /about and /about_en rendering

This renders the About and About-but-in-English templates already
present.

It integrates header.html and rotimage_at.html into the basic template.
These were separates so that different webapps on boston-packets could
serve the same header file from the same sources, but this approach will
have to be abandoned for this version of the site anyway.

We'll have to figure out how/if to share these things between different
webapps, but probably only after we actually come up with a new site
theme. Let's keep it simple for now.

We also skip porting the 'subscribe to lists' template and
functionality, as it's broken right now anyway.

Change-Id: Ia89bfcaa1e250bd74d1771e095b3c8505b08c606
diff --git a/hswaw/site/views.go b/hswaw/site/views.go
new file mode 100644
index 0000000..ae62322
--- /dev/null
+++ b/hswaw/site/views.go
@@ -0,0 +1,63 @@
+package main
+
+import (
+	"fmt"
+	"html/template"
+	"net/http"
+
+	"github.com/golang/glog"
+
+	"code.hackerspace.pl/hscloud/hswaw/site/templates"
+)
+
+// parseTemplates parses a set of templates from
+// //hswaw/site/templates/$name.html into a Go HTML template. Typical Go text
+// templating ordering behaviour applies (this basically replicates
+// template.ParseFiles, but for statically embedded files instead).
+func parseTemplates(names ...string) (*template.Template, error) {
+	if len(names) == 0 {
+		return nil, fmt.Errorf("at least one template must be given")
+	}
+
+	var t *template.Template
+	for _, n := range names {
+		path := fmt.Sprintf("hswaw/site/templates/%s.html", n)
+		data, ok := templates.Data[path]
+		if !ok {
+			return nil, fmt.Errorf("template %q (%s) not found", n, path)
+		}
+		s := string(data)
+
+		if t == nil {
+			t = template.New(n)
+		}
+		_, err := t.Parse(s)
+		if err != nil {
+			return nil, fmt.Errorf("template %q could not be parsed: %w", n, err)
+		}
+	}
+	return t, nil
+}
+
+var (
+	tmplAbout   = template.Must(parseTemplates("basic", "about"))
+	tmplAboutEn = template.Must(parseTemplates("basic", "about_en"))
+)
+
+// render attempts to render a given Go template with data into the HTTP
+// response writer, and logs a warning if anything goes wrong.
+func render(w http.ResponseWriter, t *template.Template, data interface{}) {
+	if err := t.Execute(w, data); err != nil {
+		glog.Warningf("Rendering %v failed: %v", t, err)
+	}
+}
+
+// handleAbout handles rendering the about page at /about
+func (s *service) handleAbout(w http.ResponseWriter, r *http.Request) {
+	render(w, tmplAbout, nil)
+}
+
+// handleAboutEn handles rendering the about page at /about_en
+func (s *service) handleAboutEn(w http.ResponseWriter, r *http.Request) {
+	render(w, tmplAboutEn, nil)
+}