Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into auto-update
Browse files Browse the repository at this point in the history
  • Loading branch information
alexliebowitz committed Jan 23, 2018
2 parents 37b5ec9 + 8940942 commit 483809b
Show file tree
Hide file tree
Showing 31 changed files with 626 additions and 795 deletions.
25 changes: 2 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
/node_modules
/LBRY-darwin-x64
/dist

/src/main/dist
/src/main/locales
/src/main/node_modules
/src/renderer/dist
/build/venv
/build/daemon.ver
/lbry-app-venv
/lbry-app
/lbry-venv
/build/venv
*.pyc
/static/daemon/lbrynet*
/static/locales
/daemon/build
/daemon/venv
/daemon/requirements.txt
/.idea

*.pyc
*.iml
.#*

build/daemon.zip
.vimrc

package-lock.json

.DS_Store
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ To make contributing as easy and rewarding of possible, we have instituted the f

| Level | Description |
| --------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| [**level 0**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+0%22+no%3Aassignee) | Typos and text edits -- a tech-savvy non-programmer can fix these |
| [**level 1**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+1%22+no%3Aassignee) | Programming issues that require little knowledge of how the LBRY app works |
| [**level 2**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+2%22+no%3Aassignee) | Issues of average difficulty that require the developer to dig into how the app works a little bit |
| [**level 3**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+3%22+no%3Aassignee) | Issues that are likely too tricky to be level 2 or require more thinking outside of the box |
| [**level 4**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level+4%22+no%3Aassignee) | Big features or really hard issues |
| [**level 0**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+0%22+no%3Aassignee) | Typos and text edits -- a tech-savvy non-programmer can fix these |
| [**level 1**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+1%22+no%3Aassignee) | Programming issues that require little knowledge of how the LBRY app works |
| [**level 2**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+2%22+no%3Aassignee) | Issues of average difficulty that require the developer to dig into how the app works a little bit |
| [**level 3**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+3%22+no%3Aassignee) | Issues that are likely too tricky to be level 2 or require more thinking outside of the box |
| [**level 4**](https://github.com/lbryio/lbry-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22+label%3A%22level%3A+4%22+no%3Aassignee) | Big features or really hard issues |

The process of ranking issues is highly subjective. The purpose of sorting issues like this is to
give contributors a general idea about the type of issues they are looking at. It could very well be
Expand Down
35 changes: 2 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ development and testing purposes.
* [Git](https://git-scm.com/downloads)
* [Node.js](https://nodejs.org/en/download/)
* [Yarn](https://yarnpkg.com/en/docs/install)
* `yarn --add-python-to-path install --global --production windows-build-tools` (Windows only)

### One-time Setup

Expand Down Expand Up @@ -61,40 +60,10 @@ The app can be run from the sources using the following command:

### On Windows

#### Windows Dependency

1. Download and install `git` from <a href="https://git-for-windows.github.io/">github.io<a>
(configure to use command prompt integration)
2. Download and install `npm` and `node` from
<a href="https://nodejs.org/en/download/current/">nodejs.org<a>
3. Download and install `python 2.7` from
<a href="https://www.python.org/downloads/windows/">python.org</a>
4. Download and Install `Microsoft Visual C++ Compiler for Python 2.7` from
<a href="https://www.microsoft.com/en-us/download/confirmation.aspx?id=44266">Microsoft<a>
5. Download and install `.NET Framework 2.0 Software Development Kit (SDK) (x64)` from
<a href="https://www.microsoft.com/en-gb/download/details.aspx?id=15354">Microsoft<a> (may need
to extract setup.exe and install manually by running install.exe as Administrator)

#### One-time Setup

1. Open a command prompt as administrator and run the following:

```
npm install --global --production windows-build-tools
exit
```

2. Open a command prompt in the root of the project and run the following:

```
python -m pip install -r build\requirements.txt
npm install -g yarn
yarn install
yarn build
```

3. Download the lbry daemon and CLI [binaries](https://github.com/lbryio/lbry/releases) and place
them in `static\daemon`.
Download the lbry daemon and CLI [binaries](https://github.com/lbryio/lbry/releases) and place them
in `static\daemon`.

### Build

Expand Down
6 changes: 3 additions & 3 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ fi
# Build the app #
###################
if [ "$FULL_BUILD" == "true" ]; then
# if $OSX; then
# security unlock-keychain -p ${KEYCHAIN_PASSWORD} osx-build.keychain
# fi
if $OSX; then
security unlock-keychain -p ${KEYCHAIN_PASSWORD} osx-build.keychain
fi

yarn build

Expand Down
8 changes: 6 additions & 2 deletions build/install_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ set -eu
if $LINUX; then
INSTALL="$SUDO apt-get install --no-install-recommends -y"
$INSTALL build-essential libssl-dev libffi-dev libgmp3-dev python2.7-dev libsecret-1-dev curl
elif $OSX && ! cmd_exists brew ; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
elif $OSX; then
if ! cmd_exists brew; then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
brew update
fi
fi


Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"compile": "electron-webpack && yarn extract-langs",
"build": "yarn compile && electron-builder build",
"postinstall": "electron-builder install-app-deps",
"postmerge": "yarnhook",
"postcheckout": "yarnhook",
"postrewrite": "yarnhook",
"precommit": "lint-staged",
"lint": "eslint 'src/**/*.{js,jsx}' --fix",
"format": "prettier 'src/**/*.{js,jsx,scss,json}' --write"
Expand All @@ -41,7 +44,7 @@
"install": "^0.10.2",
"jayson": "^2.0.2",
"jshashes": "^1.0.7",
"keytar": "^4.0.3",
"keytar-prebuild": "^4.0.4",
"localforage": "^1.5.0",
"npm": "^5.5.1",
"qrcode.react": "^0.7.2",
Expand Down Expand Up @@ -102,7 +105,8 @@
"prettier": "^1.4.2",
"sass-loader": "^6.0.6",
"webpack": "^3.10.0",
"webpack-build-notifier": "^0.1.18"
"webpack-build-notifier": "^0.1.18",
"yarnhook": "^0.1.1"
},
"resolutions": {
"webpack/webpack-sources": "1.0.1"
Expand Down
64 changes: 64 additions & 0 deletions src/main/Daemon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* eslint-disable no-console */
import path from 'path';
import { spawn, execSync } from 'child_process';

export default class Daemon {
static path = process.env.LBRY_DAEMON || path.join(__static, 'daemon/lbrynet-daemon');
subprocess;
handlers;

constructor() {
this.handlers = [];
}

launch() {
// Kill any running daemon
if (process.platform === 'win32') {
try {
execSync('taskkill /im lbrynet-daemon.exe /t /f');
} catch (error) {
console.warn(error.message);
}
} else {
try {
execSync('pkill lbrynet-daemon');
} catch (error) {
console.warn(error.message);
}
}

console.log('Launching daemon:', Daemon.path);
this.subprocess = spawn(Daemon.path);

this.subprocess.stdout.on('data', data => console.log(`Daemon: ${data}`));
this.subprocess.stderr.on('data', data => console.error(`Daemon: ${data}`));
this.subprocess.on('exit', () => this.fire('exit'));
this.subprocess.on('error', error => console.error(`Daemon: ${error}`));
}

quit() {
if (process.platform === 'win32') {
try {
execSync(`taskkill /pid ${this.subprocess.pid} /t /f`);
} catch (error) {
console.error(error.message);
}
} else {
this.subprocess.kill();
}
}

// Follows the publish/subscribe pattern

// Subscribe method
on(event, handler, context = handler) {
this.handlers.push({ event, handler: handler.bind(context) });
}

// Publish method
fire(event, args) {
this.handlers.forEach(topic => {
if (topic.event === event) topic.handler(args);
});
}
}
63 changes: 63 additions & 0 deletions src/main/Tray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { app, Menu, Tray as ElectronTray } from 'electron';
import path from 'path';
import createWindow from './createWindow';

export default class Tray {
window;
updateAttachedWindow;
tray;

constructor(window, updateAttachedWindow) {
this.window = window;
this.updateAttachedWindow = updateAttachedWindow;
}

create() {
let iconPath;
switch (process.platform) {
case 'darwin': {
iconPath = path.join(__static, '/img/tray/mac/trayTemplate.png');
break;
}
case 'win32': {
iconPath = path.join(__static, '/img/tray/windows/tray.ico');
break;
}
default: {
iconPath = path.join(__static, '/img/tray/default/tray.png');
}
}

this.tray = new ElectronTray(iconPath);

this.tray.on('double-click', () => {
if (!this.window || this.window.isDestroyed()) {
this.window = createWindow();
this.updateAttachedWindow(this.window);
} else {
this.window.show();
this.window.focus();
}
});

this.tray.setToolTip('LBRY App');

const template = [
{
label: `Open ${app.getName()}`,
click: () => {
if (!this.window || this.window.isDestroyed()) {
this.window = createWindow();
this.updateAttachedWindow(this.window);
} else {
this.window.show();
this.window.focus();
}
},
},
{ role: 'quit' },
];
const contextMenu = Menu.buildFromTemplate(template);
this.tray.setContextMenu(contextMenu);
}
}
100 changes: 100 additions & 0 deletions src/main/createWindow.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { app, BrowserWindow, dialog } from 'electron';
import setupBarMenu from './menu/setupBarMenu';
import setupContextMenu from './menu/setupContextMenu';

export default deepLinkingURIArg => {
let windowConfiguration = {
backgroundColor: '#155B4A',
minWidth: 800,
minHeight: 600,
autoHideMenuBar: true,
show: false,
};

// Disable renderer process's webSecurity on development to enable CORS.
windowConfiguration =
process.env.NODE_ENV === 'development'
? {
...windowConfiguration,
webPreferences: {
webSecurity: false,
},
}
: windowConfiguration;

const rendererURL =
process.env.NODE_ENV === 'development'
? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`
: `file://${__dirname}/index.html`;

let window = new BrowserWindow(windowConfiguration);

window.maximize();

window.loadURL(rendererURL);

let deepLinkingURI;
// Protocol handler for win32
if (
!deepLinkingURIArg &&
process.platform === 'win32' &&
String(process.argv[1]).startsWith('lbry')
) {
// Keep only command line / deep linked arguments
// Windows normalizes URIs when they're passed in from other apps. On Windows, this tries to
// restore the original URI that was typed.
// - If the URI has no path, Windows adds a trailing slash. LBRY URIs can't have a slash with no
// path, so we just strip it off.
// - In a URI with a claim ID, like lbry://channel#claimid, Windows interprets the hash mark as
// an anchor and converts it to lbry://channel/#claimid. We remove the slash here as well.
deepLinkingURI = process.argv[1].replace(/\/$/, '').replace('/#', '#');
} else {
deepLinkingURI = deepLinkingURIArg;
}

setupBarMenu();
setupContextMenu(window);

window.on('closed', () => {
window = null;
});

window.on('focus', () => {
window.webContents.send('window-is-focused', null);
});

window.on('unresponsive', () => {
dialog.showMessageBox(
window,
{
type: 'warning',
buttons: ['Wait', 'Quit'],
title: 'LBRY Unresponsive',
defaultId: 1,
message: 'LBRY is not responding. Would you like to quit?',
cancelId: 0,
},
buttonIndex => {
if (buttonIndex === 1) app.quit();
}
);
});

window.once('ready-to-show', () => {
window.show();
});

window.webContents.on('did-finish-load', () => {
window.webContents.send('open-uri-requested', deepLinkingURI, true);
window.webContents.session.setUserAgent(`LBRY/${app.getVersion()}`);
if (process.env.NODE_ENV === 'development') {
window.webContents.openDevTools();
}
});

window.webContents.on('crashed', () => {
window = null;
});

return window;
};
Loading

0 comments on commit 483809b

Please sign in to comment.