incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/6] git commit: [#5314] ticket:219 check red links
Date Wed, 28 Nov 2012 01:27:57 GMT
[#5314] ticket:219 check red links


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

Branch: refs/heads/cj/4691
Commit: cde64430bb54e21884cb6347d7013a15551cca89
Parents: 50cc989
Author: Yuriy Arhipov <yuriyarhipovua@yandex.ru>
Authored: Mon Nov 26 15:27:15 2012 +0400
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Nov 27 21:03:34 2012 +0000

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


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cde64430/Allura/allura/lib/markdown_extensions.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index 6ef4b68..b34aa6a 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -104,9 +104,18 @@ class ForgeLinkPattern(markdown.inlinepatterns.LinkPattern):
         if shortlink:
             href = shortlink.url
             self.ext.forge_link_tree_processor.alinks.append(shortlink)
-        elif self.ext._use_wiki and ':' not in link:
+        elif self.ext._use_wiki and is_link_with_brackets:
             href = h.urlquote(link)
             classes += ' notfound'
+        attach_link = link.split('/attachment/')
+        if len(attach_link) == 2 and self.ext._use_wiki:
+            shortlink = M.Shortlink.lookup(attach_link[0])
+            if shortlink:
+                attach_status = ' notfound'
+                for attach in shortlink.ref.artifact.attachments:
+                    if attach.filename == attach_link[1]:
+                        attach_status = ''
+                classes += attach_status
         return href, classes
 
 

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/cde64430/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 3375b6d..cb48574 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -467,11 +467,15 @@ class TestRootController(TestController):
 * Here is a link to [Some page which does not exist]
 * Here is a link to [space page]
 * Here is a link to [space%20page]
+* Here is a link to [another attach](TEST/attachment/attach.txt)
+* Here is a link to [attach](TEST/attachment/test_root.py)
 ''',
             'labels':'',
             'labels_old':'',
             'viewable_by-0.id':'all'}
         self.app.post('/wiki/TEST/update', params=params)
+        content = file(__file__).read()
+        self.app.post('/wiki/TEST/attach', upload_files=[('file_info', 'test_root.py', content)])
         r = self.app.get('/wiki/TEST/')
         found_links = 0
         for link in r.html.findAll('a'):
@@ -479,7 +483,7 @@ class TestRootController(TestController):
                 assert 'notfound' not in link.get('class', '')
                 found_links +=1
             if link.contents == ['another page']:
-                assert 'notfound' in link.get('class', '')
+                assert 'notfound' not in link.get('class', '')
                 found_links +=1
             if link.contents == ['space page space']:
                 assert 'notfound' not in link.get('class', '')
@@ -499,7 +503,13 @@ class TestRootController(TestController):
             if link.contents == ['[space%20page]']:
                 assert 'notfound' not in link.get('class', '')
                 found_links +=1
-        assert found_links == 8, 'Wrong number of links found'
+            if link.contents == ['another attach']:
+                assert 'notfound' in link.get('class', '')
+                found_links +=1
+            if link.contents == ['attach']:
+                assert 'notfound' not in link.get('class', '')
+                found_links +=1
+        assert found_links == 10, 'Wrong number of links found'
 
     def test_home_rename(self):
         assert 'The resource was found at http://localhost/p/test/wiki/Home/;' in self.app.get('/p/test/wiki/')


Mime
View raw message