changeset 401:215d7a8f5b3e

Fixes #6. Fixing https://bitbucket.org/marchael/moin-2.0/issue/6/unpretty-search-results-rendering
author Michael Mayorov <marchael@kb.csu.ru>
date Sat, 06 Aug 2011 07:36:08 +0000
parents ea001bcb5f90
children ab4ac448d5d8
files MoinMoin/apps/frontend/views.py MoinMoin/templates/search_results.html MoinMoin/themes/modernized/static/css/common.css
diffstat 3 files changed, 16 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Sat Aug 06 06:03:50 2011 +0000
+++ b/MoinMoin/apps/frontend/views.py	Sat Aug 06 07:36:08 2011 +0000
@@ -129,7 +129,7 @@
     validators = [ValidSearch()]
 
 
-def _search(search_form):
+def _search(search_form, item_name):
     from MoinMoin.search.indexing import WhooshIndex
     from whoosh.qparser import QueryParser, MultifieldParser
     from MoinMoin.search.analyzers import item_name_analyzer
@@ -146,7 +146,8 @@
         return render_template('search_results.html',
                                results=results,
                                query=query,
-                               medium_search_form=search_form
+                               medium_search_form=search_form,
+                               item_name=item_name
                               )
 
 
@@ -156,7 +157,7 @@
     # first check whether we have a valid search query:
     search_form = SearchForm.from_flat(request.values)
     if search_form.validate():
-        return _search(search_form)
+        return _search(search_form, item_name)
     search_form['submit'].set_default() # XXX from_flat() kills all values
 
     flaskg.user.addTrail(item_name)
--- a/MoinMoin/templates/search_results.html	Sat Aug 06 06:03:50 2011 +0000
+++ b/MoinMoin/templates/search_results.html	Sat Aug 06 07:36:08 2011 +0000
@@ -1,17 +1,6 @@
 {% extends theme("layout.html") %}
 {% import "utils.html" as utils %}
 {% block content %}
-    <p class="searchhint">
-        {# TODO: make a search tip here #}
-    </p>
-    {{ gen.form.open(medium_search_form, id='moin-long-searchform', method='get', action=url_for('frontend.show_item', item_name=item_name)) }}
-        <div>
-            {{ gen.input(medium_search_form['q'], type='search', id='moin-search-query') }}
-            {{ gen.input(medium_search_form['submit'], type='submit') }}
-            {{ gen.input(medium_search_form['pagelen'], type='hidden', value='25') }}
-            {{ forms.render_errors(medium_search_form) }}
-        </div>
-    {{ gen.form.close() }}
     {% if results %}
     <p class="searchstats">
         {{ _("Result: Page %(start_page)d of %(end_page)d.
@@ -21,8 +10,17 @@
               result_len=results|length, runtime=results.results.runtime
             )
         }}
+    {% endif %}
+    {{ gen.form.open(medium_search_form, id='moin-long-searchform', method='get', action=url_for('frontend.show_item', item_name=item_name)) }}
+        <div>
+            {{ gen.input(medium_search_form['q'], type='search', id='moin-search-query') }}
+            {{ gen.input(medium_search_form['submit'], type='submit') }}
+            {{ gen.input(medium_search_form['pagelen'], type='hidden', value='25') }}
+            {{ forms.render_errors(medium_search_form) }}
+        </div>
+    {{ gen.form.close() }}
     </p>
-    <h1>{{ _("Results for search '%(query)s'", query=query) }}</h1>
+        {% if results %}
         <div class="searchresults">
         <table>
             {% for result in results %}
--- a/MoinMoin/themes/modernized/static/css/common.css	Sat Aug 06 06:03:50 2011 +0000
+++ b/MoinMoin/themes/modernized/static/css/common.css	Sat Aug 06 07:36:08 2011 +0000
@@ -179,8 +179,8 @@
 .searchresults p.info { margin-left: 2%; }
 .searchresults .searchhitinfobar { color: #008000; margin-left: 15px; margin-top: 0; }
 .searchresults .foundtext { margin-left: 15px; margin-top: 0; }
-p.searchstats { font-size: 0.8em; text-align: right; width: 100%; background-color: #E6EAF0;
-            border-top: 1px solid #9088DC; padding: 2px; }
+p.searchstats { font-size: 0.8em; text-align: right; width: 100%;
+             padding: 2px; margin-top: -15px; }
 p.searchhint { background-color: #E6EAF0; border: 1px solid #9088DC; padding: 2px; }
 .searchpages { margin-left: auto; margin-right: auto; }
 .searchpages tr,
@@ -476,8 +476,6 @@
 
 /* moin-extended searchform */
 #moin-long-searchform { padding: 0; font-size: 0.82em; text-align: left; }
-#moin-long-searchform input { font-size: 100%; vertical-align: middle;
-            border: 1px solid #A4B9DF; }
 #moin-long-searchform div { margin: 0; }
 #moin-search-query { width: 50%; }