Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Setting up the scaffolding to build a cross platform desktop app with…
Browse files Browse the repository at this point in the history
… electron and w2ui.
  • Loading branch information
gamedevsam committed Sep 17, 2015
1 parent 97b83ad commit 59ca74c
Show file tree
Hide file tree
Showing 77 changed files with 7,178 additions and 589 deletions.
13 changes: 7 additions & 6 deletions .gitignore
@@ -1,7 +1,8 @@
*.dmp

### Windows ###
# Windows image file caches
node_modules
*.log
.DS_Store
Thumbs.db
ehthumbs.db

/.vscode/
/build/
/releases/
/tmp/
126 changes: 0 additions & 126 deletions DriveShare_GUI.py

This file was deleted.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

142 changes: 140 additions & 2 deletions README.md
@@ -1,4 +1,142 @@
driveshare-gui
electron-boilerplate
==============
Comprehensive boilerplate application for [Electron](http://electron.atom.io).

This code provides for the GUI of the [DriveShare application](https://github.com/Storj/DriveShare). It is written in Python using the Kivy interface.
This project gives you mainly three things:

1. Cross-platform development environment (works the same way on OSX, Windows and Linux).
2. Basic structure for Electron app.
3. Scripts to generate installers of your app for all three operating systems.

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.

# Quick start
The only development dependency of this project is [Node.js](https://nodejs.org). So just make sure you have it installed.
Then type few commands known to every Node developer...
```
git clone https://github.com/szwacz/electron-boilerplate.git
cd electron-boilerplate
npm install
npm start
```
... and boom! You have running desktop application on your screen.

# Structure of the project

There are **two** `package.json` files:

#### 1. For development
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!**

Also here you declare the version of Electron runtime you want to use:
```json
"devDependencies": {
"electron-prebuilt": "^0.24.0"
}
```

#### 2. For your application
Sits on path: `electron-boilerplate/app/package.json`. This is **real** manifest of your application. Declare your app dependencies here.

### Project's folders

- `app` - code of your application goes here.
- `config` - place for you to declare environment specific stuff.
- `build` - in this folder lands built, runnable application.
- `releases` - ready for distribution installers will land here.
- `resources` - resources for particular operating system.
- `tasks` - build and development environment scripts.


# Development

#### Installation

```
npm install
```
It will also download Electron runtime, and install dependencies for second `package.json` file inside `app` folder.

#### Starting the app

```
npm start
```

#### Adding pure-js npm modules to your app

Remember to add your dependency to `app/package.json` file, so do:
```
cd app
npm install name_of_npm_module --save
```

#### Adding native npm modules to your app

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).
```
npm run app-install -- name_of_npm_module
```
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.

#### Module loader

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.
```javascript
// Modules you write are required through new ES6 syntax
// (It will be translated into AMD definition).
import myOwnModule from './my_own_module';
// Node.js (npm) modules are required the same way as always
// (so you can still access all the goodness of npm).
var moment = require('moment');
```

#### Unit tests

electron-boilerplate has preconfigured [jasmine](http://jasmine.github.io/2.0/introduction.html) unit test runner. To run it go with standard:
```
npm test
```
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.


# Making a release

**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.

To make ready for distribution installer use command:
```
npm run release
```
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.

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.


## Special precautions for Windows
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`).


# License

The MIT License (MIT)

Copyright (c) 2015 Jakub Szwacz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
50 changes: 50 additions & 0 deletions app/app.html
@@ -0,0 +1,50 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Electron Boilerplate</title>

<link href="./stylesheets/main.css" rel="stylesheet" type="text/css">
<link href="./lib/w2ui-1.4.3.min.css" rel="stylesheet" type="text/css">

<script src="lib/electron_boilerplate/env_config.js"></script>
<script src="lib/electron_boilerplate/context_menu.js"></script>
<script src="lib/electron_boilerplate/external_links.js"></script>

<script type="text/javascript" src="lib/jquery-1.11.3.min.js" onload="window.$ = window.jQuery = module.exports;"></script>
<script src="lib/w2ui-1.4.3.min.js"></script>

<script src="lib/require.js"></script>
<script>
requirejs(['app'], function (app) {});
</script>

</head>
<body>

<div class="container">
<h1 id="greet"></h1>
<p class="subtitle">
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.
</p>
<p class="subtitle">
You are in <strong id="env-name"></strong> environment.
</p>
</div>
<div id="grid-container" style="height: 100%"></div>
</body>
<script>
$('#grid-container').w2grid({
name : 'grid',
height : '100%',
columns: [
{ field: 'fpath', caption: 'Folder Path', size: '70%' },
{ field: 'fsize', caption: 'Allocated Size', size: '15%' },
{ field: 'fstatus', caption: 'Status', size: '15%' },
],
records: [
{ recid: 1, fsize: 'Test', fsize: '##MB', fstatus: 'Ready'}
]
});
</script>
</html>
10 changes: 10 additions & 0 deletions app/app.js
@@ -0,0 +1,10 @@
// -----------------------------------------------------
// Here is the starting point for your own code.
// All stuff below is just to show you how it works.
// -----------------------------------------------------

// Node modules are required the same way as always.
var os = require('os');

// window.env contains data from config/env_XXX.json file.
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
File renamed without changes

0 comments on commit 59ca74c

Please sign in to comment.