You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/12/23 15:33:59 UTC
[1/5] allura git commit: [#7998] ticket:878 fix request for multiple
upload
Repository: allura
Updated Branches:
refs/heads/ib/7998 [created] 06b196c67
[#7998] ticket:878 fix request for multiple upload
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/06b196c6
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/06b196c6
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/06b196c6
Branch: refs/heads/ib/7998
Commit: 06b196c679e103476ca3a901bc0a6ebdff581dc0
Parents: 5d4cde0
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 23 14:25:33 2015 +0200
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Dec 23 14:42:27 2015 +0200
----------------------------------------------------------------------
ForgeWiki/forgewiki/templates/wiki/page_edit.html | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/06b196c6/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index e1e1940..be2caae 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -141,9 +141,12 @@
processData: false,
contentType: false,
success: function(data) {
- var attachment_name = $("#file_info")[0].files[0].name;
- var attachment_url = page_url + 'attachment/' + attachment_name;
- update_attachments(attachment_url, attachment_name, $("#file_info")[0].files[0].size);
+ var i;
+ for (i = 0; i < $("#file_info")[0].files.length; i++){
+ var attachment_name = $("#file_info")[0].files[i].name;
+ var attachment_url = page_url + 'attachment/' + attachment_name;
+ update_attachments(attachment_url, attachment_name, $("#file_info")[0].files[i].size);
+ }
}
});
};
[2/5] allura git commit: [#7998] ticket:878 modified js for send
attachments
Posted by je...@apache.org.
[#7998] ticket:878 modified js for send attachments
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b091d8f4
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b091d8f4
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b091d8f4
Branch: refs/heads/ib/7998
Commit: b091d8f493203c207eaa181288132e8f6fa3a635
Parents: f07054b
Author: Denis Kotov <de...@gmail.com>
Authored: Mon Dec 21 21:56:11 2015 +0200
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Dec 23 14:42:27 2015 +0200
----------------------------------------------------------------------
.../forgewiki/templates/wiki/page_edit.html | 20 +++++++-------------
ForgeWiki/forgewiki/wiki_main.py | 5 ++---
2 files changed, 9 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/b091d8f4/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index 93b4e59..9f3335a 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -115,20 +115,20 @@
'<a href="' + attachment_url + '">' +
'<img src="' + attachment_url + '/thumb" alt="Thumbnail"/>' +
'</a><br/>' + filename +
- '<form method="post" action="' + attachment_url + '">' +
+ '<form method="post" action="' + attachment_url + '" onsubmit="del_attach(this); return false;">' +
'<input type="hidden" name="delete" value="True"/>' +
'<input type="submit" value="Delete File"/>' +
'</form>' +
'</div>';
$(new_attach).prependTo($('.attachment_images'));
} else {
- var new_attach ='<form method="post" action="' + attachment_url + '">' +
+ var new_attach ='<div><form method="post" action="' + attachment_url + '" onsubmit="del_attach(this); return false;">' +
'<a href="' + attachment_url + '">' + filename + '</a> (' + filesize + ' bytes)' +
'<input type="hidden" name="delete" value="True"/>' +
'<span>' +
'<input type="submit" value="Delete File"/>' +
'</span>' +
- '</form>';
+ '</form></div>';
$(new_attach).prependTo($('.attachment_files'));
};
};
@@ -140,9 +140,6 @@
data: new FormData($('#attachment_form')[0]),
processData: false,
contentType: false,
- headers: {
- "X-CSRF-Token": $.cookie('_session_id')
- },
success: function(data) {
var attachment_name = $("#file_info").val();
var attachment_url = page_url + 'attachment/' + attachment_name;
@@ -151,17 +148,14 @@
});
};
- function del_attach(this) {
- var attr_url = $(this).attr('action');
+ function del_attach(elem) {
+ var attr_url = $(elem).attr('action');
$.ajax({
type: "POST",
url: attr_url,
- data: $(this).serialize(),
- headers: {
- "X-CSRF-Token": $.cookie('_session_id')
- },
+ data: $(elem).serialize() +"&_session_id=" + $.cookie('_session_id'),
success: function() {
- $(this).parent().remove();
+ $(elem).parent().remove();
}
});
};
http://git-wip-us.apache.org/repos/asf/allura/blob/b091d8f4/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 8bfa863..31de5b8 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -593,8 +593,6 @@ class PageController(BaseController, FeedController):
page = self.page
else:
page = self.fake_page()
- if request.headers.get('X-Requested-With', None) == 'XMLHttpRequest':
- return
c.confirmation = W.confirmation
c.markdown_editor = W.markdown_editor
c.attachment_add = W.attachment_add
@@ -756,7 +754,8 @@ class PageController(BaseController, FeedController):
raise exc.HTTPNotFound
require_access(self.page, 'edit')
self.page.add_multiple_attachments(file_info)
- redirect(request.referer)
+ if request.headers.get('X-Requested-With', None) != 'XMLHttpRequest':
+ redirect(request.referer)
@expose('json:')
@require_post()
[4/5] allura git commit: [#7998] ticket:878 changed attachments_list
style, fix geting filename
Posted by je...@apache.org.
[#7998] ticket:878 changed attachments_list style, fix geting filename
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/5d4cde0f
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/5d4cde0f
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/5d4cde0f
Branch: refs/heads/ib/7998
Commit: 5d4cde0fa25da04bdfb27d6940cb062b9bbbdb4c
Parents: b091d8f
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 23 13:49:11 2015 +0200
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Dec 23 14:42:27 2015 +0200
----------------------------------------------------------------------
Allura/allura/templates/widgets/attachment_list.html | 1 +
ForgeWiki/forgewiki/templates/wiki/page_edit.html | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/5d4cde0f/Allura/allura/templates/widgets/attachment_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/attachment_list.html b/Allura/allura/templates/widgets/attachment_list.html
index 45f6c24..c553dd7 100644
--- a/Allura/allura/templates/widgets/attachment_list.html
+++ b/Allura/allura/templates/widgets/attachment_list.html
@@ -53,6 +53,7 @@
{{lib.csrf_token()}}
</form>
</div>
+ <div style="clear:both"></div>
{% endfor %}
</div>
{% endif %}
http://git-wip-us.apache.org/repos/asf/allura/blob/5d4cde0f/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index 9f3335a..e1e1940 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -128,7 +128,7 @@
'<span>' +
'<input type="submit" value="Delete File"/>' +
'</span>' +
- '</form></div>';
+ '</form></div><div style="clear:both"></div>';
$(new_attach).prependTo($('.attachment_files'));
};
};
@@ -141,7 +141,7 @@
processData: false,
contentType: false,
success: function(data) {
- var attachment_name = $("#file_info").val();
+ var attachment_name = $("#file_info")[0].files[0].name;
var attachment_url = page_url + 'attachment/' + attachment_name;
update_attachments(attachment_url, attachment_name, $("#file_info")[0].files[0].size);
}
[5/5] allura git commit: [#7998] ticket:878 fix tests
Posted by je...@apache.org.
[#7998] ticket:878 fix tests
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/f07054b1
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/f07054b1
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/f07054b1
Branch: refs/heads/ib/7998
Commit: f07054b151a02c988d82937261d9201f8141b322
Parents: b4c574d
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 16 16:17:47 2015 +0200
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Dec 23 14:42:27 2015 +0200
----------------------------------------------------------------------
ForgeWiki/forgewiki/templates/wiki/page_edit.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/f07054b1/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index 69304a2..93b4e59 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -101,6 +101,7 @@
});
/*]]>*/
+ {% if page_exists %}
function update_attachments(attachment_url, filename, filesize){
if ($('.attachment_files').length + $('.attachment_files').length == 0){
var attach_divs = '<strong>Attachments:</strong>' +
@@ -131,7 +132,6 @@
$(new_attach).prependTo($('.attachment_files'));
};
};
-
function send_attach() {
var page_url = '{{page.url()}}';
$.ajax({
@@ -165,5 +165,6 @@
}
});
};
+ {% endif %}
</script>
{% endblock %}
[3/5] allura git commit: [#7998] ticket:878 added upload,
delete attachments in wiki page via ajax
Posted by je...@apache.org.
[#7998] ticket:878 added upload, delete attachments in wiki page via ajax
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/b4c574d4
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/b4c574d4
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/b4c574d4
Branch: refs/heads/ib/7998
Commit: b4c574d474948f6fcb0b0251568c7a7f31eddf13
Parents: a784bde
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 16 14:22:30 2015 +0200
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Wed Dec 23 14:42:27 2015 +0200
----------------------------------------------------------------------
.../templates/widgets/attachment_add.html | 2 +
.../templates/widgets/attachment_list.html | 9 +--
.../forgewiki/templates/wiki/page_edit.html | 69 +++++++++++++++++++-
ForgeWiki/forgewiki/wiki_main.py | 2 +
4 files changed, 76 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/b4c574d4/Allura/allura/templates/widgets/attachment_add.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/attachment_add.html b/Allura/allura/templates/widgets/attachment_add.html
index d1a2775..cc8dbf7 100644
--- a/Allura/allura/templates/widgets/attachment_add.html
+++ b/Allura/allura/templates/widgets/attachment_add.html
@@ -18,7 +18,9 @@
-#}
{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
<form method="post"
+ id="attachment_form"
action="{{action}}"
+ onsubmit="{{onsubmit}}"
enctype="multipart/form-data">
<a href="#" class="btn link attachment_form_add_button">Add attachments</a>
<div class="attachment_form_fields" style="display:none">
http://git-wip-us.apache.org/repos/asf/allura/blob/b4c574d4/Allura/allura/templates/widgets/attachment_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/attachment_list.html b/Allura/allura/templates/widgets/attachment_list.html
index d26a35e..45f6c24 100644
--- a/Allura/allura/templates/widgets/attachment_list.html
+++ b/Allura/allura/templates/widgets/attachment_list.html
@@ -17,7 +17,7 @@
under the License.
-#}
{% import 'allura:templates/jinja_master/lib.html' as lib with context %}
-<div>
+<div class="attachments">
{% if attachments %}
{% set attachments = attachments|list %}
<strong>Attachments:</strong>
@@ -29,7 +29,7 @@
</a><br/>
{{att.filename}}
{% if edit_mode %}
- <form method="post" action="{{att.url()}}">
+ <form method="post" action="{{att.url()}}" onsubmit="{{onsubmit}}">
<input type="hidden" name="delete" value="True"/>
<input type="submit" value="Delete File"/>
{{lib.csrf_token()}}
@@ -38,10 +38,10 @@
</div>
{% endfor %}
</div>
-
+ <div class="attachment_files">
{% for att in attachments if not att.is_image() %}
<div>
- <form method="post" action="{{att.url()}}">
+ <form method="post" action="{{att.url()}}" onsubmit="{{onsubmit}}">
<a href="{{att.url()}}">{{att.filename}}</a>
({{att.length}} bytes)
<input type="hidden" name="delete" value="True"/>
@@ -54,6 +54,7 @@
</form>
</div>
{% endfor %}
+ </div>
{% endif %}
<div style="clear:both"></div>
</div>
http://git-wip-us.apache.org/repos/asf/allura/blob/b4c574d4/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index 31ff5ae..69304a2 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -74,9 +74,9 @@
{{lib.csrf_token()}}
</form>
<div class="grid-19">
- {{c.attachment_list.display(attachments=page.attachments, edit_mode=page_exists and h.has_access(page, 'edit')())}}
+ {{c.attachment_list.display(onsubmit='del_attach(this); return false;', attachments=page.attachments, edit_mode=page_exists and h.has_access(page, 'edit')())}}
{% if page_exists and h.has_access(page, 'edit')() %}
- {{c.attachment_add.display(action=page.url() + 'attach', name='file_info')}}
+ {{c.attachment_add.display(onsubmit='send_attach(); return false;', name='file_info')}}
{% endif %}
</div>
{{c.confirmation.display(content='')}}
@@ -100,5 +100,70 @@
{% endif %}
});
/*]]>*/
+
+ function update_attachments(attachment_url, filename, filesize){
+ if ($('.attachment_files').length + $('.attachment_files').length == 0){
+ var attach_divs = '<strong>Attachments:</strong>' +
+ '<div class="attachment_images"></div>' +
+ '<div class="attachment_files"></div>';
+ $(attach_divs).prependTo($('.attachments'));
+ };
+ var ext = filename.split('.').pop().toLowerCase();
+ if($.inArray(ext, ['gif','png','jpg','jpeg']) != -1) {
+ new_attach = '<div class="attachment_thumb">' +
+ '<a href="' + attachment_url + '">' +
+ '<img src="' + attachment_url + '/thumb" alt="Thumbnail"/>' +
+ '</a><br/>' + filename +
+ '<form method="post" action="' + attachment_url + '">' +
+ '<input type="hidden" name="delete" value="True"/>' +
+ '<input type="submit" value="Delete File"/>' +
+ '</form>' +
+ '</div>';
+ $(new_attach).prependTo($('.attachment_images'));
+ } else {
+ var new_attach ='<form method="post" action="' + attachment_url + '">' +
+ '<a href="' + attachment_url + '">' + filename + '</a> (' + filesize + ' bytes)' +
+ '<input type="hidden" name="delete" value="True"/>' +
+ '<span>' +
+ '<input type="submit" value="Delete File"/>' +
+ '</span>' +
+ '</form>';
+ $(new_attach).prependTo($('.attachment_files'));
+ };
+ };
+
+ function send_attach() {
+ var page_url = '{{page.url()}}';
+ $.ajax({
+ type: "POST",
+ url: page_url + 'attach',
+ data: new FormData($('#attachment_form')[0]),
+ processData: false,
+ contentType: false,
+ headers: {
+ "X-CSRF-Token": $.cookie('_session_id')
+ },
+ success: function(data) {
+ var attachment_name = $("#file_info").val();
+ var attachment_url = page_url + 'attachment/' + attachment_name;
+ update_attachments(attachment_url, attachment_name, $("#file_info")[0].files[0].size);
+ }
+ });
+ };
+
+ function del_attach(this) {
+ var attr_url = $(this).attr('action');
+ $.ajax({
+ type: "POST",
+ url: attr_url,
+ data: $(this).serialize(),
+ headers: {
+ "X-CSRF-Token": $.cookie('_session_id')
+ },
+ success: function() {
+ $(this).parent().remove();
+ }
+ });
+ };
</script>
{% endblock %}
http://git-wip-us.apache.org/repos/asf/allura/blob/b4c574d4/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index b08d03e..8bfa863 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -593,6 +593,8 @@ class PageController(BaseController, FeedController):
page = self.page
else:
page = self.fake_page()
+ if request.headers.get('X-Requested-With', None) == 'XMLHttpRequest':
+ return
c.confirmation = W.confirmation
c.markdown_editor = W.markdown_editor
c.attachment_add = W.attachment_add