Skip to content

Commit

Permalink
Added Electron packaging support + refactorings.
Browse files Browse the repository at this point in the history
- Moved most of the app into `app` per the recommendations
  in `electron-builder`.
- Added support for building all sorts of packages.
- Working on fixing background first launch bugs.
  • Loading branch information
ikogan committed Jun 5, 2016
1 parent 934a931 commit a61d47b
Show file tree
Hide file tree
Showing 28 changed files with 346 additions and 264 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
dist/*
app/node_modules/*
10 changes: 10 additions & 0 deletions .remarkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"plugins": {
"lint": {
"list-item-spacing": false
}
},
"settings": {
"commonmark": true
}
}
367 changes: 194 additions & 173 deletions LICENSE.md

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,29 @@ cd farnsworth
npm install && npm start
```

#### License [CCAL-4.0](LICENSE.md)
## Packaging

Currently, packages are generated with gulp:

```bash
npm install -g gulp
npm install
gulp
```

## TODO

At the moment, this is completele enough to use for my own purposes but there
is much left that should be done:

- Avoid packaging development modules
- Windows Installer, Mac DMG, Linux packages
- Keyboard support for edit tiles and settings screens
- Refactor controls to be more generic, grid based?
- Native support for game controllers
- "Profiles" for a given tile: launch the tile command differently
depending on a profile selected at launch time.
- Customizable background color, image, list URL
- Cleanup as indicated in the source

### License [Apache-2.0](LICENSE.md)
2 changes: 1 addition & 1 deletion backend/backgrounds.js → app/backend/backgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function downloadBackgrounds() {
// Save the backgrounds file. Possibly a minor performance impact
// serializing JSON and writing to disk every time we download an
// image but...see above dad quote.
fs.writeFile(BACKGROUNDS_SAVE_PATH, JSON.stringify(backgrounds), function(error) {
fs.writeFile(BACKGROUNDS_SAVE_PATH, JSON.stringify(backgrounds, null, 4), function(error) {
if(error) {
bgWindow.send('backgrounds-error', 'Could not save backgrounds list', error);
}
Expand Down
4 changes: 4 additions & 0 deletions main.js → app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function createWindow () {

mainWindow.setFullScreen(true);

if(process.argv.indexOf('--develop') !== -1) {
mainWindow.toggleDevTools();
}

// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/ui/index.html');

Expand Down
54 changes: 54 additions & 0 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "farnsworth-launcher",
"version": "0.1.0",
"description": "Fullscreen Application Launcher for TVs",
"main": "main.js",
"scripts": {
"start": "electron main.js",
"debug": "electron --debug-brk main.js",
"package": "electron-packager "
},
"repository": {
"type": "git",
"url": "[email protected]:ikogan/farnsworth.git"
},
"keywords": [
"Electron",
"quick",
"start",
"tutorial"
],
"author": "Ilya Kogan <[email protected]>",
"license": "Apache 2.0",
"bugs": {
"url": "https://bitbucket.org/ikogan/farnsworth"
},
"homepage": "https://bitbucket.org/ikogan/farnsworth#readme",
"devDependencies": {
"angular-mocks": "^1.5.5",
"electron-prebuilt": "1.2.1"
},
"dependencies": {
"angular": "^1.5.5",
"angular-animate": "^1.5.5",
"angular-aria": "^1.5.5",
"angular-hotkeys": "^1.7.0",
"angular-material": "^1.0.8",
"angular-messages": "^1.5.5",
"angular-route": "^1.5.5",
"angular-sanitize": "^1.5.5",
"angular-scroll": "^1.0.0",
"debug": "^2.2.0",
"download": "^5.0.0",
"fs-extra": "^0.30.0",
"lodash": "^4.11.1",
"material-design-icons": "^2.2.3",
"md-color-picker": "^0.2.6",
"mousetrap": "^1.5.3",
"request": "^2.72.0",
"roboto-fontface": "^0.4.5",
"sha1": "^1.1.1",
"slash": "^1.0.0",
"spawn-shell": "^1.1.2"
}
}
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.
Original file line number Diff line number Diff line change
Expand Up @@ -76,56 +76,45 @@ angular.module('farnsworth')
var waits = [service.waitForBackgroundData, service.waitForBackground];

$q.all(waits).then(function(bgData) {
bgData = bgData[0];

// Get a list of all files in the directory.
// TODO: I believe this is legacy logic and isn't necessary,
// the `fs.accessSync` call verifies that the file exists, so
// we should probably remove this.
fs.readdir(BACKGROUNDS_DIR, function(error, entries) {
if(error) {
defered.reject('Cannot read background directory.', error);
} else {
if(!entries || entries.length == 0) {
return defered.reject('No images found in directory but images supposedly available?');
bgData = _.filter(bgData[0], function(entry) {
if(entry.downloaded) {
try {
fs.accessSync(path.join(BACKGROUNDS_DIR, entry.filename));
return true;
} catch(e) {
return false;
}
} else {
return false;
}
});

// Choose a random background to start with.
var index = Math.floor(Math.random() * (bgData.length - 1));
var checks = 0; // Make sure we don't keep checking forever if we can never find a background
var background = null; // The background to use

// Keep looping so long as we haven't found a background that isn't the last
// background we've used and we haven't mmade as many checks as there are entries
//
// TODO: This logic is flawed as we can check the same background multiple times,
// increasing the number of checks without insuring we don't re-check a failed
// background over and over.
while((!background || background === lastBackground) && checks < entries.length) {
checks++;

if(bgData[index].downloaded) {
var filename = path.join(BACKGROUNDS_DIR, bgData[index].filename);

// Make sure this background actually exists
try {
fs.accessSync(filename, fs.R_OK);

background = {
filename: filename,
metadata: index < bgData.length ? bgData[index] : null
};
} catch(e) {}
}

index = Math.floor(Math.random() * (bgData.length - 1));
}
// Choose a random background to start with.
var index = Math.floor(Math.random() * (bgData.length - 1));
var checked = []; // Make sure we don't keep checking forever if we can never find a background
var background = null; // The background to use

// Keep looping so long as we haven't found a background that isn't the last
// background we've used and we haven't mmade as many checks as there are entries.
while((!background || background === lastBackground) && checked.length < bgData.length) {
checked.push(index);

lastBackground = background;
background = {
filename: path.join(BACKGROUNDS_DIR, bgData[index].filename),
metadata: bgData[index]
};

defered.resolve(background);
while(checked.indexOf(index) !== -1) {
index = Math.floor(Math.random() * (bgData.length - 1));
}
});
}

if(background) {
lastBackground = background;
defered.resolve(background);
} else {
defered.reject('Unable to find background despite assurances that they exist.');
}
});

return defered.promise;
Expand Down
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.
Binary file added build/icon.icns
Binary file not shown.
Binary file added build/icon.ico
Binary file not shown.
65 changes: 21 additions & 44 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,30 @@
{
"name": "farnsworth-laundher",
"version": "1.0.0",
"private": true,
"name": "farnsworth-launcher",
"version": "0.1.0",
"description": "Fullscreen Application Launcher for TVs",
"main": "main.js",
"scripts": {
"start": "electron main.js",
"debug": "electron --debug-brk main.js"
"clean": "rimraf dist",
"postinstall": "install-app-deps",
"start": "npm install && electron ./app",
"dist": "build --win --osx --linux --x64 && build --win --linux --ia32",
"dist:darwin": "build --osx",
"dist:win64": "build --win --x64",
"dist:win32": "build --win --ia32",
"dist:linux64": "build --linux --x64",
"dist:linux32": "build --linux --ia32"
},
"repository": {
"type": "git",
"url": "[email protected]:ikogan/farnsworth.git"
"build": {
"app-bundle-id": "org.mythicnet.farnsworth",
"app-category-type": "public.app-category.utilities",
"linux": {
"target": ["deb", "rpm", "tar.gz"]
}
},
"keywords": [
"Electron",
"quick",
"start",
"tutorial"
],
"author": "Ilya Kogan <[email protected]>",
"license": "CPAL-4.0",
"bugs": {
"url": "https://bitbucket.org/ikogan/farnsworth"
},
"homepage": "https://bitbucket.org/ikogan/farnsworth#readme",
"devDependencies": {
"angular-mocks": "^1.5.5",
"electron-prebuilt": "^0.37.0"
},
"dependencies": {
"angular": "^1.5.5",
"angular-animate": "^1.5.5",
"angular-aria": "^1.5.5",
"angular-hotkeys": "^1.7.0",
"angular-material": "^1.0.8",
"angular-messages": "^1.5.5",
"angular-route": "^1.5.5",
"angular-sanitize": "^1.5.5",
"angular-scroll": "^1.0.0",
"debug": "^2.2.0",
"download": "^5.0.0",
"fs-extra": "^0.30.0",
"lodash": "^4.11.1",
"material-design-icons": "^2.2.3",
"md-color-picker": "^0.2.6",
"mousetrap": "^1.5.3",
"request": "^2.72.0",
"roboto-fontface": "^0.4.5",
"sha1": "^1.1.1",
"slash": "^1.0.0",
"spawn-shell": "^1.1.2"
"electron-builder": "^4.2.2",
"electron-prebuilt": "1.2.1",
"rimraf": "^2.5.2"
}
}

0 comments on commit a61d47b

Please sign in to comment.