diff options
Diffstat (limited to 'content/post.go')
-rw-r--r-- | content/post.go | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/content/post.go b/content/post.go index 7dc99c1..dcdfeff 100644 --- a/content/post.go +++ b/content/post.go @@ -11,33 +11,14 @@ type Post struct { Item editor editor.Editor - Title string `json:"title"` - Content string `json:"content"` - Photo string `json:"photo"` - Author string `json:"author"` - Category []string `json:"category"` - ThemeStyle string `json:"theme"` + Title string `json:"title"` + Content string `json:"content"` + Photo string `json:"photo"` + Author string `json:"author"` + Category []string `json:"category"` + Theme string `json:"theme"` } -func init() { - Types["Post"] = func() interface{} { return new(Post) } -} - -// SetContentID partially implements editor.Editable -func (p *Post) SetContentID(id int) { p.ID = id } - -// ContentID partially implements editor.Editable -func (p *Post) ContentID() int { return p.ID } - -// ContentName partially implements editor.Editable -func (p *Post) ContentName() string { return p.Title } - -// SetSlug partially implements editor.Editable -func (p *Post) SetSlug(slug string) { p.Slug = slug } - -// Editor partially implements editor.Editable -func (p *Post) Editor() *editor.Editor { return &p.editor } - // MarshalEditor writes a buffer of html to edit a Post and partially implements editor.Editable func (p *Post) MarshalEditor() ([]byte, error) { view, err := editor.Form(p, @@ -55,7 +36,7 @@ func (p *Post) MarshalEditor() ([]byte, error) { }), }, editor.Field{ - View: editor.File("Picture", p, map[string]string{ + View: editor.File("Photo", p, map[string]string{ "label": "Author Photo", "placeholder": "Upload a profile picture for the author", }), @@ -68,16 +49,12 @@ 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", + View: editor.Tags("Category", p, map[string]string{ + "label": "Post Categories", }), }, editor.Field{ - View: editor.Select("ThemeStyle", p, map[string]string{ + View: editor.Select("Theme", p, map[string]string{ "label": "Theme Style", }, map[string]string{ "dark": "Dark", @@ -92,3 +69,22 @@ func (p *Post) MarshalEditor() ([]byte, error) { return view, nil } + +func init() { + Types["Post"] = func() interface{} { return new(Post) } +} + +// SetContentID partially implements editor.Editable +func (p *Post) SetContentID(id int) { p.ID = id } + +// ContentID partially implements editor.Editable +func (p *Post) ContentID() int { return p.ID } + +// ContentName partially implements editor.Editable +func (p *Post) ContentName() string { return p.Title } + +// SetSlug partially implements editor.Editable +func (p *Post) SetSlug(slug string) { p.Slug = slug } + +// Editor partially implements editor.Editable +func (p *Post) Editor() *editor.Editor { return &p.editor } |