diff options
Diffstat (limited to 'system/admin/admin.go')
-rw-r--r-- | system/admin/admin.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/system/admin/admin.go b/system/admin/admin.go new file mode 100644 index 0000000..bbc34cf --- /dev/null +++ b/system/admin/admin.go @@ -0,0 +1,51 @@ +// 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> + </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() +} |