You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/08/23 00:00:14 UTC

git commit: [#6595] Make Download Snapshot require POST

Updated Branches:
  refs/heads/tv/6595 [created] a8040c5bc


[#6595] Make Download Snapshot require POST

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/a8040c5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/a8040c5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/a8040c5b

Branch: refs/heads/tv/6595
Commit: a8040c5bc875977eaed4bf4e34ba4c0db4474378
Parents: d1f150e
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Thu Aug 22 20:38:58 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Thu Aug 22 20:38:58 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py         |  1 +
 Allura/allura/templates/repo/tree.html          | 32 ++++++++++++++++++--
 .../tests/functional/test_controllers.py        | 17 +++++------
 .../tests/functional/test_controllers.py        | 21 ++++++-------
 4 files changed, 47 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a8040c5b/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 36b4bdc..b1b743c 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -458,6 +458,7 @@ class CommitBrowser(BaseController):
             result.update(self._commit.context())
         return result
 
+    @require_post()
     @expose('jinja:allura:templates/repo/tarball.html')
     def tarball(self, **kw):
         path = kw.pop('path', None)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a8040c5b/Allura/allura/templates/repo/tree.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tree.html b/Allura/allura/templates/repo/tree.html
index b2dbcfe..851ad38 100644
--- a/Allura/allura/templates/repo/tree.html
+++ b/Allura/allura/templates/repo/tree.html
@@ -29,11 +29,37 @@ Tree <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(co
 {{lib.path_links(path.split('/')[1:])}}
 {% endblock %}
 
+{% block extra_css %}
+<style>
+form.tarball {
+  display: inline;
+  margin: 0;
+  padding: 0;
+}
+form.tarball button {
+    background: none;
+    border: 0;
+    box-shadow: none;
+    text-shadow: none;
+    color:  #fff;
+    font-family: "Ubuntu", sans-serif;
+    font-weight: normal;;
+    padding: 0;
+    font-size: 12px;
+    line-height: 36px;
+}
+form.tarball button:hover {
+  border: 0 !important;
+}
+</style>
+{% endblock %}
+
 {% block actions %}
 {% if tarball_url %}
-<a href="{{ tarball_url + ('?path=' + path if path else '') }}" rel="nofollow">
-    <b data-icon="{{g.icons.folder.char}}" class="ico {{g.icons.folder.css}}" title="Snapshot"> </b> Download Snapshot
-</a>
+<form class="tarball" action="{{ tarball_url }}" method="post">
+  <input type="hidden" name="path" value="{{ path or '' }}" />
+  <button><b data-icon="{{g.icons.folder.char}}" class="ico {{g.icons.folder.css}}" title="Snapshot"></b> Download Snapshot</button>
+</form>
 {% endif %}
 
 <a href="{{commit.url()}}log/?path={{ path }}">

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a8040c5b/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 597c5bb..4b9476b 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -294,8 +294,7 @@ class TestRootController(_TestCase):
         assert not M.Mailbox.subscribed(user_id=user._id)
         r = self.app.get(ci + 'tree/',
                 extra_environ={'username': str(user.username)})
-        header = r.html.find('h2', {'class': 'dark title'})
-        link = header.find('a', {'class': 'artifact_subscribe'})
+        link = r.html.find('a', 'artifact_subscribe')
         assert link is not None, header
 
         # subscribe
@@ -305,8 +304,7 @@ class TestRootController(_TestCase):
         assert M.Mailbox.subscribed(user_id=user._id)
         r = self.app.get(ci + 'tree/',
                 extra_environ={'username': str(user.username)})
-        header = r.html.find('h2', {'class': 'dark title'})
-        link = header.find('a', {'class': 'artifact_unsubscribe active'})
+        link = r.html.find('a', 'artifact_unsubscribe active')
         assert link is not None, header
 
         # unsubscribe
@@ -316,8 +314,7 @@ class TestRootController(_TestCase):
         assert not M.Mailbox.subscribed(user_id=user._id)
         r = self.app.get(ci + 'tree/',
                 extra_environ={'username': str(user.username)})
-        header = r.html.find('h2', {'class': 'dark title'})
-        link = header.find('a', {'class': 'artifact_subscribe'})
+        link = r.html.find('a', 'artifact_subscribe')
         assert link is not None, header
 
     def test_timezone(self):
@@ -345,7 +342,7 @@ class TestRootController(_TestCase):
         r = self.app.get(ci + 'tree/')
         assert '/p/test/src-git/ci/master/tarball' in r
         assert 'Download Snapshot' in r
-        r = self.app.get('/p/test/src-git/ci/master/tarball')
+        r = self.app.post('/p/test/src-git/ci/master/tarball')
         assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
@@ -358,9 +355,9 @@ class TestRootController(_TestCase):
         '''Go to repo subdir and check 'Download Snapshot' link'''
         self.setup_testgit_index_repo()
         r = self.app.get('/p/test/testgit-index/ci/master/tree/index/')
-        links = r.html.findAll('a')
-        download_link = [a for a in links if a.text == 'Download Snapshot'][0]
-        assert_equal(download_link.get('href'), '/p/test/testgit-index/ci/master/tarball?path=/index')
+        form = r.html.find('form', 'tarball')
+        assert_equal(form.get('action'), '/p/test/testgit-index/ci/master/tarball')
+        assert_equal(form.input.get('value'), '/index')
 
     def test_default_branch(self):
         assert_equal(c.app.default_branch_name, 'master')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/a8040c5b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/tests/functional/test_controllers.py b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
index 1898435..78e7705 100644
--- a/ForgeSVN/forgesvn/tests/functional/test_controllers.py
+++ b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
@@ -193,7 +193,7 @@ class TestRootController(SVNTestController):
     def test_tarball(self):
         r = self.app.get('/src/3/tree/')
         assert 'Download Snapshot' in r
-        r = self.app.get('/src/3/tarball')
+        r = self.app.post('/src/3/tarball')
         assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         ThreadLocalORMSession.flush_all()
@@ -205,20 +205,19 @@ class TestRootController(SVNTestController):
         h.set_context('test', 'svn-tags', neighborhood='Projects')
         shutil.rmtree(c.app.repo.tarball_path, ignore_errors=True)
         r = self.app.get('/p/test/svn-tags/19/tree/')
-        link = r.html.find('h2', attrs={'class': 'dark title'})
-        link = link.find('small').findAll('a')[0]
-        assert_equal(link.text, 'Download Snapshot')
-        assert_equal(link.get('href'), '/p/test/svn-tags/19/tarball')
+        form = r.html.find('form', 'tarball')
+        assert_equal(form.button.text, 'Download Snapshot')
+        assert_equal(form.get('action'), '/p/test/svn-tags/19/tarball')
 
         r = self.app.get('/p/test/svn-tags/19/tree/tags/tag-1.0/')
-        link = r.html.find('h2', attrs={'class': 'dark title'})
-        link = link.find('small').findAll('a')[0]
-        assert_equal(link.text, 'Download Snapshot')
-        assert_equal(link.get('href'), '/p/test/svn-tags/19/tarball?path=/tags/tag-1.0')
+        form = r.html.find('form', 'tarball')
+        assert_equal(form.button.text, 'Download Snapshot')
+        assert_equal(form.get('action'), '/p/test/svn-tags/19/tarball')
+        assert_equal(form.find('input', attrs=dict(name='path')).get('value'), '/tags/tag-1.0')
 
         r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/tags/tag-1.0')
         assert_equal(r.json['status'], None)
-        r = self.app.get(link.get('href'))
+        r = self.app.post('/p/test/svn-tags/19/tarball', dict(path='/tags/tag-1.0'))
         assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/tags/tag-1.0')
@@ -226,7 +225,7 @@ class TestRootController(SVNTestController):
 
         r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk')
         assert_equal(r.json['status'], None)
-        r = self.app.get('/p/test/svn-tags/19/tarball?path=/trunk/')
+        r = self.app.post('/p/test/svn-tags/19/tarball', dict(path='/trunk/'))
         assert 'Generating snapshot...' in r
         M.MonQTask.run_ready()
         r = self.app.get('/p/test/svn-tags/19/tarball_status?path=/trunk')