Browse Source

integrate the search package into create archive route in web.lisp.

The site now populates the Meilisearch database when the user creates an archive
entry. The Meilisearch needs to be set-up manually at this moment in time so
expect this to break easily if you haven't got Meilisearch working.
stable
Craig Oates 2 years ago
parent
commit
c2788c43af
  1. 72
      src/web.lisp

72
src/web.lisp

@ -16,7 +16,8 @@
#:validation #:validation
#:user #:user
#:nera-db #:nera-db
#:files) #:files
#:search)
(:export #:*web*)) (:export #:*web*))
(in-package #:ritherdon-archive.web) (in-package #:ritherdon-archive.web)
@ -1091,31 +1092,43 @@
:keywords ,keywords :keywords ,keywords
:data ,page-content)))) :data ,page-content))))
(t (nera:create-archive-entry (t (let ((search-id (utils:create-timestamp-id)))
title ;; Database Entry
(utils:create-timestamp-id) (nera:create-archive-entry
(format nil "~a.html" (utils:slugify title)) title
(utils:format-filename (cadr thumbnail-file)) ; File Name search-id
(caddr thumbnail-file) ; File Type (format nil "~a.html" (utils:slugify title))
(utils:format-keywords keywords)) (utils:format-filename (cadr thumbnail-file)) ; File Name
;; parse info and enter into meilisearch database. (caddr thumbnail-file) ; File Type
;; Use placeholder thumbnail if one not detected? (utils:format-keywords keywords))
(storage:store-text ;; Use placeholder thumbnail if one not detected?
"" "archive" ;; Meilisearch Database Entry
(format nil "~a.html" (utils:slugify title)) (search:submit-entry
page-content) (search:build-payload
(storage:store-file search-id title
"" "archive" (format nil "view/archive/~a.html"
(utils:format-filename (cadr thumbnail-file)) (utils:slugify title))
thumbnail-file) (format nil "storage/thumb/archive/~a.html"
(utils:create-thumbnail ; Overwrites the original here. (utils:slugify title))
"archive" (utils:format-filename (cadr thumbnail-file)) t) (local-time:now)
(utils:set-alert "Archive entry created. Great Success!" (utils:format-keywords keywords)))
"created") ;; Storage File Entry
(redirect "/dashboard"))) (storage:store-text
;; Not Authorised "" "archive"
(progn (utils:set-alert "You are not logged in." "error") (format nil "~a.html" (utils:slugify title))
(redirect "/login"))))))) page-content)
(storage:store-file
"" "archive"
(utils:format-filename (cadr thumbnail-file))
thumbnail-file)
(utils:create-thumbnail ; Overwrites the original here.
"archive" (utils:format-filename (cadr thumbnail-file)) t)
(utils:set-alert "Archive entry created. Great Success!"
"created")
(redirect "/dashboard"))))
;; Not Authorised
(progn (utils:set-alert "You are not logged in." "error")
(redirect "/login")))))))
(defroute ("/edit/archive/:slug" :method :GET) (&key slug) (defroute ("/edit/archive/:slug" :method :GET) (&key slug)
(if (nera:get-archive-entry :slug slug) (if (nera:get-archive-entry :slug slug)
@ -1338,6 +1351,13 @@
"error") "error")
(redirect "/login"))))))) (redirect "/login")))))))
(defroute ("/search" :method :GET) ()
(render #P"search.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)))))
;; ;;
;; Error pages ;; Error pages

Loading…
Cancel
Save