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:47 UTC

[13/22] git commit: [#2835] ticket:288 Add `version=N` to the urls

[#2835] ticket:288 Add `version=N` to the urls


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

Branch: refs/heads/master
Commit: cd839bb65bea2d7c5c1109ef85a48d75bf705af5
Parents: cf33bec
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Mar 7 13:13:03 2013 +0000
Committer: Dave Brondsema <db...@geek.net>
Committed: Tue Mar 26 20:57:37 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/wiki_main.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cd839bb6/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 0b0f143..15f86ec 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -3,6 +3,7 @@ import logging
 from pprint import pformat
 from urllib import urlencode, unquote
 from datetime import datetime
+from itertools import imap
 
 # Non-stdlib imports
 from tg import expose, validate, redirect, response, flash
@@ -310,7 +311,7 @@ class RootController(BaseController, DispatchIndex):
             # It's 'fuzzier' than standard parser, which matches only on `text`.
             allowed_types = ['WikiPage', 'WikiPage Snapshot']
             if search_comments:
-                allowed_types += ['Post', 'Post Snapshot']
+                allowed_types += ['Post']
             search_params = {
                 'qt': 'dismax',
                 'qf': 'title^2 text',
@@ -330,7 +331,14 @@ class RootController(BaseController, DispatchIndex):
                     rows=limit, start=start, **search_params)
             except SolrError as e:
                 search_error = e
-            if results: count=results.hits
+            if results:
+                count=results.hits
+                def historize_urls(doc):
+                    if doc.get('type_s', '').endswith(' Snapshot'):
+                        if doc.get('url_s'):
+                            doc['url_s'] = doc['url_s'] + '?version=%s' % doc.get('version_i')
+                    return doc
+                results = imap(historize_urls, results)
         c.search_results = W.search_results
         return dict(q=q, history=history, results=results or [],
                     count=count, limit=limit, page=page, search_error=search_error)