diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-11-03 00:54:13 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-11-03 00:54:13 -0700 |
commit | 9db0046fadcd703d9903c7abd4159ded0730bf3a (patch) | |
tree | 0ac3592b120e175372e3d78276d2cbf8bbf2bccd /management | |
parent | 607f29fd3e61df0b921178995eb12fdee5049f16 (diff) |
simplifying Editable interface by adding Sluggable and Identifiable interfaces, moving relevant interface methods to be implemented by other types and updating caller code to assert the new interface types as needed
Diffstat (limited to 'management')
-rw-r--r-- | management/editor/editor.go | 5 | ||||
-rw-r--r-- | management/manager/manager.go | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/management/editor/editor.go b/management/editor/editor.go index 2cfe1ea..f76197a 100644 --- a/management/editor/editor.go +++ b/management/editor/editor.go @@ -8,10 +8,7 @@ import ( // Editable ensures data is editable type Editable interface { - SetContentID(id int) - ContentID() int ContentName() string - SetSlug(slug string) Editor() *Editor MarshalEditor() ([]byte, error) } @@ -20,7 +17,7 @@ type Editable interface { type Sortable interface { Time() int64 Touch() int64 - ContentID() int + ItemID() int } // Editor is a view containing fields to manage content diff --git a/management/manager/manager.go b/management/manager/manager.go index c0c5519..2830ba4 100644 --- a/management/manager/manager.go +++ b/management/manager/manager.go @@ -112,11 +112,16 @@ type manager struct { func Manage(e editor.Editable, typeName string) ([]byte, error) { v, err := e.MarshalEditor() if err != nil { - return nil, fmt.Errorf("Couldn't marshal editor for content %T. %s", e, err.Error()) + return nil, fmt.Errorf("Couldn't marshal editor for content %s. %s", typeName, err.Error()) + } + + s, ok := e.(editor.Sortable) + if !ok { + return nil, fmt.Errorf("Content type %s does not implement content.Identifiable.", typeName) } m := manager{ - ID: e.ContentID(), + ID: s.ItemID(), Kind: typeName, Editor: template.HTML(v), } |