Browse Source

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.
stable
Craig Oates 2 years ago
parent
commit
a72e133f13
  1. 35
      src/web.lisp

35
src/web.lisp

@ -34,18 +34,26 @@
;; Routing rules ;; Routing rules
(defroute "/" () (defroute "/" ()
(if (not (uiop:file-exists-p (ritherdon-archive.config:database-name))) (cond ((not (uiop:file-exists-p (ritherdon-archive.config:database-name)))
(redirect "/setup") (redirect "/setup"))
(render #P"index.html" ((string= "archive" (site-settings::home-page-of (nera:get-site-settings)))
(append (if (hermetic:logged-in-p) (redirect "/archive"))
(auth:auth-user-data)) ((string= "login" (site-settings::home-page-of (nera:get-site-settings)))
`(:alert ,(utils:get-and-reset-alert) (redirect "/login"))
:nav-menu ,(nera:nav-menu-slugs) ((string= "pages" (site-settings::home-page-of (nera:get-site-settings)))
:system-data ,(nera:system-data) (redirect "/pages"))
:content ,(storage:open-text-file ((string= "sign-up" (site-settings::home-page-of (nera:get-site-settings)))
"" "pages" (redirect "/sign-up"))
(site-settings::home-page-of (t (render #P"index.html"
(nera:get-site-settings)))))))) (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" () (defroute "/setup" ()
;; If there is no database, there is no user, hence no more checks. ;; If there is no database, there is no user, hence no more checks.
@ -226,8 +234,7 @@
(hermetic:auth (:administrator) (hermetic:auth (:administrator)
;; Authorised ;; Authorised
(progn (progn
(format t "~a" (cdr (assoc "page" _parsed :test #'string=))) (nera:update-nav-menu (cdr (assoc "NAV-MENU" _parsed :test #'string=)))
(nera:update-nav-menu _parsed)
(utils:set-alert "Nav. menu updated.") (utils:set-alert "Nav. menu updated.")
(redirect "/site-settings")) (redirect "/site-settings"))
;; Not Authorised ;; Not Authorised

Loading…
Cancel
Save