Browse Source

Move core/js/files to webpack

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>
tags/v20.0.0beta1
Roeland Jago Douma 4 years ago
parent
commit
44d05bf356
No account linked to committer's email address

+ 0
- 2
core/js/core.json View File

@@ -16,8 +16,6 @@
"../search/js/search.js",
"mimetype.js",
"mimetypelist.js",
"files/fileinfo.js",
"files/client.js",
"systemtags/systemtags.js",
"systemtags/templates.js",
"systemtags/systemtagmodel.js",

+ 33
- 0
core/js/dist/files_client.js
File diff suppressed because it is too large
View File


+ 1
- 0
core/js/dist/files_client.js.map
File diff suppressed because it is too large
View File


+ 2
- 0
core/js/dist/files_fileinfo.js
File diff suppressed because it is too large
View File


+ 1
- 0
core/js/dist/files_fileinfo.js.map
File diff suppressed because it is too large
View File


+ 2
- 0
core/js/dist/files_iedavclient.js
File diff suppressed because it is too large
View File


+ 1
- 0
core/js/dist/files_iedavclient.js.map
File diff suppressed because it is too large
View File


+ 5
- 5
core/js/dist/install.js
File diff suppressed because it is too large
View File


+ 1
- 1
core/js/dist/install.js.map
File diff suppressed because it is too large
View File


+ 15
- 15
core/js/dist/login.js
File diff suppressed because it is too large
View File


+ 1
- 1
core/js/dist/login.js.map
File diff suppressed because it is too large
View File


+ 22
- 22
core/js/dist/main.js
File diff suppressed because it is too large
View File


+ 1
- 1
core/js/dist/main.js.map
File diff suppressed because it is too large
View File


+ 12
- 12
core/js/dist/maintenance.js
File diff suppressed because it is too large
View File


+ 1
- 1
core/js/dist/maintenance.js.map
File diff suppressed because it is too large
View File


+ 2
- 2
core/js/dist/recommendedapps.js
File diff suppressed because it is too large
View File


+ 1
- 1
core/js/dist/recommendedapps.js.map
File diff suppressed because it is too large
View File


+ 0
- 163
core/js/files/iedavclient.js View File

@@ -1,163 +0,0 @@
/*
* Copyright (c) 2015
*
* This file is licensed under the Affero General Public License version 3
* or later.
*
* See the COPYING-README file.
*
*/

/* global dav */
(function(dav) {

/**
* Override davclient.js methods with IE-compatible logic
*/
dav.Client.prototype = _.extend({}, dav.Client.prototype, {

/**
* Performs a HTTP request, and returns a Promise
*
* @param {string} method HTTP method
* @param {string} url Relative or absolute url
* @param {Object} headers HTTP headers as an object.
* @param {string} body HTTP request body.
* @return {Promise}
*/
request : function(method, url, headers, body) {

var self = this;
var xhr = this.xhrProvider();
headers = headers || {};

if (this.userName) {
headers.Authorization = 'Basic ' + btoa(this.userName + ':' + this.password);
// xhr.open(method, this.resolveUrl(url), true, this.userName, this.password);
}
xhr.open(method, this.resolveUrl(url), true);
var ii;
for(ii in headers) {
xhr.setRequestHeader(ii, headers[ii]);
}

if (body === undefined) {
xhr.send();
} else {
xhr.send(body);
}

return new Promise(function(fulfill, reject) {

xhr.onreadystatechange = function() {

if (xhr.readyState !== 4) {
return;
}

var resultBody = xhr.response;
if (xhr.status === 207) {
resultBody = self.parseMultiStatus(xhr.responseXML);
}

fulfill({
body: resultBody,
status: xhr.status,
xhr: xhr
});

};

xhr.ontimeout = function() {

reject(new Error('Timeout exceeded'));

};

});

},

_getElementsByTagName: function(node, name, resolver) {
var parts = name.split(':');
var tagName = parts[1];
var namespace = resolver(parts[0]);
// make sure we can get elements
if (typeof node === 'string') {
var parser = new DOMParser()
node = parser.parseFromString(node, 'text/xml')
}
if (node.getElementsByTagNameNS) {
return node.getElementsByTagNameNS(namespace, tagName);
}
return node.getElementsByTagName(name);
},

/**
* Parses a multi-status response body.
*
* @param {string} xmlBody
* @param {Array}
*/
parseMultiStatus : function(doc) {
var result = [];
var resolver = function(foo) {
var ii;
for(ii in this.xmlNamespaces) {
if (this.xmlNamespaces[ii] === foo) {
return ii;
}
}
}.bind(this);

var responses = this._getElementsByTagName(doc, 'd:response', resolver);
var i;
for (i = 0; i < responses.length; i++) {
var responseNode = responses[i];
var response = {
href : null,
propStat : []
};

var hrefNode = this._getElementsByTagName(responseNode, 'd:href', resolver)[0];

response.href = hrefNode.textContent || hrefNode.text;

var propStatNodes = this._getElementsByTagName(responseNode, 'd:propstat', resolver);
var j = 0;

for (j = 0; j < propStatNodes.length; j++) {
var propStatNode = propStatNodes[j];
var statusNode = this._getElementsByTagName(propStatNode, 'd:status', resolver)[0];

var propStat = {
status : statusNode.textContent || statusNode.text,
properties : []
};

var propNode = this._getElementsByTagName(propStatNode, 'd:prop', resolver)[0];
if (!propNode) {
continue;
}
var k = 0;
for (k = 0; k < propNode.childNodes.length; k++) {
var prop = propNode.childNodes[k];
var value = this._parsePropNode(prop);
propStat.properties['{' + prop.namespaceURI + '}' + (prop.localName || prop.baseName)] = value;

}
response.propStat.push(propStat);
}

result.push(response);
}

return result;

}


});

})(dav);


core/src/files/client.js
File diff suppressed because it is too large
View File


core/js/files/fileinfo.js → core/src/files/fileinfo.js View File

@@ -1,3 +1,4 @@
/* eslint-disable */
/*
* Copyright (c) 2015
*
@@ -18,35 +19,35 @@
*
* @since 8.2
*/
var FileInfo = function(data) {
var self = this;
const FileInfo = function(data) {
const self = this
_.each(data, function(value, key) {
if (!_.isFunction(value)) {
self[key] = value;
self[key] = value
}
});
})

if (!_.isUndefined(this.id)) {
this.id = parseInt(data.id, 10);
this.id = parseInt(data.id, 10)
}

// TODO: normalize path
this.path = data.path || '';
this.path = data.path || ''

if (this.type === 'dir') {
this.mimetype = 'httpd/unix-directory';
this.mimetype = 'httpd/unix-directory'
} else {
this.mimetype = this.mimetype || 'application/octet-stream';
this.mimetype = this.mimetype || 'application/octet-stream'
}

if (!this.type) {
if (this.mimetype === 'httpd/unix-directory') {
this.type = 'dir';
this.type = 'dir'
} else {
this.type = 'file';
this.type = 'file'
}
}
};
}

/**
* @memberof OC.Files
@@ -137,12 +138,11 @@
/**
* @type int
*/
sharePermissions: null
};
sharePermissions: null,
}

if (!OC.Files) {
OC.Files = {};
OC.Files = {}
}
OC.Files.FileInfo = FileInfo;
})(OC);

OC.Files.FileInfo = FileInfo
})(OC)

+ 162
- 0
core/src/files/iedavclient.js View File

@@ -0,0 +1,162 @@
/* eslint-disable */
/*
* Copyright (c) 2015
*
* This file is licensed under the Affero General Public License version 3
* or later.
*
* See the COPYING-README file.
*
*/

/* global dav */
(function(dav) {

/**
* Override davclient.js methods with IE-compatible logic
*/
dav.Client.prototype = _.extend({}, dav.Client.prototype, {

/**
* Performs a HTTP request, and returns a Promise
*
* @param {string} method HTTP method
* @param {string} url Relative or absolute url
* @param {Object} headers HTTP headers as an object.
* @param {string} body HTTP request body.
* @returns {Promise}
*/
request: function(method, url, headers, body) {

const self = this
const xhr = this.xhrProvider()
headers = headers || {}

if (this.userName) {
headers.Authorization = 'Basic ' + btoa(this.userName + ':' + this.password)
// xhr.open(method, this.resolveUrl(url), true, this.userName, this.password);
}
xhr.open(method, this.resolveUrl(url), true)
let ii
for (ii in headers) {
xhr.setRequestHeader(ii, headers[ii])
}

if (body === undefined) {
xhr.send()
} else {
xhr.send(body)
}

return new Promise(function(fulfill, reject) {

xhr.onreadystatechange = function() {

if (xhr.readyState !== 4) {
return
}

let resultBody = xhr.response
if (xhr.status === 207) {
resultBody = self.parseMultiStatus(xhr.responseXML)
}

fulfill({
body: resultBody,
status: xhr.status,
xhr: xhr,
})

}

xhr.ontimeout = function() {

reject(new Error('Timeout exceeded'))

}

})

},

_getElementsByTagName: function(node, name, resolver) {
const parts = name.split(':')
const tagName = parts[1]
const namespace = resolver(parts[0])
// make sure we can get elements
if (typeof node === 'string') {
const parser = new DOMParser()
node = parser.parseFromString(node, 'text/xml')
}
if (node.getElementsByTagNameNS) {
return node.getElementsByTagNameNS(namespace, tagName)
}
return node.getElementsByTagName(name)
},

/**
* Parses a multi-status response body.
*
* @param {string} xmlBody
* @param {Array}
*/
parseMultiStatus: function(doc) {
const result = []
const resolver = function(foo) {
let ii
for (ii in this.xmlNamespaces) {
if (this.xmlNamespaces[ii] === foo) {
return ii
}
}
}.bind(this)

const responses = this._getElementsByTagName(doc, 'd:response', resolver)
let i
for (i = 0; i < responses.length; i++) {
const responseNode = responses[i]
const response = {
href: null,
propStat: [],
}

const hrefNode = this._getElementsByTagName(responseNode, 'd:href', resolver)[0]

response.href = hrefNode.textContent || hrefNode.text

const propStatNodes = this._getElementsByTagName(responseNode, 'd:propstat', resolver)
let j = 0

for (j = 0; j < propStatNodes.length; j++) {
const propStatNode = propStatNodes[j]
const statusNode = this._getElementsByTagName(propStatNode, 'd:status', resolver)[0]

const propStat = {
status: statusNode.textContent || statusNode.text,
properties: [],
}

const propNode = this._getElementsByTagName(propStatNode, 'd:prop', resolver)[0]
if (!propNode) {
continue
}
let k = 0
for (k = 0; k < propNode.childNodes.length; k++) {
const prop = propNode.childNodes[k]
const value = this._parsePropNode(prop)
propStat.properties['{' + prop.namespaceURI + '}' + (prop.localName || prop.baseName)] = value

}
response.propStat.push(propStat)
}

result.push(response)
}

return result

},

})

})(dav)

+ 2
- 2
core/src/views/Login.vue View File

@@ -58,8 +58,8 @@
:redirect-url="redirectUrl"
:inverted-colors="invertedColors"
:auto-complete-allowed="autoCompleteAllowed"
:isHttps="isHttps"
:hasPublicKeyCredential="hasPublicKeyCredential"
:is-https="isHttps"
:has-public-key-credential="hasPublicKeyCredential"
@submit="loading = true" />
<a @click.prevent="passwordlessLogin = false">
{{ t('core', 'Back') }}

+ 4
- 1
core/webpack.js View File

@@ -8,7 +8,10 @@ module.exports = [
main: path.join(__dirname, 'src/main.js'),
maintenance: path.join(__dirname, 'src/maintenance.js'),
recommendedapps: path.join(__dirname, 'src/recommendedapps.js'),
install: path.join(__dirname, 'src/install.js')
install: path.join(__dirname, 'src/install.js'),
files_client: path.join(__dirname, 'src/files/client.js'),
files_fileinfo: path.join(__dirname, 'src/files/fileinfo.js'),
files_iedavclient: path.join(__dirname, 'src/files/iedavclient.js')
},
output: {
filename: '[name].js',

+ 3
- 3
lib/private/legacy/OC_Template.php View File

@@ -118,14 +118,14 @@ class OC_Template extends \OC\Template\Base {
OC_Util::addScript('search', 'search', true);
OC_Util::addScript('search', 'searchprovider');
OC_Util::addScript('merged-template-prepend', null, true);
OC_Util::addScript('files/fileinfo');
OC_Util::addScript('files/client');
OC_Util::addScript('dist/files_fileinfo');
OC_Util::addScript('dist/files_client');
}
OC_Util::addScript('core', 'dist/main', true);

if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) {
// shim for the davclient.js library
\OCP\Util::addScript('files/iedavclient');
\OCP\Util::addScript('dist/files_iedavclient');
}

self::$initTemplateEngineFirstRun = false;

+ 2
- 0
tests/karma.config.js View File

@@ -127,6 +127,8 @@ module.exports = function(config) {

files.push(corePath + 'tests/html-domparser.js');
files.push('core/js/dist/main.js');
files.push('core/js/dist/files_fileinfo.js');
files.push('core/js/dist/files_client.js');
// core mocks
files.push(corePath + 'tests/specHelper.js');


Loading…
Cancel
Save