mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 18:00:26 +00:00
More logging
This commit is contained in:
parent
3f9561dd95
commit
dfc57ffa49
@ -38,8 +38,7 @@ function Syncer(options) {
|
|||||||
Error handling
|
Error handling
|
||||||
*/
|
*/
|
||||||
Syncer.prototype.showError = function(error) {
|
Syncer.prototype.showError = function(error) {
|
||||||
alert("Syncer error: " + error);
|
this.log("Error: " + error);
|
||||||
this.log("Syncer error: " + error);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -19,6 +19,7 @@ function TiddlyWebAdaptor(syncer) {
|
|||||||
this.syncer = syncer;
|
this.syncer = syncer;
|
||||||
this.host = this.getHost();
|
this.host = this.getHost();
|
||||||
this.recipe = undefined;
|
this.recipe = undefined;
|
||||||
|
this.log = $tw.logger.makeLog("TiddlyWebAdaptor");
|
||||||
}
|
}
|
||||||
|
|
||||||
TiddlyWebAdaptor.prototype.getHost = function() {
|
TiddlyWebAdaptor.prototype.getHost = function() {
|
||||||
@ -47,7 +48,7 @@ TiddlyWebAdaptor.prototype.getStatus = function(callback) {
|
|||||||
// Get status
|
// Get status
|
||||||
var self = this,
|
var self = this,
|
||||||
wiki = self.syncer.wiki;
|
wiki = self.syncer.wiki;
|
||||||
this.syncer.log("Getting status");
|
this.log("Getting status");
|
||||||
$tw.utils.httpRequest({
|
$tw.utils.httpRequest({
|
||||||
url: this.host + "status",
|
url: this.host + "status",
|
||||||
callback: function(err,data) {
|
callback: function(err,data) {
|
||||||
@ -62,6 +63,7 @@ TiddlyWebAdaptor.prototype.getStatus = function(callback) {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
if(json) {
|
if(json) {
|
||||||
|
self.log("Status:",data);
|
||||||
// Record the recipe
|
// Record the recipe
|
||||||
if(json.space) {
|
if(json.space) {
|
||||||
self.recipe = json.space.recipe;
|
self.recipe = json.space.recipe;
|
||||||
@ -81,8 +83,7 @@ TiddlyWebAdaptor.prototype.getStatus = function(callback) {
|
|||||||
Attempt to login and invoke the callback(err)
|
Attempt to login and invoke the callback(err)
|
||||||
*/
|
*/
|
||||||
TiddlyWebAdaptor.prototype.login = function(username,password,callback) {
|
TiddlyWebAdaptor.prototype.login = function(username,password,callback) {
|
||||||
var self = this;
|
var options = {
|
||||||
$tw.utils.httpRequest({
|
|
||||||
url: this.host + "challenge/tiddlywebplugins.tiddlyspace.cookie_form",
|
url: this.host + "challenge/tiddlywebplugins.tiddlyspace.cookie_form",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
@ -93,14 +94,15 @@ TiddlyWebAdaptor.prototype.login = function(username,password,callback) {
|
|||||||
callback: function(err) {
|
callback: function(err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
this.log("Logging in:",options);
|
||||||
|
$tw.utils.httpRequest(options);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
TiddlyWebAdaptor.prototype.logout = function(callback) {
|
TiddlyWebAdaptor.prototype.logout = function(callback) {
|
||||||
var self = this;
|
var options = {
|
||||||
$tw.utils.httpRequest({
|
|
||||||
url: this.host + "logout",
|
url: this.host + "logout",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
@ -110,7 +112,9 @@ TiddlyWebAdaptor.prototype.logout = function(callback) {
|
|||||||
callback: function(err,data) {
|
callback: function(err,data) {
|
||||||
callback(err);
|
callback(err);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
this.log("Logging out:",options);
|
||||||
|
$tw.utils.httpRequest(options);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -198,6 +202,11 @@ Delete a tiddler and invoke the callback with (err)
|
|||||||
TiddlyWebAdaptor.prototype.deleteTiddler = function(title,callback) {
|
TiddlyWebAdaptor.prototype.deleteTiddler = function(title,callback) {
|
||||||
var self = this,
|
var self = this,
|
||||||
bag = this.syncer.tiddlerInfo[title].adaptorInfo.bag;
|
bag = this.syncer.tiddlerInfo[title].adaptorInfo.bag;
|
||||||
|
// If we don't have a bag it means that the tiddler hasn't been seen by the server, so we don't need to delete it
|
||||||
|
if(!bag) {
|
||||||
|
return callback(null);
|
||||||
|
}
|
||||||
|
// Issue HTTP request to delete the tiddler
|
||||||
$tw.utils.httpRequest({
|
$tw.utils.httpRequest({
|
||||||
url: this.host + "bags/" + encodeURIComponent(bag) + "/tiddlers/" + encodeURIComponent(title),
|
url: this.host + "bags/" + encodeURIComponent(bag) + "/tiddlers/" + encodeURIComponent(title),
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
|
Loading…
Reference in New Issue
Block a user