Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
joernroeder committed Sep 10, 2014
2 parents a222e49 + f7f5e84 commit 8df7357
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/config/uiChromeExtensionRoutine.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"icon": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjYwcHgiIGhlaWdodD0iNjBweCIgdmlld0JveD0iMCAwIDYwIDYwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPGcgaWQ9IlBhZ2UtMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgPgogICAgICAgICAgICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyLjAwMDAwMCwgMi4wMDAwMDApIj4KICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwiIGZpbGw9IiMzQzdGQzMiIGN4PSIyOC41IiBjeT0iMjguNSIgcj0iMTAuNSI+PC9jaXJjbGU+CiAgICAgICAgICAgICAgICA8cGF0aCBkPSJNMjguMTE3ODEyNCwxNS42MjM2NzExIEwyOC4xMTc4MTI0LDE1LjYyMjg2OTQgTDUzLjM3NSwxNS42MjI4Njk0IEM0OC43ODM0NzIyLDYuMzY1NjY1OTIgMzkuMjI3MTk0NSwwIDI4LjE4MDQzNjYsMCBDMTkuMjM3ODk5NSwwIDExLjI3MTU0MzgsNC4xNzE0NzM1NyA2LjEyNSwxMC42NzEzNjMzIEwxNS43NjA3NjIzLDI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Cw1NC4wMjM5ODY0IDI0LjMyMTQzNDQsNTYgTDM0LjEyNSwzOS4xODE3NzI2IEMzMi40MTA4MzQ1LDQwLjA1MTI1MDkgMzAuNDcwNTEwNCw0MC41NDE3NjE0IDI4LjQxNDc4NzUsNDAuNTQxNzYxNCBMMjguNDE0Nzg3NSw0MC41NDE3NjE0IEwyOC40MTQ3ODc1LDQwLjU0MTc2MTQgWiIgZmlsbD0iIzBGOUQ1OCI+PC9wYXRoPgogICAgICAgICAgICA8L2c+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=",
"extensionId": "fdebdfighadoiekjndfoholpdkcahnjg",
"crxPath" : "./ui_routines/chrome_extension/peeriod-latest.crx",
"crxPathTo": "Library/Peeriod/chrome_extension",
"version": "0.0.1",
"host": "Google Chrome",
"hostUrl": "./public/routines/ui-chrome-extension-starter.html"
Expand Down
35 changes: 33 additions & 2 deletions src/core/ui/routines/UiChromeExtensionRoutine.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/core/ui/routines/UiChromeExtensionRoutine.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 35 additions & 2 deletions src/core/ui/routines/UiChromeExtensionRoutine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ class UiChromeExtensionRoutine implements UiRoutineInterface {

logger.log('Chrome routing extension install path ' + path.resolve(process.cwd(), this._config.get('extension.crxPath')));

var externalCrxPath:string = this._moveCrxAndGetPath();

if (!externalCrxPath) {
return internalCallback(null);
}

fs.outputJson(installPath, {
external_crx: path.resolve(process.cwd(), this._config.get('extension.crxPath')),
external_crx: externalCrxPath,
external_version: this._config.get('extension.version')
}, function (err) {

Expand All @@ -62,7 +68,11 @@ class UiChromeExtensionRoutine implements UiRoutineInterface {
}

public isInstalled (callback:(installed:boolean) => any):void {
fs.exists(this._getInstallPath(), callback);
var installed:boolean = fs.existsSync(this._getInstallPath()) && fs.existsSync(this._getDestinationCrxPath());

process.nextTick(function () {
callback(installed);
});
}

public start (callback?:(err:Error) => any):void {
Expand Down Expand Up @@ -104,6 +114,29 @@ class UiChromeExtensionRoutine implements UiRoutineInterface {
return path.resolve(path.join(home, this._config.get('extension.installPath'), this._config.get('extension.extensionId') + '.json'))
}

private _getDestinationCrxPath ():string {
var destCrxFolderPath:string = path.resolve(path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']), this._config.get('extension.crxPathTo'));

return path.join(destCrxFolderPath, 'peeriod-chrome.crx');
}

private _moveCrxAndGetPath ():string {

var origCrxPath:string = path.resolve(process.cwd(), this._config.get('extension.crxPath'));
var destCrxFolderPath:string = path.resolve(path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME']), this._config.get('extension.crxPathTo'));
var destCrxPath:string = this._getDestinationCrxPath();

try {
fs.ensureDirSync(destCrxFolderPath);
fs.copySync(origCrxPath, destCrxPath);
}
catch (e) {
return null;
}

return destCrxPath;
}

}

export = UiChromeExtensionRoutine;
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"splashScreen.topologyJoinComplete": "Successfully joined network. Preparing anonymity layer…",
"core.jj.uiroutine.chromeextension.name": "Peeriod for Google Chrome",
"core.jj.uiroutine.chromeextension.description": "Peeriod’s user interface in a Google Chrome browser extension.",
"core.jj.uiroutine.chromeextension.subnotice": "Chrome restart required",
"core.jj.uiroutine.chromeextension.installButtonLabel": "Install for Google Chrome",
"uiRoutinesManager.installRoutinesHeadline": "Install Peeriod User Interface",
"uiRoutinesManager.installRoutinesDescription": "Peeriod’s main application runs in the background. The user interface – where you can download, share and search files – lives in the browser. \n In order to use Peeriod’s full functionality, please install one of the following browser addons (currently only available for Chromium based browsers). The browser addon will not connect to the Internet!",
Expand Down
1 change: 1 addition & 0 deletions ts-definitions/fs-extra/fs-extra.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ declare module "fs-extra" {
export function mkdir(path: string, mode?: string, callback?: (err: Error) => void): void;
export function mkdirSync(path: string, mode?: number): void;
export function mkdirSync(path: string, mode?: string): void;
export function ensureDirSync(path: string): void;
export function readdir(path: string, callback?: (err: Error, files: string[]) => void ): void;
export function readdirSync(path: string): string[];
export function close(fd: number, callback?: (err: Error) => void): void;
Expand Down

0 comments on commit 8df7357

Please sign in to comment.