From f0eeb90641a85f30ea364a506fa548ac3b24fd09 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Tue, 8 Nov 2016 19:49:08 -0800 Subject: moving Mergable interface to content package. Still hit cyclical import issue, still makes sense to have in content --- content/types.go | 10 ++++++++++ management/editor/editor.go | 4 ++-- management/manager/manager.go | 9 --------- system/admin/handlers.go | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/content/types.go b/content/types.go index ede2b58..f3b8bb3 100644 --- a/content/types.go +++ b/content/types.go @@ -1,5 +1,7 @@ package content +import "net/http" + const ( // ErrTypeNotRegistered means content type isn't registered (not found in Types map) ErrTypeNotRegistered = `Error: @@ -16,6 +18,14 @@ func init() { ` ) +// 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 +} + // Types is a map used to reference a type name to its actual Editable type // mainly for lookups in /admin route based utilities var Types = make(map[string]func() interface{}) diff --git a/management/editor/editor.go b/management/editor/editor.go index 25819e5..a591804 100644 --- a/management/editor/editor.go +++ b/management/editor/editor.go @@ -5,7 +5,7 @@ package editor import ( "bytes" - "github.com/bosssauce/ponzu/management/manager" + "github.com/bosssauce/ponzu/content" ) // Editable ensures data is editable @@ -109,7 +109,7 @@ func Form(post Editable, fields ...Field) ([]byte, error) { ` - m, ok := post.(manager.Mergeable) + m, ok := post.(content.Mergeable) if ok { submit += ` diff --git a/management/manager/manager.go b/management/manager/manager.go index 9a0ed19..2830ba4 100644 --- a/management/manager/manager.go +++ b/management/manager/manager.go @@ -4,19 +4,10 @@ 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 = `
diff --git a/system/admin/handlers.go b/system/admin/handlers.go index 59f6874..fe04601 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.(manager.Mergeable) + m, ok := post.(content.Mergeable) if !ok { log.Println("Content type", t, "must implement api.Mergable before it can bee approved.") res.WriteHeader(http.StatusBadRequest) -- cgit v1.2.3