diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-11-28 15:14:56 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-11-28 15:14:56 -0800 |
commit | 556bec10bc70e33660c5c0801fe9452e226fabc8 (patch) | |
tree | 948a0498a21524deba4dc73b1aa2d3cc91a3bbf9 | |
parent | 553235a85fd013ae91173f15ec74503347573cd6 (diff) |
adding uuid dep and implementation for content.Item
-rw-r--r-- | cmd/ponzu/vendor/github.com/boltdb/bolt/bolt_windows.go | 2 | ||||
m--------- | cmd/ponzu/vendor/github.com/satori/go.uuid | 0 | ||||
-rw-r--r-- | content/item.go | 18 | ||||
-rw-r--r-- | system/db/content.go | 5 |
4 files changed, 17 insertions, 8 deletions
diff --git a/cmd/ponzu/vendor/github.com/boltdb/bolt/bolt_windows.go b/cmd/ponzu/vendor/github.com/boltdb/bolt/bolt_windows.go index d538e6a..b00fb07 100644 --- a/cmd/ponzu/vendor/github.com/boltdb/bolt/bolt_windows.go +++ b/cmd/ponzu/vendor/github.com/boltdb/bolt/bolt_windows.go @@ -89,7 +89,7 @@ func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) erro func funlock(db *DB) error { err := unlockFileEx(syscall.Handle(db.lockfile.Fd()), 0, 1, 0, &syscall.Overlapped{}) db.lockfile.Close() - os.Remove(db.path+lockExt) + os.Remove(db.path + lockExt) return err } diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid b/cmd/ponzu/vendor/github.com/satori/go.uuid new file mode 160000 +Subproject b061729afc07e77a8aa4fad0a2fd840958f1942 diff --git a/content/item.go b/content/item.go index c847ed7..4583c07 100644 --- a/content/item.go +++ b/content/item.go @@ -1,6 +1,10 @@ package content -import "net/http" +import ( + "net/http" + + uuid "github.com/satori/go.uuid" +) // Sluggable makes a struct locatable by URL with it's own path // As an Item implementing Sluggable, slugs may overlap. If this is an issue, @@ -35,13 +39,13 @@ type Hookable interface { AfterReject(req *http.Request) error } - // Item should only be embedded into content type structs. type Item struct { - ID int `json:"id"` - Slug string `json:"slug"` - Timestamp int64 `json:"timestamp"` - Updated int64 `json:"updated"` + UUID uuid.UUID `json:"uuid"` + ID int `json:"id"` + Slug string `json:"slug"` + Timestamp int64 `json:"timestamp"` + Updated int64 `json:"updated"` } // Time partially implements the Sortable interface @@ -107,4 +111,4 @@ func (i Item) BeforeReject(req *http.Request) error { // AfterReject is a no-op to ensure structs which embed Item implement Hookable func (i Item) AfterReject(req *http.Request) error { return nil -}
\ No newline at end of file +} 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 |