diff options
-rw-r--r-- | cmd/cms/options.go | 34 | ||||
-rw-r--r-- | content/post.go | 27 |
2 files changed, 48 insertions, 13 deletions
diff --git a/cmd/cms/options.go b/cmd/cms/options.go index 3b6db8c..a1843b3 100644 --- a/cmd/cms/options.go +++ b/cmd/cms/options.go @@ -65,13 +65,13 @@ type {{ .name }} struct { Item editor editor.Editor -/* - // all your custom fields must have json tags! - Title string ` + "`json:" + `"title"` + "`" + ` - Content string ` + "`json:" + `"content"` + "`" + ` - Author string ` + "`json:" + `"author"` + "`" + ` - Timestamp string ` + "`json:" + `"timestamp"` + "`" + ` -*/ + // required: all maintained {{ .name }} fields must have json tags! + Title string ` + "`json:" + `"title"` + "`" + ` + Content string ` + "`json:" + `"content"` + "`" + ` + Author string ` + "`json:" + `"author"` + "`" + ` + Category []string ` + "`json:" + `"category"` + "`" + ` + ThemeStyle string ` + "`json:" + `"theme"` + "`" + ` + Timestamp string ` + "`json:" + `"timestamp"` + "`" + ` } func init() { @@ -95,7 +95,7 @@ func ({{ .initial }} *{{ .name }}) Editor() *editor.Editor { return &{{ .initial // MarshalEditor writes a buffer of html to edit a {{ .name }} and partially implements editor.Editable func ({{ .initial }} *{{ .name }}) MarshalEditor() ([]byte, error) { -/* EXAMPLE CODE (from post.go, the default content type) +/* EXAMPLE CODE (from post.go, the default content type) */ view, err := editor.Form({{ .initial }}, editor.Field{ // Take careful note that the first argument to these Input-like methods @@ -129,6 +129,23 @@ func ({{ .initial }} *{{ .name }}) MarshalEditor() ([]byte, error) { }), }, editor.Field{ + View: editor.Checkbox("Category", {{ .initial }}, map[string]string{ + "label": "{{ .name }} Category", + }, map[string]string{ + "important": "Important", + "active": "Active", + "unplanned": "Unplanned", + }), + }, + editor.Field{ + View: editor.Select("ThemeStyle", {{ .initial }}, map[string]string{ + "label": "Theme Style", + }, map[string]string{ + "dark": "Dark", + "light": "Light", + }), + }, + editor.Field{ View: editor.Input("Timestamp", {{ .initial }}, map[string]string{ "label": "Publish Date", "type": "date", @@ -141,7 +158,6 @@ func ({{ .initial }} *{{ .name }}) MarshalEditor() ([]byte, error) { } return view, nil -*/ } ` diff --git a/content/post.go b/content/post.go index b12eb1d..5b98253 100644 --- a/content/post.go +++ b/content/post.go @@ -11,10 +11,12 @@ type Post struct { Item editor editor.Editor - Title string `json:"title"` - Content string `json:"content"` - Author string `json:"author"` - Timestamp string `json:"timestamp"` + Title string `json:"title"` + Content string `json:"content"` + Author string `json:"author"` + Category []string `json:"category"` + ThemeStyle string `json:"theme"` + Timestamp string `json:"timestamp"` } func init() { @@ -68,6 +70,23 @@ func (p *Post) MarshalEditor() ([]byte, error) { }), }, editor.Field{ + View: editor.Checkbox("Category", p, map[string]string{ + "label": "Post Category", + }, map[string]string{ + "important": "Important", + "active": "Active", + "unplanned": "Unplanned", + }), + }, + editor.Field{ + View: editor.Select("ThemeStyle", p, map[string]string{ + "label": "Theme Style", + }, map[string]string{ + "dark": "Dark", + "light": "Light", + }), + }, + editor.Field{ View: editor.Input("Timestamp", p, map[string]string{ "label": "Publish Date", "type": "date", |