You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/03/26 22:02:43 UTC

[09/22] git commit: [#2835] ticket:288 Search comments option

[#2835] ticket:288 Search comments option


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/cf33bec6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/cf33bec6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/cf33bec6

Branch: refs/heads/master
Commit: cf33bec6cb977bb4eba09292149a410bee6ecc16
Parents: 8797294
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Mar 7 12:50:26 2013 +0000
Committer: Dave Brondsema <db...@geek.net>
Committed: Tue Mar 26 20:57:36 2013 +0000

----------------------------------------------------------------------
 .../allura/templates/widgets/search_results.html   |    3 ++-
 ForgeWiki/forgewiki/wiki_main.py                   |   15 ++++++++++-----
 2 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cf33bec6/Allura/allura/templates/widgets/search_results.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/search_results.html b/Allura/allura/templates/widgets/search_results.html
index 74eb466..4cfc891 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -20,8 +20,9 @@
   </div>
   <div class="grid-9">
     {% if not search_comments_disable %}
+      {% set comments = request.GET['search_comments'] %}
       <label for="search-comments">Search comments?</label>
-      <input id="search-comments" type="checkbox" name="search_comments"{% if search_comments %} checked{% endif %}>
+      <input id="search-comments" type="checkbox" name="search_comments"{% if comments %} checked{% endif %}>
     {% endif %}
     <label for="search-history">Search history?</label>
     <input id="search-history" type="checkbox" name="history"{% if history %} checked{% endif %}>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cf33bec6/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index e5482ea..0b0f143 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -292,8 +292,9 @@ class RootController(BaseController, DispatchIndex):
     @expose('jinja:forgewiki:templates/wiki/search.html')
     @validate(dict(q=validators.UnicodeString(if_empty=None),
                    history=validators.StringBool(if_empty=False),
+                   search_comments=validators.StringBool(if_empty=False),
                    project=validators.StringBool(if_empty=False)))
-    def search(self, q=None, history=None, project=None, limit=None, page=0, **kw):
+    def search(self, q=None, history=None, search_comments=None, project=None, limit=None, page=0, **kw):
         'local wiki search'
         if project:
             redirect(c.project.url() + 'search?' + urlencode(dict(q=q, history=history)))
@@ -307,15 +308,19 @@ class RootController(BaseController, DispatchIndex):
             # Match on both `title` and `text` by default, using 'dismax' parser.
             # Score on `title` matches is boosted, so title match is better than body match.
             # It's 'fuzzier' than standard parser, which matches only on `text`.
+            allowed_types = ['WikiPage', 'WikiPage Snapshot']
+            if search_comments:
+                allowed_types += ['Post', 'Post Snapshot']
             search_params = {
                 'qt': 'dismax',
                 'qf': 'title^2 text',
                 'pf': 'title^2 text',
                 'fq': [
-                    'project_id_s:%s' % c.project._id,
-                    'mount_point_s:%s'% c.app.config.options.mount_point,
-                    '-deleted_b:true'
-                ]
+                    'project_id_s:%s'  % c.project._id,
+                    'mount_point_s:%s' % c.app.config.options.mount_point,
+                    '-deleted_b:true',
+                    'type_s:(%s)' % ' OR '.join(['"%s"' % t for t in allowed_types])
+                ],
             }
             if not history:
                search_params['fq'].append('is_history_b:False')