incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [42/50] [abbrv] git commit: [#5644] ticket:332 Better repo feed
Date Thu, 16 May 2013 22:30:33 GMT
[#5644] ticket:332 Better repo feed


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

Branch: refs/heads/db/6208
Commit: 63b4e59163f226be9f2971882ea97c76e675050b
Parents: 78e97ac
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Fri May 10 11:16:53 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed May 15 19:23:47 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py            |    9 ++++-
 Allura/allura/model/repo_refresh.py                |   16 +++++++--
 .../forgegit/tests/functional/test_controllers.py  |   26 +++++++++++++-
 3 files changed, 45 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/63b4e591/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index e444db7..6c8cc7d 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -49,7 +49,7 @@ from allura.lib.widgets.subscriptions import SubscribeForm
 from allura import model as M
 from allura.lib.widgets import form_fields as ffw
 from allura.controllers.base import DispatchIndex
-from allura.controllers.feed import FeedController
+from allura.controllers.feed import FeedController, FeedArgs
 from allura.lib.diff import HtmlSideBySideDiff
 from paste.deploy.converters import asbool
 from allura.app import SitemapEntry
@@ -66,6 +66,13 @@ class RepoRootController(BaseController, FeedController):
     _discuss = AppDiscussionController()
     commit_browser_widget=SCMCommitBrowserWidget()
 
+    def get_feed(self, project, app, user):
+        query = dict(project_id=project._id, app_config_id=app.config._id)
+        pname, repo =  (project.shortname, app.config.options.mount_label)
+        title = '%s %s changes' % (pname, repo)
+        description = 'Recent changes to %s repository in %s project' % (repo, pname)
+        return FeedArgs(query, title, app.url, description=description)
+
     def _check_security(self):
         security.require(security.has_access(c.app, 'read'))
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/63b4e591/Allura/allura/model/repo_refresh.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repo_refresh.py b/Allura/allura/model/repo_refresh.py
index f0d9c75..58a5411 100644
--- a/Allura/allura/model/repo_refresh.py
+++ b/Allura/allura/model/repo_refresh.py
@@ -23,7 +23,7 @@ from collections import OrderedDict
 import bson
 
 import tg
-
+import jinja2
 from pylons import tmpl_context as c, app_globals as g
 
 from ming.base import Object
@@ -400,13 +400,15 @@ def send_notifications(repo, commit_ids):
         for oid in chunk:
             ci = index[oid]
             href = repo.url_for_commit(oid)
+            title = _title(ci.message)
             summary = _summarize(ci.message)
             Feed.post(
-                repo, title='New commit',
+                repo, title=title,
                 description='%s<br><a href="%s">View Changes</a>' % (
                     summary, href),
                 author_link=ci.author_url,
-                author_name=ci.authored.name)
+                author_name=ci.authored.name,
+                link=href)
             branches = repo.symbolics_for_commit(ci)[0]
             commit_msgs.append('%s: %s by %s %s%s' % (
                     ",".join(b for b in branches),
@@ -433,6 +435,14 @@ def send_notifications(repo, commit_ids):
             subject=subject,
             text=text)
 
+
+def _title(message):
+    if not message:
+        return ''
+    line = message.splitlines()[0]
+    return jinja2.filters.do_truncate(line, 200, True)
+
+
 def _summarize(message):
     if not message: return ''
     summary = []

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/63b4e591/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 e1efee9..11cf6aa 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -166,8 +166,30 @@ class TestRootController(_TestCase):
         assert 'Rick' in resp, resp.showbrowser()
 
     def test_feed(self):
-        for ext in ['', '.rss', '.atom']:
-            assert 'Add README' in self.app.get('/feed%s' % ext)
+        for ext in ['', '.rss']:
+            r = self.app.get('/src-git/feed%s' % ext)
+            channel = r.xml.find('channel')
+            title = channel.find('title').text
+            assert_equal(title, 'test Git changes')
+            description = channel.find('description').text
+            assert_equal(description, 'Recent changes to Git repository in test project')
+            link = channel.find('link').text
+            assert_equal(link, 'http://localhost:80/p/test/src-git/')
+            commit = channel.find('item')
+            assert_equal(commit.find('title').text, 'Initial commit')
+            link = 'http://localhost:80/p/test/src-git/ci/9a7df788cf800241e3bb5a849c8870f2f8259d98/'
+            assert_equal(commit.find('link').text, link)
+        # .atom has slightly different structure
+        prefix = '{http://www.w3.org/2005/Atom}'
+        r = self.app.get('/src-git/feed.atom')
+        title = r.xml.find(prefix + 'title').text
+        assert_equal(title, 'test Git changes')
+        link = r.xml.find(prefix + 'link').attrib['href']
+        assert_equal(link, 'http://localhost:80/p/test/src-git/')
+        commit = r.xml.find(prefix + 'entry')
+        assert_equal(commit.find(prefix + 'title').text, 'Initial commit')
+        link = 'http://localhost:80/p/test/src-git/ci/9a7df788cf800241e3bb5a849c8870f2f8259d98/'
+        assert_equal(commit.find(prefix + 'link').attrib['href'], link)
 
     def test_tree(self):
         ci = self._get_ci()


Mime
View raw message