From c0ba07669d8403f428ec250e3f3da74844c6c587 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Thu, 6 Oct 2016 03:14:10 -0700 Subject: adding authentication & token-based persistence for users, init setup for first-use, pulling out some handlers into separate file for readability and navigation --- system/admin/config/config.go | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 system/admin/config/config.go (limited to 'system/admin/config') diff --git a/system/admin/config/config.go b/system/admin/config/config.go new file mode 100644 index 0000000..791510e --- /dev/null +++ b/system/admin/config/config.go @@ -0,0 +1,89 @@ +package config + +import ( + "github.com/nilslice/cms/content" + "github.com/nilslice/cms/management/editor" +) + +//Config represents the confirgurable options of the system +type Config struct { + content.Item + editor editor.Editor + + Name string `json:"name"` + Domain string `json:"domain"` + ClientSecret string `json:"client_secret"` +} + +// SetContentID partially implements editor.Editable +func (c *Config) SetContentID(id int) { c.ID = id } + +// ContentID partially implements editor.Editable +func (c *Config) ContentID() int { return c.ID } + +// ContentName partially implements editor.Editable +func (c *Config) ContentName() string { return c.Name } + +// SetSlug partially implements editor.Editable +func (c *Config) SetSlug(slug string) { c.Slug = slug } + +// Editor partially implements editor.Editable +func (c *Config) Editor() *editor.Editor { return &c.editor } + +// MarshalEditor writes a buffer of html to edit a Post and partially implements editor.Editable +func (c *Config) MarshalEditor() ([]byte, error) { + view, err := editor.Form(c, + editor.Field{ + View: editor.Input("Name", c, map[string]string{ + "label": "Site Name", + "placeholder": "Add a name to this site (internal use only)", + }), + }, + editor.Field{ + View: editor.Input("Domain", c, map[string]string{ + "label": "Domain Name (required for SSL certificate)", + "placeholder": "e.g. www.example.com or example.com", + }), + }, + editor.Field{ + View: editor.Input("ClientSecret", c, map[string]string{ + "label": "Client Secret (used to validate requests)", + "disabled": "true", + }), + }, + ) + if err != nil { + return nil, err + } + + open := []byte(`
`) + close := []byte(`
`) + script := []byte(` + + `) + + view = append(open, view...) + view = append(view, close...) + view = append(view, script...) + + return view, nil +} -- cgit v1.2.3