Skip to content

Commit 59ca74c

Browse files
committed
Setting up the scaffolding to build a cross platform desktop app with electron and w2ui.
1 parent 97b83ad commit 59ca74c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+7178
-589
lines changed

.gitignore

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
*.dmp
2-
3-
### Windows ###
4-
# Windows image file caches
1+
node_modules
2+
*.log
3+
.DS_Store
54
Thumbs.db
6-
ehthumbs.db
7-
5+
/.vscode/
6+
/build/
7+
/releases/
8+
/tmp/

DriveShare_GUI.py

-126
This file was deleted.

LICENSE

-21
This file was deleted.

README.md

+140-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,142 @@
1-
driveshare-gui
1+
electron-boilerplate
22
==============
3+
Comprehensive boilerplate application for [Electron](http://electron.atom.io).
34

4-
This code provides for the GUI of the [DriveShare application](https://github.com/Storj/DriveShare). It is written in Python using the Kivy interface.
5+
This project gives you mainly three things:
6+
7+
1. Cross-platform development environment (works the same way on OSX, Windows and Linux).
8+
2. Basic structure for Electron app.
9+
3. Scripts to generate installers of your app for all three operating systems.
10+
11+
By the way, there is a twin project to this one: [nw-boilerplate](https://github.com/szwacz/nw-boilerplate), which is the same thing but for NW.js.
12+
13+
# Quick start
14+
The only development dependency of this project is [Node.js](https://nodejs.org). So just make sure you have it installed.
15+
Then type few commands known to every Node developer...
16+
```
17+
git clone https://github.com/szwacz/electron-boilerplate.git
18+
cd electron-boilerplate
19+
npm install
20+
npm start
21+
```
22+
... and boom! You have running desktop application on your screen.
23+
24+
# Structure of the project
25+
26+
There are **two** `package.json` files:
27+
28+
#### 1. For development
29+
Sits on path: `electron-boilerplate/package.json`. Here you declare dependencies for your development environment and build scripts. **This file is not distributed with real application!**
30+
31+
Also here you declare the version of Electron runtime you want to use:
32+
```json
33+
"devDependencies": {
34+
"electron-prebuilt": "^0.24.0"
35+
}
36+
```
37+
38+
#### 2. For your application
39+
Sits on path: `electron-boilerplate/app/package.json`. This is **real** manifest of your application. Declare your app dependencies here.
40+
41+
### Project's folders
42+
43+
- `app` - code of your application goes here.
44+
- `config` - place for you to declare environment specific stuff.
45+
- `build` - in this folder lands built, runnable application.
46+
- `releases` - ready for distribution installers will land here.
47+
- `resources` - resources for particular operating system.
48+
- `tasks` - build and development environment scripts.
49+
50+
51+
# Development
52+
53+
#### Installation
54+
55+
```
56+
npm install
57+
```
58+
It will also download Electron runtime, and install dependencies for second `package.json` file inside `app` folder.
59+
60+
#### Starting the app
61+
62+
```
63+
npm start
64+
```
65+
66+
#### Adding pure-js npm modules to your app
67+
68+
Remember to add your dependency to `app/package.json` file, so do:
69+
```
70+
cd app
71+
npm install name_of_npm_module --save
72+
```
73+
74+
#### Adding native npm modules to your app
75+
76+
If you want to install native module you need to compile it agains Electron, not Node.js you are firing in command line by typing `npm install` [(Read more)](https://github.com/atom/electron/blob/master/docs/tutorial/using-native-node-modules.md).
77+
```
78+
npm run app-install -- name_of_npm_module
79+
```
80+
Of course this method works also for pure-js modules, so you can use it all the time if you're able to remember such an ugly command.
81+
82+
#### Module loader
83+
84+
How about splitting your JavaScript code into modules? This project supports it by new ES6 syntax (thanks to [babel](https://babeljs.io/)). ES6 modules are translated into AMD (RequireJS) modules. The main advantage of this setup is that you can use ES6 -> RequireJS for your own modules, and at the same time have normal access to node's `require()` to obtain stuff from npm.
85+
```javascript
86+
// Modules you write are required through new ES6 syntax
87+
// (It will be translated into AMD definition).
88+
import myOwnModule from './my_own_module';
89+
// Node.js (npm) modules are required the same way as always
90+
// (so you can still access all the goodness of npm).
91+
var moment = require('moment');
92+
```
93+
94+
#### Unit tests
95+
96+
electron-boilerplate has preconfigured [jasmine](http://jasmine.github.io/2.0/introduction.html) unit test runner. To run it go with standard:
97+
```
98+
npm test
99+
```
100+
You don't have to declare paths to spec files in any particular place. The runner will search through the project for all `*.spec.js` files and include them automatically.
101+
102+
103+
# Making a release
104+
105+
**Note:** There are various icon and bitmap files in `resources` directory. Those are used in installers and are intended to be replaced by your own graphics.
106+
107+
To make ready for distribution installer use command:
108+
```
109+
npm run release
110+
```
111+
It will start the packaging process for operating system you are running this command on. Ready for distribution file will be outputted to `releases` directory.
112+
113+
You can create Windows installer only when running on Windows, the same is true for Linux and OSX. So to generate all three installers you need all three operating systems.
114+
115+
116+
## Special precautions for Windows
117+
As installer [NSIS](http://nsis.sourceforge.net/Main_Page) is used. You have to install it (version 3.0), and add NSIS folder to PATH in Environment Variables, so it is reachable to scripts in this project (path should look something like `C:/Program Files (x86)/NSIS`).
118+
119+
120+
# License
121+
122+
The MIT License (MIT)
123+
124+
Copyright (c) 2015 Jakub Szwacz
125+
126+
Permission is hereby granted, free of charge, to any person obtaining a copy
127+
of this software and associated documentation files (the "Software"), to deal
128+
in the Software without restriction, including without limitation the rights
129+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
130+
copies of the Software, and to permit persons to whom the Software is
131+
furnished to do so, subject to the following conditions:
132+
133+
The above copyright notice and this permission notice shall be included in all
134+
copies or substantial portions of the Software.
135+
136+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
137+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
138+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
139+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
140+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
141+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
142+
SOFTWARE.

app/app.html

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Electron Boilerplate</title>
6+
7+
<link href="./stylesheets/main.css" rel="stylesheet" type="text/css">
8+
<link href="./lib/w2ui-1.4.3.min.css" rel="stylesheet" type="text/css">
9+
10+
<script src="lib/electron_boilerplate/env_config.js"></script>
11+
<script src="lib/electron_boilerplate/context_menu.js"></script>
12+
<script src="lib/electron_boilerplate/external_links.js"></script>
13+
14+
<script type="text/javascript" src="lib/jquery-1.11.3.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
15+
<script src="lib/w2ui-1.4.3.min.js"></script>
16+
17+
<script src="lib/require.js"></script>
18+
<script>
19+
requirejs(['app'], function (app) {});
20+
</script>
21+
22+
</head>
23+
<body>
24+
25+
<div class="container">
26+
<h1 id="greet"></h1>
27+
<p class="subtitle">
28+
Welcome to <a href="http://electron.atom.io" class="js-external-link">Electron</a> app running on this magnificent <strong id="platform-info"></strong> machine.
29+
</p>
30+
<p class="subtitle">
31+
You are in <strong id="env-name"></strong> environment.
32+
</p>
33+
</div>
34+
<div id="grid-container" style="height: 100%"></div>
35+
</body>
36+
<script>
37+
$('#grid-container').w2grid({
38+
name : 'grid',
39+
height : '100%',
40+
columns: [
41+
{ field: 'fpath', caption: 'Folder Path', size: '70%' },
42+
{ field: 'fsize', caption: 'Allocated Size', size: '15%' },
43+
{ field: 'fstatus', caption: 'Status', size: '15%' },
44+
],
45+
records: [
46+
{ recid: 1, fsize: 'Test', fsize: '##MB', fstatus: 'Ready'}
47+
]
48+
});
49+
</script>
50+
</html>

app/app.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// -----------------------------------------------------
2+
// Here is the starting point for your own code.
3+
// All stuff below is just to show you how it works.
4+
// -----------------------------------------------------
5+
6+
// Node modules are required the same way as always.
7+
var os = require('os');
8+
9+
// window.env contains data from config/env_XXX.json file.
10+
var envName = window.env.name;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)