Author: enorman
Date: Sat Mar 26 19:12:29 2011
New Revision: 1085787
URL: http://svn.apache.org/viewvc?rev=1085787&view=rev
Log:
SLING-2019 explorer doesn't work when sling is used in a non-root context
Modified:
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/explorer/js/explorer.js
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/edit.esp
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/node.esp
Modified:
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/explorer/js/explorer.js
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/explorer/js/explorer.js?rev=1085787&r1=1085786&r2=1085787&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/explorer/js/explorer.js
(original)
+++
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/explorer/js/explorer.js
Sat Mar 26 19:12:29 2011
@@ -19,23 +19,31 @@
/** replace the default get and post jQuery utility functions */
(function($) {
+ Sling.contextPath = "";
+ if (Sling.baseurl.lastIndexOf('/') > window.location.protocol.length + 3) {
+ Sling.contextPath =
Sling.baseurl.substring(Sling.baseurl.lastIndexOf('/'));
+ };
+
$.ajaxSetup({
timeout: 5 * 60 * 1000 // in ms, 5 minutes
});
- $.getRaw = $.get;
- $.getJSONRaw = $.getJSON;
$.postRaw = $.post;
- $.get = function(url, parameters, callback) {
- return $.getRaw(Sling.baseurl + url, parameters, callback)
- };
- $.getJson = function(url, parameters, callback) {
- return $.getJSONRaw(Sling.baseurl + url, parameters, callback)
- };
+ $.ajaxRaw = $.ajax;
$.post = function(url, parameters, callback) {
var params = { "_charset_":"utf-8" };
$.extend(params, parameters);
- return $.postRaw(Sling.baseurl + url, parameters, callback)
+ return $.postRaw(Sling.baseurl + url, parameters, callback);
};
+ $.ajax = function(settings) {
+ var url = settings.url;
+ if (url.charAt(0) == '/' && url.indexOf(Sling.contextPath) == -1) {
+ settings.url = Sling.baseurl + url;
+ }
+ if (settings.url && settings.url.charAt(0) == '/') {
+ }
+ return $.ajaxRaw(settings);
+ };
+
})(jQuery);
/** load the initial tree on editor startup */
@@ -164,7 +172,7 @@ load_branch = function( path, callback,
},
complete: function( xmlHttpRequest, textStatus) {
loadingbranch = false;
- if ( textStatus.equals("timeout") )
+ if ( textStatus == "timeout" )
{
show_error("Timeout!");
}
Modified:
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/edit.esp
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/edit.esp?rev=1085787&r1=1085786&r2=1085787&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/edit.esp
(original)
+++
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/edit.esp
Sat Mar 26 19:12:29 2011
@@ -80,7 +80,7 @@
if ( mixinTypes || canModifyProperties ) { %>
<h3>mixin types</h3>
<div id="property_element_<%= mixinTypesId %>" class="multivalued
property_element">
- <form id="properties_form_<%= mixinTypesId %>" action="<%= path
%>" method="post">
+ <form id="properties_form_<%= mixinTypesId %>" action="<%=
request.getContextPath() %><%= path %>" method="post">
<fieldset>
<label for="<%= mixinTypesId %>"><%= mixinTypesId
%></label>
<%
@@ -131,7 +131,7 @@
}
if ( !id.equals( primaryNodeTypeId ) && !id.equals( mixinTypesId )
) { %>
<div id="property_element_<%= id %>" class="<% if (
isMultivalueProperty ) {%> multivalued <% } %> property_element">
- <form id="properties_form_<%= id %>" action="<%=path%>"
method="post">
+ <form id="properties_form_<%= id %>" action="<%=
request.getContextPath() %><%=path%>" method="post">
<fieldset>
<label for="<%= id %>"><%= id %>
<% if (isProperty) { %>
Modified:
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp?rev=1085787&r1=1085786&r2=1085787&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp
(original)
+++
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/explorer.esp
Sat Mar 26 19:12:29 2011
@@ -46,7 +46,7 @@
<form accept-charset="UTF-8" enctype="multipart/form-data" action="#"
method="post" id="login-form">
<fieldset>
<input type="hidden" value="UTF-8" name="_charset_" />
- <input type="hidden" value="/" name="resource" />
+ <input type="hidden" value="<%= request.getContextPath() %>"
name="resource" />
<input type="hidden" value="form" name="selectedAuthType" />
</fieldset>
Modified:
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/node.esp
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/node.esp?rev=1085787&r1=1085786&r2=1085787&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/node.esp
(original)
+++
sling/trunk/bundles/extensions/explorer/src/main/resources/libs/sling/servlet/default/explorer/node.esp
Sat Mar 26 19:12:29 2011
@@ -54,7 +54,7 @@
if (path != '/')
{
%>
- <form class="deleteNote" action="<%= path %>" method="post">
+ <form class="deleteNote" action="<%= request.getContextPath()
%><%= path %>" method="post">
<input name=":operation" type="hidden" value="delete">
<input name=":redirect" type="hidden"
value="<%=request.getContextPath()%><%=
Packages.org.apache.sling.api.resource.ResourceUtil.getParent(resource)
%>.explorer.html">
<input type="submit" class="button" value="delete this node">
@@ -193,9 +193,10 @@
var child_node_location =
xmlHttpRequest.getResponseHeader('Location');
if ( child_node_location )
{
+ var childPath =
child_node_location.substring(Sling.contextPath.length);
load_branch(
'<%=path%>',
- function() {
skip_to( child_node_location );},
+ function() {
skip_to( childPath );},
true
);
}