changeset 805:7b28a1e0774e pytest2

search: add name/content key terms as suggestions to search result view
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 30 Aug 2011 00:53:12 +0200
parents 396132cbcfc7
children 1165a3658720
files MoinMoin/apps/frontend/views.py MoinMoin/templates/search.html
diffstat 2 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Mon Aug 29 20:13:37 2011 +0200
+++ b/MoinMoin/apps/frontend/views.py	Tue Aug 30 00:53:12 2011 +0200
@@ -156,6 +156,8 @@
             results = searcher.search(q, limit=100)
             return render_template('search.html',
                                    results=results,
+                                   name_suggestions=u', '.join([word for word, score in results.key_terms('name', docs=20, numterms=10)]),
+                                   content_suggestions=u', '.join([word for word, score in results.key_terms('content', docs=20, numterms=10)]),
                                    query=query,
                                    medium_search_form=search_form,
                                    item_name='+search', # XXX
--- a/MoinMoin/templates/search.html	Mon Aug 29 20:13:37 2011 +0200
+++ b/MoinMoin/templates/search.html	Tue Aug 30 00:53:12 2011 +0200
@@ -22,6 +22,10 @@
         </div>
     {{ gen.form.close() }}
     {% if results is defined %}
+    <div>
+        <p>{{ _("name term suggestions: %(termlist)s", termlist=name_suggestions) }}</p>
+        <p>{{ _("content term suggestions: %(termlist)s", termlist=content_suggestions) }}</p>
+    </div>
     <div class="searchresults">
         <table>
             {% for result in results %}