TagSpaces is an offline, open source, document manager with tagging support
Added warning for chrome users if TagSpaces has no access to local file URLs
uggrock7e4c63b0bfaa
diff --git a/data/chrome/ChromeAllowAccessFileURLs.png b/data/chrome/ChromeAllowAccessFileURLs.pngnew file mode 100644index 000000000..524e98874Binary files /dev/null and b/data/chrome/ChromeAllowAccessFileURLs.png differdiff --git a/data/js/core.ui.js b/data/js/core.ui.jsindex b300a1b21..ada8ce16a 100644--- a/data/js/core.ui.js+++ b/data/js/core.ui.js@@ -30,7 +30,7 @@ define(function(require, exports, module) {'</div>');alertModal.find('h4').text(title);- alertModal.find('.lead').text(message);+ alertModal.find('.lead').append(message);alertModal.find('#okButton').click(function(event) {alertModal.modal('hide');});diff --git a/data/js/fileopener.js b/data/js/fileopener.jsindex a7215c86d..cbd51438e 100644--- a/data/js/fileopener.js+++ b/data/js/fileopener.js@@ -1,4 +1,4 @@-/* Copyright (c) 2012 The Tagspaces Authors. All rights reserved.+/* Copyright (c) 2012-2013 The TagSpaces Authors. All rights reserved.* Use of this source code is governed by a AGPL3 license that* can be found in the LICENSE file. */define(function(require, exports, module) {@@ -56,9 +56,12 @@ define(function(require, exports, module) {console.log("File Viewer: "+viewerExt);initTagSuggestionMenu(filePath);-+$( "#viewer" ).empty();- if(!viewerExt) {++ TSCORE.IO.checkAccessFileURLAllowed();++ if(!viewerExt) {$( "#viewer" ).html("<div class='alert alert-info'><strong>Info</strong> File type not supported for viewing."+"<button type='button' class='close' data-dismiss='alert'>×</button></div>");} else if (viewerExt == "viewerBrowser") {diff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.jsindex 7e1c81abb..a55d055cd 100644--- a/data/js/ioapi.chrome.js+++ b/data/js/ioapi.chrome.js@@ -315,6 +315,20 @@ Still Missing:});}+ exports.checkAccessFileURLAllowed = function() {+ chrome.extension.isAllowedFileSchemeAccess(function(isAllowedAccess) {+ if(!isAllowedAccess) {+ TSCORE.showAlertDialog(+ "Please make shure that you select the 'Allow access to file URLs'"++ " checkbox as shown in the following screenshot "++ " from the extension ('chrome://extensions/') settings of chrome/chromium"++ "<img src='chrome/ChromeAllowAccessFileURLs.png' />",+ "TagSpaces can not read files from your local disk!"+ );+ }+ });+ }+exports.openDirectory = function(dirPath) {// TODO implement openDirectoryconsole.log("Open directory functionality not implemented on chrome yet!");diff --git a/data/js/ioapi.mozilla.js b/data/js/ioapi.mozilla.jsindex 9771fb933..363fc6e17 100644--- a/data/js/ioapi.mozilla.js+++ b/data/js/ioapi.mozilla.js@@ -6,295 +6,299 @@define(function(require, exports, module) {"use strict";-console.log("Loading ioapi.mozilla.js..");--var TSCORE = require("tscore");--var TSPOSTIO = require("tspostioapi");--document.documentElement.addEventListener("tsMessage", function(event) {- console.log("Message received in page script from content script: "); //+JSON.stringify(event.detail));- TSCORE.hideLoadingAnimation();- var message = event.detail;- switch (message.command) {- case "loadSettings":- if(message.success) {- try {- console.log("Loading settings...: "+JSON.stringify(message.content));- TSCORE.Config.updateSettingMozillaPreferences(message.content);-- TSCORE.initConnections();- TSCORE.generateTagGroups();-- } catch (ex) {- console.log("Exception while getting setting from firefox failed "+ex)+ console.log("Loading ioapi.mozilla.js..");++ var TSCORE = require("tscore");++ var TSPOSTIO = require("tspostioapi");++ document.documentElement.addEventListener("tsMessage", function(event) {+ console.log("Message received in page script from content script: "); //+JSON.stringify(event.detail));+ TSCORE.hideLoadingAnimation();+ var message = event.detail;+ switch (message.command) {+ case "loadSettings":+ if(message.success) {+ try {+ console.log("Loading settings...: "+JSON.stringify(message.content));+ TSCORE.Config.updateSettingMozillaPreferences(message.content);++ TSCORE.initConnections();+ TSCORE.generateTagGroups();++ } catch (ex) {+ console.log("Exception while getting setting from firefox failed "+ex)+ }+ } else {+ console.log("Getting setting from firefox failed")}- } else {- console.log("Getting setting from firefox failed")- }- break;- case "saveSettings":- if(message.success) {- console.log("Saving setting as native mozilla preference successfull!")- } else {- console.log("Saving setting as native mozilla preference failed!")- }- break;- case "rename":- if(message.success){- TSPOSTIO.renameFile(message.content[0],message.content[1]);- } else {- TSCORE.updateLogger("Rename failed");- }- break;- case "saveTextFile":- if(message.success){- TSPOSTIO.saveTextFile(message.content);- } else {- TSCORE.updateLogger("Save failed");- }- break;- case "createDirectory":- if(message.success){- TSPOSTIO.createDirectory();- } else {- TSCORE.updateLogger("Create dir failed");- }- break;- case "loadTextFile":- if(message.success){- TSPOSTIO.loadTextFile(message.content);- } else {- TSCORE.updateLogger("File loading failed");- }- break;- case "listDirectory":- if(message.success){- TSPOSTIO.listDirectory(message.content);- } else {- TSCORE.updateLogger("List directory failed");- }- break;- case "indexDirectory":- if(message.success){- TSPOSTIO.createDirectoryIndex(message.content);- } else {- TSCORE.updateLogger("Indexing directory failed");- }- break;- case "createDirectoryTree":- if(message.success){- console.log("Directory tree: "+JSON.stringify(message.content));- TSPOSTIO.createDirectoryTree(message.content);- } else {- TSCORE.updateLogger("Indexing directory failed");- }- break;- case "getSubdirs":- if(message.success){- var dirListing = [];- for (var i=0; i < message.content.length; i++) {- dirListing.push(message.content[i]);+ break;+ case "saveSettings":+ if(message.success) {+ console.log("Saving setting as native mozilla preference successfull!")+ } else {+ console.log("Saving setting as native mozilla preference failed!")}- // TODO JSON functions are a workarround for a bug....- TSPOSTIO.getSubdirs(JSON.parse( JSON.stringify(dirListing)));- } else {- TSCORE.updateLogger("Getting subdirs failed");- }- break;- case "delete":- if(message.success){- TSPOSTIO.deleteElement();- } else {- TSCORE.updateLogger("Delete failed");- }- break;- case "selectDirectory":- if(message.success){- TSPOSTIO.selectDirectory(message.content);- } else {- TSCORE.updateLogger("Selecting directory failed.");- }- break;- case "checkNewVersion":- if(message.success){- TSPOSTIO.checkNewVersion(message.content);- } else {- TSCORE.updateLogger("Create dir failed");- }- break;- default:- break;- }-}, false);--exports.saveSettings = function(content) {- console.log("Saving setting...");- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "saveSettings",- "content": content- }});- document.documentElement.dispatchEvent(event);-}--exports.loadSettings = function() {- console.log("Loading setting from firefox preferences...");- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "loadSettings"- }});- document.documentElement.dispatchEvent(event);-}--exports.createDirectory = function(dirPath) {- console.log("Directory "+dirPath+" created.");- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "createDirectory",- "path": dirPath- }});- document.documentElement.dispatchEvent(event);-}--exports.loadTextFile = function(filePath) {- console.log("Loading file: "+filePath);- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "loadTextFile",- "path": filePath- }});- document.documentElement.dispatchEvent(event);-}--exports.renameFile = function(filePath, newFilePath) {- console.log("Renaming "+filePath+" to "+newFilePath);- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "rename",- "path": filePath,- "newPath": newFilePath- }});- document.documentElement.dispatchEvent(event);-}--exports.saveTextFile = function(filePath,content) {- console.log("Saving file: "+filePath);- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "saveTextFile",- "path": filePath,- "content": content- }});- document.documentElement.dispatchEvent(event);-}--exports.listDirectory = function(dirPath) {- console.log("Listing directory: "+dirPath);- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "listDirectory",- "path": dirPath- }});- document.documentElement.dispatchEvent(event);-}--exports.getSubdirs = function(dirPath) {- console.log("Getting subdirs: "+dirPath);- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "getSubdirs",- "path": dirPath- }});- document.documentElement.dispatchEvent(event);-}--exports.deleteElement = function(path) {- console.log("Deleting: "+path);- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "delete",- "path": path- }});- document.documentElement.dispatchEvent(event);-}--exports.selectDirectory = function() {- console.log("Selecting directory...");- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "selectDirectory",- }});- document.documentElement.dispatchEvent(event);-}--exports.selectFile = function() {- console.log("Selecting file...");- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "selectFile"- }});- document.documentElement.dispatchEvent(event);-}+ break;+ case "rename":+ if(message.success){+ TSPOSTIO.renameFile(message.content[0],message.content[1]);+ } else {+ TSCORE.updateLogger("Rename failed");+ }+ break;+ case "saveTextFile":+ if(message.success){+ TSPOSTIO.saveTextFile(message.content);+ } else {+ TSCORE.updateLogger("Save failed");+ }+ break;+ case "createDirectory":+ if(message.success){+ TSPOSTIO.createDirectory();+ } else {+ TSCORE.updateLogger("Create dir failed");+ }+ break;+ case "loadTextFile":+ if(message.success){+ TSPOSTIO.loadTextFile(message.content);+ } else {+ TSCORE.updateLogger("File loading failed");+ }+ break;+ case "listDirectory":+ if(message.success){+ TSPOSTIO.listDirectory(message.content);+ } else {+ TSCORE.updateLogger("List directory failed");+ }+ break;+ case "indexDirectory":+ if(message.success){+ TSPOSTIO.createDirectoryIndex(message.content);+ } else {+ TSCORE.updateLogger("Indexing directory failed");+ }+ break;+ case "createDirectoryTree":+ if(message.success){+ console.log("Directory tree: "+JSON.stringify(message.content));+ TSPOSTIO.createDirectoryTree(message.content);+ } else {+ TSCORE.updateLogger("Indexing directory failed");+ }+ break;+ case "getSubdirs":+ if(message.success){+ var dirListing = [];+ for (var i=0; i < message.content.length; i++) {+ dirListing.push(message.content[i]);+ }+ // TODO JSON functions are a workarround for a bug....+ TSPOSTIO.getSubdirs(JSON.parse( JSON.stringify(dirListing)));+ } else {+ TSCORE.updateLogger("Getting subdirs failed");+ }+ break;+ case "delete":+ if(message.success){+ TSPOSTIO.deleteElement();+ } else {+ TSCORE.updateLogger("Delete failed");+ }+ break;+ case "selectDirectory":+ if(message.success){+ TSPOSTIO.selectDirectory(message.content);+ } else {+ TSCORE.updateLogger("Selecting directory failed.");+ }+ break;+ case "checkNewVersion":+ if(message.success){+ TSPOSTIO.checkNewVersion(message.content);+ } else {+ TSCORE.updateLogger("Create dir failed");+ }+ break;+ default:+ break;+ }+ }, false);-exports.openDirectory = function(dirPath) {- console.log("Opening directory: "+dirPath);- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "openDirectory",- "path": dirPath,- }});- document.documentElement.dispatchEvent(event);-}--exports.openExtensionsDirectory = function() {- console.log("Opening extensions directory...");- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "openExtensionsDirectory"- }});- document.documentElement.dispatchEvent(event);-}--exports.createDirectoryIndex = function(dirPath) {- console.log("Creating directory index for: "+dirPath);- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "createDirectoryIndex",- "path": dirPath- }});- document.documentElement.dispatchEvent(event);-}--exports.createDirectoryTree = function(dirPath) {- console.log("Creating directory tree for: "+dirPath);- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "createDirectoryTree",- "path": dirPath- }});- document.documentElement.dispatchEvent(event);-}--exports.checkNewVersion = function() {- console.log("Checking for new version...");- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "checkNewVersion",- }});- document.documentElement.dispatchEvent(event);-}+ exports.saveSettings = function(content) {+ console.log("Saving setting...");+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "saveSettings",+ "content": content+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.loadSettings = function() {+ console.log("Loading setting from firefox preferences...");+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "loadSettings"+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.createDirectory = function(dirPath) {+ console.log("Directory "+dirPath+" created.");+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "createDirectory",+ "path": dirPath+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.loadTextFile = function(filePath) {+ console.log("Loading file: "+filePath);+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "loadTextFile",+ "path": filePath+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.renameFile = function(filePath, newFilePath) {+ console.log("Renaming "+filePath+" to "+newFilePath);+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "rename",+ "path": filePath,+ "newPath": newFilePath+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.saveTextFile = function(filePath,content) {+ console.log("Saving file: "+filePath);+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "saveTextFile",+ "path": filePath,+ "content": content+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.listDirectory = function(dirPath) {+ console.log("Listing directory: "+dirPath);+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "listDirectory",+ "path": dirPath+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.getSubdirs = function(dirPath) {+ console.log("Getting subdirs: "+dirPath);+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "getSubdirs",+ "path": dirPath+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.deleteElement = function(path) {+ console.log("Deleting: "+path);+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "delete",+ "path": path+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.checkAccessFileURLAllowed = function() {+ console.log("checkAccessFileURLAllowed function not relevant for node..");+ }++ exports.selectDirectory = function() {+ console.log("Selecting directory...");+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "selectDirectory",+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.selectFile = function() {+ console.log("Selecting file...");+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "selectFile"+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.openDirectory = function(dirPath) {+ console.log("Opening directory: "+dirPath);+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "openDirectory",+ "path": dirPath,+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.openExtensionsDirectory = function() {+ console.log("Opening extensions directory...");+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "openExtensionsDirectory"+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.createDirectoryIndex = function(dirPath) {+ console.log("Creating directory index for: "+dirPath);+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "createDirectoryIndex",+ "path": dirPath+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.createDirectoryTree = function(dirPath) {+ console.log("Creating directory tree for: "+dirPath);+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "createDirectoryTree",+ "path": dirPath+ }});+ document.documentElement.dispatchEvent(event);+ }++ exports.checkNewVersion = function() {+ console.log("Checking for new version...");+ TSCORE.showLoadingAnimation();+ var event = document.createEvent('CustomEvent');+ event.initCustomEvent("addon-message", true, true, {"detail":{+ "command": "checkNewVersion",+ }});+ document.documentElement.dispatchEvent(event);+ }});diff --git a/data/js/ioapi.node.js b/data/js/ioapi.node.jsindex 177e324d0..8f36af685 100644--- a/data/js/ioapi.node.js+++ b/data/js/ioapi.node.js@@ -93,6 +93,26 @@ define(function(require, exports, module) {console.error("Scanning directory "+dirPath+" failed "+ex);}}++ exports.getFileSize = function(filePath) {+ console.log("Get filesize of: "+filePath);+ var stats = fs.statSync(filePath);+ return stats.size;+ //TSPOSTIO.createDirectoryIndex(directoryIndex);+ }++ exports.getLMDT = function(filePath) {+ console.log("Get last modified date time of: "+filePath);+ var stats = fs.statSync(filePath);+ return stats.mtime;+ //TSPOSTIO.createDirectoryIndex(directoryIndex);+ }++ exports.directoryExist = function(dirPath) {+ console.log("Checks if a directory exist: "+dirPath);++ //TSPOSTIO.createDirectoryIndex(directoryIndex);+ }exports.createDirectoryIndex = function(dirPath) {console.log("Creating index for directory: "+dirPath);@@ -226,6 +246,10 @@ define(function(require, exports, module) {});}+ exports.checkAccessFileURLAllowed = function() {+ console.log("checkAccessFileURLAllowed function not relevant for node..");+ }+exports.checkNewVersion = function() {console.log("Checking for new version...");var cVer = TSCORE.Config.DefaultSettings["appVersion"]+"."+TSCORE.Config.DefaultSettings["appBuild"];