mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +00:00
Fix for beaker 072 - new dat API (#2918)
* initial version that works again with beaker 0.7.2 * activate path again
This commit is contained in:
parent
cf9085b5ce
commit
ef9efbc399
@ -4,6 +4,7 @@ type: application/javascript
|
|||||||
module-type: saver
|
module-type: saver
|
||||||
|
|
||||||
Saves files using the Beaker browser's (https://beakerbrowser.com) Dat protocol (https://datproject.org/)
|
Saves files using the Beaker browser's (https://beakerbrowser.com) Dat protocol (https://datproject.org/)
|
||||||
|
Compatible with beaker >= V0.7.2
|
||||||
|
|
||||||
\*/
|
\*/
|
||||||
(function(){
|
(function(){
|
||||||
@ -19,17 +20,20 @@ var BeakerSaver = function(wiki) {
|
|||||||
this.wiki = wiki;
|
this.wiki = wiki;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var dat = new DatArchive('' + window.location);
|
||||||
|
|
||||||
BeakerSaver.prototype.save = function(text,method,callback) {
|
BeakerSaver.prototype.save = function(text,method,callback) {
|
||||||
var url = (location.toString()).split("#")[0];
|
var path = (location.pathname.toString()).split("#")[0];
|
||||||
dat.stat(url).then(function(value) {
|
|
||||||
if(value.type === "directory") {
|
dat.stat(path).then(function(value) {
|
||||||
url = url + "/index.html";
|
if(value.isDirectory) {
|
||||||
|
path = path + "/index.html";
|
||||||
}
|
}
|
||||||
dat.writeFile(url,text,"utf8").then(function(value) {
|
dat.writeFile(path,text,"utf8").then(function(value) {
|
||||||
callback(null);
|
callback(null);
|
||||||
},function(reason) {
|
},function(reason) {
|
||||||
callback("Beaker Saver Write Error: " + reason);
|
callback("Beaker Saver Write Error: " + reason);
|
||||||
});
|
});
|
||||||
},function(reason) {
|
},function(reason) {
|
||||||
callback("Beaker Saver Stat Error: " + reason);
|
callback("Beaker Saver Stat Error: " + reason);
|
||||||
});
|
});
|
||||||
@ -49,7 +53,7 @@ BeakerSaver.prototype.info = {
|
|||||||
Static method that returns true if this saver is capable of working
|
Static method that returns true if this saver is capable of working
|
||||||
*/
|
*/
|
||||||
exports.canSave = function(wiki) {
|
exports.canSave = function(wiki) {
|
||||||
return !!window.dat;
|
return !!window.DatArchive;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user