website: make camlistore.org go-import meta tags reference a snapshot

I created https://github.com/camlistore/old-cam-snapshot with a snapshot
of our git repo before we start rearranging things.

This way we won't break anybody depending on camlistore.org/* Go
packages after the move. They just won't get any updates. Actually
things will probably break if they run "go get -u". Need to
investigate what happens there.

Change-Id: I45e109c18323e65bd76706faa08d955dcbc5f6c6
This commit is contained in:
Brad Fitzpatrick 2017-12-29 16:51:06 -08:00
parent ca3118aa12
commit b9a68c3000
3 changed files with 29 additions and 16 deletions

View File

@ -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 = `<a href="$1$3">$1$3</a>`

View File

@ -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) {
<h3>Overview</h3><p>`
content = bytes.Replace(content, []byte("<p>"), []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)
}
}

View File

@ -16,8 +16,8 @@
{{define "header"}}
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
{{if .Domain}}
<meta name="go-import" content="{{.Domain}} git https://camlistore.googlesource.com/camlistore">
{{if .GoImportDomain}}
<meta name="go-import" content="{{.GoImportDomain}} git {{.GoImportUpstream}}">
{{end}}
{{with $x := .Title}}
<title>{{$x}} - Perkeep</title>