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
#:user
#:nera-db
#:files)
#:files
#:search)
(:export #:*web*))
(in-package #:ritherdon-archive.web)
@ -1091,31 +1092,43 @@
:keywords ,keywords
:data ,page-content))))
(t (nera:create-archive-entry
title
(utils:create-timestamp-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?
(storage:store-text
"" "archive"
(format nil "~a.html" (utils:slugify title))
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")))))))
(t (let ((search-id (utils:create-timestamp-id)))
;; Database Entry
(nera:create-archive-entry
title
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))
;; 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))
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)
(if (nera:get-archive-entry :slug slug)
@ -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