diff options
Diffstat (limited to 'fussy.lisp')
-rw-r--r-- | fussy.lisp | 69 |
1 files changed, 47 insertions, 22 deletions
@@ -178,7 +178,6 @@ returns a list of those names." (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)))))) (defun search-themes (&rest terms) @@ -342,22 +341,27 @@ that they are not loaded during image gen.") (:nav (:a :href "/" (:h1 "FUSSY"))))) -(defun page-nav (page page-count) +(defun page-nav (page page-count &optional terms) "relative pagination nav to current page." - (html:with-html - (:div :class "center bigger" - (:span (when (plusp page) (:a :href (format nil "?page=~a" (1- page)) " << ")) - (when (< page (1- page-count)) - (:a :href (format nil "?page=~a" (1+ page)) " >> ")))) - (:div - :class "page-nav" - (dotimes (pg (ceiling (/ page-count +themes-per-page+))) - (if (= pg page) - (:span (format nil " ~a " (1+ pg))) - (:span " " - (:a :href (format nil "?page=~a" pg) - (format nil "~a" (1+ pg))) - " ")))))) + (flet ((format-string (pg) + (if terms + (format nil "?page=~a&terms=~{~a~^+~}" pg terms) + (format nil "?page=~a" pg)))) + (html:with-html + (:div :class "bigger center" + (:span (when (plusp page) + (:a :href (format-string (1- page)) " <<--- ")) + " | " + (when (< page (1- page-count)) + (:a :href (format-string (1+ page)) " --->> ")))) + (:div + :class "page-nav" + (dotimes (pg page-count) + (if (= pg page) + (:span (format nil " ~a " (1+ pg))) + (:span " " + (:a :href (format-string pg) (format nil "~a" (1+ pg))) + " "))))))) (defun theme-preview-image (theme &optional variant) (html:with-html @@ -440,6 +444,12 @@ html, body { text-align: center; } +.search { + margin-left: auto; + margin-right: auto; + width: 300px; +} + h1 { text-align: center; } @@ -484,12 +494,20 @@ h1 { (lzb:http-err 404 "no such file")) file-path)) -(lzb:defendpoint* :get "/" ((page an-integer)) () +(defun a-string (s) s) + +(lzb:defendpoint* :get "/" ((page an-integer) (terms a-string)) () "The landing page" (let* ((page (or page 0)) + (terms + (when terms (str:split-omit-nulls #\space terms))) (all-themes - (all-themes)) + (if terms + (apply #'search-themes terms) + (all-themes))) + (page-count + (ceiling (/ (length all-themes) +themes-per-page+))) (themes (a:subseq* all-themes (* page +themes-per-page+) @@ -503,16 +521,23 @@ h1 { (:body (:div :class "main" (nav) - (:div :class "center header" + (:div :class "center header" (:p "Emacs Themes Gallery for your Daily Procrastination Needs." (:br) (write-to-string (length all-themes)) " themes and counting...")) - (page-nav page (1- (length all-themes))) + (:div :class "search" + (:form :method "GET" :action "/" + (:label :for "terms") + (:input :name "terms" :value (format nil "~{~a ~}" terms)) + (:button :type "submit" "search"))) + (when (< 1 page-count) + (page-nav page page-count terms)) (:div :class "container" (dolist (theme themes) (theme-preview-card theme))) (:div :class "foooter" - (page-nav page (1- (length all-themes)))))))))) + (when (< 1 page-count) + (page-nav page page-count terms))))))))) (defun a-package (string) (a:if-let (pkg @@ -552,7 +577,7 @@ h1 { (:p (:a :href (theme-pkg-url pkg) (theme-pkg-url pkg)))) (when (< +themes-per-page+ (length themes)) - (page-nav page (1- (length themes)))) + (page-nav page (floor (/ (length themes) +themes-per-page+)))) (:div :class "container" (dolist (theme (a:subseq* themes (* page +themes-per-page+) |