diff --git a/src/web.lisp b/src/web.lisp index 2493b5a..59ae56d 100644 --- a/src/web.lisp +++ b/src/web.lisp @@ -738,6 +738,15 @@ (progn (utils:set-alert "You are not authorised to delete page.") (redirect "/login"))))))) +;; TODO: Add condition branches for file-type. +;; This is working but I could do with adding content-types for images +;; and text so the browser doesn't always down the asset/media/file. +(defroute ("/storage/view/:slug" :method :GET) (&key slug) + (if (storage:file-exists-p "" "media" slug) + `(200 (:content-type "octet/stream") + ,(storage:open-binary-file "" "media" slug)) + (on-exception *web* 404))) + (defroute ("/storage/manage" :method :GET) () (hermetic:auth (:logged-in) ;; Authorised @@ -843,7 +852,6 @@ (utils:set-alert "You are not authorised to view this page.") (redirect "/login")))))) -;; TODO: FINISH WORKING ON /STORAGE/DELETE DEFROUTE -- NEED TO TEST IT. (defroute ("/storage/delete/:slug" :method :POST) (&key slug) (destructuring-bind (&key authenticity-token &allow-other-keys) diff --git a/templates/user/storage.html b/templates/user/storage.html index 07f2117..a80f19c 100644 --- a/templates/user/storage.html +++ b/templates/user/storage.html @@ -26,7 +26,9 @@ {% for item in files %}

- + + + {{item.name}} {% if roles.administrator %}

@@ -42,5 +44,4 @@

{% endfor %} - {% endblock %}