Author: reebalazs
Date: Wed Jan 30 15:42:55 2008
New Revision: 51130
Modified:
kukit/kukit.js/trunk/kukit/utils.js
kukit/kukit.js/trunk/tests/test_utils.js
Log:
Compensate for kss-base-url generation currently done by Plone.
Since Grok is not using this, it will not break Grok but
this currently fixes Plone.
The two failing tests are modified to pass in the current state.
TODO, change the kss-base-url generation in Plone to always
put a trailing slash in the end, and after that,
revert this change to where it was.
Modified: kukit/kukit.js/trunk/kukit/utils.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/utils.js (original)
+++ kukit/kukit.js/trunk/kukit/utils.js Wed Jan 30 15:42:55 2008
@@ -622,6 +622,32 @@
var link = nodes[i];
if (link.rel == 'kss-base-url') {
var base = link.href;
+ // XXX Special handling for Plone and systems that has a broken
+ // url generated in base.
+ //
+ // kss-base-url is currently giving us the page url without the
+ // trailing / and the method called within the page. Page is
always the
+ // real page we are viewing, without the trailing method
section.
+ //
+ // Examples:
+ //
+ // url entered in browser kss-base-url
+ // ---------------------- ------------
+ // http://127.0.0.1:8080/portal
...portal/front-page
+ // http://127.0.0.1:8080/portal/view ...portal
+ // http://127.0.0.1:8080/portal/front-page
...portal/front-page
+ // http://127.0.0.1:8080/portal/front-page/view
...portal/front-page
+ //
+ // ... so, we *always* need to put a trailing slash to the end
+ // to be standard compatible and compensate for the following
+ // code, that correctly removes the part after the last slash.
+ //
+ if (! /\/$/.test(base)) {
+ // (actually, we always get here right now
+ // since it never has the /, but to be sure,
+ // we only add it if it's not there)
+ base = base + '/';
+ }
}
}
}
Modified: kukit/kukit.js/trunk/tests/test_utils.js
==============================================================================
--- kukit/kukit.js/trunk/tests/test_utils.js (original)
+++ kukit/kukit.js/trunk/tests/test_utils.js Wed Jan 30 15:42:55 2008
@@ -203,11 +203,15 @@
this.assertEquals(base, this.kssBaseLocation + '/');
};
+ // XXX This test is currently wrong, because Plone does _not_
+ // XXX put the trailing slash to the end, so kss-base-url without
+ // XXX the trailing slash is currently interpreted as if it were there.
this.testKssBaseTag = function() {
this.kssBaseTag.href = this.kssBaseLocation;
this.html.appendChild(this.kssBaseTag);
var base = kukit.ut.calculateBase(this.doc, this.pageLocation);
- this.assertEquals(base, this.pageRoot + '/');
+ // XXX this.assertEquals(base, this.pageRoot + '/');
+ this.assertEquals(base, this.kssBaseLocation + '/');
};
this.testBothKssAndBaseTagWithTrailingSlash = function() {
@@ -219,13 +223,17 @@
this.assertEquals(base, this.kssBaseLocation + '/');
};
+ // XXX This test is currently wrong, because Plone does _not_
+ // XXX put the trailing slash to the end, so kss-base-url without
+ // XXX the trailing slash is currently interpreted as if it were there.
this.testBothKssAndBaseTag = function() {
this.kssBaseTag.href = this.kssBaseLocation;
this.html.appendChild(this.kssBaseTag);
this.baseTag.href = this.baseLocation;
this.html.appendChild(this.baseTag);
var base = kukit.ut.calculateBase(this.doc, this.pageLocation);
- this.assertEquals(base, this.pageRoot + '/');
+ // XXX this.assertEquals(base, this.pageRoot + '/');
+ this.assertEquals(base, this.kssBaseLocation + '/');
};
};
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins