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. 30
      src/web.lisp

30
src/web.lisp

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

Loading…
Cancel
Save