|
|
|
@ -1030,7 +1030,8 @@
|
|
|
|
|
(defroute ("/edit/archive/:slug" :method :GET) (&key slug) |
|
|
|
|
(if (nera:get-archive-entry :slug slug) |
|
|
|
|
(progn |
|
|
|
|
(hermetic:auth (:logged-in) |
|
|
|
|
(hermetic:auth |
|
|
|
|
(:logged-in) |
|
|
|
|
;; Authorised |
|
|
|
|
(let ((alert (utils:get-and-reset-alert))) |
|
|
|
|
(render "/user/edit-archive.html" |
|
|
|
@ -1038,8 +1039,7 @@
|
|
|
|
|
`(:alert ,alert |
|
|
|
|
:system-data ,(nera:system-data) |
|
|
|
|
:db-data ,(nera:get-archive-entry :slug slug) |
|
|
|
|
:data ,(storage:open-text-file |
|
|
|
|
"" "archive" slug))))) |
|
|
|
|
:data ,(storage:open-text-file "" "archive" slug))))) |
|
|
|
|
;; Not Authorised |
|
|
|
|
(progn |
|
|
|
|
(utils:set-alert "You are not logged in.") |
|
|
|
@ -1047,19 +1047,53 @@
|
|
|
|
|
(on-exception *web* 404))) |
|
|
|
|
|
|
|
|
|
(defroute ("/edit/archive-thumbnail" :method :POST) () |
|
|
|
|
(utils:set-alert "ROUTE NOT IMPLEMENTED") |
|
|
|
|
(destructuring-bind |
|
|
|
|
(&key archive-slug thumbnail-file authenticity-token &allow-other-keys) |
|
|
|
|
(utils:request-params (lack.request:request-body-parameters ningle:*request*)) |
|
|
|
|
(cond ((not (string= authenticity-token (auth:csrf-token))) |
|
|
|
|
`(,+forbidden+ (:content-type "text/plain") ("Denied"))) |
|
|
|
|
(t (hermetic:auth |
|
|
|
|
(:administrator) |
|
|
|
|
;; Authorised |
|
|
|
|
(cond ((utils:string-is-nil-or-empty? archive-slug) |
|
|
|
|
(utils:set-alert "No archive slug provided. Thumbnail not updated.") |
|
|
|
|
(redirect "/user/archive")) |
|
|
|
|
|
|
|
|
|
(defroute ("/rename/archive-entry" :method :POST) () |
|
|
|
|
(utils:set-alert "ROUTE NOT IMPLEMENTED") |
|
|
|
|
((null (nera:get-archive-entry :slug archive-slug)) |
|
|
|
|
(utils:set-alert "Cannot file thumbnail's archive entry. Nothing updated.") |
|
|
|
|
(redirect "/user/archive")) |
|
|
|
|
|
|
|
|
|
(defroute ("/edit/archive" :method :POST) () |
|
|
|
|
((not (str:contains? "image" (caddr thumbnail-file) :ignore-case t)) |
|
|
|
|
(utils:set-alert "File uploaded is not an image. Thumbnail not updated.") |
|
|
|
|
(redirect (format nil "/edit/archive/~a" archive-slug))) |
|
|
|
|
|
|
|
|
|
(t (utils:set-alert "Thumbnail updated.") |
|
|
|
|
(storage:store-file |
|
|
|
|
"" |
|
|
|
|
"archive" |
|
|
|
|
(archive::thumbnail-slug-of |
|
|
|
|
(nera:get-archive-entry :slug archive-slug)) |
|
|
|
|
thumbnail-file) |
|
|
|
|
(nera:update-archive-entry-property |
|
|
|
|
:slug archive-slug |
|
|
|
|
:property 'archive::thumbnail-file-type-of |
|
|
|
|
:value (caddr thumbnail-file)) |
|
|
|
|
(utils:create-thumbnail |
|
|
|
|
"archive" |
|
|
|
|
(archive::thumbnail-slug-of |
|
|
|
|
(nera:get-archive-entry :slug archive-slug)) |
|
|
|
|
t) |
|
|
|
|
;; Integrate updating Meilisearch here. |
|
|
|
|
(redirect (format nil "/edit/archive/~a" archive-slug)))) |
|
|
|
|
;; Not Authorised |
|
|
|
|
(progn (utils:set-alert "You are not authorised to delete this archive entry.") |
|
|
|
|
(redirect "/login"))))))) |
|
|
|
|
|
|
|
|
|
(defroute ("/rename/archive-entry" :method :POST) () |
|
|
|
|
(utils:set-alert "ROUTE NOT IMPLEMENTED") |
|
|
|
|
(redirect "/user/archive")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defroute ("/edit/archive-thumbnail" :method :POST) () |
|
|
|
|
(defroute ("/edit/archive" :method :POST) () |
|
|
|
|
(utils:set-alert "ROUTE NOT IMPLEMENTED") |
|
|
|
|
(redirect "/user/archive")) |
|
|
|
|
|
|
|
|
|