From 3ce333bf50fea3ee6bad1921085f97c285c87772 Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 27 Apr 2021 11:59:55 -0400 Subject: [PATCH] use htmlfiller filter --- AdvSearchPage.py | 4 +- BaseFormatter.py | 5 +- templates/advresults.html | 3 +- templates/advsearch.html | 850 +++++++++++++++++++------------------- 4 files changed, 433 insertions(+), 429 deletions(-) diff --git a/AdvSearchPage.py b/AdvSearchPage.py index 55347a9..5fc44f5 100644 --- a/AdvSearchPage.py +++ b/AdvSearchPage.py @@ -26,6 +26,7 @@ import cherrypy import routes from sqlalchemy import or_, and_, select +from genshi.filters import HTMLFormFiller from libgutenberg.Models import ( Alias, Attribute, Author, Book, BookAuthor, Category, File, Lang, Locc, Subject) @@ -201,6 +202,7 @@ class AdvSearchPage(Page): else: os.entries = entries(resultpks, offset) os.search_terms = selections - rendered = self.formatter.render('advresults', os) + instance_filter = HTMLFormFiller(data=params) + rendered = self.formatter.render('advresults', os, instance_filter) session.close() return rendered diff --git a/BaseFormatter.py b/BaseFormatter.py index d16c31f..7f3f738 100644 --- a/BaseFormatter.py +++ b/BaseFormatter.py @@ -71,7 +71,7 @@ class BaseFormatter(object): cherrypy.response.headers['Content-Type'] = self.CONTENT_TYPE - def render(self, page, os): + def render(self, page, os, instance_filter=None): """ Render and send to browser. """ self.send_headers() @@ -82,6 +82,9 @@ class BaseFormatter(object): stream = template.stream for filter_ in template.filters: stream = filter_(iter(stream), ctxt) + if instance_filter: + stream = instance_filter(stream) + # there's no easy way in genshi to pass collapse_lines to this filter stream = WHITESPACE_FILTER(stream, collapse_lines=COLLAPSE_LINES) diff --git a/templates/advresults.html b/templates/advresults.html index e73eabf..1c9fae1 100644 --- a/templates/advresults.html +++ b/templates/advresults.html @@ -70,7 +70,6 @@

More than 1000 books matched your search. Please refine your query to see results.

-
@@ -135,7 +134,7 @@ - + diff --git a/templates/advsearch.html b/templates/advsearch.html index 98bb1db..f2a7a81 100644 --- a/templates/advsearch.html +++ b/templates/advsearch.html @@ -1,457 +1,457 @@
-
- + +

- +

- +

- +

- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

- + + + + + + + + + +

- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +