-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathtemplate.js
49 lines (45 loc) · 1.24 KB
/
template.js
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
var h = require("hyperscript")
var styleContent = [
"body {",
" padding: 50px;",
" font: 13px Helvetica, Arial, sans-serif;",
"}",
".error {",
" color: red;",
"}",
".success {",
" color: green;",
"}"
].join("\n")
module.exports = template
function template(opts) {
return layout("Authentication Example", [
h("h1", "Login"),
h("div", { innerHTML: opts.message }),
"Try accessing ",
h("a", { href: "/restricted" }, "/restricted"),
", then authenticate with tj and foobar",
h("form", { method: "post", action: "/login" }, [
h("p", [
h("label", "Username:"),
h("input", { type: "text", name: "username" })
]),
h("p", [
h("label", "Password:"),
h("input", { type: "text", name: "password" })
]),
h("p",
h("input", { type: "submit", value: "Login" }))
])
])
}
function layout(title, content) {
return "<!DOCTYPE html>" +
h("html",
h("head", [
h("title", title),
h("style", styleContent)
]),
h("body", content)
).outerHTML
}