From a72e133f135ef030a53104a37572b5702f1949b8 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 26 Sep 2022 00:24:08 +0100 Subject: [PATCH] update / (site's index page) route and nav. menu update feature. I hard-coded redirects to the pages which can't be deleted into the site's index ('/' route). This allows them to be set as the home page in the site's settings. I, also, updated the data which is passed to nera:update-nav-menu. This change is part of the Nav. Menu settings in the site's settings. --- src/web.lisp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/web.lisp b/src/web.lisp index 1ad5cf1..17be863 100644 --- a/src/web.lisp +++ b/src/web.lisp @@ -34,18 +34,26 @@ ;; Routing rules (defroute "/" () - (if (not (uiop:file-exists-p (ritherdon-archive.config:database-name))) - (redirect "/setup") - (render #P"index.html" - (append (if (hermetic:logged-in-p) - (auth:auth-user-data)) - `(:alert ,(utils:get-and-reset-alert) - :nav-menu ,(nera:nav-menu-slugs) - :system-data ,(nera:system-data) - :content ,(storage:open-text-file - "" "pages" - (site-settings::home-page-of - (nera:get-site-settings)))))))) + (cond ((not (uiop:file-exists-p (ritherdon-archive.config:database-name))) + (redirect "/setup")) + ((string= "archive" (site-settings::home-page-of (nera:get-site-settings))) + (redirect "/archive")) + ((string= "login" (site-settings::home-page-of (nera:get-site-settings))) + (redirect "/login")) + ((string= "pages" (site-settings::home-page-of (nera:get-site-settings))) + (redirect "/pages")) + ((string= "sign-up" (site-settings::home-page-of (nera:get-site-settings))) + (redirect "/sign-up")) + (t (render #P"index.html" + (append (if (hermetic:logged-in-p) + (auth:auth-user-data)) + `(:alert ,(utils:get-and-reset-alert) + :nav-menu ,(nera:nav-menu-slugs) + :system-data ,(nera:system-data) + :content ,(storage:open-text-file + "" "pages" + (site-settings::home-page-of + (nera:get-site-settings))))))))) (defroute "/setup" () ;; If there is no database, there is no user, hence no more checks. @@ -226,8 +234,7 @@ (hermetic:auth (:administrator) ;; Authorised (progn - (format t "~a" (cdr (assoc "page" _parsed :test #'string=))) - (nera:update-nav-menu _parsed) + (nera:update-nav-menu (cdr (assoc "NAV-MENU" _parsed :test #'string=))) (utils:set-alert "Nav. menu updated.") (redirect "/site-settings")) ;; Not Authorised