oficina / memoria Public

Clone
git clone https://amadan.net/oficina/memoria

Plain git — no account needed to clone.

Download

Download this file

1package memoria
2
3import (
4 "bytes"
5 "net/http"
6
7 "amadan.net/oficina/home/connect"
8)
9
10type homePage struct {
11 page
12 Home connect.PageData
13}
14
15// renderHome renders connect's account-link pages (link, confirm, failed)
16// inside Memoria's layout, with the viewer's own chrome. Signed out is
17// Memoria's own signed-out page, the one Sign out lands on either way.
18func (a *app) renderHome(w http.ResponseWriter, r *http.Request, state, label string, status int) {
19 if state == "signedout" {
20 a.signedOut(w, r)
21 return
22 }
23 data := connect.Page(state, label, func(k string) string { return homeCopy[k] })
24 pg := a.pageFor(r, titled(data.Title))
25 var body bytes.Buffer
26 if err := pages["home"].ExecuteTemplate(&body, "layout", homePage{page: pg, Home: data}); err != nil {
27 plainError(w, http.StatusInternalServerError)
28 return
29 }
30 w.Header().Set("Content-Type", "text/html; charset=utf-8")
31 w.Header().Set("Cache-Control", "no-store")
32 w.WriteHeader(status)
33 _, _ = w.Write(body.Bytes())
34}
35
36// homeCopy is connect's account-connection copy (which already leaves
37// the hub unnamed — "your Oficina account" — and says Connect, Paul's
38// §13 answer 3), with only Memoria's own words on top. The same wording
39// Sheets and Slides use.
40var homeCopy = func() map[string]string {
41 out := make(map[string]string, len(connect.English))
42 for k, v := range connect.English {
43 out[k] = v
44 }
45 out["start_body"] = "Use your Oficina account to sign in to this account. What Memoria holds stays as it is."
46 out["documents_action"] = "Back to Memoria"
47 return out
48}()
49