Skip to content

TagSpaces is an offline, open source, document manager with tagging support

adding initial implementation for firefox os

Ilian8ed4fb390fc5
diff --git a/data/loader.js b/data/loader.js
index ed3ad06f9..6c5a7d640 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -14,6 +14,7 @@ if (PRODUCTION == "true") {
}
var isFirefox = document.URL.indexOf( 'resource://' ) == 0;
+var isFirefoxOS = document.URL.indexOf( 'app://' ) == 0;
//var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
var isChrome = document.URL.indexOf( 'chrome-extension://' ) == 0;
var isNode = undefined;
@@ -37,6 +38,8 @@ try {
var IO_JS = undefined;
if( isFirefox ) {
IO_JS = "mozilla/mozilla.api";
+} else if ( isFirefoxOS ) {
+ IO_JS = "mozilla/firefoxos.api";
} else if ( isChrome ) {
IO_JS = "chrome/chrome.api";
} else if (isNode){
diff --git a/data/manifest.webapp b/data/manifest.webapp
new file mode 100644
index 000000000..f5069bfe6
--- /dev/null
+++ b/data/manifest.webapp
@@ -0,0 +1,31 @@
+{
+ "version":"1.0",
+ "name": "TagSpaces",
+ "description": "TagSpaces",
+ "launch_path": "/index.html",
+ "developer": {
+ "name": "TagSpaces Authors",
+ "url": "http://tagspaces.com"
+ },
+ "locales": {
+ "en-US": {
+ "name": "TagSpaces",
+ "description": "TagSpaces"
+ }
+ },
+ "default_locale": "en-US",
+ "icons": {
+ "16": "/assets/icon16.png",
+ "32": "/assets/icon32.png",
+ "48": "/assets/icon48.png",
+ "128": "/assets/icon128.png"
+ },
+ "orientation": "portrait-primary",
+ "type": "privileged",
+ "permissions": {
+ "device-storage:videos": { "access": "readwrite" },
+ "device-storage:pictures":{ "access": "readwrite" },
+ "device-storage:sdcard": { "access": "readwrite" },
+ "device-storage:music": { "access": "readwrite" }
+ }
+}
\ No newline at end of file
diff --git a/data/mozilla/firefoxos.api.js b/data/mozilla/firefoxos.api.js
new file mode 100644
index 000000000..2ec358719
--- /dev/null
+++ b/data/mozilla/firefoxos.api.js
@@ -0,0 +1,235 @@
+/* Copyright (c) 2012-2014 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) {
+"use strict";
+
+ // Activating browser specific exports modul
+ console.log("Loading firefoxos.js..");
+
+ var TSCORE = require("tscore");
+ var TSPOSTIO = require("tspostioapi");
+
+
+
+ /* var directoryExist = function(dirPath) {
+ console.log("Checks if a directory exist: "+dirPath);
+ //TSPOSTIO.
+ }; */
+
+ var createDirectoryIndex = function(dirPath) {
+ console.log("Creating index for directory: "+dirPath);
+ TSCORE.showLoadingAnimation();
+
+ var directoryIndex = [];
+ TSPOSTIO.createDirectoryIndex(directoryIndex);
+ };
+
+ var createDirectoryTree = function(dirPath) {
+ console.log("Creating directory index for: "+dirPath);
+ TSCORE.showLoadingAnimation();
+
+ var directoyTree = [];
+ //console.log(JSON.stringify(directoyTree));
+ TSPOSTIO.createDirectoryTree(directoyTree);
+ };
+
+ var createDirectory = function(dirPath) {
+ console.log("Creating directory: "+dirPath);
+ TSCORE.showLoadingAnimation();
+
+ TSPOSTIO.createDirectory(dirPath);
+
+ };
+
+ var renameFile = function(filePath, newFilePath) {
+ console.log("Renaming file: "+filePath+" to "+newFilePath);
+ TSCORE.showLoadingAnimation();
+
+ TSPOSTIO.renameFile(filePath, newFilePath);
+ };
+
+ var loadTextFile = function(filePath) {
+ console.log("Loading file: "+filePath);
+ TSCORE.showLoadingAnimation();
+
+ TSPOSTIO.loadTextFile(content);
+ };
+
+ var saveTextFile = function(filePath,content,overWrite) {
+ console.log("Saving file: "+filePath);
+ TSCORE.showLoadingAnimation();
+
+
+ // Handling the UTF8 support for text files
+ var UTF8_BOM = "\ufeff";
+
+ if(content.indexOf(UTF8_BOM) == 0) {
+ // already has a UTF8 bom
+ } else {
+ content = UTF8_BOM+content;
+ }
+
+ var isNewFile = !pathUtils.existsSync(filePath);
+
+ TSPOSTIO.saveTextFile(filePath, isNewFile);
+ };
+
+ /*
+ http://rominirani.com/2013/08/16/firefox-os-tutorial-episode-9-device-storage/
+ listContents('sdcard');
+ listContents('videos');
+ listContents('music');
+ listContents('pictures');
+
+ */
+ function listContents(storagename) {
+ //Clear up the list first
+ var files = navigator.getDeviceStorage(storagename);
+ var cursor = files.enumerate();
+ console.log("Listing storage!");
+ cursor.onsuccess = function () {
+ console.log("Listing storage success!");
+ var file = this.result;
+ if (file != null) {
+ //var imageElement = $('<img height="100" width="75">');
+ //imageElement.attr('src', window.URL.createObjectURL(file));
+ //$("<p>" + file.name + "," + file.lastModifiedDate + "," + file.type + "," + file.size + "</p>").appendTo('#results');
+ //imageElement.appendTo("#results");
+ console.log("file: " + file.name + "," + file.lastModifiedDate + "," + file.type + "," + file.size);
+ this.done = false;
+ } else {
+ this.done = true;
+ }
+ if (!this.done) {
+ this.continue();
+ }
+ };
+ cursor.onerror = function (e) {
+ console.log("Listing storage failed! "+e);
+ };
+ }
+
+ listContents('sdcard');
+
+
+ var listDirectory = function(dirPath) {
+ console.log("Listing directory: "+dirPath);
+ TSCORE.showLoadingAnimation();
+
+
+ TSPOSTIO.errorOpeningPath();
+
+ var anotatedDirList = [],
+ dirList = []; // remove
+ for (var i=0; i < dirList.length; i++) {
+ var path = dirPath+TSCORE.dirSeparator+dirList[i];
+ var stats = fs.statSync(path);
+ //console.log('stats: ' + JSON.stringify(stats));
+ anotatedDirList.push({
+ "name": dirList[i],
+ "isFile": !stats.isDirectory(),
+ "size": stats.size,
+ "lmdt": stats.mtime,
+ "path": path
+ });
+ }
+ TSPOSTIO.listDirectory(anotatedDirList);
+
+
+
+ };
+
+ var deleteElement = function(path) {
+ console.log("Deleting: "+path);
+ TSCORE.showLoadingAnimation();
+
+ TSPOSTIO.deleteElement(path);
+
+ };
+
+ var checkAccessFileURLAllowed = function() {
+ console.log("checkAccessFileURLAllowed function not relevant for node..");
+ };
+
+ var checkNewVersion = function() {
+ console.log("Checking for new version...");
+ var cVer = TSCORE.Config.DefaultSettings["appVersion"]+"."+TSCORE.Config.DefaultSettings["appBuild"];
+ $.ajax({
+ url: 'http://tagspaces.org/releases/version.json?nVer='+cVer,
+ type: 'GET',
+ })
+ .done(function(data) {
+ TSPOSTIO.checkNewVersion(data);
+ })
+ .fail(function(data) {
+ console.log("AJAX failed "+data);
+ })
+ ;
+ };
+
+ var selectDirectory = function() {
+
+ };
+
+ var openDirectory = function(dirPath) {
+
+ };
+
+ var openFile = function(filePath) {
+
+ };
+
+ var selectFile = function() {
+ };
+
+ var openExtensionsDirectory = function() {
+
+ };
+
+/* stats for file:
+ dev: 2114,
+ ino: 48064969,
+ mode: 33188,
+ nlink: 1,
+ uid: 85,
+ gid: 100,
+ rdev: 0,
+ size: 527,
+ blksize: 4096,
+ blocks: 8,
+ atime: Mon, 10 Oct 2011 23:24:11 GMT,
+ mtime: Mon, 10 Oct 2011 23:24:11 GMT,
+ ctime: Mon, 10 Oct 2011 23:24:11 GMT
+*/
+ var getFileProperties = function(filePath) {
+ var fileProperties = {};
+/* var stats = fs.statSync(filePath);
+ if (stats.isFile()) {
+ fileProperties.path = filePath;
+ fileProperties.size = stats.size;
+ fileProperties.lmdt = stats.mtime;
+ TSPOSTIO.getFileProperties(fileProperties);
+ } else {
+ console.warn("Error getting file properties. "+filePath+" is directory");
+ }*/
+ };
+
+ exports.createDirectory = createDirectory;
+ exports.renameFile = renameFile;
+ exports.loadTextFile = loadTextFile;
+ exports.saveTextFile = saveTextFile;
+ exports.listDirectory = listDirectory;
+ exports.deleteElement = deleteElement;
+ exports.createDirectoryIndex = createDirectoryIndex;
+ exports.createDirectoryTree = createDirectoryTree;
+ exports.selectDirectory = selectDirectory;
+ exports.openDirectory = openDirectory;
+ exports.openFile = openFile;
+ exports.selectFile = selectFile;
+ exports.openExtensionsDirectory = openExtensionsDirectory;
+ exports.checkAccessFileURLAllowed = checkAccessFileURLAllowed;
+ exports.checkNewVersion = checkNewVersion;
+ exports.getFileProperties = getFileProperties;
+
+});
\ No newline at end of file
diff --git a/data/mozilla/mozilla.manifest.tmpl.webapp b/data/mozilla/mozilla.manifest.tmpl.webapp
index 457033568..44ec1d90c 100644
--- a/data/mozilla/mozilla.manifest.tmpl.webapp
+++ b/data/mozilla/mozilla.manifest.tmpl.webapp
@@ -1,10 +1,10 @@
{
+ "version":"1.0",
"name": "TagSpaces",
"description": "TagSpaces",
- "type": "certified?",
"launch_path": "/index.html",
"developer": {
- "name": "The TagSpaces Team",
+ "name": "TagSpaces Authors",
"url": "http://tagspaces.com"
},
"locales": {
@@ -15,8 +15,17 @@
},
"default_locale": "en-US",
"icons": {
- "120": "/Icon64.png",
- "60": "/Icon64.png"
+ "16": "/assets/icon16.png",
+ "32": "/assets/icon32.png",
+ "48": "/assets/icon48.png",
+ "128": "/assets/icon128.png"
},
"orientation": "portrait-primary"
+ "type": "privileged",
+ "permissions": {
+ "device-storage:videos": { "access": "readwrite" },
+ "device-storage:pictures":{ "access": "readwrite" },
+ "device-storage:sdcard": { "access": "readwrite" },
+ "device-storage:music": { "access": "readwrite" }
+ }
}
diff --git a/data/templates/OptionsDialog.html b/data/templates/OptionsDialog.html
index 9b227f209..5f42648b6 100644
--- a/data/templates/OptionsDialog.html
+++ b/data/templates/OptionsDialog.html
@@ -16,13 +16,13 @@
<div class="tab-pane active" id="general" style="height: 370px; padding-top: 10px; overflow-y: auto;">
<div class='form-group'>
<label class="checkbox">
- <input type='checkbox' id='showHiddenFilesCheckbox' >
+ <input type='checkbox' id='showHiddenFilesCheckbox' />
Show files/directories with a dot(.) in front of the name (e.g. Unix, Linux, OS X hidden files)
</label>
</div>
<div class='form-group'>
<label class="checkbox">
- <input type='checkbox' id='checkforUpdatesCheckbox' >
+ <input type='checkbox' id='checkforUpdatesCheckbox' />
Check for new version on startup
</label>
</div>
@@ -49,14 +49,14 @@
<label for='extensionsPathInput' data-i18n="app.extensionsFolder">Extensions folder (default value is "ext")</label>
<input type='text' class='form-control' id='extensionsPathInput'
data-i18n="[placeholder]app" placeholder='file:///c:\\tagspaces-extensions'
- data-i18n="[title]app" title='Path to your tagspaces extensions'>
+ data-i18n="[title]app" title='Path to your tagspaces extensions' />
</div>
<!--button class="btn btn-default" style="margin-bottom: 10px" id="switchLang" data-i18n="[title]app.switchLanguageTooltip;">
<i class="fa fa-asterisk"> Test Change Language</i>
</button-->
<div class='form-group'>
<label class="checkbox">
- <input type='checkbox' id='calculateTagsCheckbox' >
+ <input type='checkbox' id='calculateTagsCheckbox' />
Calculate tags from the current search results
</label>
<p class="help-block">Reduces the performance while browsing directories</p>
@@ -65,13 +65,13 @@
<label for='tagsDelimiterInput' data-i18n="app.extensionsFolder">Tag delimiter (e.g. Filename[TAG1_TAG2], _ is the delimiter)</label>
<input type='text' class='form-control' id='tagsDelimiterInput'
data-i18n="[placeholder]app" placeholder=''
- data-i18n="[title]app" title=''>
+ data-i18n="[title]app" title='' />
</div>
<div class='form-group'>
<label for='prefixTagContainerInput' data-i18n="app.extensionsFolder">Prefix for the tag container (e.g. in "Filename-[TAG1].txt" - is the prefix), </label>
<input type='text' class='form-control' id='prefixTagContainerInput'
data-i18n="[placeholder]app" placeholder=''
- data-i18n="[title]app" title=''>
+ data-i18n="[title]app" title='' />
</div>
</div>