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 2016/01/08 12:05:41 UTC

[1/7] allura git commit: [#7998] ticket:878 fix request for multiple upload

Repository: allura
Updated Branches:
  refs/heads/ib/7998a [created] d2e8761bd


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

Branch: refs/heads/ib/7998a
Commit: a2d542403f87bb670144c6d50b2e400001b07b6e
Parents: 7fea8f6
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 23 14:25:33 2015 +0200
Committer: Denis Kotov <de...@gmail.com>
Committed: Thu Jan 7 21:17:38 2016 +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/a2d54240/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);
+        }
       }
     });
   };


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

Branch: refs/heads/ib/7998a
Commit: ebd8e6bc48f00406ab610f617b3311d0301e6af4
Parents: ee2895e
Author: Denis Kotov <de...@gmail.com>
Authored: Mon Dec 21 21:56:11 2015 +0200
Committer: Denis Kotov <de...@gmail.com>
Committed: Thu Jan 7 21:17:38 2016 +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/ebd8e6bc/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/ebd8e6bc/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()


[7/7] allura git commit: [#7998] ticket:883 fix mistake in update_attachments

Posted by je...@apache.org.
[#7998] ticket:883 fix mistake in update_attachments


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

Branch: refs/heads/ib/7998a
Commit: d2e8761bd745a5ba1ee7cde04a99c4146d1f9466
Parents: 7b83164
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Jan 6 12:51:06 2016 +0200
Committer: Denis Kotov <de...@gmail.com>
Committed: Thu Jan 7 21:33:36 2016 +0200

----------------------------------------------------------------------
 ForgeWiki/forgewiki/templates/wiki/page_edit.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/d2e8761b/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 b587075..204b20c 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -115,7 +115,7 @@
                      '<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 + '">' +
                        '<input type="hidden" name="delete" value="True"/>' +
                        '<input type="submit" value="Delete File"/>' +
                      '</form>' +


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

Branch: refs/heads/ib/7998a
Commit: ee2895efca5bfb6e01bce8cd2ca15b0da430a8fc
Parents: b5df9ce
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 16 16:17:47 2015 +0200
Committer: Denis Kotov <de...@gmail.com>
Committed: Thu Jan 7 21:17:38 2016 +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/ee2895ef/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 %}


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

Branch: refs/heads/ib/7998a
Commit: 7fea8f643832b72f4036a86dcbbd7e3cb01fcd06
Parents: ebd8e6b
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 23 13:49:11 2015 +0200
Committer: Denis Kotov <de...@gmail.com>
Committed: Thu Jan 7 21:17:38 2016 +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/7fea8f64/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/7fea8f64/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);
       }


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

Branch: refs/heads/ib/7998a
Commit: b5df9ce1f55e267e0c2caed29c2b306b1417075b
Parents: dfa249a
Author: Denis Kotov <de...@gmail.com>
Authored: Wed Dec 16 14:22:30 2015 +0200
Committer: Denis Kotov <de...@gmail.com>
Committed: Thu Jan 7 21:17:38 2016 +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/b5df9ce1/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/b5df9ce1/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/b5df9ce1/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/b5df9ce1/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


[6/7] allura git commit: [#7998] ticket:883 change way to calling attach functions, add is_ajax func

Posted by je...@apache.org.
[#7998] ticket:883 change way to calling attach functions, add is_ajax func


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

Branch: refs/heads/ib/7998a
Commit: 7b8316447a6d5bbf5610333588c7c9a1f2fb3b30
Parents: a2d5424
Author: Denis Kotov <de...@gmail.com>
Authored: Tue Jan 5 19:57:40 2016 +0200
Committer: Denis Kotov <de...@gmail.com>
Committed: Thu Jan 7 21:33:35 2016 +0200

----------------------------------------------------------------------
 Allura/allura/controllers/attachments.py        |  3 ++
 Allura/allura/lib/utils.py                      |  7 +++++
 .../forgewiki/templates/wiki/page_edit.html     | 30 +++++++++++---------
 ForgeWiki/forgewiki/wiki_main.py                |  6 ++--
 4 files changed, 31 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7b831644/Allura/allura/controllers/attachments.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/attachments.py b/Allura/allura/controllers/attachments.py
index 6766d02..61c0bf2 100644
--- a/Allura/allura/controllers/attachments.py
+++ b/Allura/allura/controllers/attachments.py
@@ -22,6 +22,7 @@ from tg import expose, request, redirect
 from ming.utils import LazyProperty
 
 from allura.lib.security import require_access
+from allura.lib.utils import is_ajax
 from .base import BaseController
 
 
@@ -110,6 +111,8 @@ class AttachmentController(BaseController):
     def index(self, delete=False, **kw):
         if request.method == 'POST':
             self.handle_post(delete, **kw)
+            if is_ajax(request):
+                return
             redirect(request.referer)
         if self.artifact.deleted:
             raise exc.HTTPNotFound

http://git-wip-us.apache.org/repos/asf/allura/blob/7b831644/Allura/allura/lib/utils.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 17721b0..90ad4cc 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -655,3 +655,10 @@ def unique_attachments(attachments):
     for _, atts in groupby(attachments, op.attrgetter('filename')):
         result.append(max(atts, key=op.attrgetter('_id')))
     return result
+
+
+
+def is_ajax(request):
+    if request.headers.get('X-Requested-With', None) == 'XMLHttpRequest':
+        return True
+    return False

http://git-wip-us.apache.org/repos/asf/allura/blob/7b831644/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 be2caae..b587075 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(onsubmit='del_attach(this); return false;', attachments=page.attachments, edit_mode=page_exists and h.has_access(page, 'edit')())}}
+  {{c.attachment_list.display(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(onsubmit='send_attach(); return false;', name='file_info')}}
+    {{c.attachment_add.display(name='file_info')}}
   {% endif %}
 </div>
 {{c.confirmation.display(content='')}}
@@ -115,14 +115,14 @@
                      '<a href="' + attachment_url + '">' +
                      '<img src="' + attachment_url + '/thumb" alt="Thumbnail"/>' +
                      '</a><br/>' + filename +
-                     '<form method="post" action="' + attachment_url + '" onsubmit="del_attach(this); return false;">' +
+                     '<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 ='<div><form method="post" action="' + attachment_url + '" onsubmit="del_attach(this); return false;">' +
+      var new_attach ='<div><form method="post" action="' + attachment_url + '">' +
                         '<a href="' + attachment_url + '">' + filename + '</a> (' + filesize + ' bytes)' +
                         '<input type="hidden" name="delete" value="True"/>' +
                         '<span>' +
@@ -132,7 +132,9 @@
       $(new_attach).prependTo($('.attachment_files'));
     };
   };
-  function send_attach() {
+
+  $('#attachment_form').on('submit', function(event) {
+    event.preventDefault();
     var page_url = '{{page.url()}}';
     $.ajax({
       type: "POST",
@@ -140,7 +142,7 @@
       data: new FormData($('#attachment_form')[0]),
       processData: false,
       contentType: false,
-      success: function(data) {
+      success: function() {
         var i;
         for (i = 0; i < $("#file_info")[0].files.length; i++){
           var attachment_name = $("#file_info")[0].files[i].name;
@@ -149,19 +151,21 @@
         }
       }
     });
-  };
+  });
 
-  function del_attach(elem) {
-    var attr_url = $(elem).attr('action');
+  $('.attachments').on('submit', 'form', function(event) {
+    event.preventDefault();
+    elem = $(this);
+    var attr_url = elem.attr('action');
     $.ajax({
       type: "POST",
       url: attr_url,
-      data: $(elem).serialize() +"&_session_id=" + $.cookie('_session_id'),
-      success:  function() {
-        $(elem).parent().remove();
+      data: elem.serialize() +"&_session_id=" + $.cookie('_session_id'),
+      success:  function() {;
+        elem.parent().remove();
       }
     });
-  };
+  });
   {% endif %}
 </script>
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/7b831644/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 31de5b8..560af82 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -37,6 +37,7 @@ from allura.app import Application, SitemapEntry, DefaultAdminController, Config
 from allura.lib.search import search_app
 from allura.lib.decorators import require_post
 from allura.lib.security import require_access, has_access
+from allura.lib.utils import is_ajax
 from allura.lib import exceptions as forge_exc
 from allura.controllers import AppDiscussionController, BaseController, AppDiscussionRestController
 from allura.controllers import DispatchIndex
@@ -754,8 +755,9 @@ class PageController(BaseController, FeedController):
             raise exc.HTTPNotFound
         require_access(self.page, 'edit')
         self.page.add_multiple_attachments(file_info)
-        if request.headers.get('X-Requested-With', None) != 'XMLHttpRequest':
-            redirect(request.referer)
+        if is_ajax(request):
+            return
+        redirect(request.referer)
 
     @expose('json:')
     @require_post()