summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/post.go17
-rw-r--r--management/editor/elements.go12
2 files changed, 14 insertions, 15 deletions
diff --git a/content/post.go b/content/post.go
index 65ea88f..1dfb8fb 100644
--- a/content/post.go
+++ b/content/post.go
@@ -4,29 +4,28 @@ import (
"fmt"
"github.com/nilslice/cms/management/editor"
- "github.com/nilslice/cms/system/db"
)
// Post is the generic content struct
type Post struct {
- db.Item
+ Item
editor editor.Editor
- Title []byte `json:"title"`
- Content []byte `json:"content"`
- Author []byte `json:"author"`
- Timestamp []byte `json:"timestamp"`
+ Title string `json:"title"`
+ Content string `json:"content"`
+ Author string `json:"author"`
+ Timestamp string `json:"timestamp"`
}
func init() {
- Types["Post"] = Post{}
+ Types["Post"] = &Post{}
}
// ContentID partially implements editor.Editable
-func (p Post) ContentID() int { return p.ID }
+func (p *Post) ContentID() int { return p.ID }
// Editor partially implements editor.Editable
-func (p Post) Editor() *editor.Editor { return &p.editor }
+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) {
diff --git a/management/editor/elements.go b/management/editor/elements.go
index da63f39..7c1c429 100644
--- a/management/editor/elements.go
+++ b/management/editor/elements.go
@@ -30,7 +30,7 @@ type element struct {
Attrs map[string]string
Name string
label string
- data []byte
+ data string
viewBuf *bytes.Buffer
}
@@ -41,10 +41,10 @@ func domElementSelfClose(e *element) []byte {
e.viewBuf.Write([]byte(`<label>` + e.label + `</label>`))
}
e.viewBuf.Write([]byte(`<` + e.TagName + ` value="`))
- e.viewBuf.Write(append(e.data, []byte(`" `)...))
+ e.viewBuf.Write([]byte(e.data + `" `))
for attr, value := range e.Attrs {
- e.viewBuf.Write([]byte(attr + `="` + string(value) + `"`))
+ e.viewBuf.Write([]byte(attr + `="` + value + `" `))
}
e.viewBuf.Write([]byte(` name="` + e.Name + `"`))
e.viewBuf.Write([]byte(` />`))
@@ -60,7 +60,7 @@ func domElement(e *element) []byte {
e.viewBuf.Write([]byte(`<` + e.TagName + ` `))
for attr, value := range e.Attrs {
- e.viewBuf.Write([]byte(attr + `="` + string(value) + `"`))
+ e.viewBuf.Write([]byte(attr + `="` + string(value) + `" `))
}
e.viewBuf.Write([]byte(` name="` + e.Name + `"`))
e.viewBuf.Write([]byte(` >`))
@@ -85,10 +85,10 @@ func tagNameFromStructField(name string, post interface{}) string {
return tag
}
-func valueFromStructField(name string, post interface{}) []byte {
+func valueFromStructField(name string, post interface{}) string {
field := reflect.Indirect(reflect.ValueOf(post)).FieldByName(name)
- return field.Bytes()
+ return field.String()
}
func newElement(tagName, label, fieldName string, p interface{}, attrs map[string]string) *element {