diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-11-08 19:44:21 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-11-08 19:44:21 -0800 |
commit | c8c4ae95a14e9b976a8bf0aa796e9c995ef071e7 (patch) | |
tree | dfcbe5085a4e59409fdbcecd5cf33f41a1a4d388 | |
parent | 559e8c8996ab86e254a8fe74f52ebede0ba2013e (diff) |
moving interface Mergable from api package to manager package. It avoids a cyclical import and also makes more sense logically as the management of content owns the scope of merging external to interal items
-rw-r--r-- | management/editor/editor.go | 4 | ||||
-rw-r--r-- | management/manager/manager.go | 9 | ||||
-rw-r--r-- | system/admin/handlers.go | 2 | ||||
-rw-r--r-- | system/api/external.go | 8 |
4 files changed, 12 insertions, 11 deletions
diff --git a/management/editor/editor.go b/management/editor/editor.go index fb60c99..25819e5 100644 --- a/management/editor/editor.go +++ b/management/editor/editor.go @@ -5,7 +5,7 @@ package editor import ( "bytes" - "github.com/bosssauce/ponzu/system/api" + "github.com/bosssauce/ponzu/management/manager" ) // Editable ensures data is editable @@ -109,7 +109,7 @@ func Form(post Editable, fields ...Field) ([]byte, error) { <button class="right waves-effect waves-light btn red delete-post" type="submit">Delete</button> </div> ` - m, ok := post.(api.Mergeable) + m, ok := post.(manager.Mergeable) if ok { submit += ` diff --git a/management/manager/manager.go b/management/manager/manager.go index 2830ba4..9a0ed19 100644 --- a/management/manager/manager.go +++ b/management/manager/manager.go @@ -4,10 +4,19 @@ import ( "bytes" "fmt" "html/template" + "net/http" "github.com/bosssauce/ponzu/management/editor" ) +// Mergeable allows external post content to be approved and published through +// the public-facing API +type Mergeable interface { + // Approve copies an external post to the internal collection and triggers + // a re-sort of its content type posts + Approve(req *http.Request) error +} + const managerHTML = ` <div class="card editor"> <form method="post" action="/admin/edit" enctype="multipart/form-data"> diff --git a/system/admin/handlers.go b/system/admin/handlers.go index a53ebd3..59f6874 100644 --- a/system/admin/handlers.go +++ b/system/admin/handlers.go @@ -837,7 +837,7 @@ func approvePostHandler(res http.ResponseWriter, req *http.Request) { } // check if we have a Mergeable - m, ok := post.(api.Mergeable) + m, ok := post.(manager.Mergeable) if !ok { log.Println("Content type", t, "must implement api.Mergable before it can bee approved.") res.WriteHeader(http.StatusBadRequest) diff --git a/system/api/external.go b/system/api/external.go index 7eade92..5c50172 100644 --- a/system/api/external.go +++ b/system/api/external.go @@ -19,14 +19,6 @@ type Externalable interface { Accepts() bool } -// Mergeable allows external post content to be approved and published through -// the public-facing API -type Mergeable interface { - // Approve copies an external post to the internal collection and triggers - // a re-sort of its content type posts - Approve(req *http.Request) error -} - func externalPostHandler(res http.ResponseWriter, req *http.Request) { if req.Method != http.MethodPost { res.WriteHeader(http.StatusMethodNotAllowed) |