Merge branch 'new-guest-access' into tom-welcome-page

This commit is contained in:
Matthew Hodgson 2017-05-29 18:38:57 +01:00
commit 1af86405bd
309 changed files with 2043 additions and 393 deletions

3
.gitignore vendored
View File

@ -12,5 +12,8 @@
/.npmrc /.npmrc
.DS_Store .DS_Store
npm-debug.log npm-debug.log
electron/dist
electron/pub
/.idea
/config.json /config.json
/src/component-index.js /src/component-index.js

View File

@ -281,6 +281,19 @@ If any of these steps error with, `file table overflow`, you are probably on a m
which has a very low limit on max open files. Run `ulimit -Sn 1024` and try again. which has a very low limit on max open files. Run `ulimit -Sn 1024` and try again.
You'll need to do this in each new terminal you open before building Riot. You'll need to do this in each new terminal you open before building Riot.
How to add a new translation?
=============================
[<img src="https://translate.nordgedanken.de/widgets/riot-web/-/multi-auto.svg" alt="translationsstatus" width="340">](https://translate.nordgedanken.de/engage/riot-web/?utm_source=widget)
Head to the [translating doc](docs/translating.md)
Adding Strings to the translations (Developer Guide)
====================================================
Head to the [translating dev doc](docs/translating-dev.md)
Triaging issues Triaging issues
=============== ===============
@ -300,7 +313,7 @@ bug or feature:
* feature * feature
bug severity: bug severity:
* cosmetic - feature works functionally but UI/UX is broken * cosmetic - feature works functionally but UI/UX is broken
* critical - whole app doesn't work * critical - whole app doesn't work
* major - entire feature doesn't work * major - entire feature doesn't work

View File

@ -11,5 +11,5 @@
"matrix.org" "matrix.org"
] ]
}, },
"welcomeUserId": "@RiotBot:matrix.org" "welcomeUserId": "@riot-bot:matrix.org"
} }

26
docs/translating-dev.md Normal file
View File

@ -0,0 +1,26 @@
# How to translate riot-web (Dev Guide)
## Requirements
- A working [Development Setup](../../#setting-up-a-dev-environment)
- Be able to understand English
- Be able to understand the language you want to translate riot-web into
## Adding new strings
1. Check if the import ``import _t from 'counterpart-riot'`` is present. If not add it to the other import statements.
2. Add ``_t()`` to your string. (Don't forget curly braces when you assign an expression to JSX attributes in the render method)
3. Add the String to the ``en_EN.json`` file in ``src/i18n`` or if you are working in matrix-react-sdk you can find the json file in ``src/i18n/strings``
## Adding variables inside a string.
1. Extend your ``_t()`` call. Instead of ``_t(STRING)`` use ``_t(STRING, {})``
2. Decide how to name it. Please think about if the person who has to translate it can understand what it does.
3. Add it to the array in ``_t`` for example ``_t(STRING, {variable: this.variable})``
4. Add the variable inside the string. The syntax for variables is ``%(variable)s``. Please note the s at the end. The name of the variable has to match the previous used name.
## Things to know/Style Guides
- Do not use it inside ``getDefaultProps`` at the point where ``getDefaultProps`` is initialized the translations aren't loaded yet and it causes missing translations.
- If using translated strings as constants, translated strings can't be in constants loaded at class-load time since the translations won't be loaded.
- If a string is presented in the UI with punctuation like a full stop, include this in the translation strings, since punctuation varies between languages too.

64
docs/translating.md Normal file
View File

@ -0,0 +1,64 @@
# How to translate riot-web
## Requirements
- Web Browser
- Be able to understand English
- Be able to understand the language you want to translate riot-web into
## Step 0: Join #riotweb-translations:matrix.org
1. Come and join https://riot.im/develop/#/room/#riotweb-translations:matrix.org
2. Read scrollback and/or ask if anyone else is working on your language, and co-ordinate if needed. In general little-or-no coordination is needed though :)
## Step 1: Preparing your Weblate Profile
1. Head to https://translate.nordgedanken.de and register either via Github or email
2. After registering check if you got an email to verify your account and click the link (if there is none head to step 1.4)
3. Log into weblate
4. Head to https://translate.nordgedanken.de/accounts/profile/ and select the languages you know and maybe another language you know too.
6. Head to https://translate.nordgedanken.de/accounts/profile/#subscriptions and select Riot Web as Project
## How to check if your language already is being translated
Go to https://translate.nordgedanken.de/projects/riot-web/ and visit the 2 sub-projects.
If your language is listed go to Step 2a and if not go to Step 2b
## Step 2a: Helping on existing languages.
1. Head to one of the projects listed https://translate.nordgedanken.de/projects/riot-web/
2. Click on the ``translate`` button on the right side of your language
3. Fill in the translations in the writeable field. You will see the original English string and the string of your second language above.
Head to the explanations under Steb 2b
## Step 2b: Adding a new language
1. Go to one of the projects listed https://translate.nordgedanken.de/projects/riot-web/
2. Click the ``Start new language`` button at the bottom
3. Select a language
4. Start translating like in 2a.3
5. Repeat these steps for the other projects which are listed at the link of step 2b.1
### What means the green button under the text field?
The green button let you save our translations directly. Please only use it if you are 100% sure about that translation. If you do not know a translation please DO NOT click that button. Use the arrows above the translations field and click to the right.
### What means the yellow button under the text field?
The yellow button has to be used if you are unsure about the translation but you have a rough idea. It adds a new suggestion to the string which can than be reviewed by others.
### What are "%(something)s"?
These things are variables that are expanded when displayed by Riot. They can be room names, usernames or similar. If you find one, you can move to the right place for your language, but not delete it as the variable will be missing if you do.
A special case is `%(urlStart)s` and `%(urlEnd)s` which are used to mark the beginning of a hyperlink (i.e. `<a href="/somewhere">` and `</a>`. You must keep these markers surrounding the equivalent string in your language that needs to be hyperlinked.
### "I want to come back to this string. How?"
You can use inside the translation field "Review needed" checkbox. It will be shown as Strings that need to be reviewed.
### Further reading
The official Weblate doc provides some more in-deepth explanation on how to do translations and talks about do and don'ts. You can find it at: https://docs.weblate.org/en/latest/user/translating.html

View File

@ -1,5 +1,3 @@
// @flow
/* /*
Copyright 2016 Aviral Dasgupta Copyright 2016 Aviral Dasgupta
Copyright 2016 OpenMarket Ltd Copyright 2016 OpenMarket Ltd
@ -20,15 +18,14 @@ limitations under the License.
// Squirrel on windows starts the app with various flags // Squirrel on windows starts the app with various flags
// as hooks to tell us when we've been installed/uninstalled // as hooks to tell us when we've been installed/uninstalled
// etc. // etc.
const check_squirrel_hooks = require('./squirrelhooks'); const checkSquirrelHooks = require('./squirrelhooks');
if (check_squirrel_hooks()) return; if (checkSquirrelHooks()) return;
const electron = require('electron'); const electron = require('electron');
const url = require('url');
const tray = require('./tray'); const tray = require('./tray');
const vectorMenu = require('./vectormenu');
const VectorMenu = require('./vectormenu'); const webContentsHandler = require('./webcontents-handler');
const windowStateKeeper = require('electron-window-state'); const windowStateKeeper = require('electron-window-state');
@ -42,12 +39,6 @@ try {
// Continue with the defaults (ie. an empty config) // Continue with the defaults (ie. an empty config)
} }
const PERMITTED_URL_SCHEMES = [
'http:',
'https:',
'mailto:',
];
const UPDATE_POLL_INTERVAL_MS = 60 * 60 * 1000; const UPDATE_POLL_INTERVAL_MS = 60 * 60 * 1000;
const INITIAL_UPDATE_DELAY_MS = 30 * 1000; const INITIAL_UPDATE_DELAY_MS = 30 * 1000;
@ -59,13 +50,13 @@ function safeOpenURL(target) {
// so put fairly stringent limits on what can be opened // so put fairly stringent limits on what can be opened
// (for instance, open /bin/sh does indeed open a terminal // (for instance, open /bin/sh does indeed open a terminal
// with a shell, albeit with no arguments) // with a shell, albeit with no arguments)
const parsed_url = url.parse(target); const parsedUrl = url.parse(target);
if (PERMITTED_URL_SCHEMES.indexOf(parsed_url.protocol) > -1) { if (PERMITTED_URL_SCHEMES.indexOf(parsedUrl.protocol) > -1) {
// explicitly use the URL re-assembled by the url library, // explicitly use the URL re-assembled by the url library,
// so we know the url parser has understood all the parts // so we know the url parser has understood all the parts
// of the input string // of the input string
const new_target = url.format(parsed_url); const newTarget = url.format(parsedUrl);
electron.shell.openExternal(new_target); electron.shell.openExternal(newTarget);
} }
} }
@ -79,20 +70,19 @@ function onWindowOrNavigate(ev, target) {
} }
function onLinkContextMenu(ev, params) { function onLinkContextMenu(ev, params) {
const popup_menu = new electron.Menu(); const popupMenu = new electron.Menu();
popup_menu.append(new electron.MenuItem({
popupMenu.append(new electron.MenuItem({
label: params.linkURL, label: params.linkURL,
click() { click() { safeOpenURL(params.linkURL); },
safeOpenURL(params.linkURL);
},
})); }));
popup_menu.append(new electron.MenuItem({
popupMenu.append(new electron.MenuItem({
label: 'Copy Link Address', label: 'Copy Link Address',
click() { click() { electron.clipboard.writeText(params.linkURL); },
electron.clipboard.writeText(params.linkURL);
},
})); }));
popup_menu.popup();
popupMenu.popup();
ev.preventDefault(); ev.preventDefault();
} }
@ -107,13 +97,13 @@ function pollForUpdates() {
try { try {
electron.autoUpdater.checkForUpdates(); electron.autoUpdater.checkForUpdates();
} catch (e) { } catch (e) {
console.log("Couldn't check for update", e); console.log('Couldn\'t check for update', e);
} }
} }
function startAutoUpdate(update_base_url) { function startAutoUpdate(updateBaseUrl) {
if (update_base_url.slice(-1) !== '/') { if (updateBaseUrl.slice(-1) !== '/') {
update_base_url = update_base_url + '/'; updateBaseUrl = updateBaseUrl + '/';
} }
try { try {
// For reasons best known to Squirrel, the way it checks for updates // For reasons best known to Squirrel, the way it checks for updates
@ -121,7 +111,7 @@ function startAutoUpdate(update_base_url) {
// hits a URL that either gives it a 200 with some json or // hits a URL that either gives it a 200 with some json or
// 204 No Content. On windows it takes a base path and looks for // 204 No Content. On windows it takes a base path and looks for
// files under that path. // files under that path.
if (process.platform == 'darwin') { if (process.platform === 'darwin') {
// include the current version in the URL we hit. Electron doesn't add // include the current version in the URL we hit. Electron doesn't add
// it anywhere (apart from the User-Agent) so it's up to us. We could // it anywhere (apart from the User-Agent) so it's up to us. We could
// (and previously did) just use the User-Agent, but this doesn't // (and previously did) just use the User-Agent, but this doesn't
@ -129,16 +119,15 @@ function startAutoUpdate(update_base_url) {
// and also acts as a convenient cache-buster to ensure that when the // and also acts as a convenient cache-buster to ensure that when the
// app updates it always gets a fresh value to avoid update-looping. // app updates it always gets a fresh value to avoid update-looping.
electron.autoUpdater.setFeedURL( electron.autoUpdater.setFeedURL(
update_base_url + `${updateBaseUrl}macos/?localVersion=${encodeURIComponent(electron.app.getVersion())}`);
'macos/?localVersion=' + encodeURIComponent(electron.app.getVersion())
); } else if (process.platform === 'win32') {
} else if (process.platform == 'win32') { electron.autoUpdater.setFeedURL(`${updateBaseUrl}win32/${process.arch}/`);
electron.autoUpdater.setFeedURL(update_base_url + 'win32/' + process.arch + '/');
} else { } else {
// Squirrel / electron only supports auto-update on these two platforms. // Squirrel / electron only supports auto-update on these two platforms.
// I'm not even going to try to guess which feed style they'd use if they // I'm not even going to try to guess which feed style they'd use if they
// implemented it on Linux, or if it would be different again. // implemented it on Linux, or if it would be different again.
console.log("Auto update not supported on this platform"); console.log('Auto update not supported on this platform');
} }
// We check for updates ourselves rather than using 'updater' because we need to // We check for updates ourselves rather than using 'updater' because we need to
// do it in the main process (and we don't really need to check every 10 minutes: // do it in the main process (and we don't really need to check every 10 minutes:
@ -151,7 +140,7 @@ function startAutoUpdate(update_base_url) {
setInterval(pollForUpdates, UPDATE_POLL_INTERVAL_MS); setInterval(pollForUpdates, UPDATE_POLL_INTERVAL_MS);
} catch (err) { } catch (err) {
// will fail if running in debug mode // will fail if running in debug mode
console.log("Couldn't enable update checking", err); console.log('Couldn\'t enable update checking', err);
} }
} }
@ -162,7 +151,7 @@ function startAutoUpdate(update_base_url) {
// Assuming we generally run from the console when developing, // Assuming we generally run from the console when developing,
// this is far preferable. // this is far preferable.
process.on('uncaughtException', function(error) { process.on('uncaughtException', function(error) {
console.log("Unhandled exception", error); console.log('Unhandled exception', error);
}); });
electron.ipcMain.on('install_update', installUpdate); electron.ipcMain.on('install_update', installUpdate);
@ -186,6 +175,24 @@ electron.ipcMain.on('setBadgeCount', function(ev, count) {
} }
}); });
let powerSaveBlockerId;
electron.ipcMain.on('app_onAction', function(ev, payload) {
switch (payload.action) {
case 'call_state':
if (powerSaveBlockerId && powerSaveBlockerId.isStarted(powerSaveBlockerId)) {
if (payload.state === 'ended') {
electron.powerSaveBlocker.stop(powerSaveBlockerId);
}
} else {
if (payload.state === 'connected') {
powerSaveBlockerId = electron.powerSaveBlocker.start('prevent-display-sleep');
}
}
break;
}
});
electron.app.commandLine.appendSwitch('--enable-usermedia-screen-capturing'); electron.app.commandLine.appendSwitch('--enable-usermedia-screen-capturing');
const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirectory) => { const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirectory) => {
@ -198,30 +205,28 @@ const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirector
}); });
if (shouldQuit) { if (shouldQuit) {
console.log("Other instance detected: exiting"); console.log('Other instance detected: exiting');
electron.app.quit() electron.app.quit();
} }
electron.app.on('ready', () => { electron.app.on('ready', () => {
if (vectorConfig.update_base_url) { if (vectorConfig.update_base_url) {
console.log("Starting auto update with base URL: " + vectorConfig.update_base_url); console.log(`Starting auto update with base URL: ${vectorConfig.update_base_url}`);
startAutoUpdate(vectorConfig.update_base_url); startAutoUpdate(vectorConfig.update_base_url);
} else { } else {
console.log("No update_base_url is defined: auto update is disabled"); console.log('No update_base_url is defined: auto update is disabled');
} }
const icon_path = `${__dirname}/../img/riot.` + ( const iconPath = `${__dirname}/../img/riot.${process.platform === 'win32' ? 'ico' : 'png'}`;
process.platform == 'win32' ? 'ico' : 'png'
);
// Load the previous window state with fallback to defaults // Load the previous window state with fallback to defaults
let mainWindowState = windowStateKeeper({ const mainWindowState = windowStateKeeper({
defaultWidth: 1024, defaultWidth: 1024,
defaultHeight: 768, defaultHeight: 768,
}); });
mainWindow = new electron.BrowserWindow({ mainWindow = new electron.BrowserWindow({
icon: icon_path, icon: iconPath,
show: false, show: false,
autoHideMenuBar: true, autoHideMenuBar: true,
@ -231,12 +236,12 @@ electron.app.on('ready', () => {
height: mainWindowState.height, height: mainWindowState.height,
}); });
mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`); mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`);
electron.Menu.setApplicationMenu(VectorMenu); electron.Menu.setApplicationMenu(vectorMenu);
// Create trayIcon icon // Create trayIcon icon
tray.create(mainWindow, { tray.create(mainWindow, {
icon_path: icon_path, icon_path: iconPath,
brand: vectorConfig.brand || 'Riot' brand: vectorConfig.brand || 'Riot',
}); });
if (!process.argv.includes('--hidden')) { if (!process.argv.includes('--hidden')) {
@ -249,7 +254,7 @@ electron.app.on('ready', () => {
mainWindow = null; mainWindow = null;
}); });
mainWindow.on('close', (e) => { mainWindow.on('close', (e) => {
if (!appQuitting && (tray.hasTray() || process.platform == 'darwin')) { if (!appQuitting && (tray.hasTray() || process.platform === 'darwin')) {
// On Mac, closing the window just hides it // On Mac, closing the window just hides it
// (this is generally how single-window Mac apps // (this is generally how single-window Mac apps
// behave, eg. Mail.app) // behave, eg. Mail.app)
@ -259,15 +264,7 @@ electron.app.on('ready', () => {
} }
}); });
mainWindow.webContents.on('new-window', onWindowOrNavigate); webContentsHandler(mainWindow.webContents);
mainWindow.webContents.on('will-navigate', onWindowOrNavigate);
mainWindow.webContents.on('context-menu', function(ev, params) {
if (params.linkURL) {
onLinkContextMenu(ev, params);
}
});
mainWindowState.manage(mainWindow); mainWindowState.manage(mainWindow);
}); });

View File

@ -16,30 +16,30 @@ limitations under the License.
const path = require('path'); const path = require('path');
const spawn = require('child_process').spawn; const spawn = require('child_process').spawn;
const app = require('electron').app; const {app} = require('electron');
function run_update_exe(args, done) { function runUpdateExe(args, done) {
// Invokes Squirrel's Update.exe which will do things for us like create shortcuts // Invokes Squirrel's Update.exe which will do things for us like create shortcuts
// Note that there's an Update.exe in the app-x.x.x directory and one in the parent // Note that there's an Update.exe in the app-x.x.x directory and one in the parent
// directory: we need to run the one in the parent directory, because it discovers // directory: we need to run the one in the parent directory, because it discovers
// information about the app by inspecting the directory it's run from. // information about the app by inspecting the directory it's run from.
const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe'); const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe');
console.log('Spawning `%s` with args `%s`', updateExe, args); console.log(`Spawning '${updateExe}' with args '${args}'`);
spawn(updateExe, args, { spawn(updateExe, args, {
detached: true detached: true,
}).on('close', done); }).on('close', done);
}; }
function check_squirrel_hooks() { function checkSquirrelHooks() {
if (process.platform != 'win32') return false; if (process.platform !== 'win32') return false;
const cmd = process.argv[1]; const cmd = process.argv[1];
const target = path.basename(process.execPath); const target = path.basename(process.execPath);
if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') { if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
run_update_exe(['--createShortcut=' + target + ''], app.quit); runUpdateExe(['--createShortcut=' + target + ''], app.quit);
return true; return true;
} else if (cmd === '--squirrel-uninstall') { } else if (cmd === '--squirrel-uninstall') {
run_update_exe(['--removeShortcut=' + target + ''], app.quit); runUpdateExe(['--removeShortcut=' + target + ''], app.quit);
return true; return true;
} else if (cmd === '--squirrel-obsolete') { } else if (cmd === '--squirrel-obsolete') {
app.quit(); app.quit();
@ -48,4 +48,4 @@ function check_squirrel_hooks() {
return false; return false;
} }
module.exports = check_squirrel_hooks; module.exports = checkSquirrelHooks;

View File

@ -25,9 +25,7 @@ exports.hasTray = function hasTray() {
exports.create = function(win, config) { exports.create = function(win, config) {
// no trays on darwin // no trays on darwin
if (process.platform === 'darwin' || trayIcon) { if (process.platform === 'darwin' || trayIcon) return;
return;
}
const toggleWin = function() { const toggleWin = function() {
if (win.isVisible() && !win.isMinimized()) { if (win.isVisible() && !win.isMinimized()) {
@ -41,12 +39,10 @@ exports.create = function(win, config) {
const contextMenu = Menu.buildFromTemplate([ const contextMenu = Menu.buildFromTemplate([
{ {
label: 'Show/Hide ' + config.brand, label: `Show/Hide ${config.brand}`,
click: toggleWin, click: toggleWin,
}, },
{ { type: 'separator' },
type: 'separator',
},
{ {
label: 'Quit', label: 'Quit',
click: function() { click: function() {

View File

@ -14,170 +14,112 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
const electron = require('electron'); const {app, shell, Menu} = require('electron');
// Menu template from http://electron.atom.io/docs/api/menu/, edited // Menu template from http://electron.atom.io/docs/api/menu/, edited
const template = [ const template = [
{ {
label: 'Edit', label: 'Edit',
submenu: [ submenu: [
{ { role: 'undo' },
role: 'undo' { role: 'redo' },
}, { type: 'separator' },
{ { role: 'cut' },
role: 'redo' { role: 'copy' },
}, { role: 'paste' },
{ { role: 'pasteandmatchstyle' },
type: 'separator' { role: 'delete' },
}, { role: 'selectall' },
{ ],
role: 'cut'
},
{
role: 'copy'
},
{
role: 'paste'
},
{
role: 'pasteandmatchstyle'
},
{
role: 'delete'
},
{
role: 'selectall'
}
]
}, },
{ {
label: 'View', label: 'View',
submenu: [ submenu: [
{ { type: 'separator' },
type: 'separator' { role: 'resetzoom' },
}, { role: 'zoomin' },
{ { role: 'zoomout' },
role: 'resetzoom' { type: 'separator' },
}, { role: 'togglefullscreen' },
{ { role: 'toggledevtools' },
role: 'zoomin' ],
},
{
role: 'zoomout'
},
{
type: 'separator'
},
{
role: 'togglefullscreen'
},
{
role: 'toggledevtools'
}
]
}, },
{ {
role: 'window', role: 'window',
submenu: [ submenu: [
{ { role: 'minimize' },
role: 'minimize' { role: 'close' },
}, ],
{
role: 'close'
}
]
}, },
{ {
role: 'help', role: 'help',
submenu: [ submenu: [
{ {
label: 'riot.im', label: 'riot.im',
click () { electron.shell.openExternal('https://riot.im/') } click() { shell.openExternal('https://riot.im/'); },
} },
] ],
} },
]; ];
// macOS has specific menu conventions... // macOS has specific menu conventions...
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
// first macOS menu is the name of the app // first macOS menu is the name of the app
const name = electron.app.getName() const name = app.getName();
template.unshift({ template.unshift({
label: name, label: name,
submenu: [ submenu: [
{ { role: 'about' },
role: 'about' { type: 'separator' },
},
{
type: 'separator'
},
{ {
role: 'services', role: 'services',
submenu: [] submenu: [],
}, },
{ { type: 'separator' },
type: 'separator' { role: 'hide' },
}, { role: 'hideothers' },
{ { role: 'unhide' },
role: 'hide' { type: 'separator' },
}, { role: 'quit' },
{ ],
role: 'hideothers' });
},
{
role: 'unhide'
},
{
type: 'separator'
},
{
role: 'quit'
}
]
})
// Edit menu. // Edit menu.
// This has a 'speech' section on macOS // This has a 'speech' section on macOS
template[1].submenu.push( template[1].submenu.push(
{ { type: 'separator' },
type: 'separator'
},
{ {
label: 'Speech', label: 'Speech',
submenu: [ submenu: [
{ { role: 'startspeaking' },
role: 'startspeaking' { role: 'stopspeaking' },
}, ],
{ });
role: 'stopspeaking'
}
]
}
)
// Window menu. // Window menu.
// This also has specific functionality on macOS // This also has specific functionality on macOS
template[3].submenu = [ template[3].submenu = [
{ {
label: 'Close', label: 'Close',
accelerator: 'CmdOrCtrl+W', accelerator: 'CmdOrCtrl+W',
role: 'close' role: 'close',
}, },
{ {
label: 'Minimize', label: 'Minimize',
accelerator: 'CmdOrCtrl+M', accelerator: 'CmdOrCtrl+M',
role: 'minimize' role: 'minimize',
}, },
{ {
label: 'Zoom', label: 'Zoom',
role: 'zoom' role: 'zoom',
}, },
{ {
type: 'separator' type: 'separator',
}, },
{ {
label: 'Bring All to Front', label: 'Bring All to Front',
role: 'front' role: 'front',
} },
] ];
} else { } else {
template.unshift({ template.unshift({
label: 'File', label: 'File',
@ -186,12 +128,10 @@ if (process.platform === 'darwin') {
/*{ /*{
role: 'about' role: 'about'
},*/ },*/
{ { role: 'quit' },
role: 'quit' ],
}
]
}); });
} }
module.exports = electron.Menu.buildFromTemplate(template) module.exports = Menu.buildFromTemplate(template);

View File

@ -0,0 +1,122 @@
const {clipboard, nativeImage, Menu, MenuItem, shell} = require('electron');
const url = require('url');
const PERMITTED_URL_SCHEMES = [
'http:',
'https:',
'mailto:',
];
function safeOpenURL(target) {
// openExternal passes the target to open/start/xdg-open,
// so put fairly stringent limits on what can be opened
// (for instance, open /bin/sh does indeed open a terminal
// with a shell, albeit with no arguments)
const parsedUrl = url.parse(target);
if (PERMITTED_URL_SCHEMES.indexOf(parsedUrl.protocol) > -1) {
// explicitly use the URL re-assembled by the url library,
// so we know the url parser has understood all the parts
// of the input string
const newTarget = url.format(parsedUrl);
shell.openExternal(newTarget);
}
}
function onWindowOrNavigate(ev, target) {
// always prevent the default: if something goes wrong,
// we don't want to end up opening it in the electron
// app, as we could end up opening any sort of random
// url in a window that has node scripting access.
ev.preventDefault();
safeOpenURL(target);
}
function onLinkContextMenu(ev, params) {
const url = params.linkURL || params.srcURL;
const popupMenu = new Menu();
popupMenu.append(new MenuItem({
label: url,
click() {
safeOpenURL(url);
},
}));
if (params.mediaType && params.mediaType === 'image' && !url.startsWith('file://')) {
popupMenu.append(new MenuItem({
label: 'Copy Image',
click() {
if (url.startsWith('data:')) {
clipboard.writeImage(nativeImage.createFromDataURL(url));
} else {
ev.sender.copyImageAt(params.x, params.y);
}
},
}));
}
popupMenu.append(new MenuItem({
label: 'Copy Link Address',
click() {
clipboard.writeText(url);
},
}));
popupMenu.popup();
ev.preventDefault();
}
function _CutCopyPasteSelectContextMenus(params) {
return [{
role: 'cut',
enabled: params.editFlags.canCut,
}, {
role: 'copy',
enabled: params.editFlags.canCopy,
}, {
role: 'paste',
enabled: params.editFlags.canPaste,
}, {
role: 'pasteandmatchstyle',
enabled: params.editFlags.canPaste,
}, {
role: 'selectall',
enabled: params.editFlags.canSelectAll,
}];
}
function onSelectedContextMenu(ev, params) {
const items = _CutCopyPasteSelectContextMenus(params);
const popupMenu = Menu.buildFromTemplate(items);
popupMenu.popup();
ev.preventDefault();
}
function onEditableContextMenu(ev, params) {
const items = [
{ role: 'undo' },
{ role: 'redo', enabled: params.editFlags.canRedo },
{ type: 'separator' },
].concat(_CutCopyPasteSelectContextMenus(params));
const popupMenu = Menu.buildFromTemplate(items);
popupMenu.popup();
ev.preventDefault();
}
module.exports = (webContents) => {
webContents.on('new-window', onWindowOrNavigate);
webContents.on('will-navigate', onWindowOrNavigate);
webContents.on('context-menu', function(ev, params) {
if (params.linkURL || params.srcURL) {
onLinkContextMenu(ev, params);
} else if (params.selectionText) {
onSelectedContextMenu(ev, params);
} else if (params.isEditable) {
onEditableContextMenu(ev, params);
}
});
};

View File

@ -47,7 +47,6 @@ webpack_config.module.noParse.push(/sinon\/pkg\/sinon\.js$/);
webpack_config.resolve.alias['sinon'] = 'sinon/pkg/sinon.js'; webpack_config.resolve.alias['sinon'] = 'sinon/pkg/sinon.js';
webpack_config.resolve.root = [ webpack_config.resolve.root = [
path.resolve('./src'),
path.resolve('./test'), path.resolve('./test'),
]; ];

View File

@ -65,8 +65,8 @@
"gfm.css": "^1.1.1", "gfm.css": "^1.1.1",
"highlight.js": "^9.0.0", "highlight.js": "^9.0.0",
"linkifyjs": "^2.1.3", "linkifyjs": "^2.1.3",
"matrix-js-sdk": "0.7.8", "matrix-js-sdk": "matrix-org/matrix-js-sdk#develop",
"matrix-react-sdk": "0.8.9", "matrix-react-sdk": "matrix-org/matrix-react-sdk#develop",
"modernizr": "^3.1.0", "modernizr": "^3.1.0",
"pako": "^1.0.5", "pako": "^1.0.5",
"q": "^1.4.1", "q": "^1.4.1",
@ -104,6 +104,7 @@
"emojione": "^2.2.7", "emojione": "^2.2.7",
"eslint": "^3.14.0", "eslint": "^3.14.0",
"eslint-config-google": "^0.7.1", "eslint-config-google": "^0.7.1",
"eslint-plugin-babel": "^4.1.1",
"eslint-plugin-flowtype": "^2.30.0", "eslint-plugin-flowtype": "^2.30.0",
"eslint-plugin-react": "^6.9.0", "eslint-plugin-react": "^6.9.0",
"expect": "^1.16.0", "expect": "^1.16.0",
@ -158,6 +159,7 @@
], ],
"linux": { "linux": {
"target": "deb", "target": "deb",
"category": "Network;InstantMessaging;Chat",
"maintainer": "support@riot.im", "maintainer": "support@riot.im",
"desktop": { "desktop": {
"StartupWMClass": "riot-web" "StartupWMClass": "riot-web"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 841 B

After

Width:  |  Height:  |  Size: 1015 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 955 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 938 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 900 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 978 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 689 B

After

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 954 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 737 B

After

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 842 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 777 B

After

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 733 B

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 866 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 697 B

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 950 B

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 800 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 964 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 908 B

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 734 B

After

Width:  |  Height:  |  Size: 785 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 970 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 734 B

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 797 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 946 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 723 B

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 914 B

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 841 B

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 834 B

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 692 B

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 753 B

After

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1001 B

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1010 B

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 743 B

After

Width:  |  Height:  |  Size: 709 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 699 B

After

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Some files were not shown because too many files have changed in this diff Show More