Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Hot reloading and redesign #43

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ff62659
Update dependencies
dignifiedquire Sep 19, 2015
093764c
Add travis
dignifiedquire Sep 19, 2015
7eef78d
New build system with hot reloading and babel
dignifiedquire Sep 19, 2015
8da10e4
Start refactoring of views
dignifiedquire Sep 20, 2015
daae181
Fix hot reloading
dignifiedquire Sep 20, 2015
9b314f5
Pretty new start screen
dignifiedquire Sep 20, 2015
fa677b3
Make start button do work
dignifiedquire Sep 21, 2015
a454d13
Start work on profile screen
dignifiedquire Sep 21, 2015
8708ec3
Add simple-stat component
dignifiedquire Sep 21, 2015
8322a2d
Add loader component
dignifiedquire Sep 21, 2015
6a0341d
Tweak window settings
dignifiedquire Sep 21, 2015
a517486
Setup fade transitions
dignifiedquire Sep 22, 2015
2c551e7
Update and clean dependencies
dignifiedquire Sep 22, 2015
0249bbf
Add action buttons with icons to the profile screen
dignifiedquire Sep 22, 2015
4e6c20e
ES201xify controls and use safe-ipc
dignifiedquire Sep 22, 2015
c317a40
Add location display
dignifiedquire Sep 22, 2015
df3028f
Refactor main process code
dignifiedquire Sep 22, 2015
b1d3b37
Remove unused dependency open
dignifiedquire Sep 22, 2015
9c1cc52
misc
dignifiedquire Sep 22, 2015
38a461f
Cleanup dependencies
dignifiedquire Sep 26, 2015
6fa46eb
Updated react-transform config
dignifiedquire Sep 26, 2015
dc9a095
Extract window urls into config
dignifiedquire Sep 26, 2015
08c8de0
More es201x
dignifiedquire Sep 26, 2015
0e162c1
Ignore npm log
dignifiedquire Sep 26, 2015
9d13988
Start work on new welcome screen
dignifiedquire Sep 26, 2015
2ec3391
Improve welcome dialog with a select dir dialog
dignifiedquire Sep 26, 2015
13ef8fd
More work on welcome
dignifiedquire Oct 2, 2015
dd99729
Auto start daemon
dignifiedquire Oct 2, 2015
36af49d
Update dependencies
dignifiedquire Oct 2, 2015
e6799e1
[setup] Add key selection dropdown
dignifiedquire Oct 2, 2015
f0d8c75
Fixes
dignifiedquire Oct 2, 2015
48a4895
[setup] Show and hide options
dignifiedquire Oct 2, 2015
99c181d
Drop silent-chromium as electron now is silent by default
dignifiedquire Oct 6, 2015
c4a35c3
Fix file uploading
dignifiedquire Oct 6, 2015
1ebbd69
Add system notifications for file uploading
dignifiedquire Oct 6, 2015
d95fa77
Add file uploading to main window
dignifiedquire Oct 6, 2015
72cae21
Always be on top
dignifiedquire Oct 6, 2015
3fcca21
Do not show settings for now
dignifiedquire Oct 6, 2015
4a4a8b9
Fix and improve profile buttons
dignifiedquire Oct 6, 2015
04668bc
Cleanup and proper logging
dignifiedquire Oct 6, 2015
4886473
Remove jsxstyle
dignifiedquire Oct 6, 2015
d253ddf
Fix header
dignifiedquire Oct 6, 2015
0abdcd3
Remove unused files
dignifiedquire Oct 6, 2015
54365a9
Remove unused view
dignifiedquire Oct 6, 2015
33f2977
Fixes for start:production
dignifiedquire Oct 6, 2015
949c5ee
Properly handle application quit.
dignifiedquire Oct 7, 2015
9befeda
Fix shutdown when the daemon is stopped
dignifiedquire Oct 7, 2015
14e0918
docs: Start improving the readme documentation
dignifiedquire Oct 7, 2015
09593b2
docs: Drop unused badges
dignifiedquire Oct 7, 2015
f34f203
fix: Rename Quit to Stop
dignifiedquire Oct 7, 2015
f8571b3
refactor: Start work on the welcome screen
dignifiedquire Oct 7, 2015
7711a10
feat: Setup screen is nearly ready
dignifiedquire Oct 7, 2015
beab2d6
feat: Add key size option to advanced setup
dignifiedquire Oct 7, 2015
75101f7
Upgrade to react@0.14
dignifiedquire Oct 11, 2015
3945797
Integrate ipfs logo into the header
dignifiedquire Oct 11, 2015
63aa734
Cleanup settings
dignifiedquire Oct 11, 2015
6b0ca37
Cleanup and reorganise components.
dignifiedquire Oct 11, 2015
1ff9bd8
Update travis config
dignifiedquire Oct 11, 2015
ecb013f
Make packaging work
dignifiedquire Oct 11, 2015
3483763
Try to fix travis
dignifiedquire Oct 12, 2015
e4d5320
packaging: Add app-version number
dignifiedquire Oct 12, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"stage": 0,
"env": {
"production": {
"optional": [
"utility.inlineEnvironmentVariables",
"optimisation"
]
},
"development": {
"plugins": [
"react-transform"
],
"extra": {
"react-transform": {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}, {
"transform": "react-transform-catch-errors",
"imports": ["react", "redbox-react"]
}]
}
}
}
}
}
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
release
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["standard", "standard-react"],
"parser": "babel-eslint"
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
debug.log
node_modules
build
dist
release
npm-debug.log
app.log
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
sudo: false
language: node_js
node_js:
- "4.0"

# Make sure we have a new npm@3
before_install:
- npm install -g npm
- npm config set loglevel warn

script:
- npm run lint
- NODE_ENV=production npm run build
63 changes: 26 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,46 @@
IPFS Native Application
=======================
# 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) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/ipfs/electron-app)

> A Native Application for your OS to run your own IPFS Node. Built with Electron Shell
[![Build Status](https://img.shields.io/travis/ipfs/electron-app/master.svg?style=flat-square)](https://travis-ci.org/ipfs/electron-app) [![Dependency Status](https://img.shields.io/david/ipfs/electron-app.svg?style=flat-square)](https://david-dm.org/ipfs/electron-app) [![devDependency Status](https://img.shields.io/david/dev/ipfs/electron-app.svg?style=flat-square)](https://david-dm.org/ipfs/electron-app#info=devDependencies)

## folder structure
> A Native Application for your OS to run your own IPFS Node. Built with [Electron](http://electron.atom.io/).

```bash
$ tree app
app
├── controls # Application controls to interact with the system
├── img
│   ├── loading.gif
│   └── logo.png
├── init.js
├── js # React/Frontend components
│   ├── help.js
│   ├── menubar.jsx # React view for all the things menu bar
│   ├── toggle.jsx
│   └── welcome.jsx # React component for the welcoming screen for 1st time users
├── styles
│   ├── common.css
│   └── menu.css
└── views
├── help.html
├── menubar.html
└── welcome.html
```
## Development

## Setup

# usage
You will need [Node.js](https://nodejs.org/en/) installed. Preferrably a version `>=4.0`. Also you will need [npm](npmjs.org). After that you should run

```bash
$ npm i
$ git clone git@github.com:ipfs/electron-app.git
$ cd electron-app
$ npm install
$ npm start
```

This launches the app and runs it in your menu bar. Click the IPFS icon to open a console. For example (in OSX):

![](https://ipfs.io/ipfs/QmU5AghSAezpYFNyuYZ7gX1zcHCheQndPtBMj1MHr5QpWL/cap.png)
![](https://ipfs.io/ipfs/QmaufMhYVWPKwhC1jSb4qHBxgiahrq9ct2hgqk5cZxeE7s)

# packaging

will be written to ./dist

### make a package for your system
## Tasks

```bash
npm run dist
$ npm run clean # Clean the build directory
$ npm run start # Start a development instance
$ npm run lint # Run linting on all files
$ npm run dist # Create a package for the current platform
$ npm run dist-all # Create a package for all platforms
$ npm run start:prod # Start a packaged instance
```

### make packages for all platforms
## Packaging

Th output will be written to the `dist` folder.

```bash
npm run dist-all
# Package for your current platform
$ npm run dist
# Package for all platforms
$ npm run dist-all
```
102 changes: 73 additions & 29 deletions app/config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,75 @@
var path = require('path')
var os = require('os')
var fs = require('fs')
var app = require('app')

var IPFS_PATH_FILE = app.getDataPath() + '/ipfs-electron-app-node-path'

exports = module.exports = {
'menu-bar-width': 240,
window: {
icon: path.resolve(__dirname, '../node_modules/ipfs-logo/ipfs-logo-256-ice.png'),
'auto-hide-menu-bar': true,
width: 800,
height: 600
},
'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')),
import path from 'path'
import os from 'os'
import fs from 'fs'

const app = require('app')

const isProduction = process.env.NODE_ENV === 'production'
const IPFS_PATH_FILE = app.getDataPath() + '/ipfs-electron-app-node-path'

const trayIcon = () => {
if (os.platform() !== 'darwin') {
return path.resolve(__dirname, '../node_modules/ipfs-logo/ipfs-logo-256-ice.png')
}

return path.resolve(__dirname, '../node_modules/ipfs-logo/platform-icons/osx-menu-bar.png')
}

const menuBar = {
dir: __dirname,
width: 300,
height: 400,
index: isProduction
? `file://${__dirname}/menubar.html`
: 'http://localhost:3000/menubar.html',
icon: trayIcon(),
'always-on-top': true,
preloadWindow: true,
resizable: false,
'web-preferences': {
'web-security': false
}
}

const window = {
icon: path.resolve(__dirname, '../node_modules/ipfs-logo/ipfs-logo-256-ice.png'),
'auto-hide-menu-bar': true,
width: 800,
height: 500,
'web-preferences': {
'web-security': false
}
}

const ipfsPath = () => {
let pathIPFS
try {
pathIPFS = fs.readFileSync(IPFS_PATH_FILE, 'utf-8')
} catch (e) {
pathIPFS = process.env.IPFS_PATH ||
(process.env.HOME || process.env.USERPROFILE) + '/.ipfs'
}

return pathIPFS
}

// -- Window URLs

const fileURL = name => `file://${__dirname}/${name}.html`
const serverURL = name => `http://localhost:3000/${name}.html`

const currentURL = name => isProduction ? fileURL(name) : serverURL(name)

export default {
menuBar,
window,
isProduction,
'tray-icon': trayIcon(),
'webui-path': '/webui',
'ipfs-path': (function () {
var pathIPFS
try {
pathIPFS = fs.readFileSync(IPFS_PATH_FILE, 'utf-8')
} catch (e) {
pathIPFS = process.env.IPFS_PATH ||
(process.env.HOME || process.env.USERPROFILE) + '/.ipfs'
}
return pathIPFS
})(),
'ipfs-path-file': IPFS_PATH_FILE
'ipfs-path': ipfsPath(),
'ipfs-path-file': IPFS_PATH_FILE,
urls: {
welcome: currentURL('welcome'),
settings: currentURL('settings')
}
}
12 changes: 0 additions & 12 deletions app/controls/alt-menu.js

This file was deleted.

70 changes: 45 additions & 25 deletions app/controls/drag-drop.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,61 @@
var init = require('./../init')
var ipfsAPI = require('ipfs-api')('localhost', '5001')
var clipboard = require('clipboard')
var path = require('path')
var shell = require('shell')
import API from 'ipfs-api'
import notifier from 'node-notifier'
import {join} from 'path'
import {getIPFS, logger} from './../init'

var ipc = require('ipc')
const ipfsAPI = API('localhost', '5001')

exports = module.exports = dragDrop
const clipboard = require('clipboard')

// TODO persist this to disk
var filesUploaded = []
const iconPath = join(__dirname, '..', '..', 'node_modules', 'ipfs-logo', 'platform-icons/osx-menu-bar@2x.png')

function dragDrop (event, fileArray) {
if (!init.getIPFS()) {
// TODO show an error to the user
return console.error(new Error('Can\'t upload file, IPFS Node is off'))
}
// TODO persist this to disk
const filesUploaded = []

function notify (title, message) {
notifier.notify({
title,
message,
icon: iconPath,
sound: true,
wait: false
})
}

fileArray.forEach(function (file) {
console.log('uploading ->', path.basename(file))
ipc.emit('uploading', {Name: path.basename(file)})
function notifyError (message) {
notifier.notify({
title: 'Error in file upload',
message,
icon: iconPath,
sound: true,
wait: false
})
}

ipfsAPI.add(fileArray, function (err, res) {
export default function dragDrop (event, files) {
if (!getIPFS()) {
notifyError('Can\'t upload file, IPFS Node is offline')
return
}
ipfsAPI.add(files, (err, res) => {
if (err || !res) {
return console.error(err)
logger.error(err)
notifyError(err || 'Failed to upload files')
}

res.forEach(function (file) {
clipboard.writeText('http://gateway.ipfs.io/ipfs/' + file.Hash)
logger.info('Uploading files', {files})

res.forEach(file => {
const url = `https://ipfs.io/ipfs/${file.Hash}`
clipboard.writeText(url)
filesUploaded.push(file)
ipc.emit('uploaded', file)

shell.beep()
logger.info('Uploaded file %s', file.Name)

console.log(file.Hash)
console.log(file.Name)
notify(
`Finished uploading ${file.Name}`,
`${file.Name} was uploaded to ${url}.`
)
})
})
}
14 changes: 0 additions & 14 deletions app/controls/error-panel.js

This file was deleted.

19 changes: 10 additions & 9 deletions app/controls/open-browser.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
var ipc = require('ipc')
var apiAddrToUrl = require('./utils').apiAddrToUrl
var init = require('./../init')
var open = require('open')
import ipc from 'electron-safe-ipc/host'
import {apiAddrToUrl} from './utils'
import {getIPFS} from './../init'

ipc.on('open-browser', openBrowser)
const shell = require('shell')

function openBrowser (cb) {
if (init.getIPFS()) {
init.getIPFS().config.get('Addresses.API', function (err, res) {
if (getIPFS()) {
getIPFS().config.get('Addresses.API', (err, res) => {
if (err) { // TODO error should be emited to a error panel
return console.error(err)
}

open(apiAddrToUrl(res.Value))
shell.openExternal(apiAddrToUrl(res.Value))
})
} else {
// TODO error should be emited to a error panel
var err = new Error('Cannot open browser, IPFS daemon not running')
const err = new Error('Cannot open browser, IPFS daemon not running')
console.error(err)
}
}

ipc.on('open-browser', openBrowser)
Loading