incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [11/40] git commit: [#2835] ticket:288 Search comments option
Date Mon, 01 Apr 2013 14:27:30 GMT
[#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/cj/5963
Commit: cf33bec6cb977bb4eba09292149a410bee6ecc16
Parents: 8797294
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Thu Mar 7 12:50:26 2013 +0000
Committer: Dave Brondsema <dbrondsema@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')


Mime
View raw message