summaryrefslogtreecommitdiff
path: root/system/admin
diff options
context:
space:
mode:
Diffstat (limited to 'system/admin')
-rw-r--r--system/admin/handlers.go31
-rw-r--r--system/admin/server.go1
-rw-r--r--system/admin/static/dashboard/css/admin.css4
3 files changed, 36 insertions, 0 deletions
diff --git a/system/admin/handlers.go b/system/admin/handlers.go
index 2be8d8e..d492335 100644
--- a/system/admin/handlers.go
+++ b/system/admin/handlers.go
@@ -513,6 +513,37 @@ func editHandler(res http.ResponseWriter, req *http.Request) {
}
}
+func deleteHandler(res http.ResponseWriter, req *http.Request) {
+ if req.Method != http.MethodPost {
+ res.WriteHeader(http.StatusMethodNotAllowed)
+ return
+ }
+
+ err := req.ParseMultipartForm(1024 * 1024 * 4) // maxMemory 4MB
+ if err != nil {
+ res.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+
+ id := req.FormValue("id")
+ t := req.FormValue("type")
+
+ if id == "" || t == "" {
+ res.WriteHeader(http.StatusBadRequest)
+ return
+ }
+
+ err = db.DeleteContent(t + ":" + id)
+ if err != nil {
+ res.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+
+ redir := strings.TrimSuffix(req.URL.Scheme+req.URL.Host+req.URL.Path, "/edit/delete")
+ redir = redir + "/posts?type=" + t
+ http.Redirect(res, req, redir, http.StatusFound)
+}
+
func editUploadHandler(res http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodPost {
res.WriteHeader(http.StatusMethodNotAllowed)
diff --git a/system/admin/server.go b/system/admin/server.go
index 6f4a96e..b3b128d 100644
--- a/system/admin/server.go
+++ b/system/admin/server.go
@@ -25,6 +25,7 @@ func Run() {
http.HandleFunc("/admin/posts/search", user.Auth(searchHandler))
http.HandleFunc("/admin/edit", user.Auth(editHandler))
+ http.HandleFunc("/admin/edit/delete", user.Auth(deleteHandler))
http.HandleFunc("/admin/edit/upload", user.Auth(editUploadHandler))
pwd, err := os.Getwd()
diff --git a/system/admin/static/dashboard/css/admin.css b/system/admin/static/dashboard/css/admin.css
index 888dbf1..7da4154 100644
--- a/system/admin/static/dashboard/css/admin.css
+++ b/system/admin/static/dashboard/css/admin.css
@@ -154,6 +154,10 @@ footer p {
color: #9e9e9e;
}
+.post-controls .save-post {
+ margin-left: 10px;
+}
+
/* OVERRIDE Bootstrap + Materialize conflicts */
.iso-texteditor.input-field label {