From 4647323fdaf3569ebe51210c2b2557e7e0fe63f3 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Fri, 30 Sep 2022 08:37:05 +0100 Subject: [PATCH] add storage, pages and archive entries to dashboard.html template. The route in web.lisp calls the recently created 'get latest' functions in the nera package. The code is web should be fine but the dashboard.html stuff is buggy and so is the back-end routes for uploading deleting file in the /storage section of the website. This is an end-of-session commit, though, so the bugs will have to be fixed at a later time. --- src/web.lisp | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/web.lisp b/src/web.lisp index 0bb7c3a..e4ee05a 100644 --- a/src/web.lisp +++ b/src/web.lisp @@ -183,6 +183,11 @@ (render #P"user/dashboard.html" (append (auth:auth-user-data) `(:alert ,alert + :storage-files + ,(nera:latest-storage-editted-files 10 t) + :pages ,(nera:latest-editted-pages 10 t) + :archive-entries + ,(nera::latest-archive-editted-entries 10 t) :system-data ,(nera:system-data))))) ;; Not Authorised (progn (utils:set-alert "You are not logged in.") @@ -865,31 +870,13 @@ (t (hermetic:auth (:administrator) ;; Authorised - (cond ((and (null (storage:file-exists-p "" "media" slug)) - (null (nera:get-storage-file :slug slug))) + (cond ((null (nera:get-storage-file :slug slug)) (utils:set-alert "Unable to find file. Nothing deleted.") (redirect "/storage/manage")) - - ((and (not (null (storage:file-exists-p "" "media" slug))) - (null (nera:get-storage-file :slug slug))) - (utils:set-alert "Unable to find entry in database. Deleted file from system.") - (storage:remove-file "" "media" slug) - ;; Delete thumbnail if there is one (for image files only) - (when (storage:file-exists-p - "" "media" (format nil "thumbnail-~a" slug)) - (storage:remove-file - "" "media" (format nil "thumbnail-~a" slug))) - (redirect "/storage/manage")) - - ((and (null (storage:file-exists-p "" "media" slug)) - (not (null (nera:get-storage-file :slug slug)))) - (utils:set-alert "Unable to find file. Deleted entry from database.") - (nera:delete-storage-file :slug slug) - (redirect "/storage/manage")) (t (storage:remove-file - "" ; `USERNAME' blank because it's not used/needed. - "media" slug) + "" "media" + (files::name-of (nera:get-storage-file :slug slug))) (when (storage:file-exists-p "" "media" (format nil "thumbnail-~a" slug)) (storage:remove-file