TagSpaces is an offline, open source, document manager with tagging support
changes needed for the cordova integration
uggrock5be682b45578
diff --git a/build.number b/build.numberindex 09e66aa1b..56a750371 100644--- a/build.number+++ b/build.number@@ -1,4 +1,4 @@#Build Number for ANT. Do not edit!-#Wed Aug 21 14:29:15 CEST 2013-build.number=1456+#Sat Aug 24 21:01:48 CEST 2013+build.number=14583=diff --git a/build.properties b/build.propertiesindex e9f8087f6..419728491 100644--- a/build.properties+++ b/build.properties@@ -3,6 +3,6 @@ backup.dir = ../backupsbuilds.dir = ../buildsbuildFirefoxExt.dir = ../builds/firefoxbuildChrome.dir = ../builds/chrome-cordovaDev.dir = ../cordova/assets/www-cordovaJSLib.file = ../cordova/assets/cordova-2.0.0.js-tagspaces.org.release.dir = ../website/webroot/releases+cordovaDev.dir = ../AndroidApp/www+cordovaJSLib.file = ../AndroidApp/cordova.js+tagspaces.org.release.dir = ../website/webroot/releases\ No newline at end of filediff --git a/build.xml b/build.xmlindex 6a88b1eb6..75933e872 100644--- a/build.xml+++ b/build.xml@@ -183,9 +183,9 @@ found in the LICENSE file.</target><target name="prepare-cordova-application" description="copy all files the cordova dev directory">- <delete dir="${cordovaDev.dir}"/>+ <!--delete dir="${cordovaDev.dir}"/><mkdir dir="${cordovaDev.dir}" />- <copy file="${cordovaJSLib.file}" todir="${cordovaDev.dir}" />+ <copy file="${cordovaJSLib.file}" todir="${cordovaDev.dir}" /--><copy file="LICENSE" tofile="${cordovaDev.dir}/LICENSE.txt" /><copy file="data/manifest.json" todir="${cordovaDev.dir}" /><copy file="data/index.html" todir="${cordovaDev.dir}" />@@ -194,7 +194,7 @@ found in the LICENSE file.<copy todir="${cordovaDev.dir}/libs" ><fileset dir="data/libs" includes="**/*"/></copy>- <copy todir="${cordovaDev.dir}/data/ext" >+ <copy todir="${cordovaDev.dir}/ext" ><fileset dir="data/ext"><include name="**/*"/></fileset>diff --git a/data/ext/perspectiveDefault/perspectiveUI.js b/data/ext/perspectiveDefault/perspectiveUI.jsindex 9d16de60e..d48f1715c 100644--- a/data/ext/perspectiveDefault/perspectiveUI.js+++ b/data/ext/perspectiveDefault/perspectiveUI.js@@ -31,12 +31,20 @@ console.log("Loading UI for perspectiveDefault");title = filePath;}+ //TODO minimize platform specific calls+ var tmbPath = undefined;+ if(isCordova) {+ tmbPath = filePath;+ } else {+ tmbPath = "file:///"+filePath;+ }+var thumbHTML = "";if(supportedFileTypeThumnailing.indexOf(fileExt) >= 0) {thumbHTML = $('<span>').append( $('<img>', {title: fileName,class: "thumbImg",- filepath: 'file:///'+filePath,+ filepath: tmbPath,style: "width: 0px; height: 0px; border: 0px"})).html();thumbHTML = "<br>" + thumbHTML;diff --git a/data/index.html b/data/index.htmlindex 139f48956..c90b639e1 100644--- a/data/index.html+++ b/data/index.html@@ -10,6 +10,7 @@<meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="shortcut icon" type="image/x-icon" href="icons/icon16.png"><title>TagSpaces</title>+ <script type="text/javascript" src="cordova.js"></script><script type="text/javascript" data-main="loader" src="libs/requirejs/require.js"></script><link rel="stylesheet" type="text/css" href="libs/font-awesome/css/font-awesome.css"><link rel="stylesheet" type="text/css" href="libs/jquerylayout/layout-default-latest.css">diff --git a/data/js/fileopener.js b/data/js/fileopener.jsindex cbd51438e..d0d9776c1 100644--- a/data/js/fileopener.js+++ b/data/js/fileopener.js@@ -65,7 +65,15 @@ define(function(require, exports, module) {$( "#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") {- var filePathURI = "file:///"+filePath;+ var filePathURI = undefined;++ //TODO minimize platform specific calls+ if(isCordova) {+ filePathURI = filePath;+ } else {+ filePathURI = "file:///"+filePath;+ }+$('#viewer').append($('<iframe>', {id: "iframeViewer",src: filePathURIdiff --git a/data/js/ioapi.cordova.js b/data/js/ioapi.cordova.jsindex f4b2a668c..7fd6af86f 100644--- a/data/js/ioapi.cordova.js+++ b/data/js/ioapi.cordova.js@@ -3,8 +3,7 @@* can be found in the LICENSE file. */define(function (require, exports, module) {"use strict";-- // Activating browser specific exports modul+console.log("Loading ioapi.cordova.js..");var TSCORE = require("tscore");@@ -17,74 +16,95 @@ define(function (require, exports, module) {// Cordova loaded and can be usedfunction onDeviceReady() {- console.log(">>>>>>>>>>>>>>>>>>>>>>> Dev Ready: "+device.platform+" - "+device.version);+ console.log("Devive Ready: "+device.platform+" - "+device.version);getFileSystem();}function getFileSystem() {- console.log(">>>>>>>>>>>>>>>>>>>>>>> FS");window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,function (fileSystem) { // success get file systemfsRoot = fileSystem.root;console.log("Filesystem Name: " + fsRoot.fullPath);- }, function (evt) { // error get file system+ },+ function (evt) { // error get file systemconsole.log("File System Error: " + evt.target.error.code);});- }+ }function scanDirectory(dirPath, index) {- try {- var dirList = nativeIO.getDirEntries(dirPath);- for (var i=0; i < dirList.length; i++) {- var path = dirPath+getDirseparator()+dirList[i];- var isDir = nativeIO.isDirectory(path);- var fileSize = 0; //nativeIO.getFileSize(path);- index.push({- "name": dirList[i],- "type": isDir?"directory":"file",- "size": fileSize,- "lmdt": "0",- "path": path- });- if (isDir) {- scanDirectory(path, index);- }- }- return index;- } catch(ex) {- console.error("Listing directory failed "+ex);- }+ dirPath = dirPath+"/"; // TODO make it platform independent+ dirPath = normalizePath(dirPath);+ fsRoot.getDirectory(dirPath, {create: false, exclusive: false},+ function (dirEntry) {+ var directoryReader = dirEntry.createReader();+ // Get a list of all the entries in the directory+ directoryReader.readEntries(+ function (entries) {+ var i;+ for (i = 0; i < entries.length; i++) {+ index.push({+ "name": entries[i].name,+ "type": entries[i].isFile?"file":"directory",+ "size": "0",+ "lmdt": "0",+ "path": entries[i].fullPath+ });+ if (entries[i].isDirectory) {+ scanDirectory(entries[i].fullPath, index);+ }+ }+ return index;+ }, function (error) { // error get file system+ console.log("Dir List Error: " + error.code);+ }+ );+ },+ function (error) {+ console.log("Getting dir: "+dirPath+" failed with error code: " + error.code);+ }+ );}function generateDirectoryTree(dirPath) {- try {- var tree = {};- tree["name"] = dirPath.substring(dirPath.lastIndexOf(getDirseparator()) + 1, dirPath.length);- tree["type"] = "directory";- tree["lmdt"] = 0;- tree["path"] = dirPath;- tree["children"] = [];- var dirList = nativeIO.getDirEntries(dirPath);- for (var i=0; i < dirList.length; i++) {- var path = dirPath+getDirseparator()+dirList[i];- var isDir = nativeIO.isDirectory(path);- if (!isDir) {- tree["children"].push({- "name": dirList[i],- "type": "file",- "size": 0,- "lmdt": 0,- "path": path- });- } else {- tree["children"].push( generateDirectoryTree(path) );- }- }- return tree;- } catch(ex) {- console.error("Scanning directory "+dirPath+" failed "+ex);- }+ dirPath = dirPath+"/"; // TODO make it platform independent+ dirPath = normalizePath(dirPath);+ var tree = {};+ fsRoot.getDirectory(dirPath, {create: false, exclusive: false},+ function (dirEntry) {+ var directoryReader = dirEntry.createReader();+ // Get a list of all the entries in the directory+ directoryReader.readEntries(+ function (entries) {+ tree["name"] = dirEntry.name;+ tree["type"] = "directory";+ tree["lmdt"] = 0;+ tree["path"] = dirEntry.fullPath;+ tree["children"] = [];+ for (var i=0; i < entries.length; i++) {+ if (entries[i].isFile) {+ tree["children"].push({+ "name": entries[i].name,+ "type": "file",+ "size": "0",+ "lmdt": "0",+ "path": entries[i].fullPath+ });+ } else {+ tree["children"].push( generateDirectoryTree(entries[i].fullPath) );+ }+ }+ return tree;+ },+ function (error) { // error get file system+ console.log("Dir Tree Creation Error: " + error.code);+ }+ );+ },+ function (error) {+ console.log("Getting dir: "+dirPath+" failed with error code: " + error.code);+ }+ );}function isWindows() {@@ -100,8 +120,8 @@ define(function (require, exports, module) {}function normalizePath(path) {- if(path.indexOf(fsRoot.path) > 0) {- path.substring(fsRoot.path.length+1, path.length);+ if(path.indexOf(fsRoot.fullPath) >= 0) {+ path = path.substring(fsRoot.fullPath.length+1, path.length);}return path;}@@ -122,11 +142,6 @@ define(function (require, exports, module) {;}- exports.loadTextFile = function(filePath) {- console.log("Loading file: "+filePath);-- }-exports.listDirectory = function (dirPath) {// directory path format DCIM/Camera/ !dirPath = dirPath+"/"; // TODO make it platform independent@@ -144,19 +159,17 @@ define(function (require, exports, module) {var i;var anotatedDirList = [];for (i = 0; i < entries.length; i++) {- console.log(entries[i].name);+ console.log("File: "+entries[i].name);anotatedDirList.push({"name": entries[i].name,- "type": entries[i].isDirectory ? "directory" : "file",+ "type": entries[i].isFile?"file":"directory","size": "0","lmdt": "0","path": entries[i].fullPath- });+ });}- // {"isFile":true,"isDirectory":false,"name":"bla.png","fullPath":"C:\\Users\\na\\Documents\\bla.png","filesystem":null}- console.log("Dir content: " + JSON.stringify(entries));- TSPOSTIO.listDirectory(anotatedDirList);-+ //console.log("Dir content: " + JSON.stringify(entries));+ TSPOSTIO.listDirectory(anotatedDirList);}, function (error) { // error get file systemconsole.log("Dir List Error: " + error.code);}@@ -243,58 +256,105 @@ define(function (require, exports, module) {TSPOSTIO.createDirectoryTree(directoyTree);}+ exports.loadTextFile = function(filePath) {+ filePath = normalizePath(filePath);+ console.log("Loading file: "+filePath);+ fsRoot.getFile(filePath, {create: false, exclusive: false},+ function(entry) {+ entry.file(+ function(file) {+ var reader = new FileReader();+ reader.onloadend = function(evt) {+ TSPOSTIO.loadTextFile(evt.target.result);+ };+ reader.readAsDataURL(file);+ },+ function() {+ console.log("error getting file: "+filePath);+ }+ );+ },+ function() {+ console.log("Error getting file entry: "+filePath);+ }+ );+ }+exports.saveTextFile = function(filePath,content) {+ filePath = normalizePath(filePath);console.log("Saving file: "+filePath);-+ fsRoot.getFile(filePath, {create: true, exclusive: false},+ function(entry) {+ entry.createWriter(+ function(writer) {+ writer.onwriteend = function(evt) {+ TSPOSTIO.saveTextFile(fsRoot.fullPath+"/"+filePath);+ };+ writer.write(content);+ },+ function() {+ console.log("error creating writter file: "+filePath);+ }+ );+ },+ function() {+ console.log("Error getting file entry: "+filePath);+ }+ );}exports.createDirectory = function(dirPath) {+ dirPath = normalizePath(dirPath);console.log("Creating directory: "+dirPath);-+ fsRoot.getDirectory(dirPath, {create: true, exclusive: false},+ function (dirEntry) {+ TSPOSTIO.createDirectory();+ },+ function (error) {+ console.log("Creating directory failed: "+dirPath+" failed with error code: " + error.code);+ }+ );}exports.renameFile = function(filePath, newFilePath) {filePath = normalizePath(filePath);var newFileName = newFilePath.substring(newFilePath.lastIndexOf('/')+1);- var parentDirEntry = undefined;+ var newFileParentPath = normalizePath(newFilePath.substring(0, newFilePath.lastIndexOf('/')));- fsRoot.getDirectory(dirPath, {create: false, exclusive: false},- function (dirEntry) {- var directoryReader = dirEntry.createReader();-+ fsRoot.getDirectory(newFileParentPath, {create: false, exclusive: false},+ function (parentDirEntry) {+ fsRoot.getFile(filePath, {create: false, exclusive: false},+ function(entry) {+ entry.moveTo(+ parentDirEntry,+ newFileName,+ function() {+ console.log("file renamed to: "+newFilePath);+ TSPOSTIO.renameFile(filePath, newFilePath);+ },+ function() {+ console.log("error renaming: "+filePath);+ }+ );+ },+ function() {+ console.log("Error getting file: "+filePath);+ }+ );},function (error) {- console.log("Getting dir: "+dirPath+" failed with error code: " + error.code);+ console.log("Getting dir: "+newFileParentPath+" failed with error code: " + error.code);}- );-- fsRoot.getFile(filePath, {create: false, exclusive: false},- function(entry) {- entry.moveTo(- parentDirEntry,- newFileName,- function() {- console.log("file renamed to: "+newFilePath);- },- function() {- console.log("error renaming: "+filePath);- }- );- },- function() {- console.log("error getting file");- });}exports.selectDirectory = function() {- console.log("Select directory!");-+ console.log("Operation selectDirectory not supported on Android yet!");+ TSCORE.showAlertDialog("Selecting directory not supported on Android yet, please type the desired directory path manually in textbox!");}exports.selectFile = function() {- console.log("Select file!");-+ console.log("Operation selectFile not supported on Android!");}exports.checkAccessFileURLAllowed = function() {@@ -302,14 +362,10 @@ define(function (require, exports, module) {}exports.openDirectory = function(dirPath) {- // TODO implement openDirectory- console.log("Open directory functionality not implemented on android yet!");- TSCORE.showAlertDialog("Select file functionality not implemented on chrome yet!");+ TSCORE.showAlertDialog("Select file functionality not supported on Android!");}exports.openExtensionsDirectory = function() {- // TODO implement openExtensionsDirectory- console.log("Open extensions directory functionality not implemented on android yet!");- TSCORE.showAlertDialog("Open extensions directory functionality not implemented on chrome yet!");+ TSCORE.showAlertDialog("Open extensions directory functionality not supported on Android!");}});\ No newline at end of filediff --git a/data/loader.js b/data/loader.jsindex aa291d29d..964ff5de3 100644--- a/data/loader.js+++ b/data/loader.js@@ -14,36 +14,24 @@ if (PRODUCTION == "true") {}// Temporal hacks-var isFirefox = 'MozBoxSizing' in document.documentElement.style;+var isFirefox = 'MozBoxSizing' in document.documentElement.style; // URL contains resource://var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;-var isChrome = !isSafari && 'WebkitTransform' in document.documentElement.style;+// TODO refactor isChrome to isChromeExt+var isChrome = document.URL.indexOf( 'chrome-extension://' ) >= 0; //!isSafari && 'WebkitTransform' in document.documentElement.style;var isNode = undefined;+var isCordova = document.URL.indexOf( 'file:///' ) >= 0; // Not perfect... evtl. adding of "android_asset" needed+var isWeb = undefined;- // BROWSER SNIFFING-/*- // Crude, but necessary to handle a number of hard-to-feature-detect- // bugs and behavior differences.- var gecko = /gecko\/\d/i.test(navigator.userAgent);- var ie = /MSIE \d/.test(navigator.userAgent);- var ie_lt8 = ie && (document.documentMode == null || document.documentMode < 8);- var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);- var webkit = /WebKit\//.test(navigator.userAgent);- var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent);- var chrome = /Chrome\//.test(navigator.userAgent);- var opera = /Opera\//.test(navigator.userAgent);- var safari = /Apple Computer/.test(navigator.vendor);- var khtml = /KHTML\//.test(navigator.userAgent);- var mac_geLion = /Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent);- var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent);- var phantom = /PhantomJS/.test(navigator.userAgent);-- var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);- // This is woefully incomplete. Suggestions for alternative methods welcome.- var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent);- var mac = ios || /Mac/.test(navigator.platform);- var windows = /windows/i.test(navigator.platform);-*/-console.log("Loading Loader 4 Firefox: "+isFirefox+" | Chrome: "+isChrome);+// Check for running in node-webkit+try {+ var fs = require('fs');+ var pathUtils = require('path');+ var gui = require('nw.gui');+ isNode = true;+} catch(e) {+ isNode = false;+ console.log("node-webkit not found!");+}// Setting up the IO functionality according to the platformvar IO_JS = undefined;@@ -51,21 +39,15 @@ if( isFirefox ) {IO_JS = "js/ioapi.mozilla";} else if ( isChrome ) {IO_JS = "js/ioapi.chrome";+} else if (isNode){+ IO_JS = "js/ioapi.node";+} else if (isCordova){+ IO_JS = "js/ioapi.cordova";} else {- // TODO safari and ie io handler needed- IO_JS = "js/ioapi.chrome";+ IO_JS = "js/ioapi.chrome";}-// Check for running in node-webkit-try {- var fs = require('fs');- var pathUtils = require('path');- var gui = require('nw.gui');- IO_JS = "js/ioapi.node";- isNode = true;-} catch(e) {- console.log("node-webkit not found!");-}+console.log("Loading Loader - Firefox: "+isFirefox+" | ChromeExt: "+isChrome+" | Node: "+isNode+" | Cordova: "+isCordova);requirejs.config({map: {diff --git a/data/manifest.json b/data/manifest.jsonindex 520180dfe..b52090149 100644--- a/data/manifest.json+++ b/data/manifest.json@@ -1,6 +1,6 @@{"name": "TagSpaces",- "version": "1.5.1454",+ "version": "1.5.1456","manifest_version": 2,"description": "An open and extensible platform, providing web based user interface for your local files.","icons": {diff --git a/node-webkit/package.json b/node-webkit/package.jsonindex 0f97b0880..fc9b86083 100644--- a/node-webkit/package.json+++ b/node-webkit/package.json@@ -5,7 +5,7 @@"main": "../data/index.html","window": {"icon": "icon128.png",- "toolbar": false,+ "toolbar": true,"width": 1024,"height": 800},diff --git a/package.json b/package.jsonindex 18b5e0f76..8adb4fb5f 100644--- a/package.json+++ b/package.json@@ -2,7 +2,7 @@"name": "tagspaces","license": "AGPL 3.0","author": "Ugg Rock",- "version": "1.5.1454",+ "version": "1.5.1456","fullName": "TagSpaces","id": "jid1-FBaMKxTifTSahQ","description": "TagSpaces is a firefox addon, which allows you to browse your local file system and add tags to your files.",diff --git a/update.rdf b/update.rdfindex 3748b230c..f98183992 100644--- a/update.rdf+++ b/update.rdf@@ -7,13 +7,13 @@<r:Seq><r:li><r:Description>- <version>1.5.1454</version>+ <version>1.5.1456</version><targetApplication><r:Description><id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id><minVersion>16.0</minVersion><maxVersion>*</maxVersion>- <updateLink>http://tagspaces.com/releases/1.5/tagspaces.1.5.1454.xpi</updateLink>+ <updateLink>http://tagspaces.com/releases/1.5/tagspaces.1.5.1456.xpi</updateLink><updateInfoURL>http://tagspaces.com/releases/1.5/updateInfo.xml</updateInfoURL></r:Description></targetApplication>