2
Hockeypuck - OpenPGP key server
3
Copyright (C) 2012-2014 Casey Marshall
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU Affero General Public License as published by
7
the Free Software Foundation, version 3.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU Affero General Public License for more details.
14
You should have received a copy of the GNU Affero General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.
26
const footerTmplSrc = `
27
{{define "page_footer"}}
29
<div id="copyright"><a href="http://hockeypuck.github.io/">Hockeypuck OpenPGP Key Server</a> - Copyright (C) 2012 <a href="/pks/lookup?op=vindex&search=0x44A2D1DB">Casey Marshall</a> and Hockeypuck contributors.</div>
30
<div id="copyleft">This program is free software: you can redistribute it and/or modify
31
it under the terms of the
32
<a href="https://www.gnu.org/licenses/agpl-3.0.html">GNU Affero General Public License</a>
33
as published by the Free Software Foundation, version 3.</div>
39
<link rel="stylesheet" href="/css/reset.css" />
40
<link rel="stylesheet" href="/css/hkp.css" />
43
const headerTmplSrc = `
44
{{define "page_header"}}
46
<h1><a id="logo" href="/">Hockeypuck</a></h1>
49
<li><span class="menu-label">OpenPGP:</span></li>
50
<li><a href="/openpgp/lookup">Search</a></li>
51
<li><a href="/openpgp/add">Add</a></li>
52
<li><a href="/pks/lookup?op=stats">Stats</a></li>
53
<li><span class="menu-label">Machines:</span></li>
54
<li><span class="todo-link">SSH</span></li>
55
<li><span class="todo-link">SSL/TLS</span></li>
56
<li class="about"><a href="http://hockeypuck.github.io/">Project Home</a></li>
62
const layoutTmplSrc = `
67
<meta charset="utf-8" />
68
<title>{{template "title"}}</title>
73
{{template "page_header"}}
79
</div><!-- container -->
80
{{template "page_footer"}}
87
{{template "page_content" .}}
88
{{template "bottom" .}}
91
const addFormTmplSrc = `
92
{{define "title"}}Hockeypuck | Add Public Key{{end}}
94
{{define "page_content"}}
95
<h2 class="pks-add">Add Public Key</h2>
96
<p>Paste the ASCII-armored public key block into the form below.</p>
97
<form class="pks-add" action="/pks/add" method="post">
99
<textarea name="keytext" cols="66" rows="20"></textarea>
102
<input id="add_submit" type="submit" value="Add Public Key"></input>
107
const addResultTmplSrc = `
108
{{define "title"}}Hockeypuck | Updated Public Keys{{end}}
110
{{define "page_content"}}
111
<h2>Updated Public Keys</h2>
113
<p><a href="/pks/lookup?op=index&search=0x{{.Fingerprint}}">{{.}}</a></p>
117
const searchFormTmplSrc = `
118
{{define "title"}}Hockeypuck | Search OpenPGP Public Keys{{end}}
120
{{define "page_content"}}
121
<h2 class="pks-search">OpenPGP Search</h2>
122
<form class="pks-search" method="post">
124
<input name="search" type="search"></input>
127
<input id="search_submit" formaction="/pks/lookup?op=index" type="submit" value="Public Key Search"></input>
128
<input id="get_submit" formaction="/pks/lookup?op=get" type="submit" value="I'm Feeling Lucky"></input>
133
const statsTmplSrc = `
134
{{define "title"}}Hockeypuck | Server Status{{end}}
136
{{define "page_content"}}
137
<h2>Server Status</h2>
139
<tr><th>Hostname:</th><td>{{.Hostname}}</td></tr>
140
<tr><th>Port:</th><td>{{.Port}}</td></tr>
141
<tr><th>Version:</th><td>{{.Version}}</td></tr>
144
<h2>Outgoing Mailsync Peers</h2>
146
<tr><th>Email Address</th><th>Last Synchronized</th></tr>
148
<tr><td>{{.Addr}}</td><td>{{timef .LastSync}}</td></tr>
154
<tr><th>Total number of keys:</th><td>{{.TotalKeys}}</td></tr>
156
{{if .KeyStatsHourly}}
157
<h3>Keys loaded in the last 24 hours</h3>
159
<tr><th>Hour</th><th>New</th><th>Updated</th></tr>
160
{{range .KeyStatsHourly}}
161
<tr><td>{{.Hour}}</td><td>{{.Created}}</td><td>{{.Modified}}</td></tr>
165
{{if .KeyStatsDaily}}
166
<h3>Keys loaded in the last 7 days</h3>
168
<tr><th>Day</th><th>New</th><th>Updated</th></tr>
169
{{range .KeyStatsDaily}}
170
<tr><td>{{.Day}}</td><td>{{.Created}}</td><td>{{.Modified}}</td></tr>
176
// baseTmplSrcs contains common templates that need to be defined
177
// for all Hockeypuck HKP templates.
178
var BaseTemplateSrcs = []string{
179
headTmplSrc, headerTmplSrc, footerTmplSrc,
182
// SearchFormTemplate is used to render the default search form at '/'
183
var SearchFormTemplate *template.Template
185
// AddFormTemplate is used to render the form to add a key.
186
var AddFormTemplate *template.Template
188
// AddResultTemplate displays the fingerprints of updated keys.
189
var AddResultTemplate *template.Template
191
// PksIndexTemplate is used to render the op=index and op=vindex
192
// responses when not in machine readable mode.
193
var PksIndexTemplate *template.Template
195
// StatsTemplate renders the op=stats page
196
var StatsTemplate *template.Template
198
func mustParseHkpTemplate(src string) *template.Template {
199
return template.Must(template.New("placeholder").Parse(strings.Join(
200
append(BaseTemplateSrcs, src), "")))
204
SearchFormTemplate = mustParseHkpTemplate(searchFormTmplSrc)
205
AddFormTemplate = mustParseHkpTemplate(addFormTmplSrc)
206
AddResultTemplate = mustParseHkpTemplate(addResultTmplSrc)
207
StatsTemplate = template.Must(template.New("placeholder").Funcs(
208
template.FuncMap{"timef": func(ts int64) string {
209
tm := time.Unix(0, ts)
210
return tm.Format(time.RFC3339)
211
}}).Parse(strings.Join(append(BaseTemplateSrcs, statsTmplSrc), "")))