Merge branch 'develop' into kegan/vector-references
This commit is contained in:
commit
4446f1d781
5 changed files with 141 additions and 47 deletions
15
header
Normal file
15
header
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
|
@ -13,6 +13,7 @@
|
|||
"reskindex": "./reskindex.js"
|
||||
},
|
||||
"scripts": {
|
||||
"reskindex": "reskindex -h header",
|
||||
"build": "babel src -d lib --source-maps",
|
||||
"start": "babel src -w -d lib --source-maps",
|
||||
"clean": "rimraf lib",
|
||||
|
@ -39,8 +40,9 @@
|
|||
"//depsbuglink": "https://github.com/webpack/webpack/issues/1472",
|
||||
"devDependencies": {
|
||||
"babel": "^5.8.23",
|
||||
"rimraf": "^2.4.3",
|
||||
"json-loader": "^0.5.3",
|
||||
"require-json": "0.0.1",
|
||||
"rimraf": "^2.4.3",
|
||||
"source-map-loader": "^0.1.5"
|
||||
}
|
||||
}
|
||||
|
|
73
reskindex.js
73
reskindex.js
|
@ -8,40 +8,13 @@ var args = require('optimist').argv;
|
|||
|
||||
var header = args.h || args.header;
|
||||
|
||||
if (args._.length == 0) {
|
||||
console.log("No skin given");
|
||||
process.exit(1);
|
||||
}
|
||||
var componentsDir = path.join('src', 'components');
|
||||
|
||||
var skin = args._[0];
|
||||
var componentIndex = path.join('src', 'component-index.js');
|
||||
|
||||
try {
|
||||
fs.accessSync(path.join('src', 'skins', skin), fs.F_OK);
|
||||
} catch (e) {
|
||||
console.log("Skin "+skin+" not found: "+e);
|
||||
process.exit(1);
|
||||
}
|
||||
var packageJson = JSON.parse(fs.readFileSync('./package.json'));
|
||||
|
||||
var skinfoFile = path.join('src', 'skins', skin, 'skinfo.json');
|
||||
|
||||
try {
|
||||
fs.accessSync(skinfoFile, fs.F_OK);
|
||||
} catch (e) {
|
||||
console.log("Skin "+skin+" has no skinfo.json");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
fs.accessSync(path.join('src', 'skins', skin, 'views'), fs.F_OK);
|
||||
} catch (e) {
|
||||
console.log("Skin "+skin+" has no views directory");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
var skindex = path.join('src', 'skins', skin, 'skindex.js');
|
||||
var viewsDir = path.join('src', 'skins', skin, 'views');
|
||||
|
||||
var strm = fs.createWriteStream(skindex);
|
||||
var strm = fs.createWriteStream(componentIndex);
|
||||
|
||||
if (header) {
|
||||
strm.write(fs.readFileSync(header));
|
||||
|
@ -55,28 +28,38 @@ strm.write(" * so you'd just be trying to swim upstream like a salmon.\n");
|
|||
strm.write(" * You are not a salmon.\n");
|
||||
strm.write(" */\n\n");
|
||||
|
||||
var mySkinfo = JSON.parse(fs.readFileSync(skinfoFile, "utf8"));
|
||||
if (packageJson['matrix-react-parent']) {
|
||||
strm.write("module.exports.components = require('"+packageJson['matrix-react-parent']+"/lib/component-index').components;\n\n");
|
||||
} else {
|
||||
strm.write("module.exports.components = {};\n");
|
||||
}
|
||||
|
||||
strm.write("var skin = {};\n");
|
||||
strm.write('\n');
|
||||
|
||||
var files = glob.sync('**/*.js', {cwd: viewsDir});
|
||||
var files = glob.sync('**/*.js', {cwd: componentsDir});
|
||||
for (var i = 0; i < files.length; ++i) {
|
||||
var file = files[i].replace('.js', '');
|
||||
var module = (file.replace(/\//g, '.'));
|
||||
|
||||
strm.write("skin['"+module+"'] = require('./views/"+file+"');\n");
|
||||
var moduleName = (file.replace(/\//g, '.'));
|
||||
|
||||
strm.write("module.exports.components['"+moduleName+"'] = require('./components/"+file+"');");
|
||||
strm.write('\n');
|
||||
strm.uncork();
|
||||
}
|
||||
|
||||
strm.write("\n");
|
||||
// Temporary Vector transition
|
||||
var vectorViewsPath = path.join('src', 'skins', 'vector', 'views');
|
||||
if (fs.existsSync(vectorViewsPath)) {
|
||||
strm.write('\n');
|
||||
strm.write('// Old, unported Vector views:\n');
|
||||
var files = glob.sync('**/*.js', {cwd: vectorViewsPath});
|
||||
for (var i = 0; i < files.length; ++i) {
|
||||
var file = files[i].replace('.js', '');
|
||||
|
||||
if (mySkinfo.baseSkin) {
|
||||
strm.write("module.exports = require('"+mySkinfo.baseSkin+"');");
|
||||
strm.write("var extend = require('matrix-react-sdk/lib/extend');\n");
|
||||
strm.write("extend(module.exports, skin);\n");
|
||||
} else {
|
||||
strm.write("module.exports = skin;");
|
||||
var moduleName = (file.replace(/\//g, '.'));
|
||||
|
||||
strm.write("module.exports.components['"+moduleName+"'] = require('./skins/vector/views/"+file+"');");
|
||||
strm.write('\n');
|
||||
strm.uncork();
|
||||
}
|
||||
}
|
||||
|
||||
strm.end();
|
||||
|
|
|
@ -32,6 +32,12 @@ class Skinner {
|
|||
if (comp) {
|
||||
return comp;
|
||||
}
|
||||
// XXX: Temporarily also try 'views.' as we're currently
|
||||
// leaving the 'views.' off views.
|
||||
var comp = this.components['views.'+name];
|
||||
if (comp) {
|
||||
return comp;
|
||||
}
|
||||
throw new Error("No such component: "+name);
|
||||
}
|
||||
|
||||
|
@ -42,7 +48,24 @@ class Skinner {
|
|||
"If you want to change the active skin, call resetSkin first"
|
||||
);
|
||||
}
|
||||
this.components = skinObject;
|
||||
this.components = {};
|
||||
var compKeys = Object.keys(skinObject.components);
|
||||
for (var i = 0; i < compKeys.length; ++i) {
|
||||
var comp = skinObject.components[compKeys[i]];
|
||||
this.addComponent(compKeys[i], comp);
|
||||
}
|
||||
}
|
||||
|
||||
addComponent(name, comp) {
|
||||
var slot = name;
|
||||
if (comp.replaces !== undefined) {
|
||||
if (comp.replaces.indexOf('.') > -1) {
|
||||
slot = comp.replaces;
|
||||
} else {
|
||||
slot = name.substr(0, name.lastIndexOf('.') + 1) + comp.replaces.split('.').pop();
|
||||
}
|
||||
}
|
||||
this.components[slot] = comp;
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
|
71
src/component-index.js
Normal file
71
src/component-index.js
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* THIS FILE IS AUTO-GENERATED
|
||||
* You can edit it you like, but your changes will be overwritten,
|
||||
* so you'd just be trying to swim upstream like a salmon.
|
||||
* You are not a salmon.
|
||||
*/
|
||||
|
||||
module.exports.components = {};
|
||||
module.exports.components['structures.CreateRoom'] = require('./components/structures/CreateRoom');
|
||||
module.exports.components['structures.login.Login'] = require('./components/structures/login/Login');
|
||||
module.exports.components['structures.login.PostRegistration'] = require('./components/structures/login/PostRegistration');
|
||||
module.exports.components['structures.login.Registration'] = require('./components/structures/login/Registration');
|
||||
module.exports.components['structures.MatrixChat'] = require('./components/structures/MatrixChat');
|
||||
module.exports.components['structures.RoomView'] = require('./components/structures/RoomView');
|
||||
module.exports.components['structures.UserSettings'] = require('./components/structures/UserSettings');
|
||||
module.exports.components['views.avatars.MemberAvatar'] = require('./components/views/avatars/MemberAvatar');
|
||||
module.exports.components['views.avatars.RoomAvatar'] = require('./components/views/avatars/RoomAvatar');
|
||||
module.exports.components['views.create_room.CreateRoomButton'] = require('./components/views/create_room/CreateRoomButton');
|
||||
module.exports.components['views.create_room.Presets'] = require('./components/views/create_room/Presets');
|
||||
module.exports.components['views.create_room.RoomAlias'] = require('./components/views/create_room/RoomAlias');
|
||||
module.exports.components['views.dialogs.ErrorDialog'] = require('./components/views/dialogs/ErrorDialog');
|
||||
module.exports.components['views.dialogs.LogoutPrompt'] = require('./components/views/dialogs/LogoutPrompt');
|
||||
module.exports.components['views.dialogs.QuestionDialog'] = require('./components/views/dialogs/QuestionDialog');
|
||||
module.exports.components['views.elements.EditableText'] = require('./components/views/elements/EditableText');
|
||||
module.exports.components['views.elements.ProgressBar'] = require('./components/views/elements/ProgressBar');
|
||||
module.exports.components['views.elements.UserSelector'] = require('./components/views/elements/UserSelector');
|
||||
module.exports.components['views.login.CaptchaForm'] = require('./components/views/login/CaptchaForm');
|
||||
module.exports.components['views.login.CasLogin'] = require('./components/views/login/CasLogin');
|
||||
module.exports.components['views.login.PasswordLogin'] = require('./components/views/login/PasswordLogin');
|
||||
module.exports.components['views.login.RegistrationForm'] = require('./components/views/login/RegistrationForm');
|
||||
module.exports.components['views.login.ServerConfig'] = require('./components/views/login/ServerConfig');
|
||||
module.exports.components['views.messages.MessageEvent'] = require('./components/views/messages/MessageEvent');
|
||||
module.exports.components['views.messages.MFileBody'] = require('./components/views/messages/MFileBody');
|
||||
module.exports.components['views.messages.MImageBody'] = require('./components/views/messages/MImageBody');
|
||||
module.exports.components['views.messages.MVideoBody'] = require('./components/views/messages/MVideoBody');
|
||||
module.exports.components['views.messages.TextualBody'] = require('./components/views/messages/TextualBody');
|
||||
module.exports.components['views.messages.TextualEvent'] = require('./components/views/messages/TextualEvent');
|
||||
module.exports.components['views.messages.UnknownBody'] = require('./components/views/messages/UnknownBody');
|
||||
module.exports.components['views.rooms.EventTile'] = require('./components/views/rooms/EventTile');
|
||||
module.exports.components['views.rooms.MemberInfo'] = require('./components/views/rooms/MemberInfo');
|
||||
module.exports.components['views.rooms.MemberList'] = require('./components/views/rooms/MemberList');
|
||||
module.exports.components['views.rooms.MemberTile'] = require('./components/views/rooms/MemberTile');
|
||||
module.exports.components['views.rooms.MessageComposer'] = require('./components/views/rooms/MessageComposer');
|
||||
module.exports.components['views.rooms.RoomHeader'] = require('./components/views/rooms/RoomHeader');
|
||||
module.exports.components['views.rooms.RoomList'] = require('./components/views/rooms/RoomList');
|
||||
module.exports.components['views.rooms.RoomSettings'] = require('./components/views/rooms/RoomSettings');
|
||||
module.exports.components['views.rooms.RoomTile'] = require('./components/views/rooms/RoomTile');
|
||||
module.exports.components['views.settings.ChangeAvatar'] = require('./components/views/settings/ChangeAvatar');
|
||||
module.exports.components['views.settings.ChangeDisplayName'] = require('./components/views/settings/ChangeDisplayName');
|
||||
module.exports.components['views.settings.ChangePassword'] = require('./components/views/settings/ChangePassword');
|
||||
module.exports.components['views.settings.EnableNotificationsButton'] = require('./components/views/settings/EnableNotificationsButton');
|
||||
module.exports.components['views.voip.CallView'] = require('./components/views/voip/CallView');
|
||||
module.exports.components['views.voip.IncomingCallBox'] = require('./components/views/voip/IncomingCallBox');
|
||||
module.exports.components['views.voip.VideoFeed'] = require('./components/views/voip/VideoFeed');
|
||||
module.exports.components['views.voip.VideoView'] = require('./components/views/voip/VideoView');
|
Loading…
Reference in a new issue