From ff62659371a5fa303fa75637a939df02661c4d55 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Sat, 19 Sep 2015 17:07:26 +0200 Subject: [PATCH 01/61] Update dependencies --- app/config.js | 4 ++-- app/init.js | 2 -- app/js/alt-menubar.jsx | 1 - app/js/menubar.jsx | 1 - package.json | 3 ++- 5 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/config.js b/app/config.js index 693dfc30b..acb1d9fc6 100644 --- a/app/config.js +++ b/app/config.js @@ -13,8 +13,8 @@ exports = module.exports = { width: 800, height: 600 }, - 'tray-icon': (os.platform() !== 'darwin' ? - path.resolve(__dirname, '../node_modules/ipfs-logo/ipfs-logo-256-ice.png') + 'tray-icon': (os.platform() !== 'darwin' + ? path.resolve(__dirname, '../node_modules/ipfs-logo/ipfs-logo-256-ice.png') : path.resolve(__dirname, '../node_modules/ipfs-logo/platform-icons/osx-menu-bar.png')), 'webui-path': '/webui', 'ipfs-path': (function () { diff --git a/app/init.js b/app/init.js index 9e7975fb7..3be7e8f64 100644 --- a/app/init.js +++ b/app/init.js @@ -12,7 +12,6 @@ var IPFS exports = module.exports = init function init () { - // main entry point ipfsd.local(function (err, node) { if (err) { @@ -27,7 +26,6 @@ function init () { }) mb.on('ready', function () { - // listen for global shortcuts events require('./controls/shortcuts') diff --git a/app/js/alt-menubar.jsx b/app/js/alt-menubar.jsx index 26d00cc4c..294565f47 100644 --- a/app/js/alt-menubar.jsx +++ b/app/js/alt-menubar.jsx @@ -66,7 +66,6 @@ var Menu = React.createClass({ ipc.emit('menu-height', menuHeight) } }, 200) - }, // -- Actions diff --git a/app/js/menubar.jsx b/app/js/menubar.jsx index 888a6cb69..e784609a9 100644 --- a/app/js/menubar.jsx +++ b/app/js/menubar.jsx @@ -73,7 +73,6 @@ var Menu = React.createClass({ ipc.emit('menu-height', menuHeight) } }, 200) - }, // -- Actions diff --git a/package.json b/package.json index af3994d94..7f8e1c068 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "minimist": "1.1.1", "multiaddr": "0.1.2", "open": "0.0.5", - "react": "0.13.1", + "react": "0.13.3", "silence-chromium": "2.0.0" }, "devDependencies": { @@ -23,6 +23,7 @@ "browserify-shim": "3.8.8", "electron-packager": "5.0.1", "electron-prebuilt": "0.30.2", + "eslint-plugin-react": "^3.4.2", "pre-commit": "1.0.6", "reactify": "1.1.1", "rimraf": "2.3.4", From 093764cb2d02e5f4474a6658a8329991e6e0db22 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Sat, 19 Sep 2015 17:11:40 +0200 Subject: [PATCH 02/61] Add travis --- .travis.yml | 7 +++++++ README.md | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..07b383999 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +sudo: false +language: node_js +node_js: + - "0.12" + +script: + - npm run lint diff --git a/README.md b/README.md index 996971d55..11f627e3d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ IPFS Native Application ======================= -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![Dependency Status](https://david-dm.org/ipfs/electron-app.svg?style=flat-square)](https://david-dm.org/ipfs/electron-app) +[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![Dependency Status](https://david-dm.org/ipfs/electron-app.svg?style=flat-square)](https://david-dm.org/ipfs/electron-app) [![Build Status](https://img.shields.io/travis/ipfs/electron-app/master.svg?style=flat-square)](https://travis-ci.org/ipfs/electron-app) > A Native Application for your OS to run your own IPFS Node. Built with Electron Shell From 7eef78d6d5ec985d3a5014a80aa3a41170072c19 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Sun, 20 Sep 2015 00:36:51 +0200 Subject: [PATCH 03/61] New build system with hot reloading and babel --- .babelrc | 16 +++++++++ app/controls/error-panel.js | 7 +++- app/controls/open-settings.js | 6 +++- app/init.js | 25 ++++++++++--- app/js/help.js | 6 +--- app/js/menubar-toggle.jsx | 42 ---------------------- app/js/menubar.jsx | 23 +++++++----- app/js/settings.jsx | 2 +- app/js/welcome.jsx | 4 +-- app/views/help.html | 24 +++---------- app/views/menubar.html | 6 +--- app/views/settings.html | 8 +---- app/views/welcome.html | 10 ++---- build.sh | 13 ------- copy.sh | 2 ++ dev-server.js | 29 +++++++++++++++ package.json | 66 ++++++++++++++++------------------- webpack.config.dev.js | 47 +++++++++++++++++++++++++ webpack.config.prod.js | 49 ++++++++++++++++++++++++++ 19 files changed, 232 insertions(+), 153 deletions(-) create mode 100644 .babelrc delete mode 100644 app/js/menubar-toggle.jsx delete mode 100755 build.sh create mode 100755 copy.sh create mode 100644 dev-server.js create mode 100644 webpack.config.dev.js create mode 100644 webpack.config.prod.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..37954582c --- /dev/null +++ b/.babelrc @@ -0,0 +1,16 @@ +{ + "stage": 0, + "plugins": [ + "react-transform" + ], + "extra": { + "react-transform": [{ + "target": "react-transform-hmr", + "imports": ["react"], + "locals": ["module"] + }, { + "target": "react-transform-catch-errors", + "imports": ["react", "redbox-react"] + }] + } +} diff --git a/app/controls/error-panel.js b/app/controls/error-panel.js index db1b75e69..b1436b4ae 100644 --- a/app/controls/error-panel.js +++ b/app/controls/error-panel.js @@ -7,7 +7,12 @@ exports = module.exports = errorPanel function errorPanel (err) { var errorWindow = new BrowserWindow(config.window) - errorWindow.loadUrl('file://' + path.resolve(__dirname, '../views/help.html')) + if (process.env.NODE_ENV === 'production') { + errorWindow.loadUrl('file://' + path.resolve(__dirname, '../help.html')) + } else { + errorWindow.loadUrl('http://localhost:3000/help.html') + } + errorWindow.webContents.on('did-finish-load', function () { errorWindow.webContents.send('err', err.toString()) }) diff --git a/app/controls/open-settings.js b/app/controls/open-settings.js index 5d741f180..12d078efb 100644 --- a/app/controls/open-settings.js +++ b/app/controls/open-settings.js @@ -9,6 +9,10 @@ ipc.on('open-settings', openSettings) function openSettings () { var settingsWindow = new BrowserWindow(config.window) - settingsWindow.loadUrl('file://' + path.resolve(__dirname, '../views/settings.html')) + if (process.env.NODE_ENV === 'production') { + settingsWindow.loadUrl('file://' + path.resolve(__dirname, '../settings.html')) + } else { + settingsWindow.loadUrl('http://localhost:3000/settings.html') + } settingsWindow.webContents.on('did-finish-load', function () {}) } diff --git a/app/init.js b/app/init.js index 3be7e8f64..29d83fcf1 100644 --- a/app/init.js +++ b/app/init.js @@ -3,6 +3,10 @@ var BrowserWindow = require('browser-window') var fs = require('fs') var ipfsd = require('ipfsd-ctl') var ipc = require('ipc') + +require('electron-debug')() +require('crash-reporter').start() + var config = require('./config') var errorPanel = require('./controls/error-panel') @@ -18,12 +22,19 @@ function init () { errorPanel(err) } - var mb = menubar({ + var mbConfig = { dir: __dirname, width: config['menu-bar-width'], - index: 'file://' + __dirname + '/views/menubar.html', - icon: config['tray-icon'] - }) + index: 'http://localhost:3000/menubar.html', + icon: config['tray-icon'], + 'always-on-top': true + } + + if (process.env.NODE_ENV === 'production') { + mbConfig.index = 'file://' + __dirname + '/menubar.html' + } + + var mb = menubar(mbConfig) mb.on('ready', function () { // listen for global shortcuts events @@ -128,7 +139,11 @@ function init () { function initialize (path, node) { var welcomeWindow = new BrowserWindow(config.window) - welcomeWindow.loadUrl('file://' + __dirname + '/views/welcome.html') + if (process.env.NODE_ENV === 'production') { + welcomeWindow.loadUrl('file://' + __dirname + '/welcome.html') + } else { + welcomeWindow.loadUrl('http://localhost:3000/welcome.html') + } welcomeWindow.webContents.on('did-finish-load', function () { ipc.emit('default-directory', path) diff --git a/app/js/help.js b/app/js/help.js index f75300f22..e4b28dc3d 100644 --- a/app/js/help.js +++ b/app/js/help.js @@ -1,10 +1,6 @@ 'use strict' -var ipc = require('ipc') - -// function initialize () { -// ipc.emit('initialize-node') -// } +var ipc = window.require('remote').require('ipc') ipc.on('err', function (err) { if (err) { diff --git a/app/js/menubar-toggle.jsx b/app/js/menubar-toggle.jsx deleted file mode 100644 index a20751ce5..000000000 --- a/app/js/menubar-toggle.jsx +++ /dev/null @@ -1,42 +0,0 @@ -'use strict' - -var React = require('react') -var $ = require('jquery-bf') -require('bootstrap-toggle-bf') - -var Toggle = React.createClass({ - // -- Initialize - - propTypes: { - label: React.PropTypes.string, - toggle: React.PropTypes.func - }, - - componentDidMount: function () { - var self = this - var input = $(React.findDOMNode(this)).find('input') - - input.bootstrapToggle() - - input.change(function () { - self.props.toggle($(this).prop('checked')) - }) - }, - - // -- Render - - render: function () { - return ( -
-
- {this.props.label} -
-
- -
-
- ) - } -}) - -module.exports = Toggle diff --git a/app/js/menubar.jsx b/app/js/menubar.jsx index e784609a9..e492fbfda 100644 --- a/app/js/menubar.jsx +++ b/app/js/menubar.jsx @@ -1,9 +1,10 @@ var React = require('react') -var $ = require('jquery-bf') +var $ = require('jquery') var ipc = window.require('remote').require('ipc') -var Toggle = require('./menubar-toggle.jsx') +var Toggle = require('react-toggle') +require('react-toggle/style.css') var Status = require('./components/status.jsx') var OpenLinks = require('./components/open-links.jsx') var Stats = require('./components/stats.jsx') @@ -77,8 +78,8 @@ var Menu = React.createClass({ // -- Actions - toggleDaemon: function (on) { - if (on) { + toggleDaemon: function ({target: {checked}}) { + if (checked) { ipc.emit('start-daemon') } else { ipc.emit('stop-daemon') @@ -107,13 +108,19 @@ var Menu = React.createClass({ var self = this var image = (this.state.status !== 'running' - ? '../../node_modules/ipfs-logo/ipfs-logo-128-black.png' - : '../../node_modules/ipfs-logo/ipfs-logo-128-ice.png') + ? require('file!../../node_modules/ipfs-logo/ipfs-logo-128-black.png') + : require('file!../../node_modules/ipfs-logo/ipfs-logo-128-ice.png')) var toggles = null if (self.state.status !== 'uninitialized') { - toggles = + toggles = ( + + IPFS Node + + ) } // var uninitialized = (this.state.status === 'uninitialized') @@ -141,7 +148,7 @@ var Menu = React.createClass({