|
|
|
@ -740,7 +740,7 @@
|
|
|
|
|
|
|
|
|
|
(defroute ("/storage/upload" :method :POST) () |
|
|
|
|
(destructuring-bind |
|
|
|
|
(&key storage-file authenticity-token &allow-other-keys) |
|
|
|
|
(&key file-name storage-file authenticity-token &allow-other-keys) |
|
|
|
|
(utils:request-params |
|
|
|
|
(lack.request:request-body-parameters ningle:*request*)) |
|
|
|
|
(if (not (string= authenticity-token (auth:csrf-token))) |
|
|
|
@ -751,12 +751,17 @@
|
|
|
|
|
(cond ((utils:string-is-nil-or-empty? (cadr storage-file)) |
|
|
|
|
(utils:set-alert "No file provided..") |
|
|
|
|
(redirect "/dashboard")) |
|
|
|
|
|
|
|
|
|
((not (null (nera:get-storage-file file-name))) |
|
|
|
|
(utils:set-alert "File with that name already exists. File not saved.") |
|
|
|
|
(redirect "/storage/manage")) |
|
|
|
|
|
|
|
|
|
(t (storage:store-file |
|
|
|
|
"" "media" |
|
|
|
|
(utils:slugify (second storage-file)) storage-file) |
|
|
|
|
(t (storage:store-file "" "media" file-name storage-file) |
|
|
|
|
(nera:add-storage-file file-name |
|
|
|
|
(utils:slugify file-name) |
|
|
|
|
(caddr storage-file)) |
|
|
|
|
(utils:set-alert "File uploaded.") |
|
|
|
|
(redirect "/dashboard"))) |
|
|
|
|
(redirect "/storage/manage"))) |
|
|
|
|
;; Not Authorised |
|
|
|
|
(progn |
|
|
|
|
(utils:set-alert "You are not authorised to view this page.") |
|
|
|
@ -778,14 +783,17 @@
|
|
|
|
|
;; Authorised |
|
|
|
|
(cond ((utils:string-is-nil-or-empty? (caddr (car files))) |
|
|
|
|
(utils:set-alert "No files provided.") |
|
|
|
|
(redirect "/dashboard")) |
|
|
|
|
(redirect "/storage/manage")) |
|
|
|
|
|
|
|
|
|
(t (loop :for item :in files :do |
|
|
|
|
;; TODO: ADD FILES TO DATABASE (IMAGE-TYPE FILE NAME ETC.) |
|
|
|
|
(storage:store-file |
|
|
|
|
"" "media" |
|
|
|
|
(utils:slugify (caddr item)) (cdr item))) |
|
|
|
|
(utils:set-alert "File uploaded.") |
|
|
|
|
(redirect "/dashboard"))) |
|
|
|
|
(utils:slugify (caddr item)) (cdr item)) |
|
|
|
|
(nera:add-storage-file (caddr item) |
|
|
|
|
(utils:slugify (caddr item)) |
|
|
|
|
(cadddr item))) |
|
|
|
|
(utils:set-alert "Multi-File upload complete.") |
|
|
|
|
(redirect "/storage/manage"))) |
|
|
|
|
;; Not Authorised |
|
|
|
|
(progn |
|
|
|
|
(utils:set-alert "You are not authorised to view this page.") |
|
|
|
@ -799,9 +807,7 @@
|
|
|
|
|
(render #P"/user/storage.html" |
|
|
|
|
(append (auth:auth-user-data) |
|
|
|
|
`(:alert ,alert |
|
|
|
|
:files ,(storage:get-file-names |
|
|
|
|
(storage:get-files-in-directory |
|
|
|
|
"" "media")) |
|
|
|
|
:files ,(nera:get-all-storage-files) |
|
|
|
|
:system-data ,(nera:system-data))))) |
|
|
|
|
;; Not Authorised |
|
|
|
|
(progn (utils:set-alert "You are not logged in.") |
|
|
|
|