Skip to content

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

Added "check for new version" functionality

uggrock4948d275abd6
diff --git a/data/index.html b/data/index.html
index 45d2e1a74..bce5f7338 100644
--- a/data/index.html
+++ b/data/index.html
@@ -18,15 +18,20 @@
<link rel="stylesheet/less" type="text/css" href="css/tagspaces.less">
</head>
<body style="background-color: lightgray;">
-<div id="loading" style="text-align: center; width: 100%; font-size: 1.4em; position:absolute; top:50%; text-shadow: 0px 1px 1px #fff; ">Loading <a href="index.html">TagSpaces</a> ... </div>
+<div id="loading" style="text-align: center; width: 100%; font-size: 1.4em; position:absolute; top:50%; text-shadow: 0px 1px 1px #fff; ">
+ Loading <a href="index.html">TagSpaces</a> ...
+</div>
<div id="container" style="display: none;">
<div class="ui-layout-north" style="padding: 3px">
<a href="http://tagspaces.org" target="_new"><span id="logo">TagSpaces<sup id="appVersion"></sup></span></a>
- <span id="loadingAnimation">&nbsp;</span>
+ <span id="loadingAnimation"></span>
+ <button id="newVersionAvailable" class="btn btn-link" style="color: white; display: none" title="New TagSpaces version available" data-dropdown="#newVersionMenu">
+ <i class="icon-leaf icon-large"></i>
+ </button>
<div id="mainMenu" class="pull-right" style="margin: 0px;">
<button id="toggleLeftPanel" class="btn btn-link" title="Toggle Navigator & Tag Panel"><i class="icon-sort icon-rotate-90"></i></button>
<div id="viewSwitcher" class="btn-group" data-toggle="buttons-radio"></div>
- <button role="button" class="btn btn-link" title="Additional Actions" data-dropdown="#settingsMenu"><i class="icon-reorder"></i></b></button>
+ <button role="button" class="btn btn-link" title="Additional Actions" data-dropdown="#settingsMenu"><i class="icon-reorder"></i></button>
</div>
</div>
@@ -408,6 +413,14 @@
<ul id="fileActionsMenu" class="dropdown-menu has-tip anchor-right"></ul>
+ <ul id="newVersionMenu" class="dropdown-menu has-tip">
+ <p style="padding: 15px" id="newVersionMessageContent">
+ New TagSpaces version available on
+ <a href="https://addons.mozilla.org/firefox/addon/tagspaces/" target="_blank">addons.mozilla.org/firefox/addon/tagspaces</a> or
+ <a href="http://tagspaces.org/download/" target="_blank">tagspaces.org/download</a>
+ </p>
+ </ul>
+
</div>
</body>
</html>
\ No newline at end of file
diff --git a/data/js/core.api.js b/data/js/core.api.js
index 4885889a3..dca5b3852 100644
--- a/data/js/core.api.js
+++ b/data/js/core.api.js
@@ -19,7 +19,7 @@ define(function(require, exports, module) {
var westLayout = undefined;
var centerLayout = undefined;
var eastLayout = undefined;
-
+
var currentPath = undefined;
var currentView = undefined;
@@ -93,13 +93,28 @@ define(function(require, exports, module) {
of: $( "#reloadTagSpace" )
});
$( "#createNewLocation" ).attr("style","border:1px solid #00AE00; border-radius:5px; border-color:#00AE00; box-shadow:0 0 10px #00AE00;")
- //$( "#createNewLocation" ).tooltip( "open" );
+ $( "#createNewLocation" ).tooltip( { placement: "bottom" } );
+ $( "#createNewLocation" ).tooltip( "show" );
}
- });
-
+ });
+
+// $( "#toggleLeftPanel" ).tooltip( { placement: "bottom" } );
+ checkForNewVersion()
}
+ function checkForNewVersion() {
+ if(tsSettings.getCheckForUpdates()) {
+ tsIOApi.checkNewVersion();
+ }
+ }
+
+ function updateNewVersionData(data) {
+ console.log("Version JSON"+data)
+ // TODO Analyse JSON
+ //$("#newVersionAvailable").css('display', "inline");
+ }
+
function updateLogger(message) {
// TODO reactivate
console.debug("Updating logger...");
@@ -284,6 +299,7 @@ define(function(require, exports, module) {
exports.toggleLeftPanel = toggleLeftPanel;
exports.toggleFileDetails = toggleFileDetails;
exports.toggleFullWidth = toggleFullWidth;
+ exports.updateNewVersionData = updateNewVersionData;
// Proxying functions from tsCoreUI
exports.showAlertDialog = tsCoreUI.showAlertDialog;
@@ -314,4 +330,5 @@ define(function(require, exports, module) {
exports.fileList = fileList;
exports.selectedTag = selectedTag;
exports.selectedTagData = selectedTagData;
+
});
\ No newline at end of file
diff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.js
index 0b2c0f698..6b9b4ee46 100644
--- a/data/js/ioapi.chrome.js
+++ b/data/js/ioapi.chrome.js
@@ -223,6 +223,25 @@ New:
// TODO implement createDirectoryTree
TSCORE.PerspectiveManager.updateTreeData();
}
+
+ exports.checkNewVersion = function() {
+ console.debug("Checking for new version...");
+ $.ajax({
+ url: 'http://tagspaces.org/releases/version.json?cVer='+TSCORE.Config.DefaultSettings["appBuild"],
+ type: 'GET',
+ })
+ .done(function(data) {
+ TSCORE.updateNewVersionData(data);
+ })
+ .fail(function(data) {
+ alert(data);
+ })
+// .always(function(data) {
+// console.log("ajax complete: "+data);
+// });
+ ;
+
+ }
});
diff --git a/data/js/ioapi.mozilla.js b/data/js/ioapi.mozilla.js
index 2ffb16442..16060ad0c 100644
--- a/data/js/ioapi.mozilla.js
+++ b/data/js/ioapi.mozilla.js
@@ -169,4 +169,14 @@ exports.createDirectoryTree = function(dirPath) {
document.documentElement.dispatchEvent(event);
}
+exports.checkNewVersion = function() {
+ console.debug("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.mozilla.receiver.js b/data/js/ioapi.mozilla.receiver.js
index e94bd71af..d9d4859df 100644
--- a/data/js/ioapi.mozilla.receiver.js
+++ b/data/js/ioapi.mozilla.receiver.js
@@ -126,7 +126,15 @@ console.debug("Loading messaging.mozilla.js..");
} else {
TSCORE.updateLogger("Selecting directory failed.");
}
- break;
+ break;
+ case "checkNewVersion":
+ if(message.success){
+ TSCORE.updateLogger("Getting New Version Information Successfull");
+ TSCORE.updateNewVersionData(message.content);
+ } else {
+ TSCORE.updateLogger("Create dir failed");
+ }
+ break;
default:
break;
}
diff --git a/data/js/settings.api.js b/data/js/settings.api.js
index 4e54a3903..998d09bb4 100644
--- a/data/js/settings.api.js
+++ b/data/js/settings.api.js
@@ -48,7 +48,7 @@ define(function(require, exports, module) {
"newHTMLFileContent": "<html><head><title>Tagspaces File</title></head><body>HTML file created with tagspaces!</body></html>",
"newMDFileContent": '#Markdown file created with tagspaces!',
"showUnixHiddenEntries": false,
- "checkForUpdates": false,
+ "checkForUpdates": true,
"lastOpenedDirectory": "",
"tagspacesList": [],
"extensionsPath": "ext",
diff --git a/lib/main.js b/lib/main.js
index 4e7dc302d..dd43c5ddd 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -4,6 +4,7 @@
// the value of this var is replaced to "true" by the build script
var PRODUCTION = "@PRODUCTION@";
+var VERSION = "@VERSION@";
// Disabling all output to console in production mode
if (PRODUCTION == "true") {
@@ -13,14 +14,14 @@ if (PRODUCTION == "true") {
console.debug = function(){};
}
-// Import the APIs we need.
-var request = require("request");
+// Import the needed APIs
var selection = require("selection");
var widgets = require("widget");
var data = require('self').data;
var addontab = require("addon-page"); // Enables the opening of main UI without location bar
var ioutils = require("ioutils");
var settings = require("settings");
+var request = require("request");
var workers = [];
@@ -125,12 +126,48 @@ function detachWorker(worker) {
workers.splice(index,1);
}
+var checkForNewVersion = request.Request({
+ url: "http://tagspaces.org/releases/version.json?fVer="+VERSION,
+ onComplete: function (response) {
+// console.log("Result: " + response.text + " " + response.status);
+ return response.text;
+ }
+});
+
+function checkNewVersion(worker) {
+ try {
+ var content = undefined;
+ var versionReq = request.Request({
+ url: "http://tagspaces.org/releases/version.json?fVer="+VERSION,
+ onComplete: function (response) {
+ console.log("Result: " + response.text + " " + response.status);
+ response.text;
+ worker.postMessage({
+ "command": "checkNewVersion",
+ "content": response.text,
+ "success": true
+ });
+ console.debug("Loading settings successful!");
+ }
+ }).get();
+ } catch(ex) {
+ worker.postMessage({
+ "command": "checkNewVersion",
+ "success": false
+ });
+ console.error("Checking new version failed "+ex);
+ }
+}
+
function handleMessage(msg, worker) {
console.debug("Message in main.js: "+JSON.stringify(msg)+" from tab "+worker.tab.title);
//console.log("Thumbnail: "+worker.tab.getThumbnail());
switch (msg.detail.command) {
case "loadSettings":
settings.loadSettings(worker)
+ break;
+ case "checkNewVersion":
+ checkNewVersion(worker);
break;
case "saveSettings":
settings.saveSettings(msg.detail.content,worker)