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
(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

Loading…
Cancel
Save