summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-04-05 20:33:25 -0700
committercolin <colin@cicadas.surf>2023-04-05 20:33:25 -0700
commit07884db1d735752d1380fde5ffbd4bc31be88e82 (patch)
tree41fd7e2af30bf84bcabc2e51ca99eba1e3f8a3d9
parent9ee2abe0548805555bd5056c3ed1db940802bfa2 (diff)
Better theme search
-rw-r--r--fussy.lisp24
1 files changed, 19 insertions, 5 deletions
diff --git a/fussy.lisp b/fussy.lisp
index def6d46..10c5612 100644
--- a/fussy.lisp
+++ b/fussy.lisp
@@ -135,7 +135,9 @@ differs from the theme-pkg instance already in the data store."
;; if we didn't error: update the db
(dolist (archive-theme themes-to-update)
- (process-archive-theme archive-theme)))))
+ (process-archive-theme archive-theme))
+
+ (reindex-themes-by-package))))
(defun all-theme-keywords ()
(delete-duplicates
@@ -174,9 +176,8 @@ returns a list of those names."
(defun theme-mentions-anywhere (term)
(lambda (theme)
- (if (stringp theme)
- (search term theme)
- (with-slots (name keywords description authors maintainer) theme
+ (or (search term theme)
+ (with-slots (name keywords description authors maintainer) (theme-package theme)
(or (search term (symbol-name name) :test #'char-equal)
(some (lambda (keyword) (search term keyword :test #'char-equal)) keywords)
(search term description :test #'char-equal))))))
@@ -184,7 +185,20 @@ returns a list of those names."
(defun search-themes (&rest terms)
(remove-if-not
(apply #'a:conjoin (mapcar #'theme-mentions-anywhere terms))
- (all-theme-packages)))
+ (all-themes)))
+
+(defvar *theme->packages* nil
+ "A hash table indexing packages by the themes they contain.")
+
+(defun theme-package (theme) (gethash theme *theme->packages*))
+
+(defun reindex-themes-by-package ()
+ (let ((table (make-hash-table :test #'equal)))
+ (dolist (pkg (all-theme-packages))
+ (dolist (theme (themes-in-package pkg))
+ (setf (gethash theme table) pkg)))
+ (setf *theme->packages* table)))
+
(defclass/std config ()
((theme-image-directory