[kupu-checkins] r54789 - in kupu/trunk/kupu: common plone
duncan at codespeak.net
duncan at codespeak.net
Fri May 16 13:38:26 CEST 2008
Author: duncan
Date: Fri May 16 13:38:24 2008
New Revision: 54789
Modified:
kupu/trunk/kupu/common/kupu_kjax.js
kupu/trunk/kupu/plone/html2captioned.py
Log:
Make the link checker handle the resolveuid fallback (so it doesn't flag things as bad links if they have special handling).
Fix kjax handling multiple requests.
Modified: kupu/trunk/kupu/common/kupu_kjax.js
==============================================================================
--- kupu/trunk/kupu/common/kupu_kjax.js (original)
+++ kupu/trunk/kupu/common/kupu_kjax.js Fri May 16 13:38:24 2008
@@ -9,7 +9,7 @@
*****************************************************************************/
/* Javascript to aid migration page. */
-function KJax() {};
+function KJax() { this.request_queue = [];};
(function(p){
p._loadXML = function(uri, callback, body, reload, extra) {
function _sarissaCallback() {
@@ -34,15 +34,26 @@
dom = Sarissa.getDomDocument();
dom.loadXML(xmlhttp.responseText);
}
+ if (this.request_queue) {
+ /* Kick off the next chained request before trying
+ * to handle the result of the last one.
+ */
+ this._loadXML.apply(this, this.request_queue.splice(0,1));
+ }
callback.apply(self, [dom, uri, extra]);
};
};
var self = this;
+ /* Make sure our requests are single-threaded. */
+ if (this.xmlhttp) {
+ this.request_queue.push([uri, callback, body, reload, extra]);
+ }
/* load the XML from a uri
calls callback with one arg (the XML DOM) when done
the (optional) body arg should contain the body for the request
*/
var xmlhttp = new XMLHttpRequest();
+ this.xmlhttp = xmlhttp;
var method = body?'POST':'GET';
// be sure that body is null and not an empty string or
// something
@@ -58,9 +69,9 @@
xmlhttp.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
};
xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
- this.xmlhttp = xmlhttp;
xmlhttp.send(body);
} catch(e) {
+ this.xmlhttp = null;
if (e && e.name && e.message) { // Microsoft
e = e.name + ': ' + e.message;
}
@@ -118,7 +129,6 @@
};
};
p.newRequest = function(uri) {
- if (this.xmlhttp) this.xmlhttp.abort();
this._loadXML(uri, this._xmlcallback);
};
p.clearLog = function() {
Modified: kupu/trunk/kupu/plone/html2captioned.py
==============================================================================
--- kupu/trunk/kupu/plone/html2captioned.py (original)
+++ kupu/trunk/kupu/plone/html2captioned.py Fri May 16 13:38:24 2008
@@ -551,6 +551,13 @@
if obj is not None:
newurl = obj.absolute_url()
return uid, newurl, tail
+ # If the uid doesn't exist then we can try the fallback
+ # script. Even if the fallback works though we'll assume
+ # an external link for simplicity.
+ hook = getattr(self.tool, 'kupu_resolveuid_hook', None)
+ if hook:
+ target = hook(uid)
+ return None, target, ''
return None, None, None
def classifyLink(self, url, base, first=True):
@@ -577,6 +584,8 @@
if 'resolveuid/' in absurl:
UID, newurl, ntail = self.resolveToPath(absurl)
if UID is None:
+ if newurl:
+ return 'external', None, newurl, ntail
return 'bad', None, url, ''
absurl = newurl
tail = ntail + tail
More information about the kupu-checkins
mailing list