-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.go
280 lines (247 loc) · 9.1 KB
/
template.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
package app_keyproofs
import (
"github.com/sour-is/keyproofs/pkg/opgp/entity"
"github.com/sour-is/keyproofs/pkg/style"
)
type page struct {
AppName string
AppBuild string
Entity *entity.Entity
Style *style.Style
Proofs *Proofs
Markdown string
HasProofs bool
IsComplete bool
Err error
}
var pageTPL = `
<html>
<head>
{{if not .IsComplete}}<meta http-equiv="refresh" content="1">{{end}}
<link href="https://pagecdn.io/lib/bootstrap/4.5.1/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-VoFZSlmyTXsegReQCNmbXrS4hBBUl/cexZvPmPWoJsY=" >
<link href="https://pagecdn.io/lib/font-awesome/5.14.0/css/fontawesome.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-7YMlwkILTJEm0TSengNDszUuNSeZu4KTN3z7XrhUQvc=" >
<link href="https://pagecdn.io/lib/font-awesome/5.14.0/css/solid.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-s0DhrAmIsT5gZ3X4f+9wIXUbH52CMiqFAwgqCmdPoec=" >
<link href="https://pagecdn.io/lib/font-awesome/5.14.0/css/regular.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-FAKIbnpfWhK6v5Re+NAi9n+5+dXanJvXVFohtH6WAuw=" >
<link href="https://pagecdn.io/lib/font-awesome/5.14.0/css/brands.min.css" rel="stylesheet" crossorigin="anonymous" integrity="sha256-xN44ju35FR+kTO/TP/UkqrVbM3LpqUI1VJCWDGbG1ew=" >
{{ with .Style }}
<style>
@font-face { font-family: "Font Awesome 5 Free"; font-weight: 900; src: url(https://pagecdn.io/lib/font-awesome/5.14.0/webfonts/fa-solid-900.woff2); }
@font-face { font-family: "Font Awesome 5 Free"; font-weight: 400; src: url(https://pagecdn.io/lib/font-awesome/5.14.0/webfonts/fa-regular-400.woff2); }
@font-face { font-family: "Font Awesome 5 Brands"; src: url(https://pagecdn.io/lib/font-awesome/5.14.0/webfonts/fa-brands-400.woff2); }
{{range $i, $val := .Palette}}.fg-color-{{$i}} { color: {{$val}}; }
{{end}}
{{range $i, $val := .Palette}}.bg-color-{{$i}} { background-color: {{$val}}; }
{{end}}
body {
background-image: url('{{.Background}}');
background-repeat: repeat;
background-color: {{index .Palette 7}};
padding-top: 1em;
}
.heading {
background-image: url('{{.Cover}}');
background-size: cover;
background-repeat: no-repeat;
background-color: {{index .Palette 3}};
}
.shade { background-color: {{index .Palette 3}}80; border-radius: .25rem;}
.lead { padding:0; margin:0; }
.scroll { height: 20em; overflow: scroll; }
@media only screen and (max-width: 991px) {
.jumbotron h1 { font-size: 2rem; }
.jumbotron .lead { font-size: 1.0rem; }
}
@media only screen and (max-width: 768px) {
.center-xs { text-align: center; width: 100% }
.center-sm { text-align: center; width: 100% }
.center-md { text-align: center; width: 100% }
.jumbotron h1 { font-size: 2rem; }
.jumbotron .lead { font-size: 1.0rem; }
}
@media only screen and (max-width: 576px) {
.center-xs { text-align: center; width: 100% }
.center-sm { text-align: center; width: 100% }
.center-md { text-align: center; width: 100% }
.jumbotron .lead { font-size: 0.8rem; }
body { font-size: 0.8rem; }
}
</style>
{{end}}
</head>
<body>
<div class="container">
<div class="card">
{{template "content" .}}
<div class="card-footer text-muted text-center">
<a href="/" alt="{{.AppBuild}}">{{.AppName}}</a>
| © 2020 Sour.is
| <a href="/id/me@sour.is">About me</a>
| <a href="https://github.com/sour-is/keyproofs">GitHub</a>
| Inspired by <a href="https://keyoxide.org/">keyoxide</a>
</div>
</div>
</div>
</body>
</html>
`
var homeTPL = `
{{define "content"}}
<div class="jumbotron heading">
<div class="container">
<div class="row shade">
<div class="col-md">
<h1 class="display-8 fg-color-8">Key Proofs</h1>
<p class="lead fg-color-11">Verify social identitys using OpenPGP</p>
</div>
</div>
</div>
</div>
<br/>
<div class="card">
<div class="card-body">
<form method="GET" action="/">
<div class="input-group mb-3">
<input type="text"
name="id"
class="form-control"
placeholder="Email or Fingerprint..."
aria-label="Email or Fingerprint"
aria-describedby="button-addon" />
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="submit" id="button-addon">GO</button>
</div>
</div>
</form>
</div>
</div>
<div class="container"> {{.Markdown | markDown}} </div>
{{end}}
`
var proofTPL = `
{{define "content"}}
<div class="jumbotron heading">
<div class="container">
<div class="row shade">
{{ with .Err }}
<div class="col-xs center-md">
<i class="fas fa-exclamation-triangle fa-4x fg-color-11"></i>
</div>
<div class="col-md">
<h1 class="display-8 fg-color-8">Something went wrong...</h1>
<pre class="fg-color-11">{{.}}</pre>
</div>
{{else}}
{{ with .Style }}
<div class="col-xs center-md">
<img src="{{.Avatar}}" class="img-thumbnail" alt="avatar" style="width:88px; height:88px">
</div>
{{end}}
{{with .Entity}}
<div class="col-md center-md">
<h1 class="display-8 fg-color-8">{{.Primary.Name}}</h1>
<p class="lead fg-color-11"><i class="fas fa-fingerprint"></i> {{.Fingerprint}}</p>
</div>
<div class="col-xs center-md">
<img src="/qr?s=-2&c=OPENPGP4FPR%3A{{.Fingerprint}}" class="img-thumbnail" alt="qrcode" style="width:88px; height:88px">
</div>
{{else}}
<div class="col-md">
<h1 class="display-8 fg-color-8">Loading...</h1>
<p class="lead fg-color-11">Reading key from remote service.</p>
</div>
{{end}}
{{end}}
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-4 col-md-12 col-sm-12 col-xs-12">
{{ with .Entity }}
<div class="card">
<div class="card-header">Contact</div>
<div class="list-group list-group-flush">
{{with .Primary}}<a href="mailto:{{.Address}}" class="list-group-item list-group-item-action"><i class="fas fa-envelope"></i> <b>{{.Name}} <{{.Address}}></b> <span class="badge badge-secondary">Primary</span></a>{{end}}
{{range .Emails}}<a href="mailto:{{.Address}}" class="list-group-item list-group-item-action"><i class="far fa-envelope"></i> {{.Name}} <{{.Address}}></a>{{end}}
</div>
</div>
<br />
{{end}}
{{if .HasProofs}}
{{with .Proofs}}
<div class="card">
<div class="card-header">Proofs</div>
<ul class="list-group list-group-flush">
{{range .}}
<li class="list-group-item">
<div>
<a title="{{.Link}}" class="font-weight-bold" href="{{.Link}}">
<i title="{{.Service}}" class="{{.Icon}}"></i>
{{.Name}}
</a>
{{if eq .Status 0}}
<a class="text-muted" href="{{.Verify}}"> <i class="fas fa-ellipsis-h"> Checking</i></a>
{{else if eq .Status 1}}
<a class="text-warning" href="{{.Verify}}"> <i class="fas fa-exclamation-triangle"></i> Error</a>
{{else if eq .Status 2}}
<a class="text-danger" href="{{.Verify}}"> <i class="far fa-times-circle"></i> Invalid</a>
{{else if eq .Status 3}}
<a class="text-success" href="{{.Verify}}"> <i class="far fa-check-square"></i> Verified</a>
{{end}}
</div>
<div>
{{if eq .Service "xmpp"}}
<br/>
<img src="/qr?s=-2&c={{.Link}}" alt="qrcode" style="width:88px; height:88px">
{{end}}
</div>
</li>
{{end}}
</ul>
</div>
</div>
{{else}}
<div class="card">
<div class="card-header">Proofs</div>
<div class="card-body">Loading...</div>
</div>
<br/>
{{end}}
{{end}}
<div class="col-lg-8 col-md-12 col-sm-12 col-xs-12">
<div class="card">
<div class="card-header">Public Key</div>
<div class="card-body scroll">
<pre><code>
Last Updated {{.Entity.SelfSignature.CreationTime}}
{{.Entity.ArmorText}}
</code></pre>
</div>
</div>
</div>
</div>
</div>
{{end}}
`
var homeMKDN = `
## About Keyproofs
KeyProofs is a server side version of Keyoxide. There is no JavaScript executed on this page and resourcesKeys are looked up via [Web key directory](https://datatracker.ietf.org/doc/draft-koch-openpgp-webkey-service/)
or from <https://keys.openpgp.org/>.
### Decentralized online identity proofs
- You decide which accounts are linked together
- You decide where this data is stored
- KeyProofs does not store your identity data on its servers
- KeyProofs merely verifies the identity proofs and displays them
### Empowering the internet citizen
- A verified identity proof proves ownership of an account and builds trust
- No bad actor can impersonate you as long as your accounts aren't compromised
- Your online identity data is safe from greedy internet corporations
### User-centric platform
- KeyProofs generates QR codes that integrate with OpenKeychain and Conversations
- KeyProofs fetches the key wherever the user decides to store it
- KeyProofs is self-hostable, meaning you could put it on any server you trust
### Secure and privacy-friendly
- KeyProofs doesn't want your personal data, track you or show you ads
- KeyProofs relies on OpenPGP, a widely used public-key cryptography standard (RFC-4880)
- Cryptographic operations are performed on server.
`