forked from GoogleCloudPlatform/govanityurls
-
Notifications
You must be signed in to change notification settings - Fork 2
/
templates.go
54 lines (51 loc) · 1.66 KB
/
templates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import "text/template"
var indexTmpl = template.Must(template.New("index").Parse(`<!DOCTYPE html>
<html>
<head>
<title>{{.Title}}</title>
<link rel='icon' href='/favicon.ico' type='image/x-icon'/ >
<style>
ul {
display: flex;
flex-wrap: wrap;
padding: 0;
list-style-type: none;
}
li { flex: 0 0 33%; }
li { text-align: center; }
li:nth-child(n) { background-color: #eed; }
li:nth-child(6n+4) { background-color: lightgray; }
li:nth-child(6n+5) { background-color: lightgray; }
li:nth-child(6n+6) { background-color: lightgray; }
</style>
</head>
<body>
<h1><a href="https://{{.Host}}/">{{.Title}}</a></h1>
{{range .Links -}}
<h3><a href="{{.URL}}">{{.Title}}</a></h3>
{{end -}}
<ul>
{{- range .Paths}} {{if and (ne .Repo "") (ne .Wildcard true)}}
<li><a href="{{.Path}}">{{.Path}}</a></li>
<li><a href="https://godoc.org/{{$.Host}}{{.Path}}">GoDoc</a></li>
<li><a href="{{.Repo}}">Code</a></li>
{{end}}{{- end -}}</ul>
{{if ne .Src ""}} (<a href="{{.Src}}">source</a>){{end}}
</body>
</html>
`))
var vanityTmpl = template.Must(template.New("vanity").Parse(`<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="/favicon.ico" type="image/x-icon"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="go-import" content="{{.ImportPath}}"/>
<meta name="go-source" content="{{.SourcePath}}"/>
<!-- meta http-equiv="refresh" content="0; url=https://godoc.org/{{.GoDocPath}}"/-->
</head>
<body>
Nothing to see here; <a href="https://godoc.org/{{.GoDocPath}}">See the package on godoc</a>.
</body>
</html>
`))