incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [40/50] git commit: [#2835] ticket:304 Nice comment links for search results
Date Wed, 24 Apr 2013 22:31:05 GMT
[#2835] ticket:304 Nice comment links for search results


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

Branch: refs/heads/cj/5655
Commit: a7840ced009284810688070f9607c236b9211020
Parents: ba9ea5d
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Thu Apr 4 10:10:36 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 24 16:34:43 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py                        |    8 ++++++++
 .../forgediscussion/controllers/root.py            |   11 -----------
 2 files changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a7840ced/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 29c28b7..309845f 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -29,6 +29,7 @@ from pylons import request
 from pysolr import SolrError
 
 from allura.lib import helpers as h
+from allura.model import ArtifactReference
 from .markdown_extensions import ForgeExtension
 
 log = getLogger(__name__)
@@ -173,8 +174,15 @@ def search_app(q='', fq=None, app=True, **kw):
                 doc['title_match'] = title
                 doc['text_match'] = text or h.get_first(doc, 'text')
                 return doc
+            def paginate_comment_urls(doc):
+                if doc.get('type_s', '') == 'Post':
+                    aref = ArtifactReference.query.get(_id=doc.get('id'))
+                    if aref and aref.artifact:
+                        doc['url_paginated'] = aref.artifact.url_paginated()
+                return doc
             results = imap(historize_urls, results)
             results = imap(add_matches, results)
+            results = imap(paginate_comment_urls, results)
 
     # Provide sort urls to the view
     score_url = 'score desc'

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a7840ced/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index f5f4ae5..3bd1b94 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -141,17 +141,6 @@ class RootController(BaseController, DispatchIndex):
             'allowed_types': ['Post', 'Post Snapshot', 'Discussion', 'Thread'],
         })
         d = search_app(**search_params)
-        results = d.get('results')
-        def prettify_urls(doc):
-            if doc.get('type_s', '') == 'Post':
-                _id = doc.get('id').split('#')
-                _id = _id[-1].replace('/', '.') if _id else ''
-                p = model.ForumPost.query.get(_id=_id)
-                doc['url_paginated'] = p.url_paginated()
-            return doc
-        if results is not None:
-            results = imap(prettify_urls, results)
-        d['results'] = results
         d['search_comments_disable'] = True
         return d
 


Mime
View raw message