Browse Source

refactor /storage (I.E. get files) routes and /edit/archive/:slug.

I added a new route to get files from the /archive directory but
needed to expand on the original /storage/view/:slug route so I could
seperate out the two (/storage/media and /storage/archive)
directories.

I added a check to make sure the archive entry
requested (/edit/archive/:slug) exists and return a 404 if it doesn't.
stable
Craig Oates 2 years ago
parent
commit
8d55ed7d61
  1. 35
      src/web.lisp

35
src/web.lisp

@ -737,7 +737,7 @@
(progn (utils:set-alert "You are not authorised to delete page.")
(redirect "/login")))))))
(defroute ("/storage/view/:slug" :method :GET) (&key slug)
(defroute ("/storage/view/media/:slug" :method :GET) (&key slug)
(if (storage:file-exists-p "" "media" slug)
`(200 (:content-type
,(files::file-type-of
@ -745,7 +745,16 @@
,(storage:open-binary-file "" "media" slug))
(on-exception *web* 404)))
(defroute ("/storage/thumb/:slug" :method :GET) (&key slug)
(defroute ("/storage/thumb/archive/:slug" :method :GET) (&key slug)
(if (nera:get-archive-entry :slug slug)
(let ((archive-entry (nera:get-archive-entry :slug slug)))
(format t "[THUMBNAIL] ~A~%" (archive::thumbnail-file-type-of archive-entry))
`(200 (:content-type ,(archive::thumbnail-file-type-of archive-entry))
,(storage:open-binary-file
"" "archive" (archive::thumbnail-slug-of archive-entry))))
(on-exception *web* 404)))
(defroute ("/storage/thumb/page/:slug" :method :GET) (&key slug)
(if (storage:file-exists-p "" "media" slug)
`(200 (:content-type
,(files::file-type-of
@ -1029,6 +1038,8 @@
(redirect "/login")))))))
(defroute ("/edit/archive/:slug" :method :GET) (&key slug)
(if (nera:get-archive-entry :slug slug)
(progn
(hermetic:auth (:logged-in)
;; Authorised
(let ((alert (utils:get-and-reset-alert)))
@ -1043,16 +1054,24 @@
(progn
(utils:set-alert "You are not logged in.")
(redirect "/login"))))
(on-exception *web* 404)))
(defroute ("/rename/archive-entry" :method :POST)
(format nil "ROUTE NOT IMPLEMENTED"))
(defroute ("/edit/archive-thumbnail" :method :POST) ()
(utils:set-alert "ROUTE NOT IMPLEMENTED")
(redirect "/user/archive"))
(defroute ("/edit/archive" :method :POST)
(format nil "ROUTE NOT IMPLEMENTED"))
(defroute ("/rename/archive-entry" :method :POST) ()
(utils:set-alert "ROUTE NOT IMPLEMENTED")
(redirect "/user/archive"))
(defroute ("/edit/archive" :method :POST) ()
(utils:set-alert "ROUTE NOT IMPLEMENTED")
(redirect "/user/archive"))
(defroute ("/edit/archive-thumbnail" :method :POST)
(format nil "ROUTE NOT IMPLEMENTED"))
(defroute ("/edit/archive-thumbnail" :method :POST) ()
(utils:set-alert "ROUTE NOT IMPLEMENTED")
(redirect "/user/archive"))
(defroute ("/archive/delete/entry" :method :POST) ()
(destructuring-bind

Loading…
Cancel
Save