mirror of https://github.com/perkeep/perkeep.git
Merge "website: mv downloadBox to all.css"
This commit is contained in:
commit
77f50b2579
|
@ -816,6 +816,12 @@ func dataStores() (blobserver.Storage, sorted.KeyValue, error) {
|
|||
return instConf, instState, nil
|
||||
}
|
||||
|
||||
// TODO(mpl): AddTemplateTheme is a mistake, since the text argument is user
|
||||
// input and hence can contain just any field, that is not a known field of
|
||||
// TemplateData. Which will make the execution of the template fail. We should
|
||||
// probably just somehow hardcode website/tmpl/page.html as the template.
|
||||
// See issue #815
|
||||
|
||||
// AddTemplateTheme allows to enhance the aesthetics of the default template. To that
|
||||
// effect, text can provide the template definitions for "header", "banner", "toplinks", and
|
||||
// "footer".
|
||||
|
@ -846,8 +852,6 @@ type TemplateData struct {
|
|||
ProjectConsoleURL string
|
||||
ZoneValues []string
|
||||
MachineValues []string
|
||||
// TODO(mpl): Do something better than IsMonthly in camweb.go, and remove that below.
|
||||
IsMonthly bool // To satisfy gross IsMonthly from website/tmpl/page.html
|
||||
}
|
||||
|
||||
const toHyperlink = `<a href="$1$3">$1$3</a>`
|
||||
|
|
|
@ -160,7 +160,14 @@ func applyTemplate(t *template.Template, name string, data interface{}) []byte {
|
|||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func servePage(w http.ResponseWriter, title, subtitle string, content []byte) {
|
||||
type pageParams struct {
|
||||
title string // required
|
||||
subtitle string // used by pkg doc
|
||||
content []byte // required
|
||||
}
|
||||
|
||||
func servePage(w http.ResponseWriter, params pageParams) {
|
||||
title, subtitle, content := params.title, params.subtitle, params.content
|
||||
// insert an "install command" if it applies
|
||||
if strings.Contains(title, cmdPattern) && subtitle != cmdPattern {
|
||||
toInsert := `
|
||||
|
@ -170,15 +177,13 @@ func servePage(w http.ResponseWriter, title, subtitle string, content []byte) {
|
|||
content = bytes.Replace(content, []byte("<p>"), []byte(toInsert), 1)
|
||||
}
|
||||
d := struct {
|
||||
Title string
|
||||
Subtitle string
|
||||
Content template.HTML
|
||||
IsMonthly bool
|
||||
Title string
|
||||
Subtitle string
|
||||
Content template.HTML
|
||||
}{
|
||||
title,
|
||||
subtitle,
|
||||
template.HTML(content),
|
||||
strings.HasPrefix(title, "Monthly Release"),
|
||||
}
|
||||
|
||||
if err := pageHTML.ExecuteTemplate(w, "page", &d); err != nil {
|
||||
|
@ -210,7 +215,10 @@ func readTemplates() {
|
|||
func serveError(w http.ResponseWriter, r *http.Request, relpath string, err error) {
|
||||
contents := applyTemplate(errorHTML, "errorHTML", err) // err may contain an absolute path!
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
servePage(w, "File "+relpath, "", contents)
|
||||
servePage(w, pageParams{
|
||||
title: "File " + relpath,
|
||||
content: contents,
|
||||
})
|
||||
}
|
||||
|
||||
const gerritURLPrefix = "https://camlistore.googlesource.com/camlistore/+/"
|
||||
|
@ -393,15 +401,15 @@ const (
|
|||
)
|
||||
|
||||
// serveFile serves a file from disk, converting any markdown to HTML.
|
||||
func serveFile(rw http.ResponseWriter, req *http.Request, relPath, absPath string) {
|
||||
func serveFile(w http.ResponseWriter, r *http.Request, relPath, absPath string) {
|
||||
if !strings.HasSuffix(absPath, ".html") && !strings.HasSuffix(absPath, ".md") {
|
||||
http.ServeFile(rw, req, absPath)
|
||||
http.ServeFile(w, r, absPath)
|
||||
return
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadFile(absPath)
|
||||
if err != nil {
|
||||
serveError(rw, req, absPath, err)
|
||||
serveError(w, r, absPath, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -413,7 +421,10 @@ func serveFile(rw http.ResponseWriter, req *http.Request, relPath, absPath strin
|
|||
title = string(m[1])
|
||||
}
|
||||
|
||||
servePage(rw, title, "", data)
|
||||
servePage(w, pageParams{
|
||||
title: title,
|
||||
content: data,
|
||||
})
|
||||
}
|
||||
|
||||
func isBot(r *http.Request) bool {
|
||||
|
@ -1080,7 +1091,10 @@ func errHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
contents := applyTemplate(camliErrorHTML, "camliErrorHTML", data)
|
||||
w.WriteHeader(http.StatusFound)
|
||||
servePage(w, errString, "", contents)
|
||||
servePage(w, pageParams{
|
||||
title: errString,
|
||||
content: contents,
|
||||
})
|
||||
}
|
||||
|
||||
func camSrcDir() string {
|
||||
|
|
|
@ -186,7 +186,10 @@ func contribHandler() http.HandlerFunc {
|
|||
if m := h1TitlePattern.FindSubmatch(c); len(m) > 1 {
|
||||
title = string(m[1])
|
||||
}
|
||||
return func(rw http.ResponseWriter, req *http.Request) {
|
||||
servePage(rw, title, "", c)
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
servePage(w, pageParams{
|
||||
title: title,
|
||||
content: c,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -389,8 +389,10 @@ func serveTextFile(w http.ResponseWriter, r *http.Request, abspath, relpath, tit
|
|||
buf.WriteString("<pre>")
|
||||
FormatText(&buf, src, 1, pathpkg.Ext(abspath) == ".go", r.FormValue("h"), rangeSelection(r.FormValue("s")))
|
||||
buf.WriteString("</pre>")
|
||||
|
||||
servePage(w, title, "", buf.Bytes())
|
||||
servePage(w, pageParams{
|
||||
title: title,
|
||||
content: buf.Bytes(),
|
||||
})
|
||||
}
|
||||
|
||||
type godocHandler struct{}
|
||||
|
@ -424,5 +426,9 @@ func (godocHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
subtitle := pathpkg.Base(diskPath)
|
||||
title := subtitle + " (" + pkgName + ")"
|
||||
servePage(w, title, subtitle, applyTextTemplate(packageHTML, "packageHTML", pi))
|
||||
servePage(w, pageParams{
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
content: applyTextTemplate(packageHTML, "packageHTML", pi),
|
||||
})
|
||||
}
|
||||
|
|
|
@ -253,3 +253,30 @@ span.termhashlink a {
|
|||
.toggle .expanded { display: none; }
|
||||
.toggleVisible .collapsed { display: none; }
|
||||
.toggleVisible .expanded { display: block; }
|
||||
|
||||
/* For monthly release page */
|
||||
a.downloadBox {
|
||||
display: block;
|
||||
color: #222;
|
||||
border: 1px solid #375EAB;
|
||||
border-radius: 5px;
|
||||
background: #E0EBF5;
|
||||
width: 280px;
|
||||
}
|
||||
a.downloadBox:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
.downloadBox .platform {
|
||||
font-size: large;
|
||||
}
|
||||
.downloadBox .filename {
|
||||
color: #375EAB;
|
||||
font-weight: bold;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
a.downloadBox:hover .filename {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.downloadBox .checksum {
|
||||
font-size: 5pt;
|
||||
}
|
||||
|
|
|
@ -27,42 +27,9 @@
|
|||
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:400,700' rel='stylesheet' type='text/css'>
|
||||
<script type="text/javascript" src="/static/all-async.js" async="true"></script>
|
||||
<script type="text/javascript" src="/static/godocs.js"></script>
|
||||
{{if .IsMonthly}}
|
||||
{{template "downloadboxstyle" .}}
|
||||
{{end}}
|
||||
</head>
|
||||
{{end}}
|
||||
|
||||
{{define "downloadboxstyle"}}
|
||||
<style>
|
||||
a.downloadBox {
|
||||
display: block;
|
||||
color: #222;
|
||||
border: 1px solid #375EAB;
|
||||
border-radius: 5px;
|
||||
background: #E0EBF5;
|
||||
width: 280px;
|
||||
}
|
||||
a.downloadBox:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
.downloadBox .platform {
|
||||
font-size: large;
|
||||
}
|
||||
.downloadBox .filename {
|
||||
color: #375EAB;
|
||||
font-weight: bold;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
a.downloadBox:hover .filename {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.downloadBox .checksum {
|
||||
font-size: 5pt;
|
||||
}
|
||||
</style>
|
||||
{{end}}
|
||||
|
||||
{{define "banner"}}
|
||||
<div id='header'>
|
||||
<a href="/"><img width='788' height='161' src='/static/camli-header.jpg' title="Camlistore" border='0' /></a>
|
||||
|
|
Loading…
Reference in New Issue