├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Gruntfile.js
├── LICENSE
├── Makefile
├── README.md
├── ROADMAP.md
├── assets
├── OrbitLogo.png
├── OrbitLogo_32x32.png
└── orbit.icns
├── circle.yml
├── config
├── orbit.config.js
└── window.config.js
├── index.js
├── menu-native.js
├── package.json
├── screenshots
├── orbit-electron-screenshot1.png
└── orbit-electron-screenshot2.png
└── scripts
├── create_app_icon.sh
└── create_favicon.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | ### OSX ###
2 | .DS_Store
3 | .AppleDouble
4 | .LSOverride
5 | Icon
6 |
7 | # Thumbnails
8 | ._*
9 |
10 | # Files that might appear on external disk
11 | .Spotlight-V100
12 | .Trashes
13 |
14 | ### Windows ###
15 | # Windows image file caches
16 | Thumbs.db
17 | ehthumbs.db
18 |
19 | # Folder config file
20 | Desktop.ini
21 |
22 | # Recycle Bin used on file shares
23 | $RECYCLE.BIN/
24 |
25 | # App specific
26 | node_modules/
27 | .tmp/
28 | .electron-prebuilt/
29 |
30 | # Build Binaries
31 | bin/
32 |
33 | # Dev data directory
34 | orbit-dev-data/
35 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at [community@orbitdb.org](mailto:community@orbitdb.org), which goes to all members of the @OrbitDB community team, or to [richardlitt@orbitdb.org](mailto:richardlitt@orbitdb.org), which goes only to [@RichardLitt](https://github.com/RichardLitt) or to [haadcode@orbitdb.org](mailto:haadcode@orbitdb.org), which goes only to [@haadcode](https://github.com/haadcode). All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contribute
2 |
3 | Please contribute! Here are some things that would be great:
4 |
5 | - [Open an issue!](https://github.com/orbitdb/orbit-electron/issues/new)
6 | - Open a pull request!
7 | - Say hi! :wave:
8 |
9 | Please note that we have a [Code of Conduct](CODE_OF_CONDUCT.md), and that all activity in the [@OrbitDB](https://github.com/orbitdb) organization falls under it. Read it before you contribute, as being part of this community means that you agree to abide by it. Thanks.
10 |
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const path = require('path')
4 |
5 | module.exports = function (grunt) {
6 | const spawn = require('child_process').spawn
7 | require('load-grunt-tasks')(grunt)
8 | grunt.loadNpmTasks('grunt-contrib-clean')
9 | grunt.loadNpmTasks('grunt-contrib-copy')
10 | grunt.loadNpmTasks('grunt-chmod')
11 |
12 | const skipNpmInstall = process.argv.includes('--cached-modules')
13 | const binDirectory = 'bin/'
14 | const moduleCacheDirectory = '.tmp/'
15 |
16 | grunt.initConfig({
17 | clean: {
18 | cache: moduleCacheDirectory,
19 | bin: binDirectory,
20 | osx: path.join(binDirectory, '/Orbit-darwin-x64'),
21 | linux: path.join(binDirectory, '/Orbit-linux-x64'),
22 | npm: [
23 | 'node_modules/ipfs/node_modules/ipfs-api',
24 | 'node_modules/ipfsd-ctl/node_modules/go-ipfs-dep',
25 | 'node_modules/ipfsd-ctl/node_modules/ipfs-api'
26 | ],
27 | npm_build: [
28 | path.join(moduleCacheDirectory, 'node_modules/ipfs/node_modules/ipfs-api'),
29 | path.join(moduleCacheDirectory, 'node_modules/ipfsd-ctl/node_modules/go-ipfs-dep'),
30 | path.join(moduleCacheDirectory, 'node_modules/uport-registry/node_modules/ipfs-api'),
31 | path.join(moduleCacheDirectory, 'node_modules/ipfs-js/node_modules/ipfs-api'),
32 | path.join(moduleCacheDirectory, 'node_modules/ipfsd-ctl/node_modules/ipfs-api')
33 | ],
34 | electron: [
35 | 'Orbit-darwin-x64/',
36 | 'Orbit-linux-x64/'
37 | ]
38 | },
39 |
40 | electron: {
41 | osxBuild: {
42 | options: {
43 | name: 'Orbit',
44 | dir: moduleCacheDirectory,
45 | out: binDirectory,
46 | platform: 'darwin',
47 | arch: 'x64',
48 | overwrite: true,
49 | icon: 'assets/orbit.icns',
50 | download: {
51 | cache: '.electron-prebuilt'
52 | }
53 | }
54 | },
55 | linuxBuild: {
56 | options: {
57 | name: 'Orbit',
58 | dir: moduleCacheDirectory,
59 | out: binDirectory,
60 | platform: 'linux',
61 | arch: 'x64',
62 | overwrite: true,
63 | icon: 'assets/orbit.icns',
64 | download: {
65 | cache: '.electron-prebuilt'
66 | }
67 | }
68 | }
69 | },
70 |
71 | copy: {
72 | main: {
73 | files: [
74 | {
75 | expand: true,
76 | src: [
77 | "./*.js",
78 | "src/**",
79 | "config/**/*.js",
80 | "./client/dist/**",
81 | "package.json",
82 | "!./Gruntfile.js",
83 | ],
84 | dest: moduleCacheDirectory
85 | }
86 | ]
87 | },
88 | },
89 |
90 | chmod: {
91 | bins: {
92 | options: {
93 | mode: '755'
94 | },
95 | src: [
96 | path.join(moduleCacheDirectory, 'node_modules/subcomandante/subcom'),
97 | path.join(moduleCacheDirectory, 'node_modules/@haad/go-ipfs-dep/go-ipfs/ipfs'),
98 | ]
99 | }
100 | },
101 | })
102 |
103 | grunt.registerTask('npm_install', '', function (os) {
104 | var done = this.async()
105 | var params = ['install', '--production', '--cache-min 9999999']
106 | var npm = spawn('npm', params, { cwd: moduleCacheDirectory, env: process.env })
107 | npm.stdout.pipe(process.stdout)
108 | npm.stderr.pipe(process.stderr)
109 | npm.on('error', (err) => done(false))
110 | npm.on('exit', done)
111 | })
112 |
113 | grunt.registerTask('default', ["build"])
114 | grunt.registerTask('build', ["build_osx", "build_linux"])
115 |
116 | grunt.registerTask('build_osx', function() {
117 | if(!skipNpmInstall)
118 | grunt.task.run('clean:cache')
119 |
120 | grunt.task.run('clean:osx')
121 | grunt.task.run('copy:main')
122 |
123 | if(!skipNpmInstall) {
124 | grunt.task.run('npm_install')
125 | }
126 |
127 | grunt.task.run('clean:npm_build')
128 | grunt.task.run('chmod:bins')
129 | grunt.task.run('electron:osxBuild')
130 | grunt.task.run('clean:electron')
131 | })
132 |
133 | grunt.registerTask('build_linux', function() {
134 | if(!skipNpmInstall)
135 | grunt.task.run('clean:cache')
136 |
137 | grunt.task.run('clean:linux')
138 | grunt.task.run('copy:main')
139 |
140 | if(!skipNpmInstall) {
141 | grunt.task.run('npm_install')
142 | }
143 |
144 | grunt.task.run('clean:npm_build')
145 | grunt.task.run('chmod:bins')
146 | grunt.task.run('electron:linuxBuild')
147 | grunt.task.run('clean:electron')
148 | })
149 |
150 | }
151 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015-2018 Protocol Labs Inc.
4 | Copyright (c) 2018 Haja Networks Oy
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
24 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | all: deps
2 |
3 | deps:
4 | npm install
5 | @echo "Done!"
6 | @echo "Run 'make build' to build orbit-electron app stand-alone binary."
7 | @echo "Run 'npm run dev' to start the app in developer mode."
8 | @echo "Run 'make start' to start the app."
9 |
10 | build: deps
11 | npm run build
12 | @echo "Build success!"
13 | @echo "Build is in 'bin/'"
14 | @echo "Run 'make dist' to build the distribution packages for orbit-electron app."
15 |
16 | start: deps
17 | npm start
18 |
19 | package:
20 | rm -rf bin/dist/
21 | mkdir -p bin/dist/
22 | # Note: This is used by https://github.com/ipfs/distributions/blob/master/site/public/_js/_platform.js#L27
23 | # The naming scheme comes from that.
24 | cd bin/ && tar -zcf dist/orbit_$(shell node -pe "require('./package.json').version")_darwin-amd64.tar.gz Orbit-darwin-x64/
25 | cd bin/ && tar -zcf dist/orbit_$(shell node -pe "require('./package.json').version")_linux-amd64.tar.gz Orbit-linux-x64/
26 | @echo "Distribution packages are in: bin/dist/"
27 |
28 | dist: package
29 | cd bin/dist/ && ipfs add -r .
30 |
31 | clean:
32 | rm -rf bin/
33 | rm -rf node_modules/
34 | rm -rf orbit-dev-data/
35 | rm -rf .tmp/
36 |
37 | .PHONY: start
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # orbit-electron
2 |
3 | [](https://gitter.im/orbitdb/Lobby) [](https://riot.permaweb.io/#/room/#orbitdb:permaweb.io)
4 |
5 | > A distributed, peer-to-peer chat application built on [IPFS](http://ipfs.io)
6 |
7 | Desktop App for [Orbit](https://github.com/orbitdb/orbit).
8 |
9 | *Currently works in OSX and Linux. We're working on Windows support.*
10 |
11 | **NOTE!** *Orbit is still more or less experimental. It means Orbit is currently ***not secure****, APIs will change and builds can break over the coming months. If you come across problems, it would help greatly to open issues so that we can fix them as quickly as possible.*
12 |
13 |
14 |
15 |
16 | Built with:
17 |
18 | - [orbit-web](https://github.com/orbitdb/orbit-web) - UI for the application which can be used as fully working Orbit client in the browser.
19 | - [orbit-core](https://github.com/orbitdb/orbit-core) - Core Orbit communication library.
20 | - [js-ipfs](https://github.com/ipfs/js-ipfs) - IPFS, a new peer-to-peer hypermedia protocol.
21 | - [electron](https://github.com/electron/electron) - Electron
22 |
23 | See also:
24 |
25 | - [orbit-textui](https://github.com/orbitdb/orbit-textui) - Terminal client prototype for Orbit.
26 | - [orbit-db](https://github.com/orbitdb/orbit-db) - Serverless, p2p database that orbit-core uses to store its data.
27 | - [IPFS](https://ipfs.io) - IPFS
28 |
29 | ## Table of Contents
30 |
31 | - [Run](#run)
32 | - [Download Binaries](#download-binaries)
33 | - [Requirements](#requirements)
34 | - [Get the source code](#get-the-source-code)
35 | - [Start the App](#start-the-app)
36 | - [Development](#development)
37 | - [Run](#run)
38 | - [Build](#build)
39 | - [Release](#release)
40 | - [Distributable Packages](#distributable-packages)
41 | - [Contributing](#contributing)
42 | - [License](#license)
43 |
44 | ## Run
45 |
46 | ### Download Binaries
47 |
48 | *Orbit binaries will soon be available from [dist.ipfs.io](https://dist.ipfs.io/). Meanwhile, you'll have to build the application from the source code.*
49 |
50 | ### Requirements
51 | - [Node.js v6.x.x](http://nodejs.org/)
52 | - [npm v3.x.x](https://npmjs.com)
53 | - g++, gcc, make, python 2
54 |
55 | **NOTE:** Orbit requires a newer version of gcc to compile crypto libraries. `gcc 6.2.1` has been tested successfully, `gcc 4.9.2` is known to fail at runtime.
56 |
57 | Standard `gcc` versions for various distros are listed below:
58 | Arch Linux `gcc 6.2.1`
59 | Debian Stretch `gcc 6.2.1`
60 | Debian Jessie `gcc 4.9`
61 | RHEL7 `gcc 4.8`
62 | Ubuntu 16.04 LTS `gcc 5.3+`
63 | OSX Uses `CLANG`, not `gcc`. Verification needed.
64 |
65 | ### Get the source code
66 |
67 | ```
68 | git clone https://github.com/orbitdb/orbit-electron.git
69 | cd orbit-electron/
70 | ```
71 |
72 | ### Start the App
73 |
74 | ```
75 | make start
76 | ```
77 |
78 | or
79 |
80 | ```
81 | npm install
82 | npm start
83 | ```
84 |
85 | ### Development
86 |
87 | ### Run
88 |
89 | *NOTE! Before running this command, make sure you have [orbit-web](https://github.com/orbitdb/orbit-web#run) development server running*
90 |
91 | ```
92 | npm run dev
93 | ```
94 |
95 | ### Build
96 |
97 | #### Release
98 |
99 | ```
100 | make build
101 | ```
102 |
103 | or
104 |
105 | ```
106 | npm run build
107 | ```
108 |
109 | *This will create binaries for OSX and Linux in `bin/`*
110 |
111 | ### Distributable Packages
112 |
113 | ```
114 | make build
115 | make dist
116 | ```
117 |
118 | *This will create `bin/dist/orbit_master_darwin-amd64.tar.gz` and `bin/dist/orbit_master_linux-amd64.tar.gz` and add them to IPFS.*
119 |
120 | Note: electron names the folders after the arch, and uses the `x64` nomenclature instead of `amd64`. They are the same thing; we create tarballs with `amd64` to match the golang distributions on [ipfs/distributions](https://github.com/ipfs/distributions).
121 |
122 | ## Contributing
123 |
124 | If you think this could be better, please [open an issue](https://github.com/orbitdb/orbit-electron/issues/new)!
125 |
126 | Please note that all interactions in [@orbitdb](https://github.com/orbitdb) fall under our [Code of Conduct](CODE_OF_CONDUCT.md).
127 |
128 | ## License
129 |
130 | [MIT](LICENSE) © 2015-2018 Protocol Labs Inc., Haja Networks Oy
131 |
--------------------------------------------------------------------------------
/ROADMAP.md:
--------------------------------------------------------------------------------
1 | # Orbit - Roadmap
2 |
3 | This document describes the current status and the upcoming milestones of the Orbit project.
4 |
5 | *Updated: Wed, 19 Oct 2016 10:13:32 GMT*
6 |
7 | ## Status and Progress
8 |
9 | [](http://waffle.io/haadcode/orbit) [](http://waffle.io/haadcode/orbit) [](http://waffle.io/haadcode/orbit)
10 |
11 | See details of current progress on [Orbit's project board](https://waffle.io/haadcode/orbit)
12 |
13 | #### Milestone Summary
14 |
15 | | Status | Milestone | Goals | ETA |
16 | | :---: | :--- | :---: | :---: |
17 | | 🚀 | **[Improve documentation and developer experience](#improve-documentation-and-developer-experience)** | 12 / 22 | Tue Nov 08 2016 |
18 | | 🚀 | **[Product Design](#product-design)** | 0 / 1 | Tue Nov 15 2016 |
19 | | 🚀 | **[Network Enhancing Bots](#network-enhancing-bots)** | 0 / 2 | Tue Nov 29 2016 |
20 | | 🚀 | **[Web version of Orbit](#web-version-of-orbit)** | 0 / 9 | Tue Dec 13 2016 |
21 | | 🚀 | **[Distribution Builds](#distribution-builds)** | 0 / 10 | Thu Dec 22 2016 |
22 |
23 | ## Milestones and Goals
24 |
25 | #### Improve documentation and developer experience
26 |
27 | > Write better documentation, write more examples, cleanup and refactor code where needed.
28 |
29 | 🚀 **OPEN** 📉 **12 / 22** goals completed **(54%)** 📅 **Tue Nov 08 2016**
30 |
31 | See [milestone goals](https://waffle.io/haadcode/orbit?milestone=Improve%20documentation%20and%20developer%20experience) for the list of goals this milestone has.
32 | #### Product Design
33 |
34 | > Product Design Document for Orbit
35 |
36 | 🚀 **OPEN** 📉 **0 / 1** goals completed **(0%)** 📅 **Tue Nov 15 2016**
37 |
38 | See [milestone goals](https://waffle.io/haadcode/orbit?milestone=Product%20Design) for the list of goals this milestone has.
39 | #### Network Enhancing Bots
40 |
41 | > Orbit network will have bots that enchance the performance and functionality of the chat network.
42 |
43 | 🚀 **OPEN** 📉 **0 / 2** goals completed **(0%)** 📅 **Tue Nov 29 2016**
44 |
45 | See [milestone goals](https://waffle.io/haadcode/orbit?milestone=Network%20Enhancing%20Bots) for the list of goals this milestone has.
46 | #### Web version of Orbit
47 |
48 | > Bring Orbit back to the browser with js-ipfs and release a web client.
49 |
50 | 🚀 **OPEN** 📉 **0 / 9** goals completed **(0%)** 📅 **Tue Dec 13 2016**
51 |
52 | See [milestone goals](https://waffle.io/haadcode/orbit?milestone=Web%20version%20of%20Orbit) for the list of goals this milestone has.
53 | #### Distribution Builds
54 |
55 | > Provide downloadable builds for Orbit
56 |
57 | 🚀 **OPEN** 📉 **0 / 10** goals completed **(0%)** 📅 **Thu Dec 22 2016**
58 |
59 | See [milestone goals](https://waffle.io/haadcode/orbit?milestone=Distribution%20Builds) for the list of goals this milestone has.
60 |
61 |
--------------------------------------------------------------------------------
/assets/OrbitLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orbitdb-archive/orbit-electron/37a53c5396ce0d0aab379ee7692c8e060f56b3b3/assets/OrbitLogo.png
--------------------------------------------------------------------------------
/assets/OrbitLogo_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orbitdb-archive/orbit-electron/37a53c5396ce0d0aab379ee7692c8e060f56b3b3/assets/OrbitLogo_32x32.png
--------------------------------------------------------------------------------
/assets/orbit.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orbitdb-archive/orbit-electron/37a53c5396ce0d0aab379ee7692c8e060f56b3b3/assets/orbit.icns
--------------------------------------------------------------------------------
/circle.yml:
--------------------------------------------------------------------------------
1 | machine:
2 | node:
3 | version: 6.9.0
4 | deployment:
5 | release:
6 | branch: master
7 | owner: haadcode
8 | commands:
9 | - npm run build
10 | - make dist
11 | - ls $CIRCLE_ARTIFACTS
12 | general:
13 | artifacts:
14 | - "bin/dist"
15 |
--------------------------------------------------------------------------------
/config/orbit.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const path = require('path')
4 | const fs = require('fs')
5 | const mkdirp = require('mkdirp')
6 |
7 | // TODO: need to mkdirp the app and logfile directories
8 |
9 | function getLogFilePath(orbitDataDir) {
10 | // Make sure we have the Orbit data directory
11 | if (!fs.existsSync(orbitDataDir))
12 | mkdirp.sync(orbitDataDir)
13 |
14 | return path.join(orbitDataDir, '/debug.log')
15 | }
16 |
17 | function getIpfsDefaultPath(appDataDir) {
18 | return process.env.IPFS_PATH
19 | ? path.resolve(process.env.IPFS_PATH)
20 | : path.join(appDataDir, '/ipfs')
21 | }
22 |
23 | module.exports = function(app) {
24 | const appDataDir = app.getPath('userData')
25 | const MODE = process.env.ENV ? process.env.ENV : 'debug'
26 |
27 | if (!fs.existsSync(appDataDir))
28 | mkdirp.sync(appDataDir)
29 |
30 | const orbitDataDir = (MODE === 'dev')
31 | ? path.join(process.cwd() , '/orbit-dev-data') // put orbit's data to './data' in dev mode
32 | : appDataDir
33 |
34 | const userDownloadPath = path.resolve(app.getPath('downloads'))
35 |
36 | return {
37 | userDownloadPath: userDownloadPath,
38 | appDataDir: appDataDir,
39 | orbitDataDir: orbitDataDir,
40 | logFilePath: getLogFilePath(orbitDataDir),
41 | ipfsDataDir: getIpfsDefaultPath(appDataDir),
42 | MODE: MODE
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/config/window.config.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // Default window settings or electron startup
4 | module.exports = {
5 | connectWindowSize: {
6 | width: 512,
7 | height: 512,
8 | center: true,
9 | resize: false,
10 | webPreferences: {
11 | webSecurity: false,
12 | }
13 | },
14 | mainWindowSize: {
15 | width: 1200,
16 | height: 800,
17 | center: true,
18 | resize: true,
19 | webPreferences: {
20 | webSecurity: false,
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | if(process.env.ENV === 'dev') delete process.versions['electron']
4 |
5 | const electron = require('electron')
6 | const app = electron.app
7 | const BrowserWindow = electron.BrowserWindow
8 | const Menu = electron.Menu
9 | const ipcMain = electron.ipcMain
10 | const dialog = electron.dialog
11 | const fs = require('fs')
12 | const path = require('path')
13 | const Logger = require('logplease')
14 | const IpfsDaemon = require('ipfs-daemon')
15 | const WindowConfig = require('./config/window.config')
16 | const OrbitConfig = require('./config/orbit.config')(app)
17 |
18 | // Hack to fix "error: too open files" in go-ipfs 0.4.5-pre1
19 | process.env.IPFS_FD_MAX = 4096
20 |
21 | // dev|debug
22 | const MODE = OrbitConfig.MODE
23 |
24 | // Setup logging, to turn on the logging, run orbit-electron with LOG=debug
25 | Logger.setLogfile(OrbitConfig.logFilePath)
26 | let logger = Logger.create("orbit-electron", { color: Logger.Colors.Yellow })
27 |
28 | // Menu bar
29 | const template = require('./menu-native')(app)
30 | const menu = Menu.buildFromTemplate(template)
31 |
32 | // IPFS instance
33 | let ipfs
34 |
35 | // The application window
36 | let mainWindow
37 |
38 | const stopIpfs = () => {
39 | if (ipfs) {
40 | // TODO: use promises when available from ipfs-daemon
41 | // ipfs.stop().then(() => ipfs = nul)
42 | ipfs.stop()
43 | ipfs = null
44 | }
45 | }
46 |
47 | // Handle shutdown gracefully
48 | const shutdown = () => {
49 | logger.debug("Closing...")
50 | mainWindow = null
51 | stopIpfs()
52 | setTimeout(() => {
53 | logger.debug("All done!\n")
54 | app.exit(0)
55 | process.exit(0)
56 | }, 1000)
57 | }
58 |
59 | app.on('window-all-closed', shutdown)
60 | app.on('will-quit', (e) => {
61 | e.preventDefault()
62 | shutdown()
63 | })
64 | process.on('SIGINT', () => shutdown())
65 | process.on('SIGTERM', () => shutdown())
66 |
67 | // Log errors
68 | process.on('uncaughtException', (error) => {
69 | // Skip 'ctrl-c' error and shutdown gracefully
70 | const match = String(error).match(/non-zero exit code 255/)
71 | if(match)
72 | shutdown()
73 | else
74 | logger.error(error)
75 | })
76 |
77 | // Window handling
78 | const connectWindowSize = WindowConfig.connectWindowSize
79 | const mainWindowSize = WindowConfig.mainWindowSize
80 |
81 | const setWindowToNormal = () => {
82 | mainWindow.setSize(mainWindowSize.width, mainWindowSize.height)
83 | mainWindow.setResizable(true)
84 | mainWindow.center()
85 | }
86 |
87 | const setWindowToLogin = () => {
88 | mainWindow.setSize(connectWindowSize.width, connectWindowSize.height)
89 | mainWindow.setResizable(false)
90 | mainWindow.center()
91 | }
92 |
93 | const logToRenderer = (source, level, text) => {
94 | if (mainWindow)
95 | mainWindow.webContents.send('log', source, level, text)
96 | }
97 |
98 | // Start
99 | logger.debug("Run index.js in '" + MODE + "' mode")
100 |
101 | app.on('ready', () => {
102 | try {
103 | mainWindow = new BrowserWindow(connectWindowSize)
104 | mainWindow.webContents.session.setDownloadPath(OrbitConfig.userDownloadPath)
105 | Menu.setApplicationMenu(menu)
106 |
107 | // Pass log messages to the renderer process
108 | Logger.events.on('data', logToRenderer)
109 |
110 | // Pass the mode and electron flag to the html (renderer process)
111 | global.DEV = MODE === 'dev'
112 | global.isElectron = true
113 | global.orbitDataDir = OrbitConfig.orbitDataDir
114 | global.ipfsDataDir = OrbitConfig.ipfsDataDir
115 |
116 | // Load the dist build or connect to webpack-dev-server
117 | const indexUrl = MODE === 'dev'
118 | ? 'http://localhost:8000/'
119 | : 'file://' + __dirname + '/node_modules/orbit-web/dist/index.html'
120 |
121 | mainWindow.loadURL(indexUrl)
122 |
123 | // Resize the window as per app state
124 | ipcMain.on('connected', (event) => setWindowToNormal())
125 | ipcMain.on('disconnected', (event) => {
126 | logger.debug("Received 'disconnected' event from renderer process")
127 | stopIpfs()
128 | setWindowToLogin()
129 | })
130 |
131 | // Handle stop daemon event from the renderer process
132 | ipcMain.on('ipfs-daemon-stop', () => {
133 | logger.debug("Received 'ipfs-daemon-stop' event from renderer process")
134 | stopIpfs()
135 | })
136 |
137 | // Handle start daemon event from the renderer process
138 | ipcMain.on('ipfs-daemon-start', (event, ipfsDaemonSettings) => {
139 | logger.debug("Received 'ipfs-daemon-start' event from renderer process")
140 | // Make sure we stop a running daemon if any
141 | stopIpfs()
142 |
143 | // Create IPFS instance
144 | ipfs = new IpfsDaemon(ipfsDaemonSettings)
145 |
146 | // We have a running IPFS daemon
147 | ipfs.on('ready', () => {
148 | // Pass the ipfs (api) instance and gateway address to the renderer process
149 | global.ipfsInstance = ipfs
150 | global.gatewayAddress = ipfs.GatewayAddress || 'http://localhost:8080/'
151 | mainWindow.webContents.send('ipfs-daemon-instance')
152 | })
153 |
154 | // Handle errors
155 | ipfs.on('error', (err) => {
156 | logger.error(err)
157 | mainWindow.webContents.send('error', err)
158 | dialog.showMessageBox({
159 | type: 'error',
160 | buttons: ['Ok'],
161 | title: 'Error',
162 | message: err.message,
163 | }, () => process.exit(1))
164 | })
165 | })
166 | } catch(e) {
167 | logger.error("Error:", e)
168 | }
169 | })
170 |
--------------------------------------------------------------------------------
/menu-native.js:
--------------------------------------------------------------------------------
1 | var getMenu = function(app) {
2 | var template = [
3 | {
4 | label: 'Edit',
5 | submenu: [
6 | {
7 | label: 'Undo',
8 | accelerator: 'CmdOrCtrl+Z',
9 | role: 'undo'
10 | },
11 | {
12 | label: 'Redo',
13 | accelerator: 'Shift+CmdOrCtrl+Z',
14 | role: 'redo'
15 | },
16 | {
17 | type: 'separator'
18 | },
19 | {
20 | label: 'Cut',
21 | accelerator: 'CmdOrCtrl+X',
22 | role: 'cut'
23 | },
24 | {
25 | label: 'Copy',
26 | accelerator: 'CmdOrCtrl+C',
27 | role: 'copy'
28 | },
29 | {
30 | label: 'Paste',
31 | accelerator: 'CmdOrCtrl+V',
32 | role: 'paste'
33 | },
34 | {
35 | label: 'Select All',
36 | accelerator: 'CmdOrCtrl+A',
37 | role: 'selectall'
38 | },
39 | ]
40 | },
41 | {
42 | label: 'View',
43 | submenu: [
44 | {
45 | label: 'Reload',
46 | accelerator: 'CmdOrCtrl+R',
47 | click: function(item, focusedWindow) {
48 | if (focusedWindow)
49 | focusedWindow.reload();
50 | }
51 | },
52 | {
53 | label: 'Zoom In',
54 | accelerator: 'CmdOrCtrl+Plus',
55 | role: 'zoomin'
56 | },
57 | {
58 | label: 'Zoom Out',
59 | accelerator: 'CmdOrCtrl+-',
60 | role: 'zoomout'
61 | },
62 | {
63 | label: 'Toggle Full Screen',
64 | accelerator: (function() {
65 | if (process.platform == 'darwin')
66 | return 'Ctrl+Command+F';
67 | else
68 | return 'F11';
69 | })(),
70 | click: function(item, focusedWindow) {
71 | if (focusedWindow)
72 | focusedWindow.setFullScreen(!focusedWindow.isFullScreen());
73 | }
74 | },
75 | {
76 | label: 'Toggle Developer Tools',
77 | accelerator: (function() {
78 | if (process.platform == 'darwin')
79 | return 'Alt+Command+I';
80 | else
81 | return 'Ctrl+Shift+I';
82 | })(),
83 | click: function(item, focusedWindow) {
84 | if (focusedWindow)
85 | focusedWindow.toggleDevTools();
86 | }
87 | },
88 | ]
89 | },
90 | {
91 | label: 'Window',
92 | role: 'window',
93 | submenu: [
94 | {
95 | label: 'Minimize',
96 | accelerator: 'CmdOrCtrl+M',
97 | role: 'minimize'
98 | },
99 | {
100 | label: 'Close',
101 | accelerator: 'CmdOrCtrl+W',
102 | role: 'close'
103 | },
104 | ]
105 | },
106 | // {
107 | // label: 'Help',
108 | // role: 'help',
109 | // submenu: [
110 | // {
111 | // label: 'Learn More',
112 | // click: function() { require('shell').openExternal('http://electron.atom.io') }
113 | // },
114 | // ]
115 | // },
116 | ];
117 |
118 | if (process.platform == 'darwin') {
119 | var name = require('electron').app.getName();
120 | template.unshift({
121 | label: name,
122 | submenu: [
123 | // {
124 | // label: 'About ' + name,
125 | // role: 'about'
126 | // },
127 | // {
128 | // type: 'separator'
129 | // },
130 | // {
131 | // label: 'Services',
132 | // role: 'services',
133 | // submenu: []
134 | // },
135 | // {
136 | // type: 'separator'
137 | // },
138 | // {
139 | // label: 'Hide ' + name,
140 | // accelerator: 'Command+H',
141 | // role: 'hide'
142 | // },
143 | // {
144 | // label: 'Hide Others',
145 | // accelerator: 'Command+Shift+H',
146 | // role: 'hideothers'
147 | // },
148 | // {
149 | // label: 'Show All',
150 | // role: 'unhide'
151 | // },
152 | // {
153 | // type: 'separator'
154 | // },
155 | {
156 | label: 'Quit',
157 | accelerator: 'Command+Q',
158 | click: function() { app.quit(); }
159 | },
160 | ]
161 | });
162 | // Window menu.
163 | // template[3].submenu.push(
164 | // {
165 | // type: 'separator'
166 | // },
167 | // {
168 | // label: 'Bring All to Front',
169 | // role: 'front'
170 | // }
171 | // );
172 | }
173 |
174 | return template;
175 | };
176 |
177 | module.exports = getMenu;
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "orbit-electron",
3 | "private": true,
4 | "version": "0.1.0",
5 | "description": "Orbit Desktop App",
6 | "author": "Haad",
7 | "contributors":[
8 | "haadcode",
9 | "RichardLitt",
10 | "adam-palazzo"
11 | ],
12 | "license": "MIT",
13 | "main": "index.js",
14 | "repository": {
15 | "type": "git",
16 | "url": "https://github.com/orbitdb/orbit-electron/orbit.git"
17 | },
18 | "bugs": {
19 | "url": "https://github.com/orbitdb/orbit-electron/issues"
20 | },
21 | "homepage": {
22 | "url": "https://github.com/orbitdb/orbit-electron/"
23 | },
24 | "readme": "README.md",
25 | "dependencies": {
26 | "ipfs-daemon": "^0.3.0-beta.18",
27 | "logplease": "^1.2.12",
28 | "orbit-web": "^0.0.6"
29 | },
30 | "devDependencies": {
31 | "electron": "^1.5.0",
32 | "grunt": "^1.0.1",
33 | "grunt-chmod": "^1.1.1",
34 | "grunt-contrib-clean": "^1.0.0",
35 | "grunt-contrib-copy": "^1.0.0",
36 | "grunt-electron": "^5.0.0",
37 | "load-grunt-tasks": "^3.5.2"
38 | },
39 | "scripts": {
40 | "test": "echo \"Error: no test specified\" && exit 1",
41 | "build": "npm run build:osx && npm run build:linux",
42 | "build:osx": "TARGET_OS=darwin $(npm bin)/grunt build_osx",
43 | "build:linux": "TARGET_OS=linux $(npm bin)/grunt build_linux",
44 | "dev": "LOG=debug IPFS_FD_MAX=4096 ENV=dev API_ORIGIN=* $(npm bin)/electron .",
45 | "start": "npm run electron",
46 | "electron": "LOG=debug IPFS_FD_MAX=4096 $(npm bin)/electron .",
47 | "publish": "npm run dist && cd bin/ && ipfs add -r dist/ && cd .."
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/screenshots/orbit-electron-screenshot1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orbitdb-archive/orbit-electron/37a53c5396ce0d0aab379ee7692c8e060f56b3b3/screenshots/orbit-electron-screenshot1.png
--------------------------------------------------------------------------------
/screenshots/orbit-electron-screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/orbitdb-archive/orbit-electron/37a53c5396ce0d0aab379ee7692c8e060f56b3b3/screenshots/orbit-electron-screenshot2.png
--------------------------------------------------------------------------------
/scripts/create_app_icon.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | mkdir .tmp/atom.iconset
3 | sips -z 16 16 assets/OrbitLogo.png --out .tmp/atom.iconset/icon_16x16.png
4 | sips -z 32 32 assets/OrbitLogo.png --out .tmp/atom.iconset/icon_16x16@2x.png
5 | sips -z 32 32 assets/OrbitLogo.png --out .tmp/atom.iconset/icon_32x32.png
6 | sips -z 64 64 assets/OrbitLogo.png --out .tmp/atom.iconset/icon_32x32@2x.png
7 | sips -z 128 128 assets/OrbitLogo.png --out .tmp/atom.iconset/icon_128x128.png
8 | sips -z 256 256 assets/OrbitLogo.png --out .tmp/atom.iconset/icon_128x128@2x.png
9 | sips -z 256 256 assets/OrbitLogo.png --out .tmp/atom.iconset/icon_256x256.png
10 | sips -z 512 512 assets/OrbitLogo.png --out .tmp/atom.iconset/icon_256x256@2x.png
11 | sips -z 512 512 assets/OrbitLogo.png --out .tmp/atom.iconset/icon_512x512.png
12 | cp assets/OrbitLogo.png .tmp/atom.iconset/icon_512x512@2x.png
13 | iconutil -c icns .tmp/atom.iconset
14 | cp .tmp/atom.icns assets/orbit.icns
15 |
--------------------------------------------------------------------------------
/scripts/create_favicon.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | convert assets/OrbitLogo_32x32.png client/src/favicon.ico
--------------------------------------------------------------------------------