TagSpaces is an offline, open source, document manager with tagging support
handling startup arguments
uggrock7364fc806b8d
diff --git a/data/electron/electron.api.js b/data/electron/electron.api.jsindex 7593d63ad..4bbe3629f 100644--- a/data/electron/electron.api.js+++ b/data/electron/electron.api.js@@ -27,15 +27,6 @@ define(function(require, exports, module) {win.show();};- /*process.on("uncaughtException", function(err) {- //var msg = ' Information | Description \n' +- // '-------------|-----------------------------\n' +- // ' Date | '+ new Date +'\n' +- // ' Type | UncaughtException \n' +- // ' Stack | '+ err.stack +'\n\n';- //fs.appendFile(errorLogFile, '---uncaughtException---\n' + msg);- });*/-// Experimental functionalityfunction watchDirecotory(dirPath, listener) {if (fsWatcher) {@@ -44,13 +35,13 @@ define(function(require, exports, module) {fsWatcher = fs.watch(dirPath, {persistent: true, recursive: false}, listener);}- function handleTray() {- // TODO disable in Ubuntu until node-webkit issue in unity fixed- console.log("TODO: handleTray");- }-function handleStartParameters() {- console.log("TODO: handleStartParameters");+ var filePath = TSCORE.Utils.getURLParameter("open");+ filePath = decodeURIComponent(filePath);+ if (filePath && (filePath.length > 0)) {+ console.log("Opening file in browser: " + openFile);+ TSCORE.FileOpener.openFileOnStartup(filePath);+ }}function initMainMenu() {diff --git a/data/electron/main.js b/data/electron/main.jsindex f9b52729a..cca7ba36b 100644--- a/data/electron/main.js+++ b/data/electron/main.js@@ -4,15 +4,22 @@ const electron = require('electron');const app = electron.app; // Module to control application life.const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.-var debugMode;-process.argv.forEach(function(arg) {- if (arg.indexOf('-d') >= 0) {+var startupFilePath;++//handling start parameter+//console.log(JSON.stringify(process.argv));+process.argv.forEach(function(arg, count) {+ if (arg.toLowerCase() === '-d' || arg.toLowerCase() === '-debug') {debugMode = true;+ } else if (arg.toLowerCase() === '-p' || arg.toLowerCase() === '-portable') {+ app.setPath('userData', 'tsprofile'); // making the app portable+ } else if (arg === '.' || count === 0) {+ //Ignore these argument+ } else if (arg.length > 2) {+ console.log("Opening file: " + arg);+ startupFilePath = arg;}-- //app.setPath('userData','data'); // making the app portable-});var path = require('path');@@ -32,11 +39,14 @@ app.on('window-all-closed', function() {app.on('ready', function() {mainWindow = new BrowserWindow({width: 1280, height: 768});- // and load the index.html of the app.//var indexPath = 'file://' + __dirname + '/index.html';- var indexPath = 'file://' + path.dirname(__dirname) + '/index.html';- console.log("mainWindow.loadURL: " + indexPath);- console.log("App path: " + app.getAppPath());+ var startupParameter = "";+ if (startupFilePath) {+ startupParameter = "?open=" + encodeURIComponent(startupFilePath);+ }+ var indexPath = 'file://' + path.dirname(__dirname) + '/index.html' + startupParameter;+ //console.log("mainWindow.loadURL: " + indexPath);+ //console.log("App path: " + app.getAppPath());mainWindow.setMenu(null);mainWindow.loadURL(indexPath);