From 1289f3faeb850fe713fe10a15470b6fc564e52bc Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Wed, 29 Oct 2014 15:14:36 +0100 Subject: [PATCH] Various fixes/improvements --- search/indico_search/__init__.py | 3 +- search/indico_search/base.py | 12 +--- search/indico_search/controllers.py | 9 +-- search/indico_search/plugin.py | 2 +- search/indico_search/static/css/search.scss | 62 ++++++++++++++++--- search/indico_search/templates/results.html | 34 ++++++---- .../templates/searchbox_category.html | 4 +- 7 files changed, 84 insertions(+), 42 deletions(-) diff --git a/search/indico_search/__init__.py b/search/indico_search/__init__.py index c4a2c7e..59c2895 100644 --- a/search/indico_search/__init__.py +++ b/search/indico_search/__init__.py @@ -14,6 +14,7 @@ # You should have received a copy of the GNU General Public License # along with Indico; if not, see . -__all__ = ('SearchPluginBase', 'SearchEngine') +__all__ = ('SearchPluginBase', 'SearchEngine', 'SearchForm') from .base import SearchPluginBase, SearchEngine +from .forms import SearchForm diff --git a/search/indico_search/base.py b/search/indico_search/base.py index 4f75f71..93666e3 100644 --- a/search/indico_search/base.py +++ b/search/indico_search/base.py @@ -41,33 +41,27 @@ class SearchPluginBase(IndicoPlugin): """If the search engine only returns public events""" return session.user is None - def perform_search(self, values, obj=None, page=1): + def perform_search(self, values, obj=None): """Performs the search. For documentation on the parameters and return value, see the documentation of the :class:`SearchEngine` class. """ - return self.engine_class(values, obj, page).process() + return self.engine_class(values, obj).process() class SearchEngine(object): """Base class for a search engine""" - def __init__(self, values, obj, page): + def __init__(self, values, obj): """ :param values: the values sent by the user :param obj: object to search in (a `Category` or `Conference`) - :param page: the result page to show (if supported) """ self.values = values self.obj = obj - self.page = page self.user = session.user - def build_url(self, **query_params): - """Creates the URL for the search request""" - raise NotImplementedError - def process(self): """Executes the search diff --git a/search/indico_search/controllers.py b/search/indico_search/controllers.py index 80d2441..7fd7a42 100644 --- a/search/indico_search/controllers.py +++ b/search/indico_search/controllers.py @@ -43,18 +43,13 @@ class RHSearch(RHCustomizable): self.obj = CategoryManager().getRoot() self.obj_type = None - try: - self.page = int(request.values['page']) - except (ValueError, KeyError): - self.page = 1 - def _process(self): with current_plugin.engine_plugin.plugin_context(): form = current_plugin.search_form(prefix='search-') result = None if form.validate_on_submit(): - result = current_plugin.perform_search(form.data, self.obj, self.page) - if isinstance(result, Response): # probably a redirect + result = current_plugin.perform_search(form.data, self.obj) + if isinstance(result, Response): # probably a redirect or a json response return result view_class = WPSearchConference if isinstance(self.obj, Conference) else WPSearchCategory return view_class.render_template('results.html', self.obj, only_public=current_plugin.only_public, diff --git a/search/indico_search/plugin.py b/search/indico_search/plugin.py index c5eeb19..be2d095 100644 --- a/search/indico_search/plugin.py +++ b/search/indico_search/plugin.py @@ -69,6 +69,6 @@ class SearchPlugin(IndicoPlugin): return render_engine_or_search_template('searchbox_conference.html', event=event, form=form) def _add_category_search_box(self, category, **kwargs): - if category is not None and request.blueprint != 'plugin_search': + if request.blueprint != 'plugin_search': form = self.engine_plugin.search_form(prefix='search-') return render_engine_or_search_template('searchbox_category.html', category=category, form=form) diff --git a/search/indico_search/static/css/search.scss b/search/indico_search/static/css/search.scss index 3135b93..8d8ddaf 100644 --- a/search/indico_search/static/css/search.scss +++ b/search/indico_search/static/css/search.scss @@ -14,17 +14,59 @@ } } -.search-public-warning { - color: #FF4444; - padding: 10px; -} +.search-container { + .search-public-warning { + float: right; + padding: 10px; + color: #FF4444; + } -.search-title { - font-size: 2em; - color: #B14300; - font-weight: normal; - margin: 0; - padding: 0; + .search-banner { + float: right; + margin-top: 10px; + + & > span { + color: #777; + } + + img { + vertical-align: middle; + border: 0; + } + } + + .content { + form { + width: 400px; + + #search-phrase { + width: 300px; + height: 20px; + font-size: 17px; + vertical-align: middle; + } + + input[type=submit] { + vertical-align: middle; + } + + .toggle-advanced-options-container { + padding-top: 4px; + } + + .advanced-options > table { + text-align: right; + } + } + } + + h1 { + font-size: 2em; + color: #B14300; + font-weight: normal; + margin: 0; + padding: 0; + } } #category-search-form { diff --git a/search/indico_search/templates/results.html b/search/indico_search/templates/results.html index bd9b941..c363684 100644 --- a/search/indico_search/templates/results.html +++ b/search/indico_search/templates/results.html @@ -1,11 +1,11 @@ -
+
{% if only_public %} -
+
{% trans %}Warning: since you are not logged in, only results from public events will appear.{% endtrans %}
{% endif %} -

+

{% trans %}Search{% endtrans %} {% if obj_type == 'event' %} {% trans %}Event{% endtrans %} @@ -17,24 +17,24 @@
-
- Search powered by +
+ Search powered by {% block banner %}{% endblock %}
-
+
- {{ form.phrase(style='width: 300px; height: 20px; font-size: 17px; vertical-align: middle;') }} - + {{ form.phrase() }} + {% block tooltip %}{% endblock %}
-
+ -