diff --git a/pkg/deploy/gce/handler.go b/pkg/deploy/gce/handler.go index f3cc43a7d..0b257ff5c 100644 --- a/pkg/deploy/gce/handler.go +++ b/pkg/deploy/gce/handler.go @@ -918,7 +918,6 @@ func (h *DeployHandler) AddTemplateTheme(text string) error { // TemplateData is the data passed for templates of tplHTML. type TemplateData struct { Title string - Domain string // unused, but needs to be defined to satisfy the page.html template. See TODO above. Help map[string]template.HTML // help bits within the form. Hints []string // helping hints printed in case of an error. Err error @@ -933,6 +932,11 @@ type TemplateData struct { ZoneValues []string MachineValues []string CamliVersion string // git revision found in https://storage.googleapis.com/camlistore-release/docker/VERSION + + // Unused stuff, but needed by page.html. See TODO above, + // before AddTemplateTheme. + GoImportDomain string + GoImportUpstream string } const toHyperlink = `$1$3` diff --git a/website/camweb.go b/website/camweb.go index 9bd92fc4c..5c2a375da 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -192,6 +192,17 @@ type pageParams struct { content []byte // required } +// pageTmplData is the template data passed to page.html. +type pageTmplData struct { + Title string + Subtitle string + Content template.HTML + + // For the "go-import" meta header: + GoImportDomain string + GoImportUpstream string +} + func servePage(w http.ResponseWriter, r *http.Request, params pageParams) { title, subtitle, content := params.title, params.subtitle, params.content // insert an "install command" if it applies @@ -202,20 +213,18 @@ func servePage(w http.ResponseWriter, r *http.Request, params pageParams) {

Overview

` content = bytes.Replace(content, []byte("

"), []byte(toInsert), 1) } - d := struct { - Title string - Subtitle string - Content template.HTML - Domain string // for the "go-import" meta header - }{ - title, - subtitle, - template.HTML(content), - // the redirects happening before should ensure that r.Host is only ever one of - // camlistore.org or perkeep.org - goGetDomain(r.Host), + domain := goGetDomain(r.Host) // camlistore.org or perkeep.org (anti-www redirects already happened) + upstream := "https://camlistore.googlesource.com/camlistore" + if domain == "camlistore.org" { + upstream = "https://github.com/camlistore/old-cam-snapshot" } - if err := pageHTML.ExecuteTemplate(w, "page", &d); err != nil { + if err := pageHTML.ExecuteTemplate(w, "page", &pageTmplData{ + Title: title, + Subtitle: subtitle, + Content: template.HTML(content), + GoImportDomain: domain, + GoImportUpstream: upstream, + }); err != nil { log.Printf("godocHTML.Execute: %s", err) } } diff --git a/website/tmpl/page.html b/website/tmpl/page.html index df6c6291b..64098f2c3 100644 --- a/website/tmpl/page.html +++ b/website/tmpl/page.html @@ -16,8 +16,8 @@ {{define "header"}} -{{if .Domain}} - +{{if .GoImportDomain}} + {{end}} {{with $x := .Title}} {{$x}} - Perkeep