summaryrefslogtreecommitdiff
path: root/system/admin/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'system/admin/handlers.go')
-rw-r--r--system/admin/handlers.go55
1 files changed, 50 insertions, 5 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go
index 23c7e50..babcff1 100644
--- a/system/admin/handlers.go
+++ b/system/admin/handlers.go
@@ -13,6 +13,7 @@ import (
"time"
"github.com/ponzu-cms/ponzu/management/editor"
+ "github.com/ponzu-cms/ponzu/management/format"
"github.com/ponzu-cms/ponzu/management/manager"
"github.com/ponzu-cms/ponzu/system/addon"
"github.com/ponzu-cms/ponzu/system/admin/config"
@@ -1492,8 +1493,20 @@ func contentsHandler(res http.ResponseWriter, req *http.Request) {
</script>
`
- btn := `<div class="col s3"><a href="/admin/edit?type=` + t + `" class="btn new-post waves-effect waves-light">New ` + t + `</a></div></div>`
- html = html + b.String() + script + btn
+ btn := `<div class="col s3">
+ <a href="/admin/edit?type=` + t + `" class="btn new-post waves-effect waves-light">
+ New ` + t + `
+ </a>`
+
+ if _, ok := pt.(format.CSVFormattable); ok {
+ btn += `<br/>
+ <a href="/admin/contents/export?type=` + t + `&format=csv" class="green darken-4 btn export-post waves-effect waves-light">
+ <i class="material-icons left">system_update_alt</i>
+ CSV
+ </a>`
+ }
+
+ html += b.String() + script + btn + `</div></div>`
adminView, err := Admin([]byte(html))
if err != nil {
@@ -2422,7 +2435,15 @@ func searchHandler(res http.ResponseWriter, req *http.Request) {
posts := db.ContentAll(t + specifier)
b := &bytes.Buffer{}
- p := item.Types[t]().(editor.Editable)
+ pt, ok := item.Types[t]
+ if !ok {
+ res.WriteHeader(http.StatusBadRequest)
+ return
+ }
+
+ post := pt()
+
+ p := post.(editor.Editable)
html := `<div class="col s9 card">
<div class="card-content">
@@ -2499,8 +2520,32 @@ func searchHandler(res http.ResponseWriter, req *http.Request) {
return
}
- btn := `<div class="col s3"><a href="/admin/edit?type=` + t + `" class="btn new-post waves-effect waves-light">New ` + t + `</a></div></div>`
- html = html + b.String() + btn
+ script := `
+ <script>
+ $(function() {
+ var del = $('.quick-delete-post.__ponzu span');
+ del.on('click', function(e) {
+ if (confirm("[Ponzu] Please confirm:\n\nAre you sure you want to delete this post?\nThis cannot be undone.")) {
+ $(e.target).parent().submit();
+ }
+ });
+ });
+
+ // disable link from being clicked if parent is 'disabled'
+ $(function() {
+ $('ul.pagination li.disabled a').on('click', function(e) {
+ e.preventDefault();
+ });
+ });
+ </script>
+ `
+
+ btn := `<div class="col s3">
+ <a href="/admin/edit?type=` + t + `" class="btn new-post waves-effect waves-light">
+ New ` + t + `
+ </a>`
+
+ html += b.String() + script + btn + `</div></div>`
adminView, err := Admin([]byte(html))
if err != nil {