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/03/12 00:07:10 UTC
[2/8] git commit: [#2840] Tweak UI for snapshot download
[#2840] Tweak UI for snapshot download
Signed-off-by: Cory Johns <jo...@geek.net>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/8b9054a5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/8b9054a5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/8b9054a5
Branch: refs/heads/master
Commit: 8b9054a5556d9b6e8f007e32f909b64525f81978
Parents: 3d10990
Author: Cory Johns <jo...@geek.net>
Authored: Mon Mar 11 20:20:19 2013 +0000
Committer: Cory Johns <jo...@geek.net>
Committed: Mon Mar 11 22:29:45 2013 +0000
----------------------------------------------------------------------
Allura/allura/controllers/repository.py | 7 +--
Allura/allura/templates/repo/tarball.html | 43 +++++++++------
Allura/allura/templates/repo/tree.html | 4 +-
.../forgegit/tests/functional/test_controllers.py | 2 +-
.../forgesvn/tests/functional/test_controllers.py | 2 +-
5 files changed, 34 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8b9054a5/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 07b92ae..4b17ea3 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -429,11 +429,10 @@ class CommitBrowser(BaseController):
def tarball(self, **kw):
if not asbool(tg.config.get('scm.repos.tarball.enable', False)):
raise exc.HTTPNotFound()
- if (c.app.repo.get_tarball_status(self._revision) == 'ready'):
- redirect(c.app.repo.tarball_url(self._revision))
- elif (c.app.repo.get_tarball_status(self._revision) is None):
+ status = c.app.repo.get_tarball_status(self._revision)
+ if status is None:
allura.tasks.repo_tasks.tarball.post(revision=self._revision)
- return dict(commit=self._commit, revision=self._revision)
+ return dict(commit=self._commit, revision=self._revision, status=status)
@expose('json:')
def tarball_status(self):
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8b9054a5/Allura/allura/templates/repo/tarball.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tarball.html b/Allura/allura/templates/repo/tarball.html
index 6aff982..c312d8b 100644
--- a/Allura/allura/templates/repo/tarball.html
+++ b/Allura/allura/templates/repo/tarball.html
@@ -9,9 +9,14 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
{% block extra_js %}
{{ super() }}
-<script type="text/javascript">(function() {
- var tarball_status = document.getElementById('tarball_status');
- if (tarball_status) {
+<script type="text/javascript">$(function() {
+ {% if status == 'ready' %}
+ {% if 'no-redirect' not in request.params %}
+ $(document).ready(function() {
+ window.location.href = '{{c.app.repo.tarball_url(revision)}}';
+ });
+ {% endif %}
+ {% else %}
var opts = {
lines: 9, // The number of lines to draw
length: 4, // The length of each line
@@ -28,36 +33,40 @@ Commit <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(
top: 10, // Top position relative to parent in px
left: 10 // Left position relative to parent in px
};
- var spinner = new Spinner(opts).spin(tarball_status);
+ var spinner = new Spinner(opts).spin($('#snapshot_status')[0]);
+ // Check tarball status every 5 seconds
function check_status() {
$.get('{{commit.url()}}tarball_status', function(data) {
if (data.status === 'ready') {
window.clearInterval(status_checker);
- spinner.opts.speed = 0;
- spinner.opts.opacity = 1;
- spinner.spin(tarball_status);
- $('#tarball_status h2').html(' <a href="{{c.app.repo.tarball_url(revision)}}">Click here to download</a>');
- window.location.href = '{{c.app.repo.tarball_url(revision)}}';
+ spinner.stop();
+ $('#snapshot_status h2').toggle();
+ {% if 'no-redirect' not in request.params %}
+ window.location.href = '{{c.app.repo.tarball_url(revision)}}';
+ {% endif %}
}
});
}
- // Check tarball status every 5 seconds
var status_checker = window.setInterval(check_status, 5000);
- }
-}());
+ {% endif %}
+});
</script>
{% endblock %}
{% block content %}
-<div id='tarball_status'>
- <h2>Generating snapshot...</h2>
+<div id='snapshot_status'>
+ <h2 class="busy">Generating snapshot...</h2>
+ <h2 class="ready">Your download will begin shortly, or use this <a href="{{c.app.repo.tarball_url(revision)}}">direct link</a>.</h2>
</div>
{% endblock %}
{% block extra_css %}
<style type="text/css">
-#tarball_status h2 {
-padding-left: 33px;
-}
+ #snapshot_status h2 {
+ padding-left: 33px;
+ }
+ #snapshot_status .{{ 'busy' if status == 'ready' else 'ready' }} {
+ display: none;
+ }
</style>
{% endblock %}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8b9054a5/Allura/allura/templates/repo/tree.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tree.html b/Allura/allura/templates/repo/tree.html
index c71dc88..ded628c 100644
--- a/Allura/allura/templates/repo/tree.html
+++ b/Allura/allura/templates/repo/tree.html
@@ -13,7 +13,9 @@ Tree <a href="{{commit.url()}}">{{commit.shorthand_id()}}</a> {{commit_labels(co
{% block actions %}
{% if tarball_enable %}
-<a href="{{commit.url()}}tarball" rel="nofollow">Download tarball</a>
+<a href="{{commit.url()}}tarball" rel="nofollow">
+ <b data-icon="{{g.icons.folder.char}}" class="ico {{g.icons.folder.css}}" title="Snapshot"> </b> Download Snapshot
+</a>
{% endif %}
<a href="{{commit.url()}}log/?path={{ path }}">
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8b9054a5/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 71af94b..7dcb88c 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -269,7 +269,7 @@ class TestRootController(_TestCase):
def test_tarball(self):
ci = self._get_ci()
r = self.app.get(ci + 'tree/')
- assert 'Download tarball' in r
+ assert 'Download Snapshot' in r
r = self.app.get(ci + 'tarball')
assert 'Generating snapshot...' in r
M.MonQTask.run_ready()
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/8b9054a5/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 302c890..ce19a79 100644
--- a/ForgeSVN/forgesvn/tests/functional/test_controllers.py
+++ b/ForgeSVN/forgesvn/tests/functional/test_controllers.py
@@ -136,7 +136,7 @@ class TestRootController(SVNTestController):
def test_tarball(self):
r = self.app.get('/src/3/tree/')
- assert 'Download tarball' in r
+ assert 'Download Snapshot' in r
r = self.app.get('/src/3/tarball')
assert 'Generating snapshot...' in r
M.MonQTask.run_ready()