Merge branch 'develop' into matthew/scalar

This commit is contained in:
Matthew Hodgson 2016-06-19 22:40:58 +01:00
commit 4dfb0e9a90
14 changed files with 220 additions and 74 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@
/packages/
/vector/bundle.*
/vector/components.css
/vector/config.json

View File

@ -3,8 +3,23 @@ Vector/Web
Vector is a Matrix web client built using the Matrix React SDK (https://github.com/matrix-org/matrix-react-sdk).
Getting started
Getting Started
===============
Vector is a modular webapp built with modern ES6 and requires and npm build system to build.
Instructions for building are below, but building from source shouldn't be necessary
for simple deployments.
1. Download the latest version from https://vector.im/packages/
1. Untar the tarball on your web server
1. Move (or symlink) the vector-x.x.x directory to an appropriate name
1. If desired, copy `config.sample.json` to `config.json` and edit it
as desired. See below for details.
1. Enter the URL into your browser and log into vector!
Building From Source
====================
If you do wish to build vector from source:
1. Install or update `node.js` so that your `npm` is at least at version `2.0.0`
1. Clone the repo: `git clone https://github.com/vector-im/vector-web.git`
@ -13,19 +28,23 @@ Getting started
1. If you are using the `develop` branch of vector, you will probably need to
rebuild one of the dependencies, due to https://github.com/npm/npm/issues/3055:
`(cd node_modules/matrix-react-sdk && npm install)`
1. Start the development builder and a testing server: `npm start`
1. Wait a few seconds for the initial build to finish (the command won't
terminate: it's running a web server for you).
1. Open http://127.0.0.1:8080/ in your browser to see your newly built Vector.
1. Configure the app by copying `config.sample.json` to `config.json` and modifying
it (see below for details)
1. `npm run package` to build a tarball to deploy. Untaring this file will give
a version-specific directory containing all the files that need to go on your
web server.
With `npm start`, any changes you make to the source files will cause a rebuild so
your changes will show up when you refresh. This development server also disables
caching, so do NOT use it in production.
Note that `npm run package` is not supported on Windows, so Windows users can run `npm
run build`, which will build all the necessary files into the `vector`
directory. The version of Vector will not appear in Settings without
using the package script. You can then mount the vector directory on your
webserver to actually serve up the app, which is entirely static content.
Configuring
config.json
===========
Configure the app by modifying the `config.json` file:
You can configure the app by copying `vector/config.sample.json` to
`vector/config.json` and customising it:
1. `default_hs_url` is the default home server url.
1. `default_is_url` is the default identity server url (this is the server used
@ -33,31 +52,13 @@ Configure the app by modifying the `config.json` file:
registering with an email address or adding an email address to your account
will not work.
You will need to re-run `npm run build` after editing `config.json`.
Deployment
==========
On a Unix-based OS, run `npm run package` to build a tarball package. Untaring
this file will give a version-specific directory containing all the files that
need to go on your web server.
The package script is not supported on Windows, so Windows users can run `npm
run build`, which will build all the necessary files into the `vector`
directory. Note that the version of Vector will not appear in Settings without
using the package script. You can then mount the vector directory on your
webserver to actually serve up the app, which is entirely static content.
Development
===========
For simple tweaks, you can work on any of the source files within Vector with
the setup above, and your changes will cause an instant rebuild.
However, much of the functionality in Vector is actually in the
`matrix-react-sdk` and `matrix-js-sdk` modules. It is possible to set these up
in a way that makes it easy to track the `develop` branches in git and to make
local changes without having to manually rebuild each time.
Much of the functionality in Vector is actually in the `matrix-react-sdk` and
`matrix-js-sdk` modules. It is possible to set these up in a way that makes it
easy to track the `develop` branches in git and to make local changes without
having to manually rebuild each time.
[Be aware that there may be problems with this process under npm version 3.]
@ -102,13 +103,14 @@ Finally, build and start vector itself:
+ 1013 hidden modules
```
Remember, the command will not terminate since it runs the web server
and rebuilds source files when they change.
and rebuilds source files when they change. This development server also
disables caching, so do NOT use it in production.
1. Open http://127.0.0.1:8080/ in your browser to see your newly built Vector.
When you make changes to `matrix-js-sdk` or `matrix-react-sdk`, you will need
to run `npm run build` in the relevant directory. You can do this automatically
by instead running `npm start` in each directory, to start a development
builder which will watch for changes to the files and rebuild automatically.
When you make changes to `matrix-react-sdk`, you will need to run `npm run
build` in the relevant directory. You can do this automatically by instead
running `npm start` in the directory, to start a development builder which
will watch for changes to the files and rebuild automatically.
If you add or remove any components from the Vector skin, you will need to rebuild
the skin's index by running, `npm run reskindex`.

View File

@ -27,6 +27,7 @@ module.exports = function (config) {
// list of files / patterns to load in the browser
files: [
'node_modules/babel-polyfill/browser.js',
testFile,
{pattern: 'vector/img/*', watched: false, included: false, served: true, nocache: false},
],
@ -130,6 +131,11 @@ module.exports = function (config) {
path.resolve('./test'),
],
},
plugins: [
// olm may not be installed, so avoid webpack warnings by
// ignoring it.
new webpack.IgnorePlugin(/^olm$/),
],
devtool: 'inline-source-map',
},
});

View File

@ -33,7 +33,9 @@
},
"dependencies": {
"babel-polyfill": "^6.5.0",
"browser-request": "^0.3.3",
"classnames": "^2.1.2",
"draft-js": "^0.7.0",
"extract-text-webpack-plugin": "^0.9.1",
"filesize": "^3.1.2",
"flux": "~2.0.3",
@ -41,8 +43,8 @@
"gfm.css": "^1.1.1",
"highlight.js": "^9.0.0",
"linkifyjs": "^2.0.0-beta.4",
"matrix-js-sdk": "^0.5.4",
"matrix-react-sdk": "^0.6.3",
"matrix-js-sdk": "matrix-org/matrix-js-sdk#develop",
"matrix-react-sdk": "matrix-org/matrix-react-sdk#develop",
"modernizr": "^3.1.0",
"q": "^1.4.1",
"react": "^15.0.1",

View File

@ -81,18 +81,20 @@ module.exports = React.createClass({
// });
},
showRoom: function(roomId) {
showRoom: function(roomId, roomAlias) {
// extract the metadata from the publicRooms structure to pass
// as out-of-band data to view_room, because we get information
// here that we can't get other than by joining the room in some
// cases.
var room;
if (roomId) {
for (var i = 0; i < this.state.publicRooms.length; ++i) {
if (this.state.publicRooms[i].room_id == roomId) {
room = this.state.publicRooms[i];
break;
}
}
}
var oob_data = {};
if (room) {
if (MatrixClientPeg.get().isGuest()) {
@ -114,11 +116,20 @@ module.exports = React.createClass({
};
}
dis.dispatch({
action: 'view_room',
room_id: roomId,
var payload = {
oob_data: oob_data,
});
action: 'view_room',
};
// It's not really possible to join Matrix rooms by ID because the HS has no way to know
// which servers to start querying. However, there's no other way to join rooms in
// this list without aliases at present, so if roomAlias isn't set here we have no
// choice but to supply the ID.
if (roomAlias) {
payload.room_alias = roomAlias;
} else {
payload.room_id = roomId;
}
dis.dispatch(payload);
},
getRows: function(filter) {
@ -164,7 +175,7 @@ module.exports = React.createClass({
topic = linkifyString(sanitizeHtml(topic));
rows.unshift(
<tr key={ rooms[i].room_id } onClick={self.showRoom.bind(null, rooms[i].room_id)}>
<tr key={ rooms[i].room_id } onClick={self.showRoom.bind(null, rooms[i].room_id, alias)}>
<td className="mx_RoomDirectory_roomAvatar">
<BaseAvatar width={24} height={24} resizeMethod='crop'
name={ name } idName={ name }
@ -193,7 +204,7 @@ module.exports = React.createClass({
this.forceUpdate();
this.setState({ roomAlias : this.refs.roomAlias.value })
if (ev.key == "Enter") {
this.showRoom(this.refs.roomAlias.value);
this.showRoom(null, this.refs.roomAlias.value);
}
},

View File

@ -103,7 +103,7 @@ module.exports = React.createClass({
className="mx_SearchBox_search"
value={ this.state.searchTerm }
onChange={ this.onChange }
placeholder="Search room names"
placeholder="Filter room names"
/>
];
}

View File

@ -21,7 +21,6 @@ var sdk = require('matrix-react-sdk');
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
var UserSettingsStore = require('matrix-react-sdk/lib/UserSettingsStore');
var Modal = require('matrix-react-sdk/lib/Modal');
var configJson = require("../../../../config.json");
var notifications = require('../../../notifications');
@ -73,6 +72,8 @@ module.exports = React.createClass({
propTypes: {
// The array of threepids from the JS SDK (required for email notifications)
threepids: React.PropTypes.array.isRequired,
// The brand string set when creating an email pusher
brand: React.PropTypes.string,
},
getDefaultProps: function() {
@ -118,9 +119,7 @@ module.exports = React.createClass({
var emailPusherPromise;
if (event.target.checked) {
var data = {}
if (configJson.brand) {
data['brand'] = configJson.brand;
}
data['brand'] = this.props.brand || 'Vector';
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
} else {
var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);

View File

@ -0,0 +1,22 @@
.mx_UserPill {
color: white;
background-color: #76cfa6;
padding: 2px 8px;
border-radius: 16px;
}
.mx_RoomPill {
background-color: white;
color: #76cfa6;
border: 1px solid #76cfa6;
padding: 2px 8px;
border-radius: 16px;
}
.mx_Markdown_BOLD {
font-weight: bold;
}
.mx_Markdown_ITALIC {
font-style: italic;
}

View File

@ -17,7 +17,7 @@ limitations under the License.
.mx_EventTile {
max-width: 100%;
clear: both;
margin-top: 24px;
padding-top: 24px;
margin-left: 65px;
}
@ -33,7 +33,15 @@ limitations under the License.
}
.mx_EventTile_continuation {
margin-top: 8px ! important;
padding-top: 8px ! important;
}
.mx_EventTile_verified {
background-color: #eaf5f0;
}
.mx_EventTile_unverified {
background-color: #ffa0a0;
}
.mx_EventTile .mx_SenderProfile {

View File

@ -0,0 +1,44 @@
/*
Copyright 2016 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.
*/
.mx_MemberDeviceInfo {
font-size: 12px;
margin-top: 5px;
}
.mx_MemberDeviceInfo div {
display: inline;
margin-right: 5px;
}
.mx_MemberDeviceInfo_textButton {
color: #fff;
height: 20px;
border-radius: 20px;
text-align: center;
padding-left: 1em;
padding-right: 1em;
cursor: pointer;
}
.mx_MemberDeviceInfo_verify {
background-color: #76cfa6;
}
.mx_MemberDeviceInfo_unverify {
background-color: #e55e5e;
}

View File

@ -22,15 +22,15 @@ limitations under the License.
}
.mx_MessageComposer_row {
display: table-row;
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
}
.mx_MessageComposer .mx_MessageComposer_avatar {
display: table-cell;
padding-left: 10px;
padding-right: 28px;
vertical-align: middle;
}
.mx_MessageComposer .mx_MessageComposer_avatar .mx_BaseAvatar {
@ -42,9 +42,7 @@ limitations under the License.
}
.mx_MessageComposer_noperm_error {
display: table-cell;
width: 100%;
vertical-align: middle;
height: 60px;
text-align: center;
font-style: italic;
@ -52,10 +50,22 @@ limitations under the License.
}
.mx_MessageComposer_input {
display: table-cell;
width: 100%;
flex: 1;
vertical-align: middle;
height: 60px;
min-height: 60px;
max-height: 120px;
display: flex;
align-items: center;
overflow: auto;
transition: 0.6s border-top ease;
border-top: 2px solid rgba(255, 255, 255, 0);
}
.mx_MessageComposer_input_rte {
border-top: 2px solid #76cfa6; /* placeholder RTE indicator */
}
.mx_MessageComposer_input .DraftEditor-root {
flex: 1;
}
.mx_MessageComposer_input textarea {
@ -92,8 +102,8 @@ limitations under the License.
.mx_MessageComposer_hangup,
.mx_MessageComposer_voicecall,
.mx_MessageComposer_videocall {
display: table-cell;
vertical-align: middle;
/*display: table-cell;*/
/*vertical-align: middle;*/
padding-left: 10px;
padding-right: 10px;
cursor: pointer;

View File

@ -26,6 +26,7 @@ require('../../vector/components.css');
require('gemini-scrollbar/gemini-scrollbar.css');
require('gfm.css/gfm.css');
require('highlight.js/styles/github.css');
require('draft-js/dist/Draft.css');
// add React and ReactPerf to the global namespace, to make them easier to
@ -40,8 +41,9 @@ var ReactDOM = require("react-dom");
var sdk = require("matrix-react-sdk");
sdk.loadSkin(require('../component-index'));
var VectorConferenceHandler = require('../VectorConferenceHandler');
var configJson = require("../../config.json");
var UpdateChecker = require("./updater");
var q = require('q');
var request = require('browser-request');
var qs = require("querystring");
@ -111,6 +113,8 @@ function parseQs(location) {
// Here, we do some crude URL analysis to allow
// deep-linking.
function routeUrl(location) {
if (!window.matrixChat) return;
console.log("Routing URL "+window.location);
var params = parseQs(location);
var loginToken = params.loginToken;
@ -181,7 +185,25 @@ window.onload = function() {
}
}
function loadApp() {
function getConfig() {
let deferred = q.defer();
request(
{ method: "GET", url: "config.json", json: true },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
deferred.reject({err: err, response: response});
return;
}
deferred.resolve(body);
}
);
return deferred.promise;
}
async function loadApp() {
if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
if (confirm("Vector runs much better as an app on iOS. Get the app?")) {
window.location = "https://itunes.apple.com/us/app/vector.im/id1083446067";
@ -189,14 +211,32 @@ function loadApp() {
}
}
else if (/Android/.test(navigator.userAgent)) {
if (confirm("Vector runs much better as an app on Vector. Get the app?")) {
if (confirm("Vector runs much better as an app on Android. Get the app?")) {
window.location = "https://play.google.com/store/apps/details?id=im.vector.alpha";
return;
}
}
let configJson;
let configError;
try {
configJson = await getConfig();
} catch (e) {
// On 404 errors, carry on without a config,
// but on other errors, fail, otherwise it will
// lead to subtle errors where the app runs with
// the default config if it fails to fetch config.json.
if (e.response.status != 404) {
configError = e;
}
}
console.log("Vector starting at "+window.location);
if (validBrowser) {
if (configError) {
window.matrixChat = ReactDOM.render(<div className="error">
Unable to load config file: please refresh the page to try again.
</div>, document.getElementById('matrixchat'));
} else if (validBrowser) {
var MatrixChat = sdk.getComponent('structures.MatrixChat');
var fragParts = parseQsFromFragment(window.location);
window.matrixChat = ReactDOM.render(

View File

@ -77,6 +77,7 @@ describe('joining a room', function () {
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
httpBackend.when('GET', '/sync').respond(200, {});
httpBackend.when('GET', '/publicRooms').respond(200, {chunk: []});
httpBackend.when('GET', '/directory/room/'+encodeURIComponent(ROOM_ALIAS)).respond(200, { room_id: ROOM_ID });
// start with a logged-in client
peg.replaceUsingAccessToken(HS_URL, IS_URL, USER_ID, ACCESS_TOKEN);
@ -102,7 +103,7 @@ describe('joining a room', function () {
// that should create a roomview which will start a peek; wait
// for the peek.
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ALIAS)+"/initialSync")
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync")
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});
return httpBackend.flush();
}).then(() => {