Skip to content

Commit

Permalink
version 0.2.1 is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-portmen committed Jan 17, 2017
1 parent b1785cb commit 6d78715
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 24 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# native-client

This [NodeJS](https://nodejs.org/) based small client helps the following extensions to communicate with your operation system

1. Open in Firefox [open Firefox browser with provided URL]
2. Open in IE [open Internet Explorer browser with provided URL]
3. Open in Chrome [open Chrome browser with provided URL]
4. Open in Edge [open Microsoft Edge browser with provided URL]
5. Open in Safari [open Safari browser with provided URL]
6. Open in GIMP photo editor [open GIMP photo editor with provided URL or a temporary local image file (data-url's are being converted to a temporary local files and then GIMP is called to open this file)]
7. Open in VLC media Player [open VLC media Player with provided URL]
8. Media Converter and Muxer [Download FFmpeg media converter, Open FFmpeg, Export media files to a temporary directory then call FFmpeg]

You can find up-to-date list as well as IDs here: https://github.com/andy-portmen/native-client/blob/master/config.js

Notes:

1. On Linux and Mac, installer script only copies node executable if it is not already defined in the PATH enviroment. Please make sure you have an up-to-date version of NodeJS
2. On Linux and Mac, you can define custom root directory by adding `--custom-dir=` to the installer script
Example: `./install.sh --custom-dir=~/Desktop/`
3. Removing the native client [Linux and Mac]: As of version 0.2.1, the installer prints all the directries it creates or inserts scripts in. Basically on Linux and Mac, two JSON files are inserted to predefined directories and a root directory is created which contains all the files. To remove the program simply delete the root directory and delete the two generated manifest JSON files. Path to all these files will be printed during installation
4. Removing the native client [windows]: On Windows OS, a directory is created in "Program Files" and all the files are inserted in this directory. To remove the program, simply delete this directory. Also note that two registry entries are also added so that Chrome, Opera, and Firefox browsers can find the actual executable. Path to these registry entries are also printed during installation
5. If you don't remember where the files are, simply run the installer one more time. It just overwrites all the files.
6. For the installer to be able to copy manifest files and to create the root directory, it needs administration (sudo) permission. If you are not comfortable to allow this permission, you can manually copy all the files
4 changes: 4 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ exports.ids = {
'fabccabfpmdadbhljpcmcbmepepfllnb', // Media Converter (Opera)
'jgpghknlbaljigdhcjimjnkkjniiipmm', // Open in GIMP (Chrome)
'cmjahocdpafkodabbojjaebogoigcipj', // Open in GIMP (Opera)
'bifmfjgpgndemajpeeoiopbeilbaifdo', // External Application Button (Chrome)
'enemdfoackoekaedijjmjlckkleokhih', // External Application Button (Opera)
'ihpiinojhnfhpdmmacgmpoonphhimkaj', // Open in VLC (Chrome)
],
firefox: [
'{5610edea-88c1-4370-b93d-86aa131971d1}', // Open in IE
'{0ff128a1-c286-4e73-bffa-9ae879b244d5}', // Media Converter
'{65b77238-bb05-470a-a445-ec0efe1d66c4}', // External Application Button
]
};
2 changes: 1 addition & 1 deletion host.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var https = lazyRequire('./follow-redirects').https;
var server, files = [];

var config = {
version: '0.1.7'
version: '0.2.1'
};
// closing node when parent process is killed
process.stdin.resume();
Expand Down
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
cd ./app

if type node 2>/dev/null; then
echo Installer is using your system node.js
sudo node install.js `which node`
echo Installer is using your system NodeJS; Please make sure your NodeJS is up-to-date.
sudo node install.js `which node` $1
else
echo Installer is using the attached node.js
sudo ../node install.js --add_node
echo Installer is using the attached NodeJS
sudo ../node install.js --add_node $1
fi

21 changes: 15 additions & 6 deletions linux/app/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
var fs = require('fs');
var path = require('path');

var share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] || '/usr/share';
if (share[0] === '~') {
share = path.join(process.env.HOME, share.slice(1));
}
share = path.resolve(share);
console.log(' -> Root directory is', share);

function exists (directory, callback) {
let root = '/';
let dirs = directory.split('/');
Expand Down Expand Up @@ -33,11 +40,12 @@ function exists (directory, callback) {
one();
}

var dir = path.join('/usr/share', 'com.add0n.node');
var dir = path.join(share, 'com.add0n.node');
var name = 'com.add0n.node';
var ids = require('./config.js').ids;

function manifest (root, type, callback) {
console.log(' -> Creating a directory at', root);
exists(root, (e) => {
if (e) {
throw e;
Expand Down Expand Up @@ -65,11 +73,12 @@ function manifest (root, type, callback) {
});
}
function application (callback) {
console.log(' -> Creating a directory at', dir);
exists(dir, (e) => {
if (e) {
throw e;
}
let isNode = process.argv[2] !== '--add_node';
let isNode = process.argv.filter(a => a === '--add_node').length;
let run = isNode ? `#!/bin/bash\n${process.argv[2]} host.js` : '#!/bin/bash\n./node host.js';
fs.writeFile(path.join(dir, 'run.sh'), run, (e) => {
if (e) {
Expand All @@ -90,7 +99,7 @@ function application (callback) {
function chrome (callback) {
if (ids.chrome.length) {
manifest('/etc/opt/chrome/native-messaging-hosts', 'chrome', callback);
console.error('Chrome Browser is supported');
console.error(' -> Chrome Browser is supported');
}
else {
callback();
Expand All @@ -99,15 +108,15 @@ function chrome (callback) {
function firefox (callback) {
if (ids.firefox.length) {
manifest('/usr/lib/mozilla/native-messaging-hosts', 'firefox', callback);
console.error('Firefox Browser is supported');
console.error(' -> Firefox Browser is supported');
}
else {
callback();
}
}
chrome(() => firefox(() => {
application(() => {
console.error('Native Host is installed in', dir);
console.error('>> Application is ready to use <<');
console.error(' => Native Host is installed in', dir);
console.error('\n\n>>> Application is ready to use <<<\n\n');
});
}));
22 changes: 15 additions & 7 deletions mac/app/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
var fs = require('fs');
var path = require('path');

var share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] || '/usr/share';
if (share[0] === '~') {
share = path.join(process.env.HOME, share.slice(1));
}
share = path.resolve(share);
console.log(' -> Root directory is', share);

function exists (directory, callback) {
let root = '/';
let dirs = directory.split('/');
Expand Down Expand Up @@ -33,11 +40,12 @@ function exists (directory, callback) {
one();
}

var dir = path.join('/usr/share', 'com.add0n.node');
var dir = path.join(share, 'com.add0n.node');
var name = 'com.add0n.node';
var ids = require('./config.js').ids;

function manifest (root, type, callback) {
console.log(' -> Creating a directory at', root);
exists(root, (e) => {
if (e) {
throw e;
Expand All @@ -62,17 +70,17 @@ function manifest (root, type, callback) {
}
callback();
});

});
}

function application (callback) {
console.log(' -> Creating a directory at', dir);
exists(dir, (e) => {
if (e) {
throw e;
}

let isNode = process.argv[2] !== '--add_node';
let isNode = process.argv.filter(a => a === '--add_node').length;
let run = isNode ? `#!/bin/bash\n${process.argv[2]} host.js` : '#!/bin/bash\n./node host.js';
fs.writeFile(path.join(dir, 'run.sh'), run, (e) => {
if (e) {
Expand All @@ -95,7 +103,7 @@ function application (callback) {
function chrome (callback) {
if (ids.chrome.length) {
manifest('/Library/Google/Chrome/NativeMessagingHosts', 'chrome', callback);
console.error('Chrome Browser is supported');
console.error(' -> Chrome Browser is supported');
}
else {
callback();
Expand All @@ -104,15 +112,15 @@ function chrome (callback) {
function firefox (callback) {
if (ids.firefox.length) {
manifest('/Library/Application Support/Mozilla/NativeMessagingHosts', 'firefox', callback);
console.error('Firefox Browser is supported');
console.error(' -> Firefox Browser is supported');
}
else {
callback();
}
}
chrome(() => firefox(() => {
application(() => {
console.error('Native Host is installed in', dir);
console.error('>> Application is ready to use <<');
console.error(' -> Native Host is installed in', dir);
console.error('\n\n>>> Application is ready to use <<<\n\n');
});
}));
8 changes: 4 additions & 4 deletions windows/app/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function application (callback) {
function chrome (callback) {
if (ids.chrome.length) {
manifest('chrome', callback);
console.error('Chrome Browser is supported');
console.error('.. Chrome Browser is supported');
}
else {
callback();
Expand All @@ -72,15 +72,15 @@ function chrome (callback) {
function firefox (callback) {
if (ids.firefox.length) {
manifest('firefox', callback);
console.error('Firefox Browser is supported');
console.error('.. Firefox Browser is supported');
}
else {
callback();
}
}
chrome(() => firefox(() => {
application(() => {
console.error('Native Host is installed in', dir);
console.error('>> Application is ready to use <<');
console.error('.. Native Host is installed in', dir);
console.error('\n\n>>> Application is ready to use <<<\n\n');
});
}));
6 changes: 4 additions & 2 deletions windows/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ exit /b

:run

echo Writting to Chrome Registry
echo .. Writting to Chrome Registry
echo .. Key: HKCU\Software\Google\Chrome\NativeMessagingHosts\com.add0n.node
REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.add0n.node" /ve /t REG_SZ /d "%ProgramFiles%\com.add0n.node\manifest-chrome.json" /f

echo Writting to Firefox
echo .. Writting to Firefox Registry
echo .. Key: HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\com.add0n.node
for %%f in ("%PROGRAMFILES%") do SET SHORT_PATH=%%~sf
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\com.add0n.node" /ve /t REG_SZ /d "%SHORT_PATH%\com.add0n.node\manifest-firefox.json" /f

Expand Down

0 comments on commit 6d78715

Please sign in to comment.