From 556bec10bc70e33660c5c0801fe9452e226fabc8 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 28 Nov 2016 15:14:56 -0800 Subject: adding uuid dep and implementation for content.Item --- system/db/content.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'system') diff --git a/system/db/content.go b/system/db/content.go index b43d611..0cfadf4 100644 --- a/system/db/content.go +++ b/system/db/content.go @@ -16,6 +16,7 @@ import ( "github.com/boltdb/bolt" "github.com/gorilla/schema" + uuid "github.com/satori/go.uuid" ) // SetContent inserts or updates values in the database. @@ -107,6 +108,10 @@ func insert(ns string, data url.Values) (int, error) { } data.Set("id", cid) + // add UUID to data for use in embedded Item + uid := uuid.NewV4() + data.Set("uuid", uid.String()) + j, err := postToJSON(ns, data) if err != nil { return err -- cgit v1.2.3 From 52ab0d2a007de6357c504302a5bd92c7cca72b79 Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Mon, 28 Nov 2016 16:06:05 -0800 Subject: adding implementation / type assertion for Identifiable in old code --- system/admin/handlers.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'system') diff --git a/system/admin/handlers.go b/system/admin/handlers.go index 38ce41d..7b8bfae 100644 --- a/system/admin/handlers.go +++ b/system/admin/handlers.go @@ -908,7 +908,7 @@ func postsHandler(res http.ResponseWriter, req *http.Request) { b.Write(post) } } - + html += ``)) @@ -947,7 +947,14 @@ func adminPostListItem(e editor.Editable, typeName, status string) []byte { s, ok := e.(editor.Sortable) if !ok { log.Println("Content type", typeName, "doesn't implement editor.Sortable") - post := `
  • Error retreiving data. Your data type doesn't implement necessary interfaces.
  • ` + post := `
  • Error retreiving data. Your data type doesn't implement necessary interfaces. (editor.Sortable)
  • ` + return []byte(post) + } + + i, ok := e.(content.Identifiable) + if !ok { + log.Println("Content type", typeName, "doesn't implement content.Identifiable") + post := `
  • Error retreiving data. Your data type doesn't implement necessary interfaces. (content.Identifiable)
  • ` return []byte(post) } @@ -957,7 +964,7 @@ func adminPostListItem(e editor.Editable, typeName, status string) []byte { updatedTime := upTime.Format("01/02/06 03:04 PM") publishTime := tsTime.Format("01/02/06") - cid := fmt.Sprintf("%d", s.ItemID()) + cid := fmt.Sprintf("%d", i.ItemID()) switch status { case "public", "": @@ -1200,7 +1207,6 @@ func editHandler(res http.ResponseWriter, req *http.Request) { return } s.SetItemID(-1) - } m, err := manager.Manage(post.(editor.Editable), t) -- cgit v1.2.3 From 62d6f575ae1acd6b23be5cd2c774234834c8c9ea Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Tue, 29 Nov 2016 11:17:04 -0800 Subject: fmt code --- system/admin/filesystem.go | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'system') diff --git a/system/admin/filesystem.go b/system/admin/filesystem.go index 4e64a26..77c721e 100644 --- a/system/admin/filesystem.go +++ b/system/admin/filesystem.go @@ -1,13 +1,12 @@ package admin import ( - "net/http" + "net/http" "os" ) - func restrict(dir http.Dir) justFilesFilesystem { - return justFilesFilesystem{dir} + return justFilesFilesystem{dir} } // the code below removes the open directory listing when accessing a URL which @@ -16,21 +15,21 @@ func restrict(dir http.Dir) justFilesFilesystem { // credit: Brad Fitzpatrick (c) 2012 type justFilesFilesystem struct { - fs http.FileSystem + fs http.FileSystem } func (fs justFilesFilesystem) Open(name string) (http.File, error) { - f, err := fs.fs.Open(name) - if err != nil { - return nil, err - } - return neuteredReaddirFile{f}, nil + f, err := fs.fs.Open(name) + if err != nil { + return nil, err + } + return neuteredReaddirFile{f}, nil } type neuteredReaddirFile struct { - http.File + http.File } func (f neuteredReaddirFile) Readdir(count int) ([]os.FileInfo, error) { - return nil, nil + return nil, nil } -- cgit v1.2.3 From a756bba5197ddd5898bc49a41059f55f5372eded Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Tue, 29 Nov 2016 11:18:00 -0800 Subject: updating comment documentation for API endpoint renaming --- system/api/external.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/api/external.go b/system/api/external.go index 5c50172..4e008af 100644 --- a/system/api/external.go +++ b/system/api/external.go @@ -13,7 +13,7 @@ import ( ) // Externalable accepts or rejects external POST requests to endpoints such as: -// /external/posts?type=Review +// /external/content?type=Review type Externalable interface { // Accepts determines whether a type will allow external submissions Accepts() bool -- cgit v1.2.3