diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/entry-points/server.scm | 2 | ||||
-rw-r--r-- | module/html/view/search.scm | 37 | ||||
-rw-r--r-- | module/output/html-search.scm | 36 |
3 files changed, 38 insertions, 37 deletions
diff --git a/module/entry-points/server.scm b/module/entry-points/server.scm index fb6b2575..466860cd 100644 --- a/module/entry-points/server.scm +++ b/module/entry-points/server.scm @@ -329,7 +329,7 @@ (with-output-to-string (lambda () (sxml->xml - ((@ (output html-search) search-result-page) + ((@ (html view search) search-result-page) search-term search-result page paginator q=)))))) ;; NOTE this only handles files with extensions. Limited, but since this diff --git a/module/html/view/search.scm b/module/html/view/search.scm new file mode 100644 index 00000000..2b93ebfc --- /dev/null +++ b/module/html/view/search.scm @@ -0,0 +1,37 @@ +(define-module (html view search) + :use-module (util) + :use-module (vcomponent) + :use-module (vcomponent search) + :use-module ((ice-9 pretty-print) :select (pretty-print)) + :use-module ((html components) + :select (xhtml-doc include-css)) + :use-module ((html vcomponent) + :select (compact-event-list)) + ) + +(define-public (search-result-page + search-term search-result page paginator q=) + (xhtml-doc + (@ (lang sv)) + (head (title "Search results") + ,(include-css "/static/style.css")) + (body + (h2 "Search term") + (form + (pre (textarea (@ (name "q") (rows 5) (spellcheck false) + (style "width:100%")) + ,(with-output-to-string + (lambda () (pretty-print search-term))))) + (input (@ (type submit)))) + (h2 "Result (page " ,page ")") + (ul + ,@(compact-event-list search-result)) + (div (@ (class "paginator")) + ,@(paginator->list + paginator + (lambda (p) (if (= p page) + `(span ,p) + `(a (@ (href "?" ,q= "&p=" ,p)) ,p))) + (lambda (p) `(a (@ (href "?" ,q= "&p=" ,p)) "»")))) + ))) + diff --git a/module/output/html-search.scm b/module/output/html-search.scm index 070a725e..e69de29b 100644 --- a/module/output/html-search.scm +++ b/module/output/html-search.scm @@ -1,36 +0,0 @@ -;; TODO rename this module -(define-module (output html-search) - :use-module (util) - :use-module (vcomponent) - :use-module (vcomponent search) - :use-module ((ice-9 pretty-print) :select (pretty-print)) - :use-module (html components) - :use-module (html vcomponent) - ) - -(define-public (search-result-page - search-term search-result page paginator q=) - (xhtml-doc - (@ (lang sv)) - (head (title "Search results") - ,(include-css "/static/style.css")) - (body - (h2 "Search term") - (form - (pre (textarea (@ (name "q") (rows 5) (spellcheck false) - (style "width:100%")) - ,(with-output-to-string - (lambda () (pretty-print search-term))))) - (input (@ (type submit)))) - (h2 "Result (page " ,page ")") - (ul - ,@(compact-event-list search-result)) - (div (@ (class "paginator")) - ,@(paginator->list - paginator - (lambda (p) (if (= p page) - `(span ,p) - `(a (@ (href "?" ,q= "&p=" ,p)) ,p))) - (lambda (p) `(a (@ (href "?" ,q= "&p=" ,p)) "»")))) - ))) - |