You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/04/25 00:30:26 UTC

[01/50] git commit: [#6083] Bug fixes and update empty repo msg text

Updated Branches:
  refs/heads/cj/5655 5c6f0fa29 -> d4524de45 (forced update)


[#6083] Bug fixes and update empty repo msg text

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/5655
Commit: 8d64c44f443632608cf6d2c089706e9ec7809f65
Parents: 2e862b7
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Mon Apr 22 21:17:13 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Mon Apr 22 21:29:56 2013 +0000

----------------------------------------------------------------------
 ForgeGit/forgegit/model/git_repo.py        |    2 +-
 ForgeGit/forgegit/templates/git/index.html |    2 +-
 ForgeSVN/forgesvn/controllers.py           |    2 +-
 ForgeSVN/forgesvn/model/svn.py             |    8 +++++++-
 ForgeSVN/forgesvn/templates/svn/index.html |    2 +-
 5 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8d64c44f/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 296430f..5c79e34 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -356,7 +356,7 @@ class GitImplementation(M.RepositoryImplementation):
                 os.remove(tmpfilename)
 
     def is_empty(self):
-        return len(self._git.heads) == 0
+        return not self._git or len(self._git.heads) == 0
 
 
 class _OpenedGitBlob(object):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8d64c44f/ForgeGit/forgegit/templates/git/index.html
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/templates/git/index.html b/ForgeGit/forgegit/templates/git/index.html
index 4276e65..f300d7a 100644
--- a/ForgeGit/forgegit/templates/git/index.html
+++ b/ForgeGit/forgegit/templates/git/index.html
@@ -86,7 +86,7 @@ git branch --set-upstream master origin/master  # so 'git pull' will work later<
     {% endif %}
   {% elif c.app.repo.status == 'ready' %}
     {% if h.has_access(c.app, 'write')() %}
-    <p>The metadata for this repository is to be missing.  Please try <a href="{{c.app.url}}refresh">refreshing</a> to correct this.</p>
+    <p>The metadata for this repository is missing.  To fix, please try a <a href="{{c.app.url}}refresh">refresh</a>.</p>
     {% else %}
     <p><b>No (more) commits</b></p>
     {% endif %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8d64c44f/ForgeSVN/forgesvn/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/controllers.py b/ForgeSVN/forgesvn/controllers.py
index b14c134..83537a9 100644
--- a/ForgeSVN/forgesvn/controllers.py
+++ b/ForgeSVN/forgesvn/controllers.py
@@ -32,7 +32,7 @@ class BranchBrowser(repository.BranchBrowser):
     def index(self, limit=None, page=0, count=0, **kw):
         is_empty = c.app.repo.is_empty()
         latest = c.app.repo.latest(branch=self._branch)
-        if empty or not latest:
+        if is_empty or not latest:
             return dict(allow_fork=False, log=[], is_empty=is_empty)
         redirect(c.app.repo._impl.url_for_symbolic(latest._id) + 'tree/')
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8d64c44f/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 1224f9c..fc9879c 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -667,7 +667,13 @@ class SVNImplementation(M.RepositoryImplementation):
                 os.remove(tmpfilename)
 
     def is_empty(self):
-        return self._svn.revpropget('revision', url=self._url)[0].number == 0
+        try:
+            return self._svn.revpropget('revision', url=self._url)[0].number == 0
+        except pysvn.ClientError as e:
+            if str(e).startswith("Unable to connect"):
+                return True
+            else:
+                raise
 
 
 Mapper.compile_all()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8d64c44f/ForgeSVN/forgesvn/templates/svn/index.html
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/templates/svn/index.html b/ForgeSVN/forgesvn/templates/svn/index.html
index 47db43e..9b81fe3 100644
--- a/ForgeSVN/forgesvn/templates/svn/index.html
+++ b/ForgeSVN/forgesvn/templates/svn/index.html
@@ -95,7 +95,7 @@ svn import {{c.app.repo.clone_url('rw', c.user.username)}} -m "Initial commit"</
     {% endif %}
   {% elif c.app.repo.status == 'ready' %}
     {% if h.has_access(c.app, 'write')() %}
-    <p>The metadata for this repository is to be missing.  Please try <a href="{{c.app.url}}refresh">refreshing</a> to correct this.</p>
+    <p>The metadata for this repository is missing.  To fix, please try a <a href="{{c.app.url}}refresh">refresh</a>.</p>
     {% else %}
     <p><b>No (more) commits</b></p>
     {% endif %}


[50/50] git commit: [#5655] Refactored site_stats and added ticket and post 24hr stats

Posted by jo...@apache.org.
[#5655] Refactored site_stats and added ticket and post 24hr stats

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/5655
Commit: d4524de4591820816f230c755290a0c1976a4986
Parents: 5639518
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Apr 24 22:30:06 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Apr 24 22:30:06 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/rest.py             |   11 +++++++----
 ForgeDiscussion/forgediscussion/site_stats.py |    8 ++++++++
 ForgeDiscussion/setup.py                      |    3 +++
 ForgeTracker/forgetracker/site_stats.py       |   10 ++++++++++
 ForgeTracker/setup.py                         |    3 +++
 5 files changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d4524de4/Allura/allura/controllers/rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index 0d519cc..70e3ac7 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -62,10 +62,13 @@ class RestController(object):
 
     @expose('json:')
     def index(self, **kw):
-        provider = g.entry_points['site_stats'].get('provider')
-        if provider:
-            return provider()
-        return dict()
+        summary = dict()
+        stats = dict()
+        for stat, provider in g.entry_points['site_stats'].iteritems():
+            stats[stat] = provider()
+        if stats:
+            summary['site_stats'] = stats
+        return summary
 
     @expose()
     def _lookup(self, name, *remainder):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d4524de4/ForgeDiscussion/forgediscussion/site_stats.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/site_stats.py b/ForgeDiscussion/forgediscussion/site_stats.py
new file mode 100644
index 0000000..e76201d
--- /dev/null
+++ b/ForgeDiscussion/forgediscussion/site_stats.py
@@ -0,0 +1,8 @@
+from datetime import datetime, timedelta
+
+from . import model as DM
+
+
+def posts_24hr():
+    window = datetime.utcnow() - timedelta(hours=24)
+    return DM.ForumPost.query.find({'timestamp': {'$gte': window}}).count()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d4524de4/ForgeDiscussion/setup.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/setup.py b/ForgeDiscussion/setup.py
index 5c58b7a..812c8a0 100644
--- a/ForgeDiscussion/setup.py
+++ b/ForgeDiscussion/setup.py
@@ -44,5 +44,8 @@ setup(name='ForgeDiscussion',
       # -*- Entry points: -*-
       [allura]
       Discussion=forgediscussion.forum_main:ForgeDiscussionApp
+
+      [allura.site_stats]
+      posts_24hr=forgediscussion.site_stats:posts_24hr
       """,
       )

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d4524de4/ForgeTracker/forgetracker/site_stats.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/site_stats.py b/ForgeTracker/forgetracker/site_stats.py
new file mode 100644
index 0000000..e0baa63
--- /dev/null
+++ b/ForgeTracker/forgetracker/site_stats.py
@@ -0,0 +1,10 @@
+from datetime import datetime, timedelta
+
+from bson import ObjectId
+
+from . import model as TM
+
+
+def tickets_stats_24hr():
+    window = datetime.utcnow() - timedelta(hours=24)
+    return TM.Ticket.query.find({'_id': {'$gte': ObjectId.from_datetime(window)}}).count()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d4524de4/ForgeTracker/setup.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/setup.py b/ForgeTracker/setup.py
index 57e5d45..1934cc2 100644
--- a/ForgeTracker/setup.py
+++ b/ForgeTracker/setup.py
@@ -43,6 +43,9 @@ setup(name='ForgeTracker',
       [allura]
       Tickets=forgetracker.tracker_main:ForgeTrackerApp
 
+      [allura.site_stats]
+      tickets_24hr=forgetracker.site_stats:tickets_stats_24hr
+
       [easy_widgets.resources]
       ew_resources=forgetracker.config.resources:register_ew_resources
 


[02/50] git commit: [#6083] Improved empty repo checking

Posted by jo...@apache.org.
[#6083] Improved empty repo checking

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/5655
Commit: 2e862b7a0fe753c3fb60270fb9817f11efd98c41
Parents: 25d0746
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Apr 19 20:47:52 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Mon Apr 22 21:29:56 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/repository.py                |    6 ++++++
 ForgeGit/forgegit/controllers.py                 |    5 +++--
 ForgeGit/forgegit/model/git_repo.py              |    3 +++
 ForgeGit/forgegit/templates/git/index.html       |    8 +++++++-
 ForgeGit/forgegit/tests/model/test_repository.py |   16 ++++++++++++++++
 ForgeSVN/forgesvn/controllers.py                 |    5 +++--
 ForgeSVN/forgesvn/model/svn.py                   |    3 +++
 ForgeSVN/forgesvn/templates/svn/index.html       |    8 +++++++-
 ForgeSVN/forgesvn/tests/model/test_repository.py |   16 ++++++++++++++++
 requirements-common.txt                          |    2 ++
 requirements-sf.txt                              |    2 +-
 11 files changed, 67 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 793f411..cae4ce0 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -163,6 +163,10 @@ class RepositoryImplementation(object):
             commit = parent
         return result
 
+    def is_empty(self):
+        '''Determine if the repository is empty by checking the filesystem'''
+        raise NotImplementedError, 'is_empty'
+
     @classmethod
     def shorthand_for_commit(cls, oid):
         return '[%s]' % oid[:6]
@@ -342,6 +346,8 @@ class Repository(Artifact, ActivityObject):
         return self._impl.commits_count(path, rev)
     def last_commit_ids(self, commit, paths):
         return self._impl.last_commit_ids(commit, paths)
+    def is_empty(self):
+        return self._impl.is_empty()
 
     def _log(self, rev, skip, limit):
         head = self.commit(rev)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/ForgeGit/forgegit/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/controllers.py b/ForgeGit/forgegit/controllers.py
index b3fdd5d..320cc9b 100644
--- a/ForgeGit/forgegit/controllers.py
+++ b/ForgeGit/forgegit/controllers.py
@@ -26,8 +26,9 @@ class BranchBrowser(repository.BranchBrowser):
     @expose('jinja:forgegit:templates/git/index.html')
     @with_trailing_slash
     def index(self, limit=None, page=0, count=0, **kw):
+        is_empty = c.app.repo.is_empty()
         latest = c.app.repo.latest(branch=self._branch)
-        if not latest:
-            return dict(allow_fork=False, log=[])
+        if is_empty or not latest:
+            return dict(allow_fork=False, log=[], is_empty=is_empty)
         redirect(c.app.repo._impl.url_for_symbolic(latest._id) + 'tree/')
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/ForgeGit/forgegit/model/git_repo.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index c47589a..296430f 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -355,6 +355,9 @@ class GitImplementation(M.RepositoryImplementation):
             if os.path.exists(tmpfilename):
                 os.remove(tmpfilename)
 
+    def is_empty(self):
+        return len(self._git.heads) == 0
+
 
 class _OpenedGitBlob(object):
     CHUNK_SIZE=4096

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/ForgeGit/forgegit/templates/git/index.html
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/templates/git/index.html b/ForgeGit/forgegit/templates/git/index.html
index 99881ae..4276e65 100644
--- a/ForgeGit/forgegit/templates/git/index.html
+++ b/ForgeGit/forgegit/templates/git/index.html
@@ -37,7 +37,7 @@
     {% if int(count) > int(limit) %}
       <a href="log?page=1">More</a>
     {% endif %}
-  {% elif c.app.repo.status == 'ready' %}
+  {% elif is_empty %}
     {% if h.has_access(c.app, 'write')() %}
     <div class="message warning scm-learn-basics">
       <div class="content">
@@ -84,5 +84,11 @@ git branch --set-upstream master origin/master  # so 'git pull' will work later<
     {% else %}
     <p><b>No (more) commits</b></p>
     {% endif %}
+  {% elif c.app.repo.status == 'ready' %}
+    {% if h.has_access(c.app, 'write')() %}
+    <p>The metadata for this repository is to be missing.  Please try <a href="{{c.app.url}}refresh">refreshing</a> to correct this.</p>
+    {% else %}
+    <p><b>No (more) commits</b></p>
+    {% endif %}
   {% endif %}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 41c48fd..18de668 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -27,6 +27,7 @@ import tg
 from ming.base import Object
 from ming.orm import ThreadLocalORMSession, session
 from nose.tools import assert_equal
+from testfixtures import TempDirectory
 
 from alluratest.controller import setup_basic_test, setup_global_objects
 from allura.lib import helpers as h
@@ -307,6 +308,21 @@ class TestGitRepo(unittest.TestCase, RepoImplTestBase):
         os.makedirs("/tmp/tarball/git/t/te/test/testgit.git/test-src-git-HEAD")
         assert_equal(self.repo.get_tarball_status('HEAD'), None)
 
+    def test_is_empty(self):
+        assert not self.repo.is_empty()
+        with TempDirectory() as d:
+            repo2 = GM.Repository(
+                name='test',
+                fs_path=d.path,
+                url_path = '/test/',
+                tool = 'git',
+                status = 'creating')
+            repo2.init()
+            assert repo2.is_empty()
+            repo2.refresh()
+            ThreadLocalORMSession.flush_all()
+            assert repo2.is_empty()
+
 
 class TestGitCommit(unittest.TestCase):
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/ForgeSVN/forgesvn/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/controllers.py b/ForgeSVN/forgesvn/controllers.py
index 156b13a..b14c134 100644
--- a/ForgeSVN/forgesvn/controllers.py
+++ b/ForgeSVN/forgesvn/controllers.py
@@ -30,9 +30,10 @@ class BranchBrowser(repository.BranchBrowser):
     @expose('jinja:forgesvn:templates/svn/index.html')
     @with_trailing_slash
     def index(self, limit=None, page=0, count=0, **kw):
+        is_empty = c.app.repo.is_empty()
         latest = c.app.repo.latest(branch=self._branch)
-        if not latest:
-            return dict(allow_fork=False, log=[])
+        if empty or not latest:
+            return dict(allow_fork=False, log=[], is_empty=is_empty)
         redirect(c.app.repo._impl.url_for_symbolic(latest._id) + 'tree/')
 
     @expose()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index b4c354d..1224f9c 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -666,5 +666,8 @@ class SVNImplementation(M.RepositoryImplementation):
             if os.path.exists(tmpfilename):
                 os.remove(tmpfilename)
 
+    def is_empty(self):
+        return self._svn.revpropget('revision', url=self._url)[0].number == 0
+
 
 Mapper.compile_all()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/ForgeSVN/forgesvn/templates/svn/index.html
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/templates/svn/index.html b/ForgeSVN/forgesvn/templates/svn/index.html
index ed80fb9..47db43e 100644
--- a/ForgeSVN/forgesvn/templates/svn/index.html
+++ b/ForgeSVN/forgesvn/templates/svn/index.html
@@ -37,7 +37,7 @@
     {% if count > limit %}
       <a href="{{c.app.url}}log?page=1">More</a>
     {% endif %}
-  {% elif c.app.repo.status == 'ready' %}
+  {% elif is_empty %}
     {% if h.has_access(c.app, 'write')() %}
     <div class="message warning scm-learn-basics">
       <div class="content">
@@ -93,5 +93,11 @@ svn import {{c.app.repo.clone_url('rw', c.user.username)}} -m "Initial commit"</
     {% else %}
     <p><b>No (more) commits</b></p>
     {% endif %}
+  {% elif c.app.repo.status == 'ready' %}
+    {% if h.has_access(c.app, 'write')() %}
+    <p>The metadata for this repository is to be missing.  Please try <a href="{{c.app.url}}refresh">refreshing</a> to correct this.</p>
+    {% else %}
+    <p><b>No (more) commits</b></p>
+    {% endif %}
   {% endif %}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/ForgeSVN/forgesvn/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/model/test_repository.py b/ForgeSVN/forgesvn/tests/model/test_repository.py
index 1f93dfd..e8fb14e 100644
--- a/ForgeSVN/forgesvn/tests/model/test_repository.py
+++ b/ForgeSVN/forgesvn/tests/model/test_repository.py
@@ -30,6 +30,7 @@ import tg
 import ming
 from ming.base import Object
 from ming.orm import session, ThreadLocalORMSession
+from testfixtures import TempDirectory
 
 from alluratest.controller import setup_basic_test, setup_global_objects
 from allura import model as M
@@ -292,6 +293,21 @@ class TestSVNRepo(unittest.TestCase, RepoImplTestBase):
         self.repo.tarball('1')
         assert os.path.isfile("/tmp/tarball/svn/t/te/test/testsvn/test-src-1.tar.gz")
 
+    def test_is_empty(self):
+        assert not self.repo.is_empty()
+        with TempDirectory() as d:
+            repo2 = SM.Repository(
+                name='test',
+                fs_path=d.path,
+                url_path = '/test/',
+                tool = 'svn',
+                status = 'creating')
+            repo2.init()
+            assert repo2.is_empty()
+            repo2.refresh()
+            ThreadLocalORMSession.flush_all()
+            assert repo2.is_empty()
+
 class TestSVNRev(unittest.TestCase):
 
     def setUp(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index e072ad9..4dcf695 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -76,3 +76,5 @@ nose==1.1.2
 pyflakes==0.5.0
 WebTest==1.4.0
 clonedigger==1.1.0
+testfixtures==3.0.0
+q==2.3

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2e862b7a/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index 628e1e8..0fc28a6 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -4,7 +4,7 @@ akismet==0.2.0
 amqplib==0.6.1
 kombu==1.0.4
 coverage==3.5a1-20110413
-ForgeHg==0.1.6
+ForgeHg==0.1.7
 ForgePastebin==0.2.6
 mechanize==0.2.4
 MySQL-python==1.2.3c1


[30/50] git commit: [#2835] update help text

Posted by jo...@apache.org.
[#2835] update help text


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

Branch: refs/heads/cj/5655
Commit: de200e8cdea99be7e3fdeff9582fa681660746fc
Parents: 196f718
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Mar 27 14:50:37 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:42 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/templates/wiki/search_help.txt |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/de200e8c/ForgeWiki/forgewiki/templates/wiki/search_help.txt
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/search_help.txt b/ForgeWiki/forgewiki/templates/wiki/search_help.txt
index 4a337b8..dc2d380 100644
--- a/ForgeWiki/forgewiki/templates/wiki/search_help.txt
+++ b/ForgeWiki/forgewiki/templates/wiki/search_help.txt
@@ -1,8 +1,6 @@
-<h1>Searching wiki</h1>
-<p>Searches use wiki page title and inner text for matching.<p>
-<p>You can also use 'Search comments?' and 'Search history?' checkboxes to include comments and history of pages editing in the search results.</p>
+<h1>Searching the wiki</h1>
+<p>Searches use wiki page title and body text for matching.<p>
+<p>To search for an exact phrase, put it in quotes.  Example: "getting started docs"</p>
+<p>To exclude a word or phrase, put a dash in front of it.  Example: docs -help</p>
+<p>You can also use 'Search comments?' and 'Search history?' checkboxes to include comments and previous revisions of pages in the search results.</p>
 
-<p>If you want to see all the page with given label, you may use url like this (there is no UI for this):</p>
-<div class="codehilite">
-<pre>/p/yourproject/wiki/search/?q=labels_t:label&amp;parser=standard</pre>
-</div>


[08/50] git commit: [#5120] Fixed branches with / in them

Posted by jo...@apache.org.
[#5120] Fixed branches with / in them

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/5655
Commit: 2eefae860b249290fbb51a4c4e1f9a52265f7bb0
Parents: 90e263e
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Apr 10 15:51:56 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:03:34 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py          |   25 +++++-----
 Allura/allura/model/repository.py                |   44 +++++------------
 ForgeGit/forgegit/controllers.py                 |    4 +-
 ForgeGit/forgegit/git_main.py                    |    2 +-
 ForgeGit/forgegit/tests/model/test_repository.py |    2 +-
 ForgeSVN/forgesvn/controllers.py                 |    4 +-
 ForgeSVN/forgesvn/model/svn.py                   |   17 ++-----
 ForgeSVN/forgesvn/svn_main.py                    |    2 +-
 8 files changed, 36 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2eefae86/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index e073f1a..80605be 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -73,8 +73,7 @@ class RepoRootController(BaseController):
     def index(self, offset=0, branch=None, **kw):
         if branch is None:
             branch=c.app.default_branch_name
-        redirect(url(quote('%s%s/' % (
-                        branch, c.app.END_OF_REF_ESCAPE))))
+        redirect(c.app.repo.url_for_commit(branch, url_type='ref'))
 
     @with_trailing_slash
     @expose('jinja:allura:templates/repo/forks.html')
@@ -377,21 +376,23 @@ class RefsController(object):
         self.BranchBrowserClass = BranchBrowserClass
 
     @expose()
-    def _lookup(self, *parts):
-        parts = map(unquote, parts)
-        ref = []
-        while parts:
-            part = parts.pop(0)
-            ref.append(part)
-            if part.endswith(c.app.END_OF_REF_ESCAPE):
-                break
-        ref = '/'.join(ref)[:-1]
-        return self.BranchBrowserClass(ref), parts
+    def _lookup(self, ref, *remainder):
+        EOR = quote(c.app.END_OF_REF_ESCAPE)
+        if EOR in remainder:
+            i = remainder.index(quote(c.app.END_OF_REF_ESCAPE))
+            ref = '/'.join((ci,) + remainder[:i])
+            remainder = remainder[i+1:]
+        return self.BranchBrowserClass(ref), remainder
 
 class CommitsController(object):
 
     @expose()
     def _lookup(self, ci, *remainder):
+        EOR = quote(c.app.END_OF_REF_ESCAPE)
+        if EOR in remainder:
+            i = remainder.index(quote(c.app.END_OF_REF_ESCAPE))
+            ci = '/'.join((ci,) + remainder[:i])
+            remainder = remainder[i+1:]
         return CommitBrowser(ci), remainder
 
 class BranchBrowser(BaseController):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2eefae86/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index cae4ce0..8a95993 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -179,40 +179,17 @@ class RepositoryImplementation(object):
         tags = [t.name for t in self._repo.repo_tags if t.object_id == commit._id]
         return branches, tags
 
-    def url_for_symbolic(self, commit):
-        if isinstance(commit, basestring):
-            object_id = commit
-        else:
-            object_id = commit._id
-
-        if self._repo.commit(object_id).symbolic_ids:
-            rev = None
-            branches, tags = self._repo.commit(object_id).symbolic_ids
-            for branch in branches:
-                last_commit = self._repo.latest(branch)
-                if last_commit and (object_id == last_commit._id):
-                    rev = branch
-                    break
-
-            for tag in tags:
-                last_commit = self._repo.latest(tag)
-                if last_commit and (object_id == last_commit._id):
-                    rev = tag
-                    break
-
-            if rev:
-                object_id = quote(rev, safe='')
-
-        return '%sci/%s/' % (self._repo.url(), object_id)
-
-    def url_for_commit(self, commit):
+    def url_for_commit(self, commit, url_type='ci'):
         'return an URL, given either a commit or object id'
         if isinstance(commit, basestring):
             object_id = commit
         else:
             object_id = commit._id
 
-        return '%sci/%s/' % (self._repo.url(), object_id)
+        if '/' in object_id:
+            object_id = os.path.join(object_id, self._repo.app.END_OF_REF_ESCAPE)
+
+        return os.path.join(self._repo.url(), url_type, object_id) + '/'
 
     def _setup_paths(self, create_repo_dir=True):
         '''
@@ -336,8 +313,8 @@ class Repository(Artifact, ActivityObject):
         return self._impl.shorthand_for_commit(oid)
     def symbolics_for_commit(self, commit):
         return self._impl.symbolics_for_commit(commit)
-    def url_for_commit(self, commit):
-        return self._impl.url_for_commit(commit)
+    def url_for_commit(self, commit, url_type='ci'):
+        return self._impl.url_for_commit(commit, url_type)
     def compute_tree_new(self, commit, path='/'):
         return self._impl.compute_tree_new(commit, path)
     def commits(self, path=None, rev=None, skip=None, limit=None):
@@ -453,8 +430,11 @@ class Repository(Artifact, ActivityObject):
         for oid in self.commitlog([ci._id]): result += 1
         return result
 
-    def latest(self, branch='master'):
-        if self._impl is None: return None
+    def latest(self, branch=None):
+        if self._impl is None:
+            return None
+        if branch is None:
+            branch = self.app.default_branch_name
         try:
             return self.commit(branch)
         except: # pragma no cover

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2eefae86/ForgeGit/forgegit/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/controllers.py b/ForgeGit/forgegit/controllers.py
index 320cc9b..93e9364 100644
--- a/ForgeGit/forgegit/controllers.py
+++ b/ForgeGit/forgegit/controllers.py
@@ -21,6 +21,7 @@ from pylons import tmpl_context as c
 
 from allura.controllers import repository
 
+
 class BranchBrowser(repository.BranchBrowser):
 
     @expose('jinja:forgegit:templates/git/index.html')
@@ -30,5 +31,4 @@ class BranchBrowser(repository.BranchBrowser):
         latest = c.app.repo.latest(branch=self._branch)
         if is_empty or not latest:
             return dict(allow_fork=False, log=[], is_empty=is_empty)
-        redirect(c.app.repo._impl.url_for_symbolic(latest._id) + 'tree/')
-
+        redirect(c.app.repo.url_for_commit(self._branch) + 'tree/')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2eefae86/ForgeGit/forgegit/git_main.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/git_main.py b/ForgeGit/forgegit/git_main.py
index 7e3a79e..85219f8 100644
--- a/ForgeGit/forgegit/git_main.py
+++ b/ForgeGit/forgegit/git_main.py
@@ -50,7 +50,7 @@ class ForgeGitApp(RepositoryApp):
     """
     ordinal=2
     forkable=True
-    default_branch_name='ref/master'
+    default_branch_name='master'
 
     def __init__(self, project, config):
         super(ForgeGitApp, self).__init__(project, config)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2eefae86/ForgeGit/forgegit/tests/model/test_repository.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 18de668..46c2daa 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -349,7 +349,7 @@ class TestGitCommit(unittest.TestCase):
 
     def test_url(self):
         assert self.rev.url().endswith('ca4a/')
-        assert self.repo._impl.url_for_symbolic(self.rev._id).endswith('master/'), self.repo._impl.url_for_symbolic(self.rev._id)
+        assert self.repo._impl.url_for_commit('master').endswith('master/'), self.repo._impl.url_for_commit('master')
 
     def test_committer_url(self):
         assert self.rev.committer_url is None

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2eefae86/ForgeSVN/forgesvn/controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/controllers.py b/ForgeSVN/forgesvn/controllers.py
index 83537a9..2e39fc7 100644
--- a/ForgeSVN/forgesvn/controllers.py
+++ b/ForgeSVN/forgesvn/controllers.py
@@ -20,7 +20,7 @@ from tg.decorators import with_trailing_slash
 from pylons import tmpl_context as c
 
 from allura.controllers import repository
-from allura.lib import helpers as h
+
 
 class BranchBrowser(repository.BranchBrowser):
 
@@ -34,7 +34,7 @@ class BranchBrowser(repository.BranchBrowser):
         latest = c.app.repo.latest(branch=self._branch)
         if is_empty or not latest:
             return dict(allow_fork=False, log=[], is_empty=is_empty)
-        redirect(c.app.repo._impl.url_for_symbolic(latest._id) + 'tree/')
+        redirect(c.app.repo.url_for_commit(c.app.default_branch_name) + 'tree/')
 
     @expose()
     def _lookup(self, rev, *remainder):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2eefae86/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 9fc9ed1..de05fd0 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -179,23 +179,14 @@ class SVNImplementation(M.RepositoryImplementation):
     def shorthand_for_commit(self, oid):
         return '[r%d]' % self._revno(oid)
 
-    def url_for_symbolic(self, commit):
+    def url_for_commit(self, commit, url_type=None):
         if isinstance(commit, basestring):
             object_id = commit
         else:
             object_id = commit._id
-        if self._repo.latest()._id == object_id:
-            return '%sHEAD/' % self._repo.url()
-        return '%s%d/' % (
-            self._repo.url(), self._revno(object_id))
-
-    def url_for_commit(self, commit):
-        if isinstance(commit, basestring):
-            object_id = commit
-        else:
-            object_id = commit._id
-        return '%s%d/' % (
-            self._repo.url(), self._revno(object_id))
+        if ':' in object_id:
+            object_id = str(self._revno(object_id))
+        return os.path.join(self._repo.url(), object_id) + '/'
 
     def init(self, default_dirs=False, skip_special_files=False):
         fullname = self._setup_paths()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2eefae86/ForgeSVN/forgesvn/svn_main.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/svn_main.py b/ForgeSVN/forgesvn/svn_main.py
index 0e8a900..cca94f7 100644
--- a/ForgeSVN/forgesvn/svn_main.py
+++ b/ForgeSVN/forgesvn/svn_main.py
@@ -57,7 +57,7 @@ class ForgeSVNApp(RepositoryApp):
     """
     ordinal=4
     forkable=False
-    default_branch_name=''
+    default_branch_name='HEAD'
 
     def __init__(self, project, config):
         super(ForgeSVNApp, self).__init__(project, config)


[39/50] git commit: [#2835] show search help on all search pages

Posted by jo...@apache.org.
[#2835] show search help on all search pages


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

Branch: refs/heads/cj/5655
Commit: d958fae688f198dceb680709a09dadb62b9291f4
Parents: 62912a9
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Apr 24 16:33:35 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:43 2013 +0000

----------------------------------------------------------------------
 Allura/allura/ext/search/search_main.py            |    3 ++-
 Allura/allura/lib/widgets/search.py                |   12 ++++++++----
 Allura/allura/templates/widgets/search_help.html   |   13 +++++++++++++
 ForgeBlog/forgeblog/main.py                        |    4 +++-
 ForgeChat/forgechat/main.py                        |    3 ++-
 .../forgediscussion/controllers/root.py            |    4 +++-
 ForgeShortUrl/forgeshorturl/main.py                |    4 +++-
 ForgeWiki/forgewiki/templates/wiki/search_help.txt |    6 ------
 ForgeWiki/forgewiki/wiki_main.py                   |    6 +-----
 9 files changed, 35 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/Allura/allura/ext/search/search_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/search/search_main.py b/Allura/allura/ext/search/search_main.py
index 9b709f4..b543e62 100644
--- a/Allura/allura/ext/search/search_main.py
+++ b/Allura/allura/ext/search/search_main.py
@@ -26,7 +26,7 @@ from formencode import validators as V
 from allura.app import Application
 from allura import version
 from allura.lib.search import search_app
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 from allura.controllers import BaseController
 
 log = logging.getLogger(__name__)
@@ -68,6 +68,7 @@ class SearchController(BaseController):
     @with_trailing_slash
     def index(self, q=None, history=None, **kw):
         c.search_results = SearchResults()
+        c.help_modal = SearchHelp(comments=False)
         pids = [c.project._id] + [
             p._id for p in c.project.subprojects ]
         project_match = ' OR '.join(

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/Allura/allura/lib/widgets/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/search.py b/Allura/allura/lib/widgets/search.py
index 22f4d8a..e553842 100644
--- a/Allura/allura/lib/widgets/search.py
+++ b/Allura/allura/lib/widgets/search.py
@@ -17,6 +17,7 @@
 
 import ew as ew_core
 import ew.jinja2_ew as ew
+import jinja2
 
 from allura.lib.widgets import form_fields as ffw
 
@@ -47,8 +48,11 @@ class SearchHelp(ffw.Lightbox):
         name='search_help_modal',
         trigger='a.search_help_modal')
 
-    content_template = '<div style="height:400px; overflow:auto;">%s</div>'
-
-    def __init__(self, content=''):
+    def __init__(self, comments=True, history=True):
         super(SearchHelp, self).__init__()
-        self.content = self.content_template % content
+        # can't use g.jinja2_env since this widget gets imported too early :(
+        jinja2_env = jinja2.Environment(loader=jinja2.PackageLoader('allura', 'templates/widgets'))
+        self.content = jinja2_env.get_template('search_help.html').render(dict(
+            comments=comments,
+            history=history,
+        ))

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/Allura/allura/templates/widgets/search_help.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/search_help.html b/Allura/allura/templates/widgets/search_help.html
new file mode 100644
index 0000000..89a4fbc
--- /dev/null
+++ b/Allura/allura/templates/widgets/search_help.html
@@ -0,0 +1,13 @@
+<div style="height:400px; overflow:auto;">
+    
+<h1>Searching</h1>
+<p>To search for an exact phrase, put it in quotes.  Example: "getting started docs"</p>
+<p>To exclude a word or phrase, put a dash in front of it.  Example: docs -help</p>
+{% if comments %}
+<p>You can use the 'Search comments?' checkbox to include comments in the search results.</p>
+{% endif %}
+{% if history %}
+<p>You can use the 'Search history?' checkbox to include previous revisions of items in the search results.</p>
+{% endif %}
+
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 91ed6b6..f745af9 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -43,7 +43,7 @@ from allura.lib.security import has_access, require_access
 from allura.lib import widgets as w
 from allura.lib.widgets.subscriptions import SubscribeForm
 from allura.lib.widgets import form_fields as ffw
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 from allura import model as M
 from allura.controllers import BaseController, AppDiscussionController
 
@@ -68,6 +68,7 @@ class W:
     preview_post_form = widgets.PreviewPostForm()
     subscribe_form = SubscribeForm()
     search_results = SearchResults()
+    help_modal = SearchHelp()
 
 class ForgeBlogApp(Application):
     __version__ = version.__version__
@@ -212,6 +213,7 @@ class RootController(BaseController):
                    project=validators.StringBool(if_empty=False)))
     def search(self, q=None, history=None, search_comments=None, project=None, limit=None, page=0, **kw):
         c.search_results = W.search_results
+        c.help_modal = W.help_modal
         search_params = kw
         search_params.update({
             'q': q or '',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeChat/forgechat/main.py
----------------------------------------------------------------------
diff --git a/ForgeChat/forgechat/main.py b/ForgeChat/forgechat/main.py
index 05eaf94..d7a9860 100644
--- a/ForgeChat/forgechat/main.py
+++ b/ForgeChat/forgechat/main.py
@@ -33,7 +33,7 @@ from allura.lib import helpers as h
 from allura.lib.search import search_app
 from allura.lib.decorators import require_post
 from allura.lib.security import require_access
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 from allura import model as M
 from allura.controllers import BaseController
 
@@ -140,6 +140,7 @@ class RootController(BaseController):
                    project=validators.StringBool(if_empty=False)))
     def search(self, q=None, project=None, limit=None, page=0, **kw):
         c.search_results = SearchResults()
+        c.help_modal = SearchHelp(comments=False, history=False)
         search_params = kw
         search_params.update({
             'q': q or '',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index 3bd1b94..d9058fb 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -42,7 +42,7 @@ from forgediscussion import model
 from forgediscussion import utils
 from forgediscussion import widgets as FW
 from allura.lib.widgets import discuss as DW
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 
 from forgediscussion.widgets.admin import AddForumShort
 
@@ -56,6 +56,7 @@ class RootController(BaseController, DispatchIndex):
         announcements_table=FW.AnnouncementsTable()
         add_forum=AddForumShort()
         search_results = SearchResults()
+        search_help = SearchHelp(comments=False, history=False)
 
     def _check_security(self):
         require_access(c.app, 'read')
@@ -131,6 +132,7 @@ class RootController(BaseController, DispatchIndex):
                    page=validators.Int(if_empty=0)))
     def search(self, q=None, history=None, project=None, limit=None, page=0, **kw):
         c.search_results = self.W.search_results
+        c.help_modal = self.W.search_help
         search_params = kw
         search_params.update({
             'q': q or '',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeShortUrl/forgeshorturl/main.py
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/main.py b/ForgeShortUrl/forgeshorturl/main.py
index 79c48ce..1ce62d8 100644
--- a/ForgeShortUrl/forgeshorturl/main.py
+++ b/ForgeShortUrl/forgeshorturl/main.py
@@ -25,7 +25,7 @@ from allura.lib import helpers as h
 from allura.lib.search import search_app
 from allura.controllers import BaseController
 from allura.lib.widgets import form_fields as ffw
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 
 from webob import exc
 from pylons import tmpl_context as c, app_globals as g
@@ -44,6 +44,7 @@ log = logging.getLogger(__name__)
 
 class W:
     search_results = SearchResults()
+    search_help = SearchHelp(comments=False, history=False)
     page_list = ffw.PageList()
     page_size = ffw.PageSize()
     create_short_url_lightbox = suw.CreateShortUrlWidget(
@@ -164,6 +165,7 @@ class RootController(BaseController):
                    project=validators.StringBool(if_empty=False)))
     def search(self, q=None, project=None, limit=None, page=0, **kw):
         c.search_results = W.search_results
+        c.help_modal = W.search_help
         search_params = kw
         search_params.update({
             'q': q or '',

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeWiki/forgewiki/templates/wiki/search_help.txt
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/search_help.txt b/ForgeWiki/forgewiki/templates/wiki/search_help.txt
deleted file mode 100644
index dc2d380..0000000
--- a/ForgeWiki/forgewiki/templates/wiki/search_help.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-<h1>Searching the wiki</h1>
-<p>Searches use wiki page title and body text for matching.<p>
-<p>To search for an exact phrase, put it in quotes.  Example: "getting started docs"</p>
-<p>To exclude a word or phrase, put a dash in front of it.  Example: docs -help</p>
-<p>You can also use 'Search comments?' and 'Search history?' checkboxes to include comments and previous revisions of pages in the search results.</p>
-

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d958fae6/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index b2dbee7..23ca7f2 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -30,7 +30,6 @@ from pylons import request
 from formencode import validators
 from webob import exc
 from ming.orm import session
-import jinja2
 
 # Pyforge-specific imports
 from allura import model as M
@@ -54,9 +53,6 @@ from forgewiki.widgets.wiki import CreatePageWidget
 
 log = logging.getLogger(__name__)
 
-jinja_env = jinja2.Environment(loader=jinja2.PackageLoader('forgewiki', 'templates'))
-search_help_text = jinja_env.get_template('wiki/search_help.txt').render()
-
 
 class W:
     thread=w.Thread(
@@ -72,7 +68,7 @@ class W:
     page_list = ffw.PageList()
     page_size = ffw.PageSize()
     search_results = SearchResults()
-    help_modal = SearchHelp(search_help_text)
+    help_modal = SearchHelp()
     icons={
         24:'images/wiki_24.png',
         32:'images/wiki_32.png',


[03/50] git commit: [#6083] Handle alternate exception msg

Posted by jo...@apache.org.
[#6083] Handle alternate exception msg

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/5655
Commit: 90e263e1a2ccebb1730822613231fee2481c9d99
Parents: 8d64c44
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Apr 23 17:02:59 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:02:59 2013 +0000

----------------------------------------------------------------------
 ForgeSVN/forgesvn/model/svn.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/90e263e1/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index fc9879c..9fc9ed1 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -670,7 +670,8 @@ class SVNImplementation(M.RepositoryImplementation):
         try:
             return self._svn.revpropget('revision', url=self._url)[0].number == 0
         except pysvn.ClientError as e:
-            if str(e).startswith("Unable to connect"):
+            if str(e).startswith("Unable to connect") or \
+                    str(e).startswith("Unable to open"):
                 return True
             else:
                 raise


[13/50] git commit: [#6093] better middleware response, so WebError works

Posted by jo...@apache.org.
[#6093] better middleware response, so WebError works


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

Branch: refs/heads/cj/5655
Commit: 3f9ff9a5582cac80c2587083c22e01d579240bb2
Parents: e6136bd
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Mon Apr 22 19:44:23 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Apr 24 13:44:40 2013 +0000

----------------------------------------------------------------------
 Allura/allura/config/middleware.py     |    1 +
 Allura/allura/lib/custom_middleware.py |    6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3f9ff9a5/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index 9cadf6b..a877221 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -124,6 +124,7 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
     # Required for sessions
     app = SessionMiddleware(app, config)
     # Converts exceptions to HTTP errors, shows traceback in debug mode
+    tg.error.footer_html = '<!-- %s %s -->'  # don't use TG footer with extra CSS & images that take time to load
     app = tg.error.ErrorHandler(app, global_conf, **config['pylons.errorware'])
     # Redirect some status codes to /error/document
     if config.get('override_root') != 'task':

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3f9ff9a5/Allura/allura/lib/custom_middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 1a1b678..6633489 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -165,10 +165,10 @@ class SSLMiddleware(object):
         elif secure:
             resp = exc.HTTPFound(location='http://' + srv_path)
 
-        if resp is None:
-            resp = req.get_response(self.app)
+        if not resp:
+            resp = self.app
         return resp(environ, start_response)
-
+    
 class AlluraTimerMiddleware(TimerMiddleware):
     def timers(self):
         import genshi


[16/50] git commit: [#2835] ticket:289 Test wiki search

Posted by jo...@apache.org.
[#2835] ticket:289 Test wiki search


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

Branch: refs/heads/cj/5655
Commit: 248e5b6ca709af5c3d1b45e22d1c1536faebafe0
Parents: 1ec5943
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 19 13:02:45 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:40 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/functional/test_root.py |   47 +++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/248e5b6c/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index ba656cc..838086c 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -21,7 +21,7 @@ import os
 import Image, StringIO
 import allura
 
-from nose.tools import assert_true, assert_equal
+from nose.tools import assert_true, assert_equal, assert_in
 
 from ming.orm.ormsession import ThreadLocalORMSession
 from mock import patch
@@ -80,6 +80,51 @@ class TestRootController(TestController):
         response = self.app.get('/wiki/search?q=tést')
         assert 'Search wiki: tést' in response
 
+    @patch('forgewiki.wiki_main.search')
+    def test_search(self, search):
+        r = self.app.get('/wiki/search?q=test')
+        assert_in('<a href="/wiki/search?q=test&amp;sort=score+asc" class="strong">relevance</a>', r)
+        assert_in('<a href="/wiki/search?q=test&amp;sort=mod_date_dt+desc" class="">date</a>', r)
+
+        p = M.Project.query.get(shortname='test')
+        r = self.app.get('/wiki/search?q=test&sort=score+asc')
+        solr_query = {
+            'short_timeout': True,
+            'ignore_errors': False,
+            'rows': 25,
+            'start': 0,
+            'qt': 'dismax',
+            'qf': 'title^2 text',
+            'pf': 'title^2 text',
+            'fq': [
+                'project_id_s:%s'  % p._id,
+                'mount_point_s:wiki',
+                '-deleted_b:true',
+                'type_s:("WikiPage" OR "WikiPage Snapshot")',
+                'is_history_b:False',
+            ],
+            'hl': 'true',
+            'hl.simple.pre': '<strong>',
+            'hl.simple.post': '</strong>',
+            'sort': 'score asc',
+        }
+        search.assert_called_with('test', **solr_query)
+
+        r = self.app.get('/wiki/search?q=test&search_comments=on&history=on&sort=mod_date_dt+desc')
+        solr_query['fq'][3] = 'type_s:("WikiPage" OR "WikiPage Snapshot" OR "Post")'
+        solr_query['fq'].remove('is_history_b:False')
+        solr_query['sort'] = 'mod_date_dt desc'
+        search.assert_called_with('test', **solr_query)
+
+        r = self.app.get('/wiki/search?q=test&parser=standard')
+        solr_query['sort'] = 'score desc'
+        solr_query['fq'][3] = 'type_s:("WikiPage" OR "WikiPage Snapshot")'
+        solr_query['fq'].append('is_history_b:False')
+        solr_query.pop('qt')
+        solr_query.pop('qf')
+        solr_query.pop('pf')
+        search.assert_called_with('test', **solr_query)
+
     def test_page_index(self):
         response = self.app.get('/wiki/tést/')
         assert 'tést' in response.follow()


[21/50] git commit: [#2835] ticket:292 Fix failing test due to minor indexation changes

Posted by jo...@apache.org.
[#2835] ticket:292 Fix failing test due to minor indexation changes


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

Branch: refs/heads/cj/5655
Commit: 1fc20bd2d730e4dbead0119cf08780d69048f2c4
Parents: b38865b
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 25 14:54:51 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_discussion.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1fc20bd2/Allura/allura/tests/model/test_discussion.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index 05ad7e2..f49446b 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -155,7 +155,7 @@ def test_post_methods():
     assert p.link_text() == p.subject
 
     ss = p.history().first()
-    assert 'Version' in h.get_first(ss.index(), 'title')
+    assert 'version' in h.get_first(ss.index(), 'title')
     assert '#' in ss.shorthand_id()
 
     jsn = p.__json__()


[07/50] git commit: [#5120] Only show first 10 branches, like with tags

Posted by jo...@apache.org.
[#5120] Only show first 10 branches, like with tags

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/5655
Commit: 0dcf37f4215d876deb60b350bebd3eb1d962c8dc
Parents: 2eefae8
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Apr 10 16:14:45 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:03:34 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py |    5 +++
 Allura/allura/lib/repository.py         |   41 ++++++++++++-------------
 Allura/allura/templates/repo/tags.html  |   10 +++---
 3 files changed, 30 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0dcf37f4/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 80605be..ef678f5 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -409,6 +409,11 @@ class BranchBrowser(BaseController):
     def tags(self, **kw):
         return dict(tags=c.app.repo.repo_tags)
 
+    @expose('jinja:allura:templates/repo/tags.html')
+    @with_trailing_slash
+    def branches(self, **kw):
+        return dict(title='Branches', tags=c.app.repo.branches)
+
     @expose()
     @with_trailing_slash
     def log(self, **kw):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0dcf37f4/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index b16392d..f59ec04 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -97,13 +97,6 @@ class RepositoryApp(Application):
     def sidebar_menu(self):
         if not self.repo or self.repo.status != 'ready':
             return []
-        if self.default_branch_name:
-            default_branch_url = (
-                c.app.url
-                + url(quote(self.default_branch_name + self.END_OF_REF_ESCAPE))
-                + '/')
-        else:
-            default_branch_url = c.app.url
         links = [SitemapEntry('Browse Commits', c.app.url + 'commit_browser', ui_icon=g.icons['folder'])]
         if self.forkable and self.repo.status == 'ready':
             links.append(SitemapEntry('Fork', c.app.url + 'fork', ui_icon=g.icons['fork']))
@@ -135,27 +128,33 @@ class RepositoryApp(Application):
                         'Pending Merges',
                         self.repo.upstream_repo.name + 'merge-requests/',
                         small=pending_upstream_merges))
+        ref_url = self.repo.url_for_commit(self.default_branch_name, url_type='ref')
         if self.repo.branches:
             links.append(SitemapEntry('Branches'))
-            for b in self.repo.branches:
+            max_branches = 10
+            for b in self.repo.branches[:max_branches]:
                 links.append(SitemapEntry(
-                        b.name, url('%sci/%s/tree/' % (c.app.url, quote(b.name, safe=''))),
+                        b.name, self.repo.url_for_commit(b.name)+'tree/',
                         small=b.count))
+            if len(self.repo.branches) > max_branches:
+                links.append(
+                    SitemapEntry(
+                        'More Branches',
+                        ref_url + 'branches/',
+                        ))
         if self.repo.repo_tags:
             links.append(SitemapEntry('Tags'))
             max_tags = 10
-            for i, b in enumerate(self.repo.repo_tags):
-                if i < max_tags:
-                    links.append(SitemapEntry(
-                            b.name, url('%sci/%s/tree/' % (c.app.url, quote(b.name, safe=''))),
-                            small=b.count))
-                elif i == max_tags:
-                    links.append(
-                        SitemapEntry(
-                            'More Tags',
-                            default_branch_url+'tags/',
-                            ))
-                    break
+            for b in self.repo.repo_tags[:max_tags]:
+                links.append(SitemapEntry(
+                        b.name, self.repo.url_for_commit(b.name)+'tree/',
+                        small=b.count))
+            if len(self.repo.repo_tags) > max_tags:
+                links.append(
+                    SitemapEntry(
+                        'More Tags',
+                        ref_url + 'tags/',
+                        ))
         return links
 
     def install(self, project):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0dcf37f4/Allura/allura/templates/repo/tags.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tags.html b/Allura/allura/templates/repo/tags.html
index ef4640e..579b294 100644
--- a/Allura/allura/templates/repo/tags.html
+++ b/Allura/allura/templates/repo/tags.html
@@ -20,18 +20,18 @@
 
 {% block title %}
   {% if c.app.repo %}
-    Tags: {{c.app.repo.name}}
+    {{title or 'Tags'}}: {{c.app.repo.name}}
   {% else %}
-    Tags
+    {{title or 'Tags'}}
   {% endif %}
 {% endblock %}
 
-{% block header %}{{c.app.config.options.mount_label}} Tags{% endblock %}
+{% block header %}{{c.app.config.options.mount_label}} {{title or 'Tags'}}{% endblock %}
 
 {% block content %}
   <div class="grid-19">
-  {% for b in c.app.repo.repo_tags %}
-    <a href="{{c.app.url}}?branch=ref/{{b.name}}">{{b.name}}</a><br>
+  {% for b in tags %}
+    <a href="{{c.app.repo.url_for_commit(b.name)}}tree/">{{b.name}}</a><br>
   {% endfor %}
   </div>
 {% endblock %}


[47/50] git commit: add a few missed license headers; ignore a few build & test dirs

Posted by jo...@apache.org.
add a few missed license headers; ignore a few build & test dirs


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

Branch: refs/heads/cj/5655
Commit: d8a9c75db5bb2bea13a807bcedf0a1adec822d2d
Parents: a1029bf
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Apr 24 16:23:04 2013 -0400
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:23:04 2013 -0400

----------------------------------------------------------------------
 Allura/allura/templates/members.html             |   18 ++++++++++++
 Allura/allura/templates/widgets/search_help.html |   20 +++++++++++++-
 rat-excludes.txt                                 |    4 +++
 vagrant/compress.sh                              |   25 ++++++++++++++---
 4 files changed, 62 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d8a9c75d/Allura/allura/templates/members.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/members.html b/Allura/allura/templates/members.html
index f709d78..2eac1d0 100644
--- a/Allura/allura/templates/members.html
+++ b/Allura/allura/templates/members.html
@@ -1,3 +1,21 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
 {% set hide_left_bar = True %}
 {% extends g.theme.master %}
 {% block title %}Members{% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d8a9c75d/Allura/allura/templates/widgets/search_help.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/search_help.html b/Allura/allura/templates/widgets/search_help.html
index 89a4fbc..ab701db 100644
--- a/Allura/allura/templates/widgets/search_help.html
+++ b/Allura/allura/templates/widgets/search_help.html
@@ -1,5 +1,23 @@
+{#-
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+-#}
 <div style="height:400px; overflow:auto;">
-    
+
 <h1>Searching</h1>
 <p>To search for an exact phrase, put it in quotes.  Example: "getting started docs"</p>
 <p>To exclude a word or phrase, put a dash in front of it.  Example: docs -help</p>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d8a9c75d/rat-excludes.txt
----------------------------------------------------------------------
diff --git a/rat-excludes.txt b/rat-excludes.txt
index 10a862f..bae4984 100644
--- a/rat-excludes.txt
+++ b/rat-excludes.txt
@@ -2,9 +2,12 @@ rat-excludes.txt
 **/setup.cfg
 **/*.json
 **/*.git/
+**/*.egg-info/
 requirements*
 **/MANIFEST.in
+**/test.log
 Allura/allura/controllers/controller.template
+Allura/docs/_build/
 Allura/allura/etc/mime.types
 Allura/allura/lib/AsciiDammit.py
 Allura/allura/lib/widgets/resources/css/autocomplete.css
@@ -31,3 +34,4 @@ ForgeSVN/forgesvn/tests/data/testsvn/
 solr_config/core0/conf/spellings.txt
 solr_config/core1/conf/spellings.txt
 solr_config/solr.xml
+

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d8a9c75d/vagrant/compress.sh
----------------------------------------------------------------------
diff --git a/vagrant/compress.sh b/vagrant/compress.sh
index c9bcd77..4fd9936 100755
--- a/vagrant/compress.sh
+++ b/vagrant/compress.sh
@@ -1,19 +1,36 @@
 #!/bin/bash
 
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
 echo 'Cleanup bash history'
 unset HISTFILE
 [ -f /root/.bash_history ] && rm /root/.bash_history
 [ -f /home/vagrant/.bash_history ] && rm /home/vagrant/.bash_history
- 
+
 echo 'Cleanup log files'
 find /var/log -type f | while read f; do echo -ne '' > $f; done;
- 
+
 echo 'Whiteout root'
-count=`df --sync -kP / | tail -n1  | awk -F ' ' '{print $4}'`; 
+count=`df --sync -kP / | tail -n1  | awk -F ' ' '{print $4}'`;
 let count--
 dd if=/dev/zero of=/tmp/whitespace bs=1024 count=$count;
 rm /tmp/whitespace;
- 
+
 echo 'Whiteout /boot'
 count=`df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}'`;
 let count--


[38/50] git commit: [#2835] ticket:304 Use new version of url_paginated instead of slicing trick

Posted by jo...@apache.org.
[#2835] ticket:304 Use new version of url_paginated instead of slicing trick


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

Branch: refs/heads/cj/5655
Commit: 57cf03a77b0ca0cb5d291659942a6b23bb071188
Parents: a7840ce
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Apr 4 12:15:04 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:43 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/discuss.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/57cf03a7/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index fe79820..d169e1b 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -225,8 +225,8 @@ class Thread(Artifact, ActivityObject):
         if not self.first_post:
             self.first_post_id = p._id
         link = None
-        if self.app.tool_label == 'Tickets':
-            link = self.artifact.url() + p.url_paginated()[len(self.url()):]
+        if self.app.tool_label.lower() == 'tickets':
+            link = p.url_paginated()
         if self.ref:
             Feed.post(self.primary(), title=p.subject, description=p.text, link=link)
         return p


[04/50] git commit: [#5120] Bump ForgeHg version

Posted by jo...@apache.org.
[#5120] Bump ForgeHg version

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/5655
Commit: 70f0064361970e0222e5c7451cba0c35d98132ba
Parents: 6194bda
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Apr 23 16:41:21 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:03:34 2013 +0000

----------------------------------------------------------------------
 requirements-sf.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/70f00643/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index 0fc28a6..79cdfe3 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -4,7 +4,7 @@ akismet==0.2.0
 amqplib==0.6.1
 kombu==1.0.4
 coverage==3.5a1-20110413
-ForgeHg==0.1.7
+ForgeHg==0.1.8
 ForgePastebin==0.2.6
 mechanize==0.2.4
 MySQL-python==1.2.3c1


[48/50] git commit: [#6000] Updated GitPython version

Posted by jo...@apache.org.
[#6000] Updated GitPython version

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/5655
Commit: 51f5361f0bdacdf93b95f1a32487bb4b80f96d6e
Parents: d8a9c75
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Apr 24 21:18:08 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Apr 24 21:18:08 2013 +0000

----------------------------------------------------------------------
 requirements-sf.txt |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/51f5361f/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index 42a1b02..ed3e552 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -17,9 +17,9 @@ wsgipreload==1.2
 pyzmq==2.1.7
 html2text==3.200.3dev-20121112
 
-# use version built from https://github.com/42cc/GitPython/commits/0.3.2-RC1-20130214
-# for unmerged fix for [#5411]
-GitPython==0.3.2.RC1.20130214
+# use version built from https://github.com/johnsca/GitPython/commits/0.3.2-RC1-20130424
+# for unmerged fixes for [#5411], [#6000], and [#6078]
+GitPython==0.3.2.RC1-20130424
 
 WebError==0.10.3-20130423
 


[31/50] git commit: [#2835] ticket:308 Removed unnecessary re-escaping of matches

Posted by jo...@apache.org.
[#2835] ticket:308 Removed unnecessary re-escaping of matches


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

Branch: refs/heads/cj/5655
Commit: 1bdaa1ecfa4962f02168d77c4632c1732085d46a
Parents: ac9e35d
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Apr 2 11:56:19 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:42 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1bdaa1ec/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 97a67da..29c28b7 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -163,11 +163,11 @@ def search_app(q='', fq=None, app=True, **kw):
                 title = h.get_first(m, 'title')
                 text = h.get_first(m, 'text')
                 if title:
-                    title = (jinja2.escape(title)
+                    title = (jinja2.Markup(title)
                                    .replace('#ALLURA-HIGHLIGHT-START#', jinja2.Markup('<strong>'))
                                    .replace('#ALLURA-HIGHLIGHT-END#', jinja2.Markup('</strong>')))
                 if text:
-                    text = (jinja2.escape(text)
+                    text = (jinja2.Markup(text)
                                   .replace('#ALLURA-HIGHLIGHT-START#', jinja2.Markup('<strong>'))
                                   .replace('#ALLURA-HIGHLIGHT-END#', jinja2.Markup('</strong>')))
                 doc['title_match'] = title


[29/50] git commit: [#2835] ticket:292 Don't use c.app if doing project search. Fix tests.

Posted by jo...@apache.org.
[#2835] ticket:292 Don't use c.app if doing project search. Fix tests.


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

Branch: refs/heads/cj/5655
Commit: ee3e61520680b82790c0b7c5047d07e47a377bff
Parents: bfee10f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Mar 27 12:13:24 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:42 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py                       |   17 +++++++--------
 Allura/allura/tests/functional/test_search.py     |    6 ++++-
 ForgeWiki/forgewiki/tests/functional/test_root.py |    2 +-
 3 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3e6152/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index cf92af8..6c96d4a 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -119,24 +119,23 @@ def search_app(q='', fq=None, app=True, **kw):
         # It's 'fuzzier' than standard parser, which matches only on `text`.
         if search_comments:
             allowed_types += ['Post']
-        search_params = {
-            'qt': 'dismax',
-            'qf': 'title^2 text',
-            'pf': 'title^2 text',
-            'fq': [
+        if app:
+            fq = [
                 '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])
-            ] + fq,
+            ] + fq
+        search_params = {
+            'qt': 'dismax',
+            'qf': 'title^2 text',
+            'pf': 'title^2 text',
+            'fq': fq,
             'hl': 'true',
             'hl.simple.pre': '<strong>',
             'hl.simple.post': '</strong>',
             'sort': sort,
         }
-        if not app:
-            # Not app-restricted search. Use only provided filter query (fq)
-            search_params['fq'] = fq
         if not history:
            search_params['fq'].append('is_history_b:False')
         if parser == 'standard':

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3e6152/Allura/allura/tests/functional/test_search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_search.py b/Allura/allura/tests/functional/test_search.py
index 2712e58..f63d4c2 100644
--- a/Allura/allura/tests/functional/test_search.py
+++ b/Allura/allura/tests/functional/test_search.py
@@ -15,14 +15,18 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+from mock import patch
 from allura.tests import TestController
 
 
 class TestSearch(TestController):
 
-    def test_global_search_controller(self):
+    @patch('allura.lib.search.search')
+    def test_global_search_controller(self, search):
         r = self.app.get('/gsearch/')
+        assert not search.called, search.called
         r = self.app.get('/gsearch/', params=dict(q='Root'))
+        assert search.called, search.called
 
     def test_project_search_controller(self):
         r = self.app.get('/search/')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ee3e6152/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 029bf56..ccc3098 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -80,7 +80,7 @@ class TestRootController(TestController):
         response = self.app.get('/wiki/search?q=tést')
         assert 'Search wiki: tést' in response
 
-    @patch('forgewiki.wiki_main.search')
+    @patch('allura.lib.search.search')
     def test_search(self, search):
         r = self.app.get('/wiki/search?q=test')
         assert_in('<a href="/wiki/search?q=test&amp;sort=score+asc" class="strong">relevance</a>', r)


[11/50] git commit: Changes for automating the vagrant build

Posted by jo...@apache.org.
Changes for automating the vagrant build

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/5655
Commit: e6136bd36d87deef6133714e19ca38b9ff3edf96
Parents: 42c758d
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Apr 23 17:39:14 2013 -0400
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:59:53 2013 -0400

----------------------------------------------------------------------
 vagrant/README                                |   15 +++++-
 vagrant/Vagrantfile                           |   54 ++++++++++++--------
 vagrant/Vagrantfile.pkg                       |   10 ++--
 vagrant/allura_setup.sh                       |    9 +--
 vagrant/compress.sh                           |   21 ++++++++
 vagrant/manifests/ubuntu-1204-server-amd64.pp |   20 ++++++-
 6 files changed, 92 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/README
----------------------------------------------------------------------
diff --git a/vagrant/README b/vagrant/README
index 27f85d1..8bbe34e 100644
--- a/vagrant/README
+++ b/vagrant/README
@@ -24,7 +24,8 @@ $ mkdir ~/vagrant_allura && cd ~/vagrant_allura
 $ vagrant box add ubuntu-1204-server-amd64 http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box
 $ vagrant init ubuntu-1204-server-amd64
 
-# Get a copy of the provisioning scripts (note, Vagrantfile may change from release to release and may need manual updating)
+# Get a copy of the provisioning scripts (note, Vagrantfile may change from
+# release to release and may need manual updating)
 $ cp -R /var/local/allura/vagrant/* .
 
 # At this point you can make whatever changes you want to the provisioning
@@ -34,7 +35,17 @@ $ cp -R /var/local/allura/vagrant/* .
 # Provision the box (this will take a while)
 $ vagrant up
 
-# If you get an error, you can run `vagrant ssh` to get in and debug, and then `vagrant destroy` to start over
+# If you get an error, you can run `vagrant ssh` to get in and debug, and then
+# `vagrant destroy` to start over
+
+# Once the provisioning succeeds, `vagrant ssh` to the vm and do any testing
+# you want to do. You should at least run `./update.sh && ~/start_allura` and
+# make sure you can access the app at http://localhost:8080. After testing,
+# remain logged into the vm for the next step (compression).
+
+# Compress the VM. This will make your final .box file much smaller. It'll
+# take a while. Once it finished, logout of the vm.
+$ sudo /vagrant/compress.sh
 
 # Package the Allura box
 $ vagrant package --vagrantfile Vagrantfile.pkg

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/Vagrantfile
----------------------------------------------------------------------
diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile
index f21346c..7572922 100644
--- a/vagrant/Vagrantfile
+++ b/vagrant/Vagrantfile
@@ -18,7 +18,7 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-Vagrant::Config.run do |config|
+Vagrant.configure("2") do |config|
   # All Vagrant configuration is done here. The most common configuration
   # options are documented and commented below. For a complete reference,
   # please see the online documentation at vagrantup.com.
@@ -30,29 +30,41 @@ Vagrant::Config.run do |config|
   # doesn't already exist on the user's system.
   # config.vm.box_url = "http://domain.com/path/to/above.box"
 
-  # Boot with a GUI so you can see the screen. (Default is headless)
-  # config.vm.boot_mode = :gui
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine. In the example below,
+  # accessing "localhost:8080" will access port 80 on the guest machine.
+  config.vm.network :forwarded_port, guest: 8080, host: 8080
+  config.vm.network :forwarded_port, guest: 8983, host: 8983
 
-  # Assign this VM to a host-only network IP, allowing you to access it
-  # via the IP. Host-only networks can talk to the host machine as well as
-  # any other machines on the same network, but cannot be accessed (through this
-  # network interface) by any external networks.
-  # config.vm.network :hostonly, "192.168.33.10"
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  # config.vm.network :private_network, ip: "192.168.33.10"
 
-  # Assign this VM to a bridged network, allowing you to connect directly to a
-  # network using the host's network device. This makes the VM appear as another
-  # physical device on your network.
-  # config.vm.network :bridged
-
-  # Forward a port from the guest to the host, which allows for outside
-  # computers to access the VM, whereas host only networking does not.
-  config.vm.forward_port 8080, 8080
-  config.vm.forward_port 8983, 8983 # solr
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  # config.vm.network :public_network
 
   # Share an additional folder to the guest VM. The first argument is
-  # an identifier, the second is the path on the guest to mount the
-  # folder, and the third is the path on the host to the actual folder.
-  # config.vm.share_folder "v-data", "/vagrant_data", "../data"
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  # config.vm.synced_folder "../data", "/vagrant_data"
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  config.vm.provider :virtualbox do |vb|
+    # Don't boot with headless mode
+    # vb.gui = true
+  
+    # Use VBoxManage to customize the VM. For example to change memory:
+    vb.customize ["modifyvm", :id, "--memory", "1024"]
+  end
+  #
+  # View the documentation for the provider you're using for more
+  # information on available options.
 
   # Enable provisioning with Puppet stand alone.  Puppet manifests
   # are contained in a directory path relative to this Vagrantfile.
@@ -112,7 +124,7 @@ Vagrant::Config.run do |config|
   # If you're using the Opscode platform, your validator client is
   # ORGNAME-validator, replacing ORGNAME with your organization name.
   #
-  # IF you have your own Chef Server, the default validation client name is
+  # If you have your own Chef Server, the default validation client name is
   # chef-validator, unless you changed the configuration.
   #
   #   chef.validation_client_name = "ORGNAME-validator"

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/Vagrantfile.pkg
----------------------------------------------------------------------
diff --git a/vagrant/Vagrantfile.pkg b/vagrant/Vagrantfile.pkg
index 8d17d78..51f6181 100644
--- a/vagrant/Vagrantfile.pkg
+++ b/vagrant/Vagrantfile.pkg
@@ -15,9 +15,9 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-Vagrant::Config.run do |config|
-  # Forward Allura web port so you can browse the site at
-  # http://localhost:8080 (local port is the second number)
-  config.vm.forward_port 8080, 8080
-  config.vm.forward_port 8983, 8983 # solr
+Vagrant.configure("2") do |config|
+  # allura
+  config.vm.network :forwarded_port, guest: 8080, host: 8080
+  # solr
+  config.vm.network :forwarded_port, guest: 8983, host: 8983 
 end

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/allura_setup.sh
----------------------------------------------------------------------
diff --git a/vagrant/allura_setup.sh b/vagrant/allura_setup.sh
index e4973f6..6a38b74 100755
--- a/vagrant/allura_setup.sh
+++ b/vagrant/allura_setup.sh
@@ -47,6 +47,9 @@ then
     chown vagrant:vagrant /home/vagrant/.bash_profile
 fi
 
+# Make sure vagrant user can execute venv bin scripts
+sudo chown -R vagrant:vagrant /home/vagrant/env-allura/bin/
+
 # Setup Allura python packages
 cd /home/vagrant/src/allura
 sudo -u vagrant bash -c '. /home/vagrant/env-allura/bin/activate; ./rebuild-all.bash'
@@ -58,12 +61,6 @@ aptitude -y -q purge installation-report landscape-client landscape-common wirel
 aptitude -y -q purge python-dbus libnl1 python-smartpm linux-headers-server python-twisted-core libiw30 language-selector-common
 aptitude -y -q purge cloud-init juju python-twisted python-twisted-bin libdbus-glib-1-2 python-pexpect python-serial python-gobject python-pam accountsservice libaccountsservice0
 
-echo "Zeroing free space to aid VM compression..."
-cat /dev/zero > zero.fill;
-echo "Errors about 'No space left' are ok; carrying on..."
-sync;sleep 1;sync;rm -f zero.fill
-dd if=/dev/zero of=/EMPTY bs=1M
-rm -f /EMPTY
 echo "Done with allura_setup.sh"
 
 # sometimes mongo ends up stopped

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/compress.sh
----------------------------------------------------------------------
diff --git a/vagrant/compress.sh b/vagrant/compress.sh
new file mode 100755
index 0000000..c9bcd77
--- /dev/null
+++ b/vagrant/compress.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+echo 'Cleanup bash history'
+unset HISTFILE
+[ -f /root/.bash_history ] && rm /root/.bash_history
+[ -f /home/vagrant/.bash_history ] && rm /home/vagrant/.bash_history
+ 
+echo 'Cleanup log files'
+find /var/log -type f | while read f; do echo -ne '' > $f; done;
+ 
+echo 'Whiteout root'
+count=`df --sync -kP / | tail -n1  | awk -F ' ' '{print $4}'`; 
+let count--
+dd if=/dev/zero of=/tmp/whitespace bs=1024 count=$count;
+rm /tmp/whitespace;
+ 
+echo 'Whiteout /boot'
+count=`df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}'`;
+let count--
+dd if=/dev/zero of=/boot/whitespace bs=1024 count=$count;
+rm /boot/whitespace;

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/e6136bd3/vagrant/manifests/ubuntu-1204-server-amd64.pp
----------------------------------------------------------------------
diff --git a/vagrant/manifests/ubuntu-1204-server-amd64.pp b/vagrant/manifests/ubuntu-1204-server-amd64.pp
index c6aabe0..1feb18e 100644
--- a/vagrant/manifests/ubuntu-1204-server-amd64.pp
+++ b/vagrant/manifests/ubuntu-1204-server-amd64.pp
@@ -107,18 +107,32 @@ file { '/home/vagrant/src/allura':
   require => [ File['/home/vagrant/src'], Exec['clone repo'] ],
 }
 
+# HACK to get numpy installed in the venv before installing
+# remaining dependencies via requirements file
+exec { "pip install numpy":
+  command => "/home/vagrant/env-allura/bin/pip install numpy==1.6.1",
+  cwd     => "/vagrant/allura",
+  timeout => 0,
+  logoutput => true,
+  returns => 0,
+  tries => 3,
+  require => [ Exec[ "clone repo"], Exec[ "create allura venv" ],
+               ],
+}
+
 # install Allura dependencies
 exec { "pip install":
-  command => "/usr/bin/sudo /home/vagrant/env-allura/bin/pip install -r requirements.txt",
+  command => "/home/vagrant/env-allura/bin/pip install -r requirements.txt",
   cwd     => "/vagrant/allura",
-  user => "vagrant",
-  group => "vagrant",
+  # user => "vagrant",
+  # group => "vagrant",
   timeout => 0,
   logoutput => true,
   returns => 0,
   tries => 3,
   require => [ Exec[ "clone repo"], Exec[ "create allura venv" ],
                File["/usr/lib/libjpeg.so"], File["/usr/lib/libz.so"],
+               Exec["pip install numpy"],
                ],
 }
 


[15/50] git commit: [#2835] ticket:290 Make solr's `text` field stored

Posted by jo...@apache.org.
[#2835] ticket:290 Make solr's `text` field stored


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

Branch: refs/heads/cj/5655
Commit: 5b2dfd3dbab226a1e41ffebe7869b931a4a1cd2e
Parents: 022d84d
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 12 12:36:08 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:34 2013 +0000

----------------------------------------------------------------------
 solr_config/core0/conf/schema.xml |    2 +-
 solr_config/core1/conf/schema.xml |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5b2dfd3d/solr_config/core0/conf/schema.xml
----------------------------------------------------------------------
diff --git a/solr_config/core0/conf/schema.xml b/solr_config/core0/conf/schema.xml
index 494f53f..e2e0d79 100644
--- a/solr_config/core0/conf/schema.xml
+++ b/solr_config/core0/conf/schema.xml
@@ -428,7 +428,7 @@
 
    <!-- catchall field, containing all other searchable text fields (implemented
         via copyField further on in this schema  -->
-   <field name="text" type="text" indexed="true" stored="false" multiValued="true"/>
+   <field name="text" type="text" indexed="true" stored="true" multiValued="true"/>
 
    <!-- catchall text field that indexes tokens both normally and in reverse for efficient
         leading wildcard queries. -->

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5b2dfd3d/solr_config/core1/conf/schema.xml
----------------------------------------------------------------------
diff --git a/solr_config/core1/conf/schema.xml b/solr_config/core1/conf/schema.xml
index 494f53f..e2e0d79 100644
--- a/solr_config/core1/conf/schema.xml
+++ b/solr_config/core1/conf/schema.xml
@@ -428,7 +428,7 @@
 
    <!-- catchall field, containing all other searchable text fields (implemented
         via copyField further on in this schema  -->
-   <field name="text" type="text" indexed="true" stored="false" multiValued="true"/>
+   <field name="text" type="text" indexed="true" stored="true" multiValued="true"/>
 
    <!-- catchall text field that indexes tokens both normally and in reverse for efficient
         leading wildcard queries. -->


[24/50] git commit: [#2835] ticket:292 Refactored wiki search into helper

Posted by jo...@apache.org.
[#2835] ticket:292 Refactored wiki search into helper


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

Branch: refs/heads/cj/5655
Commit: 891ff4503a5d1e0c951405ac0bde7a5fd1bfc94d
Parents: 1f5a295
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 25 11:56:00 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py      |  103 +++++++++++++++++++++++++++++++++
 ForgeWiki/forgewiki/wiki_main.py |  100 +++++---------------------------
 2 files changed, 117 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/891ff450/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index d9c300a..c541225 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -18,12 +18,17 @@
 import re
 import socket
 from logging import getLogger
+from urllib import urlencode
+from itertools import imap
 
 import markdown
 import jinja2
+from tg import redirect, url
 from pylons import tmpl_context as c, app_globals as g
+from pylons import request
 from pysolr import SolrError
 
+from allura.lib import helpers as h
 from .markdown_extensions import ForgeExtension
 
 log = getLogger(__name__)
@@ -83,6 +88,104 @@ def search_artifact(atype, q, history=False, rows=10, short_timeout=False, **kw)
         fq.append('is_history_b:False')
     return search(q, fq=fq, rows=rows, short_timeout=short_timeout, ignore_errors=False, **kw)
 
+
+def search_app(q='', fq=None, **kw):
+    """Helper for app search.
+
+    Uses dismax query parser. Matches on `title` and `text`. Handles paging, sorting, etc
+    """
+    history = kw.pop('history', None)
+    if kw.pop('project', False):
+        redirect(c.project.url() + 'search?' + urlencode(dict(q=q, history=history)))
+    search_comments = kw.pop('search_comments', None)
+    limit = kw.pop('limit', None)
+    page = kw.pop('page', 0)
+    default = kw.pop('default', 25)
+    allowed_types = kw.pop('allowed_types', [])
+    parser = kw.pop('parser', None)
+    sort = kw.pop('sort', 'score desc')
+    fq = fq if fq else []
+    search_error = None
+    results = []
+    count = 0
+    matches = {}
+    limit, page, start = g.handle_paging(limit, page, default=default)
+    if not q:
+        q = ''
+    else:
+        # 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`.
+        if search_comments:
+            allowed_types += ['Post']
+        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',
+                'type_s:(%s)' % ' OR '.join(['"%s"' % t for t in allowed_types])
+            ] + fq,
+            'hl': 'true',
+            'hl.simple.pre': '<strong>',
+            'hl.simple.post': '</strong>',
+            'sort': sort,
+        }
+        if not history:
+           search_params['fq'].append('is_history_b:False')
+        if parser == 'standard':
+            search_params.pop('qt', None)
+            search_params.pop('qf', None)
+            search_params.pop('pf', None)
+        try:
+            results = search(
+                q, short_timeout=True, ignore_errors=False,
+                rows=limit, start=start, **search_params)
+        except SearchError as e:
+            search_error = e
+        if results:
+            count = results.hits
+            matches = results.highlighting
+            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
+            def add_matches(doc):
+                m = matches.get(doc['id'], {})
+                doc['title_match'] = h.get_first(m, 'title')
+                doc['text_match'] = h.get_first(m, 'text')
+                if not doc['text_match']:
+                    doc['text_match'] = h.get_first(doc, 'text')
+                return doc
+            results = imap(historize_urls, results)
+            results = imap(add_matches, results)
+
+    # Provide sort urls to the view
+    score_url = 'score desc'
+    date_url = 'mod_date_dt desc'
+    try:
+        field, order = sort.split(' ')
+    except ValueError:
+        field, order = 'score', 'desc'
+    sort = ' '.join([field, 'asc' if order == 'desc' else 'desc'])
+    if field == 'score':
+        score_url = sort
+    elif field == 'mod_date_dt':
+        date_url = sort
+    params = request.GET.copy()
+    params.update({'sort': score_url})
+    score_url = url(request.path, params=params)
+    params.update({'sort': date_url})
+    date_url = url(request.path, params=params)
+    return dict(q=q, history=history, results=results or [],
+                count=count, limit=limit, page=page, search_error=search_error,
+                sort_score_url=score_url, sort_date_url=date_url,
+                sort_field=field)
+
+
 def find_shortlinks(text):
     md = markdown.Markdown(
         extensions=['codehilite', ForgeExtension(), 'tables'],

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/891ff450/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index eed1467..b2dbee7 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -18,12 +18,11 @@
 #-*- python -*-
 import logging
 from pprint import pformat
-from urllib import urlencode, unquote
+from urllib import unquote
 from datetime import datetime
-from itertools import imap
 
 # Non-stdlib imports
-from tg import expose, validate, redirect, response, flash, url
+from tg import expose, validate, redirect, response, flash
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from tg.controllers import RestController
 from pylons import tmpl_context as c, app_globals as g
@@ -37,7 +36,7 @@ import jinja2
 from allura import model as M
 from allura.lib import helpers as h
 from allura.app import Application, SitemapEntry, DefaultAdminController
-from allura.lib.search import search, SolrError
+from allura.lib.search import search_app
 from allura.lib.decorators import require_post, Property
 from allura.lib.security import require_access, has_access
 from allura.controllers import AppDiscussionController, BaseController
@@ -320,90 +319,19 @@ class RootController(BaseController, DispatchIndex):
                    project=validators.StringBool(if_empty=False)))
     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)))
-        search_error = None
-        results = []
-        count = 0
-        parser = kw.pop('parser', None)
-        sort = kw.pop('sort', 'score desc')
-        matches = {}
-        limit, page, start = g.handle_paging(limit, page, default=25)
-        if not q:
-            q = ''
-        else:
-            # 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']
-            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',
-                    'type_s:(%s)' % ' OR '.join(['"%s"' % t for t in allowed_types])
-                ],
-                'hl': 'true',
-                'hl.simple.pre': '<strong>',
-                'hl.simple.post': '</strong>',
-                'sort': sort,
-            }
-            if not history:
-               search_params['fq'].append('is_history_b:False')
-            if parser == 'standard':
-                search_params.pop('qt', None)
-                search_params.pop('qf', None)
-                search_params.pop('pf', None)
-            try:
-                results = search(
-                    q, short_timeout=True, ignore_errors=False,
-                    rows=limit, start=start, **search_params)
-            except SolrError as e:
-                search_error = e
-            if results:
-                count = results.hits
-                matches = results.highlighting
-                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
-                def add_matches(doc):
-                    m = matches.get(doc['id'], {})
-                    doc['title_match'] = h.get_first(m, 'title')
-                    doc['text_match'] = h.get_first(m, 'text')
-                    if not doc['text_match']:
-                        doc['text_match'] = h.get_first(doc, 'text')
-                    return doc
-                results = imap(historize_urls, results)
-                results = imap(add_matches, results)
         c.search_results = W.search_results
         c.help_modal = W.help_modal
-        score_url = 'score desc'
-        date_url = 'mod_date_dt desc'
-        try:
-            field, order = sort.split(' ')
-        except ValueError:
-            field, order = 'score', 'desc'
-        sort = ' '.join([field, 'asc' if order == 'desc' else 'desc'])
-        if field == 'score':
-            score_url = sort
-        elif field == 'mod_date_dt':
-            date_url = sort
-        params = request.GET.copy()
-        params.update({'sort': score_url})
-        score_url = url(request.path, params=params)
-        params.update({'sort': date_url})
-        date_url = url(request.path, params=params)
-        return dict(q=q, history=history, results=results or [],
-                    count=count, limit=limit, page=page, search_error=search_error,
-                    sort_score_url=score_url, sort_date_url=date_url,
-                    sort_field=field)
+        search_params = kw
+        search_params.update({
+            'q': q or '',
+            'history': history,
+            'search_comments': search_comments,
+            'project': project,
+            'limit': limit,
+            'page': page,
+            'allowed_types': ['WikiPage', 'WikiPage Snapshot'],
+        })
+        return search_app(**search_params)
 
     @with_trailing_slash
     @expose('jinja:forgewiki:templates/wiki/browse.html')


[40/50] git commit: [#2835] ticket:304 Nice comment links for search results

Posted by jo...@apache.org.
[#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 <je...@gmail.com>
Authored: Thu Apr 4 10:10:36 2013 +0000
Committer: Dave Brondsema <db...@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
 


[12/50] git commit: [#6093] Rearranged https and error middleware to get WebError working

Posted by jo...@apache.org.
[#6093] Rearranged https and error middleware to get WebError working

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/5655
Commit: 02ac4677b9abd82fde2490a8c1e03ce3a517ce66
Parents: 3f9ff9a
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Tue Apr 23 22:28:05 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Apr 24 13:44:40 2013 +0000

----------------------------------------------------------------------
 Allura/allura/config/middleware.py |   28 ++++++++++++++--------------
 requirements-sf.txt                |    2 ++
 2 files changed, 16 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/02ac4677/Allura/allura/config/middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index a877221..805a9b9 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -123,16 +123,6 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
     app = RoutesMiddleware(app, config['routes.map'])
     # Required for sessions
     app = SessionMiddleware(app, config)
-    # Converts exceptions to HTTP errors, shows traceback in debug mode
-    tg.error.footer_html = '<!-- %s %s -->'  # don't use TG footer with extra CSS & images that take time to load
-    app = tg.error.ErrorHandler(app, global_conf, **config['pylons.errorware'])
-    # Redirect some status codes to /error/document
-    if config.get('override_root') != 'task':
-        # "task" wsgi would get a 2nd request to /error/document if we used this middleware
-        if asbool(config['debug']):
-            app = StatusCodeRedirect(app, base_config.handle_status_codes)
-        else:
-            app = StatusCodeRedirect(app, base_config.handle_status_codes + [500])
     # Redirect 401 to the login page
     app = LoginRedirectMiddleware(app)
     # Add instrumentation
@@ -153,10 +143,6 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
         script_name=app_conf.get('ew.script_name', '/_ew_resources/'),
         url_base=app_conf.get('ew.url_base', '/_ew_resources/'),
         extra_headers=eval(app_conf.get('ew.extra_headers', 'None')))
-    # Make sure that the wsgi.scheme is set appropriately when we
-    # have the funky HTTP_X_SFINC_SSL  environ var
-    if asbool(app_conf.get('auth.method', 'local')=='sfx'):
-        app = set_scheme_middleware(app)
     # Handle static files (by tool)
     app = StaticFilesMiddleware(app, app_conf.get('static.script_name'))
     # Handle setup and flushing of Ming ORM sessions
@@ -165,6 +151,20 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
     #    streaming=true ensures they won't be cleaned up till
     #    the WSGI application's iterator is exhausted
     app = RegistryManager(app, streaming=True)
+    # Converts exceptions to HTTP errors, shows traceback in debug mode
+    tg.error.footer_html = '<!-- %s %s -->'  # don't use TG footer with extra CSS & images that take time to load
+    app = tg.error.ErrorHandler(app, global_conf, **config['pylons.errorware'])
+    # Make sure that the wsgi.scheme is set appropriately when we
+    # have the funky HTTP_X_SFINC_SSL  environ var
+    if asbool(app_conf.get('auth.method', 'local')=='sfx'):
+        app = set_scheme_middleware(app)
+    # Redirect some status codes to /error/document
+    if config.get('override_root') != 'task':
+        # "task" wsgi would get a 2nd request to /error/document if we used this middleware
+        if asbool(config['debug']):
+            app = StatusCodeRedirect(app, base_config.handle_status_codes)
+        else:
+            app = StatusCodeRedirect(app, base_config.handle_status_codes + [500])
     return app
 
 def set_scheme_middleware(app):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/02ac4677/requirements-sf.txt
----------------------------------------------------------------------
diff --git a/requirements-sf.txt b/requirements-sf.txt
index 79cdfe3..42a1b02 100644
--- a/requirements-sf.txt
+++ b/requirements-sf.txt
@@ -21,6 +21,8 @@ html2text==3.200.3dev-20121112
 # for unmerged fix for [#5411]
 GitPython==0.3.2.RC1.20130214
 
+WebError==0.10.3-20130423
+
 # for the migration scripts only
 postmarkup==1.2.0dev-20121116
 # suds needed for teamforge import script


[46/50] git commit: [#4370] ticket:322 Fix test failing due to changes in API permissions handling

Posted by jo...@apache.org.
[#4370] ticket:322 Fix test failing due to changes in API permissions handling


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

Branch: refs/heads/cj/5655
Commit: a1029bfc57c530cbad6909997e18595e1f429239
Parents: ad54b2f
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Apr 24 10:41:18 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 20:02:25 2013 +0000

----------------------------------------------------------------------
 .../forgetracker/tests/functional/test_root.py     |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a1029bfc/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 23c0890..e193a10 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -328,9 +328,7 @@ class TestFunctionalController(TrackerTestController):
         r = self.app.get('/p/test/bugs/feed.atom')
         assert 'Private Ticket' not in r
         # ... or in the API ...
-        r = self.app.get('/rest/p/test/bugs/2/')
-        assert 'Private Ticket' not in r
-        assert '/auth/?return_to' in r.headers['Location']
+        r = self.app.get('/rest/p/test/bugs/2/', status=401)
         r = self.app.get('/rest/p/test/bugs/')
         assert 'Private Ticket' not in r
 


[25/50] git commit: [#2835] ticket:292 Better search for chat

Posted by jo...@apache.org.
[#2835] ticket:292 Better search for chat


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

Branch: refs/heads/cj/5655
Commit: 7b42446932fd105962df49d38b665514f5fe1429
Parents: 91e308c
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 25 14:32:56 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:41 2013 +0000

----------------------------------------------------------------------
 .../allura/templates/widgets/search_results.html   |    6 ++-
 ForgeChat/forgechat/main.py                        |   43 ++++++---------
 ForgeChat/forgechat/templates/chat/search.html     |   29 ++--------
 3 files changed, 28 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7b424469/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 500f639..debb450 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -44,8 +44,10 @@
       <label for="search-comments">Search comments?</label>
       <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 %}>
+    {% if not search_history_disable %}
+      <label for="search-history">Search history?</label>
+      <input id="search-history" type="checkbox" name="history"{% if history %} checked{% endif %}>
+    {% endif %}
   </div>
 </form>
 <div style="clear:both">&nbsp;</div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7b424469/ForgeChat/forgechat/main.py
----------------------------------------------------------------------
diff --git a/ForgeChat/forgechat/main.py b/ForgeChat/forgechat/main.py
index 5150d61..05eaf94 100644
--- a/ForgeChat/forgechat/main.py
+++ b/ForgeChat/forgechat/main.py
@@ -22,19 +22,18 @@ import logging
 from datetime import date, time, datetime, timedelta
 
 # Non-stdlib imports
-import pkg_resources
 from tg import expose, validate, redirect, flash
 from tg.decorators import with_trailing_slash
 from pylons import tmpl_context as c, app_globals as g
-from pylons import request
 from formencode import validators
 
 # Pyforge-specific imports
 from allura.app import Application, ConfigOption, SitemapEntry, DefaultAdminController
 from allura.lib import helpers as h
-from allura.lib.search import search, SearchError
+from allura.lib.search import search_app
 from allura.lib.decorators import require_post
 from allura.lib.security import require_access
+from allura.lib.widgets.search import SearchResults
 from allura import model as M
 from allura.controllers import BaseController
 
@@ -135,30 +134,24 @@ class RootController(BaseController):
         now = datetime.utcnow()
         redirect(c.app.url + now.strftime('%Y/%m/%d/'))
 
+    @with_trailing_slash
     @expose('jinja:forgechat:templates/chat/search.html')
     @validate(dict(q=validators.UnicodeString(if_empty=None),
-                   history=validators.StringBool(if_empty=False)))
-    def search(self, q=None, history=None, **kw):
-        'local tool search'
-        results = []
-        search_error = None
-        count=0
-        if not q:
-            q = ''
-        else:
-            try:
-                results = search(
-                    q,
-                    fq=[
-                        'is_history_b:%s' % history,
-                        'project_id_s:%s' % c.project._id,
-                        'mount_point_s:%s'% c.app.config.options.mount_point ],
-                    short_timeout=True,
-                    ignore_errors=False)
-            except SearchError as e:
-                search_error = e
-            if results: count=results.hits
-        return dict(q=q, history=history, results=results or [], count=count, search_error=search_error)
+                   project=validators.StringBool(if_empty=False)))
+    def search(self, q=None, project=None, limit=None, page=0, **kw):
+        c.search_results = SearchResults()
+        search_params = kw
+        search_params.update({
+            'q': q or '',
+            'project': project,
+            'limit': limit,
+            'page': page,
+            'allowed_types': ['Chat Message'],
+        })
+        d = search_app(**search_params)
+        d['search_comments_disable'] = True
+        d['search_history_disable'] = True
+        return d
 
     @expose()
     def _lookup(self, y, m, d, *rest):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7b424469/ForgeChat/forgechat/templates/chat/search.html
----------------------------------------------------------------------
diff --git a/ForgeChat/forgechat/templates/chat/search.html b/ForgeChat/forgechat/templates/chat/search.html
index 59566c6..0447586 100644
--- a/ForgeChat/forgechat/templates/chat/search.html
+++ b/ForgeChat/forgechat/templates/chat/search.html
@@ -21,30 +21,13 @@
 
 {% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Search{% endblock %}
 
-{% block header %}ForgeChat Search{% endblock %}
+{% block header %}Search {{c.app.config.options.mount_point}}: {{q}}{% endblock %}
 
 {% block content %}
   {{ clib.checkout_info(c.app) }}
-  <form method="GET" action="search" class="grid-19">
-    <input type="text" name="q" value="{{q}}"/><br/>
-    Search history? <input type="checkbox" name="history" {% if history %}checked="checked"{% endif %}/><br/>
-    <input type="submit" value="Search"/>
-  </form>
-  {% if search_error %}
-    <p>{{ search_error }}</p>
-  {% elif count==0 and q %}
-    <p>No results.</p>
-  {% elif count==1 and q %}
-    <p>{{count}} result.</p>
-  {% elif count > 1 and q %}
-    <p>{{count}} results.</p>
-  {% endif %}
-
-  {% for doc in results %}
-  <div class="grid-19">
-    <a href="{{doc['url_s']}}">{{ h.get_first(doc, 'title') }}</a><br/>
-    <pre>{{doc|pprint}}</pre>
-    <hr/>
-  </div>
-  {% endfor %}
+  {{c.search_results.display(results=results,q=q,history=history,
+     count=count,limit=limit,page=page,search_error=search_error,
+     sort_score_url=sort_score_url, sort_date_url=sort_date_url, sort_field=sort_field,
+     search_comments_disable=search_comments_disable,
+     search_history_disable=search_history_disable)}}
 {% endblock %}


[06/50] git commit: [#5120] Quote branch/tag urls

Posted by jo...@apache.org.
[#5120] Quote branch/tag urls

- So they get highlighted properly in sidebar

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/5655
Commit: 9bf778a3080af953372a7b24aca5abe79c2da764
Parents: 0dcf37f
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Apr 23 14:28:30 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:03:34 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py |    2 +-
 Allura/allura/lib/repository.py         |    6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9bf778a3/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index ef678f5..319506e 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -380,7 +380,7 @@ class RefsController(object):
         EOR = quote(c.app.END_OF_REF_ESCAPE)
         if EOR in remainder:
             i = remainder.index(quote(c.app.END_OF_REF_ESCAPE))
-            ref = '/'.join((ci,) + remainder[:i])
+            ref = '/'.join((ref,) + remainder[:i])
             remainder = remainder[i+1:]
         return self.BranchBrowserClass(ref), remainder
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9bf778a3/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index f59ec04..69736b6 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -134,7 +134,8 @@ class RepositoryApp(Application):
             max_branches = 10
             for b in self.repo.branches[:max_branches]:
                 links.append(SitemapEntry(
-                        b.name, self.repo.url_for_commit(b.name)+'tree/',
+                        b.name,
+                        quote(self.repo.url_for_commit(b.name) + 'tree/'),
                         small=b.count))
             if len(self.repo.branches) > max_branches:
                 links.append(
@@ -147,7 +148,8 @@ class RepositoryApp(Application):
             max_tags = 10
             for b in self.repo.repo_tags[:max_tags]:
                 links.append(SitemapEntry(
-                        b.name, self.repo.url_for_commit(b.name)+'tree/',
+                        b.name,
+                        quote(self.repo.url_for_commit(b.name) + 'tree/'),
                         small=b.count))
             if len(self.repo.repo_tags) > max_tags:
                 links.append(


[17/50] git commit: [#2835] ticket:289 Sort search results

Posted by jo...@apache.org.
[#2835] ticket:289 Sort 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/1ec5943b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1ec5943b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1ec5943b

Branch: refs/heads/cj/5655
Commit: 1ec5943b5e1f0b9c55ea3529fe31d849d76adcf5
Parents: 0d09236
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 19 12:21:09 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:40 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/resources/css/search.css |    4 ++
 .../allura/templates/widgets/search_results.html   |    7 +++-
 ForgeWiki/forgewiki/templates/wiki/search.html     |    3 +-
 ForgeWiki/forgewiki/wiki_main.py                   |   24 +++++++++++++-
 4 files changed, 33 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1ec5943b/Allura/allura/lib/widgets/resources/css/search.css
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/css/search.css b/Allura/allura/lib/widgets/resources/css/search.css
index 848accc..03b5507 100644
--- a/Allura/allura/lib/widgets/resources/css/search.css
+++ b/Allura/allura/lib/widgets/resources/css/search.css
@@ -36,3 +36,7 @@ input[type="checkbox"] {
   width: 100%;
   white-space: nowrap;
 }
+
+.strong {
+  font-weight: bold;
+}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1ec5943b/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 7eb577d..feaa60f 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -79,6 +79,9 @@
   {{widget.fields['page_size'].display(limit=limit, count=count)}}
 </div>
 <div class="grid-19" style="clear:both">
-  {# TODO: highlight active sorting order #}
-  {# <p>Sort by <a href="#"><strong>relevance</strong></a> or <a href="#">date</a></p> #}
+  <p>
+    Sort by
+    <a href="{{ sort_score_url }}" class="{{ 'strong' if sort_field == 'score' else '' }}">relevance</a> or
+    <a href="{{ sort_date_url }}" class="{{ 'strong' if sort_field == 'mod_date_dt' else '' }}">date</a>
+  </p>
 </div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1ec5943b/ForgeWiki/forgewiki/templates/wiki/search.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/search.html b/ForgeWiki/forgewiki/templates/wiki/search.html
index 6c91664..6f7085e 100644
--- a/ForgeWiki/forgewiki/templates/wiki/search.html
+++ b/ForgeWiki/forgewiki/templates/wiki/search.html
@@ -24,5 +24,6 @@
 
 {% block wiki_content %}
   {{c.search_results.display(results=results,q=q,history=history,
-                             count=count,limit=limit,page=page,search_error=search_error)}}
+     count=count,limit=limit,page=page,search_error=search_error,
+     sort_score_url=sort_score_url, sort_date_url=sort_date_url, sort_field=sort_field)}}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1ec5943b/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 4a47b3b..fc5b566 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -23,7 +23,7 @@ from datetime import datetime
 from itertools import imap
 
 # Non-stdlib imports
-from tg import expose, validate, redirect, response, flash
+from tg import expose, validate, redirect, response, flash, url
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from tg.controllers import RestController
 from pylons import tmpl_context as c, app_globals as g
@@ -320,6 +320,7 @@ class RootController(BaseController, DispatchIndex):
         results = []
         count = 0
         parser = kw.pop('parser', None)
+        sort = kw.pop('sort', 'score desc')
         matches = {}
         limit, page, start = g.handle_paging(limit, page, default=25)
         if not q:
@@ -344,6 +345,7 @@ class RootController(BaseController, DispatchIndex):
                 'hl': 'true',
                 'hl.simple.pre': '<strong>',
                 'hl.simple.post': '</strong>',
+                'sort': sort,
             }
             if not history:
                search_params['fq'].append('is_history_b:False')
@@ -375,8 +377,26 @@ class RootController(BaseController, DispatchIndex):
                 results = imap(historize_urls, results)
                 results = imap(add_matches, results)
         c.search_results = W.search_results
+        score_url = 'score desc'
+        date_url = 'mod_date_dt desc'
+        try:
+            field, order = sort.split(' ')
+        except ValueError:
+            field, order = 'score', 'desc'
+        sort = ' '.join([field, 'asc' if order == 'desc' else 'desc'])
+        if field == 'score':
+            score_url = sort
+        elif field == 'mod_date_dt':
+            date_url = sort
+        params = request.GET.copy()
+        params.update({'sort': score_url})
+        score_url = url(request.path, params=params)
+        params.update({'sort': date_url})
+        date_url = url(request.path, params=params)
         return dict(q=q, history=history, results=results or [],
-                    count=count, limit=limit, page=page, search_error=search_error)
+                    count=count, limit=limit, page=page, search_error=search_error,
+                    sort_score_url=score_url, sort_date_url=date_url,
+                    sort_field=field)
 
     @with_trailing_slash
     @expose('jinja:forgewiki:templates/wiki/browse.html')


[35/50] git commit: [#2835] ticket:304 Test for url_paginated with artifact attached

Posted by jo...@apache.org.
[#2835] ticket:304 Test for url_paginated with artifact attached


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

Branch: refs/heads/cj/5655
Commit: eb43a31edf8152274c65266568f53d0022fc8d6d
Parents: 1bdaa1e
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Apr 4 09:21:56 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:42 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/model/test_discussion.py |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/eb43a31e/Allura/allura/tests/model/test_discussion.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_discussion.py b/Allura/allura/tests/model/test_discussion.py
index f49446b..7e9df32 100644
--- a/Allura/allura/tests/model/test_discussion.py
+++ b/Allura/allura/tests/model/test_discussion.py
@@ -311,6 +311,17 @@ def test_post_url_paginated():
 
 
 @with_setup(setUp, tearDown)
+def test_post_url_paginated_with_artifact():
+    """Post.url_paginated should return link to attached artifact, if any"""
+    from forgewiki.model import Page
+    page = Page.upsert(title='Test Page')
+    thread = page.discussion_thread
+    comment = thread.post('Comment')
+    url = page.url() + '?limit=50#' + comment.slug
+    assert_equals(comment.url_paginated(), url)
+
+
+@with_setup(setUp, tearDown)
 def test_post_notify():
     d = M.Discussion(shortname='test', name='test')
     d.monitoring_email = 'darthvader@deathstar.org'


[09/50] git commit: Add some matplotlib dependencies

Posted by jo...@apache.org.
Add some matplotlib dependencies

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/5655
Commit: 42c758d45cf6cc7dbcbb630cf18221fb573e4811
Parents: 883c6d3
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Mon Apr 8 21:48:52 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:57:51 2013 -0400

----------------------------------------------------------------------
 vagrant/manifests/ubuntu-1204-server-amd64.pp |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/42c758d4/vagrant/manifests/ubuntu-1204-server-amd64.pp
----------------------------------------------------------------------
diff --git a/vagrant/manifests/ubuntu-1204-server-amd64.pp b/vagrant/manifests/ubuntu-1204-server-amd64.pp
index 3e42118..c6aabe0 100644
--- a/vagrant/manifests/ubuntu-1204-server-amd64.pp
+++ b/vagrant/manifests/ubuntu-1204-server-amd64.pp
@@ -39,7 +39,9 @@ $packages = [
  "libjpeg8-dev",
  "zlib1g-dev",
  "mongodb-server",
- "python-pip"
+ "python-pip",
+ "libfreetype6-dev",
+ "libpng-dev"
 ]
 
 package { $packages:
@@ -107,7 +109,7 @@ file { '/home/vagrant/src/allura':
 
 # install Allura dependencies
 exec { "pip install":
-  command => "/home/vagrant/env-allura/bin/pip install -r requirements.txt",
+  command => "/usr/bin/sudo /home/vagrant/env-allura/bin/pip install -r requirements.txt",
   cwd     => "/vagrant/allura",
   user => "vagrant",
   group => "vagrant",


[18/50] git commit: [#2835] ticket:290 Use get_first helper and fix title displaying

Posted by jo...@apache.org.
[#2835] ticket:290 Use get_first helper and fix title displaying


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

Branch: refs/heads/cj/5655
Commit: 0d09236816af17ed92a824a9201472c6f14b3e2e
Parents: 46db582
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 19 10:42:34 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:40 2013 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d092368/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 e33fded..7eb577d 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -59,7 +59,11 @@
   <div class="grid-19">
     <p>
     <a href="{{doc['url_paginated'] or doc['url_s']}}">
-       {{- doc.title_match|safe or h.get_first(doc, 'title') or h.get_first(doc, 'title_s') -}}  {#-  title_s is legacy -#}
+      {% if doc.title_match %}
+        {{ doc.title_match|safe }}
+      {% else %}
+        {{ h.get_first(doc, 'title') or h.get_first(doc, 'title_s') -}}  {#-  title_s is legacy -#}
+      {% endif %}
     </a>
     {% if doc['type_s'] %}<span class="gray"><sup>{{ '(%s)' % doc['type_s'] }}</sup></span>{% endif %}
     <br>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0d092368/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 3e8d815..4a47b3b 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -367,10 +367,10 @@ class RootController(BaseController, DispatchIndex):
                     return doc
                 def add_matches(doc):
                     m = matches.get(doc['id'], {})
-                    doc['title_match'] = m.get('title', [''])[0]
-                    doc['text_match'] = m.get('text', [''])[0]
+                    doc['title_match'] = h.get_first(m, 'title')
+                    doc['text_match'] = h.get_first(m, 'text')
                     if not doc['text_match']:
-                        doc['text_match'] = doc.get('text', [''])[0]
+                        doc['text_match'] = h.get_first(doc, 'text')
                     return doc
                 results = imap(historize_urls, results)
                 results = imap(add_matches, results)


[33/50] git commit: [#2835] ticket:308 Add tests for solarize()

Posted by jo...@apache.org.
[#2835] ticket:308 Add tests for solarize()


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

Branch: refs/heads/cj/5655
Commit: 27016ef75322ab5efc25b6c31e9186c6990e704b
Parents: de200e8
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Apr 1 13:30:27 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:42 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/unit/test_solr.py |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/27016ef7/Allura/allura/tests/unit/test_solr.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_solr.py b/Allura/allura/tests/unit/test_solr.py
index aa0b939..e1b67c8 100644
--- a/Allura/allura/tests/unit/test_solr.py
+++ b/Allura/allura/tests/unit/test_solr.py
@@ -17,8 +17,10 @@
 
 import unittest
 import mock
+from nose.tools import assert_equal
 
 from allura.lib.solr import Solr
+from allura.lib.search import solarize
 
 class TestSolr(unittest.TestCase):
     @mock.patch('allura.lib.solr.pysolr')
@@ -45,3 +47,29 @@ class TestSolr(unittest.TestCase):
         s.delete('bar', somekw='value')
         pysolr.Solr.delete.assert_called_once_with(s, 'bar', commit=False,
                 somekw='value')
+
+class TestSolarize(unittest.TestCase):
+
+    def setUp(self):
+        self.obj = mock.MagicMock()
+        self.obj.index.return_value = {}
+
+    def test_no_object(self):
+        assert_equal(solarize(None), None)
+
+    def test_empty_index(self):
+        self.obj.index.return_value = None
+        assert_equal(solarize(self.obj), None)
+
+    def test_doc_without_text(self):
+        assert_equal(solarize(self.obj), {'text': ''})
+
+    def test_strip_markdown(self):
+        self.obj.index.return_value = {'text': '# Header'}
+        assert_equal(solarize(self.obj), {'text': 'Header'})
+
+    def test_html_in_text(self):
+        self.obj.index.return_value = {'text': '<script>alert(1)</script>'}
+        assert_equal(solarize(self.obj), {'text': ''})
+        self.obj.index.return_value = {'text': '&lt;script&gt;alert(1)&lt;/script&gt;'}
+        assert_equal(solarize(self.obj), {'text': '&lt;script&gt;alert(1)&lt;/script&gt;'})


[10/50] git commit: Making vagrant setup better

Posted by jo...@apache.org.
Making vagrant setup better

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/5655
Commit: 883c6d3866e2c411bfcc7832bc0621ad4c647a3f
Parents: 70f0064
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Thu Apr 4 21:10:02 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:57:51 2013 -0400

----------------------------------------------------------------------
 vagrant/allura_setup.sh                       |   11 +-------
 vagrant/manifests/ubuntu-1204-server-amd64.pp |   23 +++++++++++++-------
 2 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/883c6d38/vagrant/allura_setup.sh
----------------------------------------------------------------------
diff --git a/vagrant/allura_setup.sh b/vagrant/allura_setup.sh
index 18d1ba6..e4973f6 100755
--- a/vagrant/allura_setup.sh
+++ b/vagrant/allura_setup.sh
@@ -30,13 +30,6 @@ then
     chown -R vagrant:vagrant /home/vagrant/src/apache-solr* /home/vagrant/src/allura/solr_config/conf/
 fi
 
-# Create log dir
-if [ ! -d /var/log/allura ]
-then
-    sudo mkdir -p /var/log/allura
-    sudo chown vagrant:vagrant /var/log/allura
-fi
-
 # Create startup script
 if [ ! -f /home/vagrant/start_allura ]
 then
@@ -50,13 +43,13 @@ if [ ! -f /home/vagrant/.bash_profile ]
 then
     echo "Creating ~/.bash_profile ..."
     cp /home/vagrant/.profile /home/vagrant/.bash_profile
-    echo -e "\n# Activate Allura virtualenv\n. /home/vagrant/anvil/bin/activate && cd /home/vagrant/src/allura" >> /home/vagrant/.bash_profile
+    echo -e "\n# Activate Allura virtualenv\n. /home/vagrant/env-allura/bin/activate && cd /home/vagrant/src/allura" >> /home/vagrant/.bash_profile
     chown vagrant:vagrant /home/vagrant/.bash_profile
 fi
 
 # Setup Allura python packages
 cd /home/vagrant/src/allura
-sudo -u vagrant bash -c '. /home/vagrant/anvil/bin/activate; ./rebuild-all.bash'
+sudo -u vagrant bash -c '. /home/vagrant/env-allura/bin/activate; ./rebuild-all.bash'
 
 echo "Purging unneeded packages..."
 aptitude clean

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/883c6d38/vagrant/manifests/ubuntu-1204-server-amd64.pp
----------------------------------------------------------------------
diff --git a/vagrant/manifests/ubuntu-1204-server-amd64.pp b/vagrant/manifests/ubuntu-1204-server-amd64.pp
index 26cbe3c..3e42118 100644
--- a/vagrant/manifests/ubuntu-1204-server-amd64.pp
+++ b/vagrant/manifests/ubuntu-1204-server-amd64.pp
@@ -66,9 +66,9 @@ exec { "install venv":
 
 # create Allura virtualenv
 exec { "create allura venv":
-  command => "/usr/local/bin/virtualenv anvil",
+  command => "/usr/local/bin/virtualenv env-allura",
   cwd     => "/home/vagrant",
-  creates => "/home/vagrant/anvil",
+  creates => "/home/vagrant/env-allura",
   user => "vagrant",
   group => "vagrant",
   require => Exec[ "install venv" ],
@@ -91,17 +91,24 @@ file { "/var/log/allura":
 # clone Allura source from git
 exec { "clone repo":
   command => "/usr/bin/git clone https://git-wip-us.apache.org/repos/asf/incubator-allura.git allura",
-  cwd     => "/home/vagrant/src",
-  creates => "/home/vagrant/src/allura",
+  cwd     => "/vagrant",
+  creates => "/vagrant/allura",
   user => "vagrant",
   group => "vagrant",
-  require => [ File[ "/home/vagrant/src" ], Package[ "git-core" ] ],
+  require => [ Package[ "git-core" ] ],
+}
+
+# symlink allura src into the vagrant home dir just to be nice
+file { '/home/vagrant/src/allura':
+  ensure => 'link',
+  target => '/vagrant/allura',
+  require => [ File['/home/vagrant/src'], Exec['clone repo'] ],
 }
 
 # install Allura dependencies
 exec { "pip install":
-  command => "/home/vagrant/anvil/bin/pip install -r requirements.txt",
-  cwd     => "/home/vagrant/src/allura",
+  command => "/home/vagrant/env-allura/bin/pip install -r requirements.txt",
+  cwd     => "/vagrant/allura",
   user => "vagrant",
   group => "vagrant",
   timeout => 0,
@@ -114,7 +121,7 @@ exec { "pip install":
 }
 
 # symlink pysvn in from the system installation
-file { '/home/vagrant/anvil/lib/python2.7/site-packages/pysvn':
+file { '/home/vagrant/env-allura/lib/python2.7/site-packages/pysvn':
   ensure => 'link',
   target => '/usr/lib/python2.7/dist-packages/pysvn',
   require => [ Package[ "python-svn" ], Exec[ "pip install" ]],


[28/50] git commit: [#2835] ticket:292 Better search for url shortener

Posted by jo...@apache.org.
[#2835] ticket:292 Better search for url shortener


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

Branch: refs/heads/cj/5655
Commit: b38865b36b24f7aa727a82729ae3a55f79debe7f
Parents: 7b42446
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 25 14:47:22 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:41 2013 +0000

----------------------------------------------------------------------
 ForgeShortUrl/forgeshorturl/main.py               |   49 +++++-----------
 ForgeShortUrl/forgeshorturl/templates/search.html |    7 ++-
 2 files changed, 21 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b38865b3/ForgeShortUrl/forgeshorturl/main.py
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/main.py b/ForgeShortUrl/forgeshorturl/main.py
index b85b7a3..79c48ce 100644
--- a/ForgeShortUrl/forgeshorturl/main.py
+++ b/ForgeShortUrl/forgeshorturl/main.py
@@ -17,19 +17,17 @@
 
 from tg import expose, validate, redirect, flash, request
 from tg.decorators import without_trailing_slash
-from urllib import urlencode
 
 from allura.app import Application, SitemapEntry, DefaultAdminController
 from allura import model as M
 from allura.lib.security import require_access, has_access
 from allura.lib import helpers as h
-from allura.lib.search import search, SearchError
+from allura.lib.search import search_app
 from allura.controllers import BaseController
 from allura.lib.widgets import form_fields as ffw
 from allura.lib.widgets.search import SearchResults
 
 from webob import exc
-import pylons
 from pylons import tmpl_context as c, app_globals as g
 from datetime import datetime
 from formencode import validators
@@ -163,38 +161,23 @@ class RootController(BaseController):
 
     @expose('jinja:forgeshorturl:templates/search.html')
     @validate(dict(q=validators.UnicodeString(if_empty=None),
-                   history=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):
-        if project:
-            redirect(c.project.url() +
-                     'search?' +
-                     urlencode(dict(q=q, history=history)))
-        results = []
-        search_error = None
-        count = 0
-        limit, page, start = g.handle_paging(limit, page, default=25)
-        if not q:
-            q = ''
-        else:
-            query = ['is_history_b:%s' % history,
-                    'project_id_s:%s' % c.project._id,
-                    'mount_point_s:%s' % c.app.config.options.mount_point,
-                    'type_s:%s' % ShortUrl.type_s]
-            if not has_access(c.app, 'view_private'):
-                query.append('private_b:False')
-            try:
-                results = search(q, fq=query, short_timeout=True, ignore_errors=False)
-            except SearchError as e:
-                search_error = e
-
-            if results:
-                count = results.hits
+    def search(self, q=None, project=None, limit=None, page=0, **kw):
         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)
+        search_params = kw
+        search_params.update({
+            'q': q or '',
+            'project': project,
+            'limit': limit,
+            'page': page,
+            'allowed_types': ['ShortUrl'],
+        })
+        if not has_access(c.app, 'view_private'):
+            search_params['fq'] = ['private_b:False']
+        d = search_app(**search_params)
+        d['search_comments_disable'] = True
+        d['search_history_disable'] = True
+        return d
 
     @expose()
     def _lookup(self, pname, *remainder):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b38865b3/ForgeShortUrl/forgeshorturl/templates/search.html
----------------------------------------------------------------------
diff --git a/ForgeShortUrl/forgeshorturl/templates/search.html b/ForgeShortUrl/forgeshorturl/templates/search.html
index 1093121..87aa838 100644
--- a/ForgeShortUrl/forgeshorturl/templates/search.html
+++ b/ForgeShortUrl/forgeshorturl/templates/search.html
@@ -23,7 +23,10 @@
 {% block header %}Search {{c.app.config.options.mount_point}}: {{q}}{% endblock %}
 {% block short_url_content %}{% endblock %}
 {% block content %}
-{{c.search_results.display(results=results,q=q,history=history,
-count=count,limit=limit,page=page,search_error=search_error)}}
+  {{c.search_results.display(results=results,q=q,history=history,
+     count=count,limit=limit,page=page,search_error=search_error,
+     sort_score_url=sort_score_url, sort_date_url=sort_date_url, sort_field=sort_field,
+     search_comments_disable=search_comments_disable,
+     search_history_disable=search_history_disable)}}
 {% endblock %}
 


[20/50] git commit: [#2835] ticket:290 Show content preview with highlighted matches on wiki search results

Posted by jo...@apache.org.
[#2835] ticket:290 Show content preview with highlighted matches on wiki 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/0a42328a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0a42328a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0a42328a

Branch: refs/heads/cj/5655
Commit: 0a42328a1d305043ca306e41ff879a9f8b39d9a3
Parents: 5b2dfd3
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Mar 12 13:23:45 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:40 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/resources/css/search.css |    8 ++++++++
 .../allura/templates/widgets/search_results.html   |    7 ++++---
 ForgeWiki/forgewiki/wiki_main.py                   |   15 ++++++++++++++-
 3 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0a42328a/Allura/allura/lib/widgets/resources/css/search.css
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/css/search.css b/Allura/allura/lib/widgets/resources/css/search.css
index 3f25fd2..848accc 100644
--- a/Allura/allura/lib/widgets/resources/css/search.css
+++ b/Allura/allura/lib/widgets/resources/css/search.css
@@ -28,3 +28,11 @@ input[type="radio"],
 input[type="checkbox"] {
   vertical-align: middle;
 }
+
+.text-match {
+  overflow: hidden;
+  text-overflow: ellipsis;
+  display: inline-block;
+  width: 100%;
+  white-space: nowrap;
+}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0a42328a/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 3d28f49..e33fded 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -57,14 +57,15 @@
 </div>
 {% for doc in results %}
   <div class="grid-19">
-    {# TODO: mark matches in title and snippet #}
     <p>
     <a href="{{doc['url_paginated'] or doc['url_s']}}">
-       {{- h.get_first(doc, 'title') or h.get_first(doc, 'title_s') -}}  {#-  title_s is legacy -#}
+       {{- doc.title_match|safe or h.get_first(doc, 'title') or h.get_first(doc, 'title_s') -}}  {#-  title_s is legacy -#}
     </a>
     {% if doc['type_s'] %}<span class="gray"><sup>{{ '(%s)' % doc['type_s'] }}</sup></span>{% endif %}
     <br>
-    {{ doc.snippet }}
+    {% if doc.text_match %}
+      <span class="text-match">{{ doc.text_match|safe }}</span><br>
+    {% endif %}
     <span class="gray">Last updated: {{ h.ago_string(doc['mod_date_dt']) }}</span>
     </p>
   </div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0a42328a/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 62d6c83..3e8d815 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -320,6 +320,7 @@ class RootController(BaseController, DispatchIndex):
         results = []
         count = 0
         parser = kw.pop('parser', None)
+        matches = {}
         limit, page, start = g.handle_paging(limit, page, default=25)
         if not q:
             q = ''
@@ -340,6 +341,9 @@ class RootController(BaseController, DispatchIndex):
                     '-deleted_b:true',
                     'type_s:(%s)' % ' OR '.join(['"%s"' % t for t in allowed_types])
                 ],
+                'hl': 'true',
+                'hl.simple.pre': '<strong>',
+                'hl.simple.post': '</strong>',
             }
             if not history:
                search_params['fq'].append('is_history_b:False')
@@ -354,13 +358,22 @@ class RootController(BaseController, DispatchIndex):
             except SolrError as e:
                 search_error = e
             if results:
-                count=results.hits
+                count = results.hits
+                matches = results.highlighting
                 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
+                def add_matches(doc):
+                    m = matches.get(doc['id'], {})
+                    doc['title_match'] = m.get('title', [''])[0]
+                    doc['text_match'] = m.get('text', [''])[0]
+                    if not doc['text_match']:
+                        doc['text_match'] = doc.get('text', [''])[0]
+                    return doc
                 results = imap(historize_urls, results)
+                results = imap(add_matches, 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)


[41/50] git commit: [#2835] make solarize test cases independent

Posted by jo...@apache.org.
[#2835] make solarize test cases independent


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

Branch: refs/heads/cj/5655
Commit: bb9a5021f11167794ce28a66292c837e060f1a60
Parents: 57cf03a
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Apr 17 19:47:21 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:43 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/unit/test_solr.py |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bb9a5021/Allura/allura/tests/unit/test_solr.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_solr.py b/Allura/allura/tests/unit/test_solr.py
index e1b67c8..5226f07 100644
--- a/Allura/allura/tests/unit/test_solr.py
+++ b/Allura/allura/tests/unit/test_solr.py
@@ -50,26 +50,27 @@ class TestSolr(unittest.TestCase):
 
 class TestSolarize(unittest.TestCase):
 
-    def setUp(self):
-        self.obj = mock.MagicMock()
-        self.obj.index.return_value = {}
-
     def test_no_object(self):
         assert_equal(solarize(None), None)
 
     def test_empty_index(self):
-        self.obj.index.return_value = None
-        assert_equal(solarize(self.obj), None)
+        obj = mock.MagicMock()
+        obj.index.return_value = None
+        assert_equal(solarize(obj), None)
 
     def test_doc_without_text(self):
-        assert_equal(solarize(self.obj), {'text': ''})
+        obj = mock.MagicMock()
+        obj.index.return_value = {}
+        assert_equal(solarize(obj), {'text': ''})
 
     def test_strip_markdown(self):
-        self.obj.index.return_value = {'text': '# Header'}
-        assert_equal(solarize(self.obj), {'text': 'Header'})
+        obj = mock.MagicMock()
+        obj.index.return_value = {'text': '# Header'}
+        assert_equal(solarize(obj), {'text': 'Header'})
 
     def test_html_in_text(self):
-        self.obj.index.return_value = {'text': '<script>alert(1)</script>'}
-        assert_equal(solarize(self.obj), {'text': ''})
-        self.obj.index.return_value = {'text': '&lt;script&gt;alert(1)&lt;/script&gt;'}
-        assert_equal(solarize(self.obj), {'text': '&lt;script&gt;alert(1)&lt;/script&gt;'})
+        obj = mock.MagicMock()
+        obj.index.return_value = {'text': '<script>alert(1)</script>'}
+        assert_equal(solarize(obj), {'text': ''})
+        obj.index.return_value = {'text': '&lt;script&gt;alert(1)&lt;/script&gt;'}
+        assert_equal(solarize(obj), {'text': '&lt;script&gt;alert(1)&lt;/script&gt;'})


[27/50] git commit: [#2835] ticket:292 Use new search on 'entire project search' page

Posted by jo...@apache.org.
[#2835] ticket:292 Use new search on 'entire project search' page


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

Branch: refs/heads/cj/5655
Commit: bfee10f6e49890a7583c47a2d9d6991b5b7a8e21
Parents: 1fc20bd
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 25 15:51:38 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/search.py                |   27 +++++-----
 Allura/allura/ext/search/search_main.py            |   39 ++++++++------
 Allura/allura/lib/search.py                        |   12 +++--
 Allura/allura/templates/search_index.html          |   37 ++------------
 .../allura/templates/widgets/search_results.html   |    3 +
 5 files changed, 53 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bfee10f6/Allura/allura/controllers/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/search.py b/Allura/allura/controllers/search.py
index 0a7e699..a58ee9f 100644
--- a/Allura/allura/controllers/search.py
+++ b/Allura/allura/controllers/search.py
@@ -22,7 +22,8 @@ from pylons import tmpl_context as c
 from webob import exc
 import pymongo
 
-from allura.lib import search
+from allura.lib.search import search_app
+from allura.lib.widgets.search import SearchResults
 from allura.app import SitemapEntry
 from allura import model as M
 from allura.lib.widgets import project_list as plw
@@ -30,6 +31,7 @@ from allura.controllers import BaseController
 
 class W:
     project_summary = plw.ProjectSummary()
+    search_results = SearchResults()
 
 class SearchController(BaseController):
 
@@ -38,18 +40,17 @@ class SearchController(BaseController):
                    history=V.StringBool(if_empty=False)))
     @with_trailing_slash
     def index(self, q=None, history=False, **kw):
-        results = []
-        count=0
-        if not q:
-            q = ''
-        else:
-            results = search.search(
-                q,
-                fq='is_history_b:%s' % history,
-                short_timeout=True)
-            if results: count=results.hits
-        return dict(q=q, history=history, results=results or [], count=count)
-
+        c.search_results = W.search_results
+        search_params = kw
+        search_params.update({
+            'q': q,
+            'history': history,
+            'app': False,
+        })
+        d = search_app(**search_params)
+        d['search_comments_disable'] = True
+        d['hide_app_project_switcher'] = True
+        return d
 
 class ProjectBrowseController(BaseController):
     def __init__(self, category_name=None, parent_category=None):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bfee10f6/Allura/allura/ext/search/search_main.py
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/search/search_main.py b/Allura/allura/ext/search/search_main.py
index bcb1ee9..9b709f4 100644
--- a/Allura/allura/ext/search/search_main.py
+++ b/Allura/allura/ext/search/search_main.py
@@ -25,7 +25,8 @@ from formencode import validators as V
 
 from allura.app import Application
 from allura import version
-from allura.lib import search
+from allura.lib.search import search_app
+from allura.lib.widgets.search import SearchResults
 from allura.controllers import BaseController
 
 log = logging.getLogger(__name__)
@@ -66,19 +67,23 @@ class SearchController(BaseController):
                    history=V.StringBool(if_empty=False)))
     @with_trailing_slash
     def index(self, q=None, history=None, **kw):
-        results = []
-        count=0
-        if not q:
-            q = ''
-        else:
-            pids = [c.project._id] + [
-                p._id for p in c.project.subprojects ]
-            project_match = ' OR '.join(
-                'project_id_s:%s' % pid
-                for pid in pids )
-            search_query = '%s AND is_history_b:%s AND (%s) AND -deleted_b:true' % (
-                q, history, project_match)
-            results = search.search(search_query, is_history_b=history, short_timeout=True)
-            if results: count=results.hits
-        return dict(q=q, history=history, results=results or [], count=count)
-
+        c.search_results = SearchResults()
+        pids = [c.project._id] + [
+            p._id for p in c.project.subprojects ]
+        project_match = ' OR '.join(
+            'project_id_s:%s' % pid
+            for pid in pids )
+        search_params = kw
+        search_params.update({
+            'q': q,
+            'history': history,
+            'app': False,
+            'fq': [
+                'project_id_s:(%s)' % project_match,
+                '-deleted_b:true',
+            ],
+        })
+        d = search_app(**search_params)
+        d['search_comments_disable'] = True
+        d['hide_app_project_switcher'] = True
+        return d

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bfee10f6/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index c541225..cf92af8 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -89,14 +89,15 @@ def search_artifact(atype, q, history=False, rows=10, short_timeout=False, **kw)
     return search(q, fq=fq, rows=rows, short_timeout=short_timeout, ignore_errors=False, **kw)
 
 
-def search_app(q='', fq=None, **kw):
-    """Helper for app search.
+def search_app(q='', fq=None, app=True, **kw):
+    """Helper for app/project search.
 
     Uses dismax query parser. Matches on `title` and `text`. Handles paging, sorting, etc
     """
     history = kw.pop('history', None)
-    if kw.pop('project', False):
-        redirect(c.project.url() + 'search?' + urlencode(dict(q=q, history=history)))
+    if app and kw.pop('project', False):
+        # Used from app's search controller. If `project` is True, redirect to 'entire project search' page
+        redirect(c.project.url() + 'search/?' + urlencode(dict(q=q, history=history)))
     search_comments = kw.pop('search_comments', None)
     limit = kw.pop('limit', None)
     page = kw.pop('page', 0)
@@ -133,6 +134,9 @@ def search_app(q='', fq=None, **kw):
             'hl.simple.post': '</strong>',
             'sort': sort,
         }
+        if not app:
+            # Not app-restricted search. Use only provided filter query (fq)
+            search_params['fq'] = fq
         if not history:
            search_params['fq'].append('is_history_b:False')
         if parser == 'standard':

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bfee10f6/Allura/allura/templates/search_index.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/search_index.html b/Allura/allura/templates/search_index.html
index ea2b566..13fa9d1 100644
--- a/Allura/allura/templates/search_index.html
+++ b/Allura/allura/templates/search_index.html
@@ -24,35 +24,10 @@
 {% block header %}Search Project: {{q}}{% endblock %}
 
 {% block content %}
-  <div class="grid-24">
-  <form method="GET" action="search">
-    <input type="text" name="q" value="{{q}}" class="title"/><br/>
-    Search history? <input type="checkbox" name="history" {% if history %}checked{% endif %}/><br/>
-    &nbsp;<br/>
-    <input type="submit" value="Search"/>
-  </form>
-  {% if count == 0 and q %}
-    <p>No results.</p>
-  {% elif count == 1 and q %}
-    <p>{{count}} result.</p>
-  {% elif count > 1 and q %}
-    <p>{{count}} results.</p>
-  {% endif %}
-  <hr/>
-  </div>
-
-  <div class="grid-24">
-  <ol>
-  {% for doc in results %}
-  <li>
-    <a href="{{doc['url_s']}}">
-       {{- h.get_first(doc, 'title') or h.get_first(doc, 'title_s') -}}  {#-  title_s is legacy -#}
-    </a>
-    {% if doc.get('snippet') %}
-      <p>{{doc['snippet']|safe}}</p>
-    {% endif %}
-  </li>
-  {% endfor %}
-  </ol>
-  </div>
+  {{c.search_results.display(results=results,q=q,history=history,
+     count=count,limit=limit,page=page,search_error=search_error,
+     sort_score_url=sort_score_url, sort_date_url=sort_date_url, sort_field=sort_field,
+     search_comments_disable=search_comments_disable,
+     search_history_disable=search_history_disable,
+     hide_app_project_switcher=hide_app_project_switcher)}}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/bfee10f6/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 debb450..2eaaf61 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -31,6 +31,8 @@
     </a>
   </div>
   {% endif %}
+  <div style="clear:both"></div>
+  {% if not hide_app_project_switcher %}
   <div class="grid-10">
     {% set search_project = request.GET['project'] == '1' %}
     <input type="radio" name="project" value="0" id="search-app" {% if not search_project %}checked{% endif %}>
@@ -38,6 +40,7 @@
     <input type="radio" name="project" value="1" id="search-project" {% if search_project %}checked{% endif %}>
     <label for="search-project">Search entire project</label>
   </div>
+  {% endif %}
   <div class="grid-9">
     {% if not search_comments_disable %}
       {% set comments = request.GET['search_comments'] %}


[43/50] git commit: [#2835] fix test to match search help text changes

Posted by jo...@apache.org.
[#2835] fix test to match search help text changes


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

Branch: refs/heads/cj/5655
Commit: 54cca78f463643b3475d1ce94755d0a57853ba19
Parents: d958fae
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Apr 24 18:38:52 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 18:38:52 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/functional/test_root.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/54cca78f/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 2b6a190..14e70c6 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -131,7 +131,7 @@ class TestRootController(TestController):
         assert btn is not None, "Can't find a help button"
         div = r.html.find('div', attrs={'id': 'lightbox_search_help_modal'})
         assert div is not None, "Can't find help text"
-        assert_in('Searching the wiki', div.text)
+        assert_in('To search for an exact phrase', div.text)
 
     def test_page_index(self):
         response = self.app.get('/wiki/tést/')


[19/50] git commit: [#2835] ticket:290 Convert markdown to plain text before indexation

Posted by jo...@apache.org.
[#2835] ticket:290 Convert markdown to plain text before indexation


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

Branch: refs/heads/cj/5655
Commit: 46db582d6a47fb16c9802aa25940ecd029ef6093
Parents: 0a42328
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Mar 13 13:22:40 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:40 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/46db582d/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 04b6ec3..d9c300a 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -20,6 +20,7 @@ import socket
 from logging import getLogger
 
 import markdown
+import jinja2
 from pylons import tmpl_context as c, app_globals as g
 from pysolr import SolrError
 
@@ -34,6 +35,11 @@ def solarize(obj):
     # if index() returned doc without text, assume empty text
     if not doc.get('text'):
         doc['text'] = ''
+    # Convert text to plain text (It usually contains markdown markup).
+    # To do so, we convert markdown into html, and then strip all html tags.
+    text = doc['text']
+    text = g.markdown.convert(text)
+    doc['text'] = jinja2.Markup.escape(text).striptags()
     return doc
 
 class SearchError(SolrError):


[23/50] git commit: [#2835] ticket:291 Search help button

Posted by jo...@apache.org.
[#2835] ticket:291 Search help button


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

Branch: refs/heads/cj/5655
Commit: 1f5a295dfb8cb1b39b3eacf52e91596e1341c0a4
Parents: 248e5b6
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Mar 21 13:47:55 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/search.py                |   13 +++++++++++++
 .../allura/templates/widgets/search_results.html   |    5 +++--
 ForgeWiki/forgewiki/templates/wiki/search_help.txt |    8 ++++++++
 ForgeWiki/forgewiki/tests/functional/test_root.py  |    8 ++++++++
 ForgeWiki/forgewiki/wiki_main.py                   |    9 ++++++++-
 5 files changed, 40 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1f5a295d/Allura/allura/lib/widgets/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/search.py b/Allura/allura/lib/widgets/search.py
index bebbe20..22f4d8a 100644
--- a/Allura/allura/lib/widgets/search.py
+++ b/Allura/allura/lib/widgets/search.py
@@ -39,3 +39,16 @@ class SearchResults(ew_core.Widget):
             for r in f.resources():
                 yield r
         yield ew.CSSLink('css/search.css')
+
+
+class SearchHelp(ffw.Lightbox):
+    defaults=dict(
+        ffw.Lightbox.defaults,
+        name='search_help_modal',
+        trigger='a.search_help_modal')
+
+    content_template = '<div style="height:400px; overflow:auto;">%s</div>'
+
+    def __init__(self, content=''):
+        super(SearchHelp, self).__init__()
+        self.content = self.content_template % content

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1f5a295d/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 feaa60f..500f639 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -23,14 +23,14 @@
   <div class="grid-3">
     <input type="submit" value="Search">
   </div>
+  {% if c.help_modal %}
   <div class="grid-6">
-    {# TODO: when help text provided, show button
     <a href="#" class="btn search_help_modal">
       <b data-icon="{{g.icons['help'].char}}" class="ico {{g.icons['help'].css}}"></b>
       Help
     </a>
-    #}
   </div>
+  {% endif %}
   <div class="grid-10">
     {% set search_project = request.GET['project'] == '1' %}
     <input type="radio" name="project" value="0" id="search-app" {% if not search_project %}checked{% endif %}>
@@ -85,3 +85,4 @@
     <a href="{{ sort_date_url }}" class="{{ 'strong' if sort_field == 'mod_date_dt' else '' }}">date</a>
   </p>
 </div>
+{% if c.help_modal %}{{ c.help_modal.display() }}{% endif %}

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1f5a295d/ForgeWiki/forgewiki/templates/wiki/search_help.txt
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/search_help.txt b/ForgeWiki/forgewiki/templates/wiki/search_help.txt
new file mode 100644
index 0000000..4a337b8
--- /dev/null
+++ b/ForgeWiki/forgewiki/templates/wiki/search_help.txt
@@ -0,0 +1,8 @@
+<h1>Searching wiki</h1>
+<p>Searches use wiki page title and inner text for matching.<p>
+<p>You can also use 'Search comments?' and 'Search history?' checkboxes to include comments and history of pages editing in the search results.</p>
+
+<p>If you want to see all the page with given label, you may use url like this (there is no UI for this):</p>
+<div class="codehilite">
+<pre>/p/yourproject/wiki/search/?q=labels_t:label&amp;parser=standard</pre>
+</div>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1f5a295d/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 838086c..029bf56 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -125,6 +125,14 @@ class TestRootController(TestController):
         solr_query.pop('pf')
         search.assert_called_with('test', **solr_query)
 
+    def test_search_help(self):
+        r = self.app.get('/wiki/search?q=test')
+        btn = r.html.find('a', attrs={'class': 'btn search_help_modal'})
+        assert btn is not None, "Can't find a help button"
+        div = r.html.find('div', attrs={'id': 'lightbox_search_help_modal'})
+        assert div is not None, "Can't find help text"
+        assert_in('Searching wiki', div.text)
+
     def test_page_index(self):
         response = self.app.get('/wiki/tést/')
         assert 'tést' in response.follow()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1f5a295d/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index fc5b566..eed1467 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -31,6 +31,7 @@ from pylons import request
 from formencode import validators
 from webob import exc
 from ming.orm import session
+import jinja2
 
 # Pyforge-specific imports
 from allura import model as M
@@ -45,7 +46,7 @@ from allura.controllers import attachments as ac
 from allura.lib import widgets as w
 from allura.lib.widgets import form_fields as ffw
 from allura.lib.widgets.subscriptions import SubscribeForm
-from allura.lib.widgets.search import SearchResults
+from allura.lib.widgets.search import SearchResults, SearchHelp
 
 # Local imports
 from forgewiki import model as WM
@@ -54,6 +55,10 @@ from forgewiki.widgets.wiki import CreatePageWidget
 
 log = logging.getLogger(__name__)
 
+jinja_env = jinja2.Environment(loader=jinja2.PackageLoader('forgewiki', 'templates'))
+search_help_text = jinja_env.get_template('wiki/search_help.txt').render()
+
+
 class W:
     thread=w.Thread(
         page=None, limit=None, page_size=None, count=None,
@@ -68,6 +73,7 @@ class W:
     page_list = ffw.PageList()
     page_size = ffw.PageSize()
     search_results = SearchResults()
+    help_modal = SearchHelp(search_help_text)
     icons={
         24:'images/wiki_24.png',
         32:'images/wiki_32.png',
@@ -377,6 +383,7 @@ class RootController(BaseController, DispatchIndex):
                 results = imap(historize_urls, results)
                 results = imap(add_matches, results)
         c.search_results = W.search_results
+        c.help_modal = W.help_modal
         score_url = 'score desc'
         date_url = 'mod_date_dt desc'
         try:


[22/50] git commit: [#2835] ticket:292 Better blog search

Posted by jo...@apache.org.
[#2835] ticket:292 Better blog search


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

Branch: refs/heads/cj/5655
Commit: b636c9d2a5ec36d469b6743e19a9241c5d14857e
Parents: 891ff45
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 25 12:31:07 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:41 2013 +0000

----------------------------------------------------------------------
 ForgeBlog/forgeblog/main.py                    |   48 +++++++++----------
 ForgeBlog/forgeblog/model/blog.py              |    5 +-
 ForgeBlog/forgeblog/templates/blog/search.html |   27 ++---------
 3 files changed, 28 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b636c9d2/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 65f5c6d..91ed6b6 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -21,7 +21,6 @@ from datetime import datetime
 import urllib2
 
 # Non-stdlib imports
-import pkg_resources
 import pymongo
 from tg import config, expose, validate, redirect, flash
 from tg.decorators import with_trailing_slash, without_trailing_slash
@@ -35,15 +34,16 @@ from webob import exc
 from ming.orm import session
 
 # Pyforge-specific imports
-from allura.app import Application, ConfigOption, SitemapEntry
+from allura.app import Application, SitemapEntry
 from allura.app import DefaultAdminController
 from allura.lib import helpers as h
-from allura.lib.search import search, SearchError
+from allura.lib.search import search_app
 from allura.lib.decorators import require_post, Property
 from allura.lib.security import has_access, require_access
 from allura.lib import widgets as w
 from allura.lib.widgets.subscriptions import SubscribeForm
 from allura.lib.widgets import form_fields as ffw
+from allura.lib.widgets.search import SearchResults
 from allura import model as M
 from allura.controllers import BaseController, AppDiscussionController
 
@@ -67,6 +67,7 @@ class W:
     attachment_list = ffw.AttachmentList()
     preview_post_form = widgets.PreviewPostForm()
     subscribe_form = SubscribeForm()
+    search_results = SearchResults()
 
 class ForgeBlogApp(Application):
     __version__ = version.__version__
@@ -203,31 +204,26 @@ class RootController(BaseController):
         c.pager = W.pager
         return dict(posts=posts, page=page, limit=limit, count=post_count)
 
+    @with_trailing_slash
     @expose('jinja:forgeblog:templates/blog/search.html')
     @validate(dict(q=validators.UnicodeString(if_empty=None),
-                   history=validators.StringBool(if_empty=False)))
-    def search(self, q=None, history=None, **kw):
-        'local tool search'
-        results = []
-        search_error = None
-        count=0
-        if not q:
-            q = ''
-        else:
-            try:
-                results = search(
-                    q,
-                    fq=[
-                        'state_s:published',
-                        'is_history_b:%s' % history,
-                        'project_id_s:%s' % c.project._id,
-                        'mount_point_s:%s'% c.app.config.options.mount_point ],
-                    short_timeout=True,
-                    ignore_errors=False)
-            except SearchError as e:
-                search_error = e
-            if results: count=results.hits
-        return dict(q=q, history=history, results=results or [], count=count, search_error=search_error)
+                   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, search_comments=None, project=None, limit=None, page=0, **kw):
+        c.search_results = W.search_results
+        search_params = kw
+        search_params.update({
+            'q': q or '',
+            'history': history,
+            'search_comments': search_comments,
+            'project': project,
+            'limit': limit,
+            'page': page,
+            'allowed_types': ['Blog Post', 'Blog Post Snapshot'],
+            'fq': ['state_s:published']
+        })
+        return search_app(**search_params)
 
     @expose('jinja:forgeblog:templates/blog/edit_post.html')
     @without_trailing_slash

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b636c9d2/ForgeBlog/forgeblog/model/blog.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/model/blog.py b/ForgeBlog/forgeblog/model/blog.py
index 1801c22..d5ec233 100644
--- a/ForgeBlog/forgeblog/model/blog.py
+++ b/ForgeBlog/forgeblog/model/blog.py
@@ -74,8 +74,7 @@ class BlogPostSnapshot(M.Snapshot):
             return None
         result = super(BlogPostSnapshot, self).index()
         result.update(
-            title='Version %d of %s' % (
-                self.version, orig.shorthand_id()),
+            title='%s (version %d)' % (orig.title, self.version),
             type_s=self.type_s,
             text=self.data.text)
         return result
@@ -201,7 +200,7 @@ class BlogPost(M.VersionedArtifact, ActivityObject):
     def index(self):
         result = super(BlogPost, self).index()
         result.update(
-            title=self.slug,
+            title=self.title,
             type_s=self.type_s,
             state_s=self.state,
             snippet_s='%s: %s' % (self.title, h.text.truncate(self.text, 200)),

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/b636c9d2/ForgeBlog/forgeblog/templates/blog/search.html
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/templates/blog/search.html b/ForgeBlog/forgeblog/templates/blog/search.html
index b8574ca..76b4372 100644
--- a/ForgeBlog/forgeblog/templates/blog/search.html
+++ b/ForgeBlog/forgeblog/templates/blog/search.html
@@ -20,29 +20,10 @@
 
 {% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Search{% endblock %}
 
-{% block header %}ForgeBlog Search{% endblock %}
+{% block header %}Search {{c.app.config.options.mount_point}}: {{q}}{% endblock %}
 
 {% block content %}
-  <form method="GET" action="search" class="grid-19">
-    <input type="text" name="q" value="{{q}}"/><br/>
-    Search history? <input type="checkbox" name="history" {% if history %}checked="checked"{% endif %}/><br/>
-    <input type="submit" value="Search"/>
-  </form>
-  <div style="clear: both">&nbsp;</div>
-  {% if search_error %}
-  <p>{{ search_error }}</p>
-  {% elif count==0 and q %}
-  <p>No results.</p>
-  {% elif count==1 and q %}
-  <p>{{count}} result.</p>
-  {% elif count > 1 and q %}
-  <p>{{count}} results.</p>
-  {% endif %}
-  {% for doc in results %}
-  <div>
-    <div class="grid-19"><a href="{{doc['url_s']}}">{{ h.get_first(doc, 'title') }}</a></div>
-    <p>{{doc.get('snippet_s', '...')}}</p>
-    <hr/>
-  </div>
-  {% endfor %}
+  {{c.search_results.display(results=results,q=q,history=history,
+     count=count,limit=limit,page=page,search_error=search_error,
+     sort_score_url=sort_score_url, sort_date_url=sort_date_url, sort_field=sort_field)}}
 {% endblock %}


[49/50] git commit: [#5655] Added root REST view with hook for providing site stats

Posted by jo...@apache.org.
[#5655] Added root REST view with hook for providing site stats

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/5655
Commit: 5639518514cb00c8db0ad3077fc1e1a513655946
Parents: 51f5361
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Mon Apr 22 23:29:12 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Apr 24 21:48:34 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/rest.py |    9 ++++++++-
 Allura/allura/lib/app_globals.py  |    1 +
 2 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/56395185/Allura/allura/controllers/rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index e7d11f9..0d519cc 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -23,7 +23,7 @@ import logging
 import oauth2 as oauth
 from webob import exc
 from tg import expose, flash, redirect
-from pylons import tmpl_context as c
+from pylons import tmpl_context as c, app_globals as g
 from pylons import request
 
 from ming.orm import session
@@ -60,6 +60,13 @@ class RestController(object):
         else:
             return None
 
+    @expose('json:')
+    def index(self, **kw):
+        provider = g.entry_points['site_stats'].get('provider')
+        if provider:
+            return provider()
+        return dict()
+
     @expose()
     def _lookup(self, name, *remainder):
         api_token = self._authenticate_request()

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/56395185/Allura/allura/lib/app_globals.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 3eb816b..e5b00c7 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -185,6 +185,7 @@ class Globals(object):
             user_prefs=_cache_eps('allura.user_prefs'),
             spam=_cache_eps('allura.spam'),
             stats=_cache_eps('allura.stats'),
+            site_stats=_cache_eps('allura.site_stats'),
             )
 
         # Zarkov logger


[05/50] git commit: [#5120] Fix test url

Posted by jo...@apache.org.
[#5120] Fix test url

Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>


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

Branch: refs/heads/cj/5655
Commit: 6194bda1c1405df9664f824e5008701029e213c7
Parents: 9bf778a
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Tue Apr 23 15:23:38 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 17:03:34 2013 +0000

----------------------------------------------------------------------
 .../forgegit/tests/functional/test_controllers.py  |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6194bda1/ForgeGit/forgegit/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index 5b7f97e..78a8d7e 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -140,7 +140,7 @@ class TestRootController(_TestCase):
         resp = self.app.get('/src-git/ref/master~/tags/')
 
     def _get_ci(self):
-        r = self.app.get('/src-git/ref/master:/')
+        r = self.app.get('/src-git/ref/master/')
         resp = r.follow()
         for tag in resp.html.findAll('a'):
             if tag['href'].startswith('/p/test/src-git/ci/'):


[45/50] git commit: [#4370] ticket:322 Don't redirect from API to login url

Posted by jo...@apache.org.
[#4370] ticket:322 Don't redirect from API to login url


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

Branch: refs/heads/cj/5655
Commit: ad54b2fde6231bf18d7489d4c67c4050e80aef24
Parents: 3207e95
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Apr 24 10:10:28 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 20:02:25 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/custom_middleware.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ad54b2fd/Allura/allura/lib/custom_middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 6633489..6c121b4 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -93,7 +93,8 @@ class LoginRedirectMiddleware(object):
     def __call__(self, environ, start_response):
         status, headers, app_iter, exc_info = call_wsgi_application(
             self.app, environ, catch_exc_info=True)
-        if status[:3] == '401':
+        is_api_request = environ.get('PATH_INFO', '').startswith('/rest/')
+        if status[:3] == '401' and not is_api_request:
             login_url = tg.config.get('auth.login_url', '/auth/')
             if environ['REQUEST_METHOD'] == 'GET':
                 return_to = environ['PATH_INFO']


[32/50] git commit: [#2835] add --tasks option to reindex cmd, so macros work

Posted by jo...@apache.org.
[#2835] add --tasks option to reindex cmd, so macros work


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

Branch: refs/heads/cj/5655
Commit: 196f718649439d2a5c07bc92ea34cc8269565921
Parents: ee3e615
Author: Dave Brondsema <db...@geek.net>
Authored: Wed Mar 27 14:36:25 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:42 2013 +0000

----------------------------------------------------------------------
 Allura/allura/command/show_models.py |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/196f7186/Allura/allura/command/show_models.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/show_models.py b/Allura/allura/command/show_models.py
index 940adbd..890805d 100644
--- a/Allura/allura/command/show_models.py
+++ b/Allura/allura/command/show_models.py
@@ -59,6 +59,10 @@ class ReindexCommand(base.Command):
                       help='Solr needs artifact references to already exist.')
     parser.add_option('--refs', action='store_true', dest='refs',
                       help='Update artifact references and shortlinks')
+    parser.add_option('--tasks', action='store_true', dest='tasks',
+                      help='Run each individual index operation as a background task.  '
+                           'Note: this is often better, since tasks have "request" objects '
+                           'which are needed for some markdown macros to run properly')
 
     def command(self):
         from allura import model as M
@@ -108,15 +112,18 @@ class ReindexCommand(base.Command):
                     M.main_orm_session.flush()
                     M.artifact_orm_session.clear()
                     try:
-                        allura.tasks.index_tasks.add_artifacts(ref_ids,
-                                                               update_solr=self.options.solr,
-                                                               update_refs=self.options.refs)
+                        add_artifacts = allura.tasks.index_tasks.add_artifacts
+                        if self.options.tasks:
+                            add_artifacts = add_artifacts.post
+                        add_artifacts(ref_ids,
+                                       update_solr=self.options.solr,
+                                       update_refs=self.options.refs)
                     except CompoundError, err:
                         base.log.exception('Error indexing artifacts:\n%r', err)
                         base.log.error('%s', err.format_error())
                     M.main_orm_session.flush()
                     M.main_orm_session.clear()
-        base.log.info('Reindex done')
+        base.log.info('Reindex %s', 'queued' if self.options.tasks else 'done')
 
 class EnsureIndexCommand(base.Command):
     min_args=1


[42/50] git commit: [#2835] use escape instead of Markup() on solr search responses

Posted by jo...@apache.org.
[#2835] use escape instead of Markup() on solr search responses


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

Branch: refs/heads/cj/5655
Commit: 62912a96ea805872dc60c67bb2e19f4f811ecaf0
Parents: bb9a502
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Wed Apr 17 19:57:29 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:43 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/62912a96/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 309845f..203e37a 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -164,11 +164,11 @@ def search_app(q='', fq=None, app=True, **kw):
                 title = h.get_first(m, 'title')
                 text = h.get_first(m, 'text')
                 if title:
-                    title = (jinja2.Markup(title)
+                    title = (jinja2.escape(title)
                                    .replace('#ALLURA-HIGHLIGHT-START#', jinja2.Markup('<strong>'))
                                    .replace('#ALLURA-HIGHLIGHT-END#', jinja2.Markup('</strong>')))
                 if text:
-                    text = (jinja2.Markup(text)
+                    text = (jinja2.escape(text)
                                   .replace('#ALLURA-HIGHLIGHT-START#', jinja2.Markup('<strong>'))
                                   .replace('#ALLURA-HIGHLIGHT-END#', jinja2.Markup('</strong>')))
                 doc['title_match'] = title


[44/50] git commit: [#4370] ticket:322 Test for REST API permissions

Posted by jo...@apache.org.
[#4370] ticket:322 Test for REST API permissions


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

Branch: refs/heads/cj/5655
Commit: 3207e959ac1e12e98e6b55f3b6475d0e103b3a9e
Parents: 54cca78
Author: Igor Bondarenko <je...@gmail.com>
Authored: Wed Apr 24 09:43:57 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 20:02:25 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_rest.py |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3207e959/Allura/allura/tests/functional/test_rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_rest.py b/Allura/allura/tests/functional/test_rest.py
index aaba26b..68f769f 100644
--- a/Allura/allura/tests/functional/test_rest.py
+++ b/Allura/allura/tests/functional/test_rest.py
@@ -19,9 +19,12 @@
 
 from datetime import datetime, timedelta
 
+from nose.tools import assert_equal
+
 from allura.tests import decorators as td
 from alluratest.controller import TestRestApiBase
 from allura.lib import helpers as h
+from allura import model as M
 
 class TestRestHome(TestRestApiBase):
 
@@ -77,3 +80,19 @@ class TestRestHome(TestRestApiBase):
         assert r.status_int == 200
         assert r.json['title'].encode('utf-8') == 'tést', r.json
 
+    @td.with_wiki
+    def test_deny_access(self):
+        wiki = M.Project.query.get(shortname='test').app_instance('wiki')
+        anon_read_perm = M.ACE.allow(M.ProjectRole.by_name('*anonymous')._id, 'read')
+        auth_read_perm = M.ACE.allow(M.ProjectRole.by_name('*authenticated')._id, 'read')
+        acl = wiki.config.acl
+        if anon_read_perm in acl:
+            acl.remove(anon_read_perm)
+        if auth_read_perm in acl:
+            acl.remove(auth_read_perm)
+        self.app.get('/rest/p/test/wiki/Home/',
+                     extra_environ={'username': '*anonymous'},
+                     status=401)
+        self.app.get('/rest/p/test/wiki/Home/',
+                     extra_environ={'username': 'test-user-0'},
+                     status=401)


[34/50] git commit: [#2835] ticket:308 Safer matches highlighting

Posted by jo...@apache.org.
[#2835] ticket:308 Safer matches highlighting


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

Branch: refs/heads/cj/5655
Commit: 6c49711f033fb1d94ba594f865ec5b3500941c0b
Parents: 27016ef
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Apr 1 14:21:16 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:42 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/search.py                        |   22 +++++++++++----
 .../allura/templates/widgets/search_results.html   |    4 +-
 2 files changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6c49711f/Allura/allura/lib/search.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/search.py b/Allura/allura/lib/search.py
index 6c96d4a..97a67da 100644
--- a/Allura/allura/lib/search.py
+++ b/Allura/allura/lib/search.py
@@ -45,6 +45,8 @@ def solarize(obj):
     text = doc['text']
     text = g.markdown.convert(text)
     doc['text'] = jinja2.Markup.escape(text).striptags()
+    # striptags decodes html entities, so we should escape them again
+    doc['text'] = jinja2.Markup.escape(doc['text'])
     return doc
 
 class SearchError(SolrError):
@@ -132,8 +134,8 @@ def search_app(q='', fq=None, app=True, **kw):
             'pf': 'title^2 text',
             'fq': fq,
             'hl': 'true',
-            'hl.simple.pre': '<strong>',
-            'hl.simple.post': '</strong>',
+            'hl.simple.pre': '#ALLURA-HIGHLIGHT-START#',
+            'hl.simple.post': '#ALLURA-HIGHLIGHT-END#',
             'sort': sort,
         }
         if not history:
@@ -158,10 +160,18 @@ def search_app(q='', fq=None, app=True, **kw):
                 return doc
             def add_matches(doc):
                 m = matches.get(doc['id'], {})
-                doc['title_match'] = h.get_first(m, 'title')
-                doc['text_match'] = h.get_first(m, 'text')
-                if not doc['text_match']:
-                    doc['text_match'] = h.get_first(doc, 'text')
+                title = h.get_first(m, 'title')
+                text = h.get_first(m, 'text')
+                if title:
+                    title = (jinja2.escape(title)
+                                   .replace('#ALLURA-HIGHLIGHT-START#', jinja2.Markup('<strong>'))
+                                   .replace('#ALLURA-HIGHLIGHT-END#', jinja2.Markup('</strong>')))
+                if text:
+                    text = (jinja2.escape(text)
+                                  .replace('#ALLURA-HIGHLIGHT-START#', jinja2.Markup('<strong>'))
+                                  .replace('#ALLURA-HIGHLIGHT-END#', jinja2.Markup('</strong>')))
+                doc['title_match'] = title
+                doc['text_match'] = text or h.get_first(doc, 'text')
                 return doc
             results = imap(historize_urls, results)
             results = imap(add_matches, results)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/6c49711f/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 2eaaf61..464dab4 100644
--- a/Allura/allura/templates/widgets/search_results.html
+++ b/Allura/allura/templates/widgets/search_results.html
@@ -65,7 +65,7 @@
     <p>
     <a href="{{doc['url_paginated'] or doc['url_s']}}">
       {% if doc.title_match %}
-        {{ doc.title_match|safe }}
+        {{ doc.title_match }}
       {% else %}
         {{ h.get_first(doc, 'title') or h.get_first(doc, 'title_s') -}}  {#-  title_s is legacy -#}
       {% endif %}
@@ -73,7 +73,7 @@
     {% if doc['type_s'] %}<span class="gray"><sup>{{ '(%s)' % doc['type_s'] }}</sup></span>{% endif %}
     <br>
     {% if doc.text_match %}
-      <span class="text-match">{{ doc.text_match|safe }}</span><br>
+      <span class="text-match">{{ doc.text_match }}</span><br>
     {% endif %}
     <span class="gray">Last updated: {{ h.ago_string(doc['mod_date_dt']) }}</span>
     </p>


[36/50] git commit: [#2835] ticket:308 Fix tests

Posted by jo...@apache.org.
[#2835] ticket:308 Fix tests


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

Branch: refs/heads/cj/5655
Commit: ac9e35d25085985b9cfc7c41b31f43237fe467d5
Parents: 6c49711
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Apr 1 14:52:57 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:42 2013 +0000

----------------------------------------------------------------------
 ForgeWiki/forgewiki/tests/functional/test_root.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ac9e35d2/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index ccc3098..2b6a190 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -104,8 +104,8 @@ class TestRootController(TestController):
                 'is_history_b:False',
             ],
             'hl': 'true',
-            'hl.simple.pre': '<strong>',
-            'hl.simple.post': '</strong>',
+            'hl.simple.pre': '#ALLURA-HIGHLIGHT-START#',
+            'hl.simple.post': '#ALLURA-HIGHLIGHT-END#',
             'sort': 'score asc',
         }
         search.assert_called_with('test', **solr_query)
@@ -131,7 +131,7 @@ class TestRootController(TestController):
         assert btn is not None, "Can't find a help button"
         div = r.html.find('div', attrs={'id': 'lightbox_search_help_modal'})
         assert div is not None, "Can't find help text"
-        assert_in('Searching wiki', div.text)
+        assert_in('Searching the wiki', div.text)
 
     def test_page_index(self):
         response = self.app.get('/wiki/tést/')


[37/50] git commit: [#2835] ticket:304 Change url_paginated to respect attached artifact

Posted by jo...@apache.org.
[#2835] ticket:304 Change url_paginated to respect attached artifact


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

Branch: refs/heads/cj/5655
Commit: ba9ea5dfcd75143213eb4e3a249d4bd2ba33c2da
Parents: eb43a31
Author: Igor Bondarenko <je...@gmail.com>
Authored: Thu Apr 4 09:45:55 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:43 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/discuss.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/ba9ea5df/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index e3cf591..fe79820 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -32,7 +32,7 @@ from allura.lib import helpers as h
 from allura.lib import security
 from allura.lib.security import require_access, has_access
 from allura.model.notification import Notification, Mailbox
-from .artifact import Artifact, VersionedArtifact, Snapshot, Message, Feed
+from .artifact import Artifact, ArtifactReference, VersionedArtifact, Snapshot, Message, Feed
 from .attachments import BaseAttachment
 from .auth import User
 from .timeline import ActivityObject
@@ -556,7 +556,11 @@ class Post(Message, VersionedArtifact, ActivityObject):
             page = find_i(posts) / limit
 
         slug = h.urlquote(self.slug)
-        url = self.thread.url()
+        aref = ArtifactReference.query.get(_id=self.thread.ref_id)
+        if aref and aref.artifact:
+            url = aref.artifact.url()
+        else:
+            url = self.thread.url()
         if page == 0:
             return '%s?limit=%s#%s' % (url, limit, slug)
         return '%s?limit=%s&page=%s#%s' % (url, limit, page, slug)


[14/50] git commit: [#6093] Moved WebError requirement so it's not duplicated for SF build

Posted by jo...@apache.org.
[#6093] Moved WebError requirement so it's not duplicated for SF build

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


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

Branch: refs/heads/cj/5655
Commit: 022d84de5559b159396e6e6ec772a3855c1b7154
Parents: 02ac467
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Apr 24 14:01:59 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Apr 24 14:01:59 2013 +0000

----------------------------------------------------------------------
 requirements-common.txt |    1 -
 requirements.txt        |    1 +
 2 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/022d84de/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index 4dcf695..75f4541 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -59,7 +59,6 @@ Pylons==1.0
 simplejson==2.2.1
 Tempita==0.5.1
 Routes==1.12.3
-WebError==0.10.3
 WebFlash==0.1a9
 WebHelpers==1.3
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/022d84de/requirements.txt
----------------------------------------------------------------------
diff --git a/requirements.txt b/requirements.txt
index c01f4d8..5fcf891 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,3 +4,4 @@
 -r requirements-common.txt
 
 GitPython==0.3.2.RC1
+WebError==0.10.3


[26/50] git commit: [#2835] ticket:292 Better search for discussion

Posted by jo...@apache.org.
[#2835] ticket:292 Better search for discussion


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

Branch: refs/heads/cj/5655
Commit: 91e308c6375731f5d61dc64fb462fa2156870a8a
Parents: b636c9d
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Mar 25 12:54:06 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Wed Apr 24 16:34:41 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/artifact.py                    |    4 +-
 Allura/allura/model/discuss.py                     |    4 +-
 .../forgediscussion/controllers/root.py            |   62 ++++++---------
 .../templates/discussionforums/search.html         |    4 +-
 4 files changed, 33 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/91e308c6/Allura/allura/model/artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/artifact.py b/Allura/allura/model/artifact.py
index 49109c7..681ac26 100644
--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -332,8 +332,8 @@ class Snapshot(Artifact):
         if original:
             original_index = original.index()
             result.update(original_index)
-            result['title'] = 'Version %d of %s' % (
-                    self.version, h.get_first(original_index, 'title'))
+            result['title'] = '%s (version %d)' % (
+                    h.get_first(original_index, 'title'), self.version)
         result.update(
             id=self.index_id(),
             version_i=self.version,

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/91e308c6/Allura/allura/model/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/discuss.py b/Allura/allura/model/discuss.py
index 76a9aa1..e3cf591 100644
--- a/Allura/allura/model/discuss.py
+++ b/Allura/allura/model/discuss.py
@@ -107,7 +107,7 @@ class Discussion(Artifact, ActivityObject):
     def index(self):
         result = Artifact.index(self)
         result.update(
-            title='Discussion: %s' % self.name,
+            title=self.name,
             name_s=self.name,
             text=self.description)
         return result
@@ -356,7 +356,7 @@ class Thread(Artifact, ActivityObject):
     def index(self):
         result = Artifact.index(self)
         result.update(
-           title='Thread: %s' % (self.subject or '(no subject)'),
+           title=self.subject or '(no subject)',
            name_s=self.subject,
            views_i=self.num_views,
            text=self.subject)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/91e308c6/ForgeDiscussion/forgediscussion/controllers/root.py
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index cce0090..f5f4ae5 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -15,11 +15,10 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
-import re
 import json
 import logging
-import pymongo
-from urllib import urlencode, unquote
+from urllib import unquote
+from itertools import imap
 
 from tg import expose, validate, redirect, flash, response
 from tg.decorators import with_trailing_slash
@@ -31,7 +30,7 @@ from webob import exc
 
 from allura.lib.security import require_access, has_access, require_authenticated
 from allura.model import Feed
-from allura.lib.search import search, SearchError
+from allura.lib.search import search_app
 from allura.lib import helpers as h
 from allura.lib.utils import AntiSpam
 from allura.lib.decorators import require_post
@@ -130,40 +129,31 @@ class RootController(BaseController, DispatchIndex):
                    project=validators.StringBool(if_empty=False),
                    limit=validators.Int(if_empty=None),
                    page=validators.Int(if_empty=0)))
-    def search(self, q=None, history=False, project=False, limit=None, page=0, **kw):
-        'local tool search'
-        if project:
-            redirect(c.project.url() + 'search?' + urlencode(dict(q=q, history=history)))
-        results = []
-        search_error = None
-        count=0
-        limit, page, start = g.handle_paging(limit, page, default=25)
-        if not q:
-            q = ''
-        else:
-            try:
-                results = search(
-                    q, rows=limit, start=start,
-                    fq=[
-                        'is_history_b:%s' % history,
-                        'project_id_s:%s' % c.project._id,
-                        'mount_point_s:%s'% c.app.config.options.mount_point,
-                        '-deleted_b:true'],
-                    short_timeout=True,
-                    ignore_errors=False)
-            except SearchError as e:
-                search_error = e
-            if results: count=results.hits
+    def search(self, q=None, history=None, project=None, limit=None, page=0, **kw):
         c.search_results = self.W.search_results
+        search_params = kw
+        search_params.update({
+            'q': q or '',
+            'history': history,
+            'project': project,
+            'limit': limit,
+            'page': page,
+            '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:
-            for doc in results:
-                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 dict(q=q, history=history, results=results or [],
-                    count=count, limit=limit, page=page, search_error=search_error)
+            results = imap(prettify_urls, results)
+        d['results'] = results
+        d['search_comments_disable'] = True
+        return d
 
     @expose('jinja:allura:templates/markdown_syntax.html')
     def markdown_syntax(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/91e308c6/ForgeDiscussion/forgediscussion/templates/discussionforums/search.html
----------------------------------------------------------------------
diff --git a/ForgeDiscussion/forgediscussion/templates/discussionforums/search.html b/ForgeDiscussion/forgediscussion/templates/discussionforums/search.html
index 4c549cd..0fdb640 100644
--- a/ForgeDiscussion/forgediscussion/templates/discussionforums/search.html
+++ b/ForgeDiscussion/forgediscussion/templates/discussionforums/search.html
@@ -24,5 +24,7 @@
 
 {% block content %}
   {{c.search_results.display(results=results,q=q,history=history,
-                             count=count,limit=limit,page=page,search_error=search_error)}}
+     count=count,limit=limit,page=page,search_error=search_error,
+     sort_score_url=sort_score_url, sort_date_url=sort_date_url, sort_field=sort_field,
+     search_comments_disable=search_comments_disable)}}
 {% endblock %}