diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/admin/config/config.go | 9 | ||||
-rw-r--r-- | system/admin/handlers.go | 20 | ||||
-rw-r--r-- | system/db/content.go | 2 |
3 files changed, 14 insertions, 17 deletions
diff --git a/system/admin/config/config.go b/system/admin/config/config.go index 66f767d..ba8ffb3 100644 --- a/system/admin/config/config.go +++ b/system/admin/config/config.go @@ -18,18 +18,9 @@ type Config struct { CacheInvalidate []string `json:"-"` } -// SetContentID partially implements editor.Editable -func (c *Config) SetContentID(id int) { c.ID = id } - -// ContentID partially implements editor.Editable -func (c *Config) ContentID() int { return c.ID } - // ContentName partially implements editor.Editable func (c *Config) ContentName() string { return c.Name } -// SetSlug partially implements editor.Editable -func (c *Config) SetSlug(slug string) { c.Slug = slug } - // Editor partially implements editor.Editable func (c *Config) Editor() *editor.Editor { return &c.editor } diff --git a/system/admin/handlers.go b/system/admin/handlers.go index 12750e2..18faec9 100644 --- a/system/admin/handlers.go +++ b/system/admin/handlers.go @@ -752,10 +752,10 @@ func postsHandler(res http.ResponseWriter, req *http.Request) { // adminPostListItem is a helper to create the li containing a post. // p is the asserted post as an Editable, t is the Type of the post. // specifier is passed to append a name to a namespace like _pending -func adminPostListItem(p editor.Editable, t, status string) []byte { - s, ok := p.(editor.Sortable) +func adminPostListItem(e editor.Editable, typeName, status string) []byte { + s, ok := e.(editor.Sortable) if !ok { - log.Println("Content type", t, "doesn't implement editor.Sortable") + log.Println("Content type", typeName, "doesn't implement editor.Sortable") post := `<li class="col s12">Error retreiving data. Your data type doesn't implement necessary interfaces.</li>` return []byte(post) } @@ -766,7 +766,7 @@ func adminPostListItem(p editor.Editable, t, status string) []byte { updatedTime := upTime.Format("01/02/06 03:04 PM") publishTime := tsTime.Format("01/02/06") - cid := fmt.Sprintf("%d", p.ContentID()) + cid := fmt.Sprintf("%d", s.ItemID()) switch status { case "public", "": @@ -777,14 +777,14 @@ func adminPostListItem(p editor.Editable, t, status string) []byte { post := ` <li class="col s12"> - <a href="/admin/edit?type=` + t + `&status=` + strings.TrimPrefix(status, "_") + `&id=` + cid + `">` + p.ContentName() + `</a> + <a href="/admin/edit?type=` + typeName + `&status=` + strings.TrimPrefix(status, "_") + `&id=` + cid + `">` + e.ContentName() + `</a> <span class="post-detail">Updated: ` + updatedTime + `</span> <span class="publish-date right">` + publishTime + `</span> <form enctype="multipart/form-data" class="quick-delete-post __ponzu right" action="/admin/edit/delete" method="post"> <span>Delete</span> <input type="hidden" name="id" value="` + cid + `" /> - <input type="hidden" name="type" value="` + t + status + `" /> + <input type="hidden" name="type" value="` + typeName + status + `" /> </form> </li>` @@ -940,7 +940,13 @@ func editHandler(res http.ResponseWriter, req *http.Request) { return } } else { - post.(editor.Editable).SetContentID(-1) + s, ok := post.(content.Identifiable) + if !ok { + log.Println("Content type", typeName, "doesn't implement editor.Sortable") + return + } + s.SetContentID(-1) + } m, err := manager.Manage(post.(editor.Editable), t) diff --git a/system/db/content.go b/system/db/content.go index cfbd4ef..b43d611 100644 --- a/system/db/content.go +++ b/system/db/content.go @@ -381,7 +381,7 @@ func postToJSON(ns string, data url.Values) ([]byte, error) { if err != nil { return nil, err } - post.(editor.Editable).SetSlug(slug) + post.(content.Sluggable).SetSlug(slug) // marshall content struct to json for db storage j, err := json.Marshal(post) |