Skip to content

Commit

Permalink
Base
Browse files Browse the repository at this point in the history
  • Loading branch information
YoruNoHikage committed Nov 8, 2017
0 parents commit 6fada06
Show file tree
Hide file tree
Showing 10 changed files with 5,707 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
out/
yarn-error.log
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
language: node_js
node_js: "6"
os:
- linux
- osx
dist: trusty
osx_image: xcode8.3
sudo: false

cache:
directories:
- node_modules
- $HOME/.cache/electron

addons:
apt:
packages:
- fakeroot
- rpm

branches:
only:
- master
- /^v\d+\.\d+\.\d+/

install:
- npm install
- npm update

script:
- if test -z "$TRAVIS_TAG"; then npm run make; fi
after_success: if test -n "$TRAVIS_TAG"; then npm run publish; fi
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Prototypo Desktop

[Prototypo](https://github.com/byte-foundry/prototypo) right in your desktop. Create unique identities.

## Installation

Go to the [releases page](https://github.com/byte-foundry/prototypo-desktop/releases) and grab the one you need.
25 changes: 25 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
platform:
- x64
environment:
nodejs_version: "6"
cache:
- '%APPDATA%\npm-cache'
- '%USERPROFILE%\.electron'
- node_modules
branches:
only:
- master
- /^v\d+\.\d+\.\d+/
install:
- ps: Install-Product node $env:nodejs_version $env:platform
- set PATH=%APPDATA%\npm;%PATH%
- npm install
- npm update

test_script:
- node --version
- npm --version
- if %APPVEYOR_REPO_TAG% EQU false npm run make

build_script:
- IF %APPVEYOR_REPO_TAG% EQU true npm run publish
Binary file added icon.ico
Binary file not shown.
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"name": "prototypo-desktop",
"version": "1.0.0",
"description": "Create your own fonts in a few clicks on your desktop",
"main": "src/index.js",
"repository": "https://github.com/byte-foundry/prototypo-desktop",
"license": "MIT",
"private": true,
"author": "Prototypo",
"dependencies": {
"electron-compile": "^6.4.2"
},
"devDependencies": {
"electron-forge": "^4.1.2",
"electron-prebuilt-compile": "1.7.9"
},
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish"
},
"config": {
"forge": {
"make_targets": {
"win32": [
"squirrel"
],
"darwin": [
"zip",
"dmg"
],
"linux": [
"deb",
"rpm"
]
},
"electronPackagerConfig": {
"name": "Prototypo",
"icon": "./icon"
},
"electronWinstallerConfig": {
"name": "Prototypo",
"loadingGif": "loading.gif",
"iconUrl": "http://localhost:5000/icon.ico",
"setupIcon": "./icon.ico"
},
"electronInstallerDMG": {
"icon": "./icon.png"
},
"electronInstallerDebian": {},
"electronInstallerRedhat": {},
"github_repository": {
"owner": "yorunohikage",
"name": "prototypo-desktop"
},
"windowsStoreConfig": {
"packageName": "Prototypo"
}
}
}
}
126 changes: 126 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
const { app, shell, session, BrowserWindow } = require('electron');
const path = require('path');
const url = require('url');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;

function createWindow() {
win = new BrowserWindow({
width: 1600,
height: 1000,
minWidth: 1450,
minHeight: 1000,
backgroundColor: '#3b3b3b',
webPreferences: { devTools: false },
});

session.defaultSession.webRequest.onBeforeSendHeaders((details, callback) => {
details.requestHeaders['User-Agent'] =
'Prototypo-Desktop-' + require('../package.json').version;
callback({ cancel: false, requestHeaders: details.requestHeaders });
});

win.webContents.on('new-window', (e, url) => {
e.preventDefault();
shell.openExternal(url);
});

win.loadURL('https://app.prototypo.io');
win.setMenu(null);

win.webContents.openDevTools();

win.on('closed', () => {
win = null;
});
}

app.on('ready', () => {
// this should be placed at top of main.js to handle setup events quickly
if (handleSquirrelEvent()) {
// squirrel event handled and app will exit in 1000ms, so don't do anything else
return;
}

createWindow();
});

app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow();
}
});

function handleSquirrelEvent() {
if (process.argv.length === 1) {
return false;
}

const ChildProcess = require('child_process');
const path = require('path');

const appFolder = path.resolve(process.execPath, '..');
const rootAtomFolder = path.resolve(appFolder, '..');
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
const exeName = path.basename(process.execPath);

const spawn = function(command, args) {
let spawnedProcess, error;

try {
spawnedProcess = ChildProcess.spawn(command, args, { detached: true });
} catch (error) {}

return spawnedProcess;
};

const spawnUpdate = function(args) {
return spawn(updateDotExe, args);
};

const squirrelEvent = process.argv[1];
switch (squirrelEvent) {
case '--squirrel-install':
case '--squirrel-updated':
// Optionally do things such as:
// - Add your .exe to the PATH
// - Write to the registry for things like file associations and
// explorer context menus

// Install desktop and start menu shortcuts
spawnUpdate(['--createShortcut', exeName]);

setTimeout(app.quit, 1000);
return true;

case '--squirrel-uninstall':
// Undo anything you did in the --squirrel-install and
// --squirrel-updated handlers

// Remove desktop and start menu shortcuts
spawnUpdate(['--removeShortcut', exeName]);

setTimeout(app.quit, 1000);
return true;

case '--squirrel-obsolete':
// This is called on the outgoing version of your app before
// we update to the new version - it's the opposite of
// --squirrel-updated

app.quit();
return true;
}
}
Loading

0 comments on commit 6fada06

Please sign in to comment.