diff --git a/src/web.lisp b/src/web.lisp index 48afb82..f897359 100644 --- a/src/web.lisp +++ b/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