summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2016-09-22 17:47:14 -0700
committerSteve Manuel <nilslice@gmail.com>2016-09-22 17:47:14 -0700
commit27c175f6c626175598ee0a3d5c7b750a84d583e2 (patch)
tree563cd0451d81464afb1269d7f703ddb8e4d9d9f0 /content
parentf31c13d76e5de8ab0420ecaf0f570e52f6218066 (diff)
adding a generator for custom post content types, slug for url based on title, main file to manage commands
Diffstat (limited to 'content')
-rw-r--r--content/item.go4
-rw-r--r--content/post.go16
2 files changed, 17 insertions, 3 deletions
diff --git a/content/item.go b/content/item.go
index 8b834e4..08d6359 100644
--- a/content/item.go
+++ b/content/item.go
@@ -1,7 +1,7 @@
package content
// Item should only be embedded into content type structs.
-// Helper for DB-related actions
type Item struct {
- ID int `json:"id"`
+ ID int `json:"id"`
+ Slug string `json:"slug"`
}
diff --git a/content/post.go b/content/post.go
index 4690f41..b12eb1d 100644
--- a/content/post.go
+++ b/content/post.go
@@ -21,18 +21,32 @@ 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.New(p,
+ view, err := editor.Form(p,
+ editor.Field{
+ View: editor.Input("Slug", p, map[string]string{
+ "label": "URL Path",
+ "type": "text",
+ "disabled": "true",
+ "placeholder": "Will be set automatically",
+ }),
+ },
editor.Field{
View: editor.Input("Title", p, map[string]string{
"label": "Post Title",