diff options
-rw-r--r-- | content/post.go | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/content/post.go b/content/post.go deleted file mode 100644 index b81bb5a..0000000 --- a/content/post.go +++ /dev/null @@ -1,83 +0,0 @@ -package content - -import ( - "fmt" - - "github.com/bosssauce/ponzu/management/editor" -) - -// Post is the generic content struct -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"` - Theme string `json:"theme"` -} - -// 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, - editor.Field{ - View: editor.Input("Title", p, map[string]string{ - "label": "Post Title", - "type": "text", - "placeholder": "Enter your Post Title here", - }), - }, - editor.Field{ - View: editor.Richtext("Content", p, map[string]string{ - "label": "Content", - "placeholder": "Add the content of your post here", - }), - }, - editor.Field{ - View: editor.File("Photo", p, map[string]string{ - "label": "Author Photo", - "placeholder": "Upload a profile picture for the author", - }), - }, - editor.Field{ - View: editor.Input("Author", p, map[string]string{ - "label": "Author", - "type": "text", - "placeholder": "Enter the author name here", - }), - }, - editor.Field{ - View: editor.Tags("Category", p, map[string]string{ - "label": "Post Categories", - }), - }, - editor.Field{ - View: editor.Select("Theme", p, map[string]string{ - "label": "Theme Style", - }, map[string]string{ - "dark": "Dark", - "light": "Light", - }), - }, - ) - - if err != nil { - return nil, fmt.Errorf("Failed to render Post editor view: %s", err.Error()) - } - - return view, nil -} - -func init() { - Types["Post"] = func() interface{} { return new(Post) } -} - -// ContentName is required to set the display name for a piece of content in the editor -// Partially implements editor.Editable -func (p *Post) ContentName() string { return p.Title } - -// Editor is a buffer of bytes for the Form function to write input views -// partially implements editor.Editable -func (p *Post) Editor() *editor.Editor { return &p.editor } |