diff --git a/bower.json b/bower.json index 0735f4eb5a..6a64e184b0 100644 --- a/bower.json +++ b/bower.json @@ -29,7 +29,7 @@ "underscore": "~1.8.0", "bootstrap": "~3.3.6", "backbone": "~1.2.3", - "davclient.js": "https://github.com/evert/davclient.js.git", + "davclient.js": "https://github.com/evert/davclient.js.git#0.1.1", "es6-promise": "https://github.com/jakearchibald/es6-promise.git#~2.3.0", "base64": "~0.3.0", "clipboard": "^1.5.12", diff --git a/core/vendor/davclient.js/.bower.json b/core/vendor/davclient.js/.bower.json index 5ae36dac53..485af9e088 100644 --- a/core/vendor/davclient.js/.bower.json +++ b/core/vendor/davclient.js/.bower.json @@ -1,6 +1,6 @@ { "name": "davclient.js", - "version": "0.0.1", + "version": "0.1.1", "authors": [ "Evert Pot " ], @@ -20,13 +20,14 @@ "test", "tests" ], - "_release": "0.0.1", + "_release": "0.1.1", "_resolution": { "type": "version", - "tag": "0.0.1", - "commit": "2d054c63ba5bf7f7d40de904a742f3ad9c71e63c" + "tag": "0.1.1", + "commit": "a2731f81540816b212c09d14596621cb070a4f10" }, "_source": "https://github.com/evert/davclient.js.git", - "_target": "*", - "_originalSource": "https://github.com/evert/davclient.js.git" + "_target": "0.1.1", + "_originalSource": "https://github.com/evert/davclient.js.git", + "_direct": true } \ No newline at end of file diff --git a/core/vendor/davclient.js/lib/client.js b/core/vendor/davclient.js/lib/client.js index db1a1954af..0fc3f61f9f 100644 --- a/core/vendor/davclient.js/lib/client.js +++ b/core/vendor/davclient.js/lib/client.js @@ -1,3 +1,8 @@ +/* + * vim: expandtab shiftwidth=4 softtabstop=4 + */ + +/* global dav */ if (typeof dav == 'undefined') { dav = {}; }; dav._XML_CHAR_MAP = { @@ -99,11 +104,43 @@ dav.Client.prototype = { }, + /** + * Renders a "d:set" block for the given properties. + * + * @param {Object.} properties + * @return {String} XML "" block + */ + _renderPropSet: function(properties) { + var body = ' \n' + + ' \n'; + + for(var ii in properties) { + var property = this.parseClarkNotation(ii); + var propName; + var propValue = properties[ii]; + if (this.xmlNamespaces[property.namespace]) { + propName = this.xmlNamespaces[property.namespace] + ':' + property.name; + } else { + propName = 'x:' + property.name + ' xmlns:x="' + property.namespace + '"'; + } + + // FIXME: hard-coded for now until we allow properties to + // specify whether to be escaped or not + if (propName !== 'd:resourcetype') { + propValue = dav._escapeXml(propValue); + } + body += ' <' + propName + '>' + propValue + '\n'; + } + body +=' \n'; + body +=' \n'; + return body; + }, + /** * Generates a propPatch request. * * @param {string} url Url to do the proppatch request on - * @param {Array} properties List of properties to store. + * @param {Object.} properties List of properties to store. * @param {Object} [headers] headers * @return {Promise} */ @@ -119,25 +156,8 @@ dav.Client.prototype = { for (namespace in this.xmlNamespaces) { body += ' xmlns:' + this.xmlNamespaces[namespace] + '="' + namespace + '"'; } - body += '>\n' + - ' \n' + - ' \n'; - - for(var ii in properties) { - - var property = this.parseClarkNotation(ii); - var propName; - var propValue = properties[ii]; - if (this.xmlNamespaces[property.namespace]) { - propName = this.xmlNamespaces[property.namespace] + ':' + property.name; - } else { - propName = 'x:' + property.name + ' xmlns:x="' + property.namespace + '"'; - } - body += ' <' + propName + '>' + dav._escapeXml(propValue) + '\n'; - } - body+=' \n'; - body+=' \n'; - body+=''; + body += '>\n' + this._renderPropSet(properties); + body += ''; return this.request('PROPPATCH', url, headers, body).then( function(result) { @@ -151,6 +171,44 @@ dav.Client.prototype = { }, + /** + * Generates a MKCOL request. + * If attributes are given, it will use an extended MKCOL request. + * + * @param {string} url Url to do the proppatch request on + * @param {Object.} [properties] list of properties to store. + * @param {Object} [headers] headers + * @return {Promise} + */ + mkcol : function(url, properties, headers) { + var body = ''; + headers = headers || {}; + headers['Content-Type'] = 'application/xml; charset=utf-8'; + + if (properties) { + body = + '\n' + + '