mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-06-25 23:03:15 +00:00
Add preliminary Dat file saver
See https://datproject.org/ and https://beakerbrowser.com/
This commit is contained in:
parent
daad0ec142
commit
a20da9f530
55
core/modules/savers/dat.js
Normal file
55
core/modules/savers/dat.js
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/*\
|
||||||
|
title: $:/core/modules/savers/dat.js
|
||||||
|
type: application/javascript
|
||||||
|
module-type: saver
|
||||||
|
|
||||||
|
Saves wiki using the Dat protocol (https://datproject.org/)
|
||||||
|
|
||||||
|
\*/
|
||||||
|
(function(){
|
||||||
|
|
||||||
|
/*jslint node: true, browser: true */
|
||||||
|
/*global $tw: false */
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Select the appropriate saver module and set it up
|
||||||
|
*/
|
||||||
|
var DatSaver = function(wiki) {
|
||||||
|
this.wiki = wiki;
|
||||||
|
};
|
||||||
|
|
||||||
|
DatSaver.prototype.save = function(text,method,callback) {
|
||||||
|
console.log("Saving Dat")
|
||||||
|
dat.writeFile(document.location.protocol + "//" + document.location.hostname + ":" + document.location.port + document.location.pathname,text,"utf8").then(function(value) {
|
||||||
|
callback(null);
|
||||||
|
},function(reason) {
|
||||||
|
callback("Dat Saver Error: " + reason);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Information about this saver
|
||||||
|
*/
|
||||||
|
DatSaver.prototype.info = {
|
||||||
|
name: "dat",
|
||||||
|
priority: 3000,
|
||||||
|
capabilities: ["save", "autosave"]
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Static method that returns true if this saver is capable of working
|
||||||
|
*/
|
||||||
|
exports.canSave = function(wiki) {
|
||||||
|
return !!window.dat;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Create an instance of this saver
|
||||||
|
*/
|
||||||
|
exports.create = function(wiki) {
|
||||||
|
return new DatSaver(wiki);
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
Loading…
Reference in New Issue
Block a user