blob: a4053ad244c27c23a7df8f169aa42ab8ba33fad6 (
plain)
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
|
// Package admin desrcibes the admin view containing references to
// various managers and editors
package admin
import (
"bytes"
"html/template"
"github.com/nilslice/cms/content"
)
const adminHTML = `<!doctype html>
<html>
<head>
<title>CMS</title>
<style type="text/css">
label {
display: block;
margin-top: 11px;
}
input {
display: block;
margin-bottom: 11px;
padding: 2px;
}
</style>
</head>
<body>
<h1><a href="/admin">CMS</a></h1>
<div class="types">
<ul>
{{ range $t, $f := .Types }}
<li><a href="/admin/posts?type={{ $t }}">{{ $t }}</a></li>
{{ end }}
</ul>
</div>
{{ if .Subview}}
<div class="manager">
{{ .Subview }}
</div>
{{ end }}
</body>
</html>`
type admin struct {
Types map[string]func() interface{}
Subview template.HTML
}
// Admin ...
func Admin(manager []byte) []byte {
a := admin{
Types: content.Types,
Subview: template.HTML(manager),
}
buf := &bytes.Buffer{}
tmpl := template.Must(template.New("admin").Parse(adminHTML))
tmpl.Execute(buf, a)
return buf.Bytes()
}
|