summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-04-10 14:04:40 -0700
committercolin <colin@cicadas.surf>2023-04-10 14:04:40 -0700
commitb661a958f28f9256d9eb7e38a1c45ef5086b4bf2 (patch)
treeee9671bf476730384655befa51a87a7756aedb6b
parent2d539cd06c741e304e5b4bc66bb85c3c33c9d663 (diff)
Sorting themes by recency of update
-rw-r--r--fussy.lisp35
1 files changed, 25 insertions, 10 deletions
diff --git a/fussy.lisp b/fussy.lisp
index 2fd64d2..692c911 100644
--- a/fussy.lisp
+++ b/fussy.lisp
@@ -96,6 +96,16 @@ the emacs' reader readtable."
(theme-pkg-authors pkg) (cdr (assoc :authors meta-alist))
(theme-pkg-keywords pkg) (cdr (assoc :keywords meta-alist))))))
+(defun package-name<= (pkg1 pkg2)
+ (string<=
+ (symbol-name (theme-pkg-name pkg1))
+ (symbol-name (theme-pkg-name pkg2))))
+
+(defun package-version<= (pkg1 pkg2)
+ (<= (first (theme-pkg-version pkg1))
+ (first (theme-pkg-version pkg2))))
+
+
(defun process-archive-theme (archive-theme)
;; ugg this is ugly. I hate it when code is all dense like this.
@@ -154,8 +164,12 @@ differs from the theme-pkg instance already in the data store."
:test #'string-equal)
:collect theme))
-(defun all-theme-packages ()
- (db:store-objects-with-class 'theme-pkg))
+(defun all-theme-packages (&optional sort-by)
+ (let ((packages
+ (db:store-objects-with-class 'theme-pkg)))
+ (if sort-by
+ (sort (copy-seq packages) sort-by)
+ packages)))
(defun just-the-directory-namestring (path)
"returns a string, the name of the directory that the path represents."
@@ -173,8 +187,8 @@ returns a list of those names."
(string-downcase (format nil "~a/" (theme-pkg-name pkg)))
(full-theme-image-directory config)))))
-(defun all-themes ()
- (a:mappend #'themes-in-package (all-theme-packages)))
+(defun all-themes (&key sort-by)
+ (a:mappend #'themes-in-package (all-theme-packages sort-by)))
(defun theme-mentions-anywhere (term)
(lambda (theme)
@@ -183,10 +197,10 @@ returns a list of those names."
(or (search term (symbol-name name) :test #'char-equal)
(search term description :test #'char-equal))))))
-(defun search-themes (&rest terms)
+(defun search-themes (terms &key sort-by)
(remove-if-not
(apply #'a:conjoin (mapcar #'theme-mentions-anywhere terms))
- (all-themes)))
+ (all-themes :sort-by sort-by)))
(defvar *theme->packages* nil
"A hash table indexing packages by the themes they contain.")
@@ -255,7 +269,7 @@ are treated as such.")
(defparameter +standard-themes+
- '(adwaita deeper-blue dichromacy light-blue modus-operandi modus-vivendi tango-dark
+ '(adwaita deeper-blue dichromacy light-blue tango-dark
wheatgrass manoj-dark tsdh-dark tsdh-light whiteboard
leuven misterioso tango wombat)
"these are built in themes - this list can be passed to the image
@@ -506,8 +520,8 @@ h1 {
(when terms (str:split-omit-nulls #\space terms)))
(all-themes
(if terms
- (apply #'search-themes terms)
- (all-themes)))
+ (search-themes terms :sort-by (complement #'package-version<=))
+ (all-themes :sort-by (complement #'package-version<=))))
(page-count
(ceiling (/ (length all-themes) +themes-per-page+)))
(themes
@@ -526,7 +540,8 @@ h1 {
(:div :class "center header"
(:p
"Emacs Themes Gallery for your Daily Procrastination Needs." (:br)
- (write-to-string (length all-themes)) " themes and counting..."))
+ "Showing " (write-to-string (length all-themes)) " themes." (:br)
+ "Newer themes, or newly updated themes, are shown first"))
(:div :class "search"
(:form :method "GET" :action "/"
(:label :for "terms")