summaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/admin/filesystem.go21
-rw-r--r--system/admin/handlers.go14
-rw-r--r--system/api/external.go2
-rw-r--r--system/db/content.go5
4 files changed, 26 insertions, 16 deletions
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
}
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 += `<ul class="posts row">`
b.Write([]byte(`</ul></div></div>`))
@@ -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 := `<li class="col s12">Error retreiving data. Your data type doesn't implement necessary interfaces.</li>`
+ post := `<li class="col s12">Error retreiving data. Your data type doesn't implement necessary interfaces. (editor.Sortable)</li>`
+ return []byte(post)
+ }
+
+ i, ok := e.(content.Identifiable)
+ if !ok {
+ log.Println("Content type", typeName, "doesn't implement content.Identifiable")
+ post := `<li class="col s12">Error retreiving data. Your data type doesn't implement necessary interfaces. (content.Identifiable)</li>`
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)
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
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