mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-09-10 06:46:06 +00:00
Experimental plugin for Tahoe-LAFS
This commit is contained in:
7
plugins/tiddlywiki/tahoelafs/plugin.info
Normal file
7
plugins/tiddlywiki/tahoelafs/plugin.info
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"title": "$:/plugins/tiddlywiki/tahoelafs",
|
||||
"description": "Support for saving changes to Tahoe-LAFS",
|
||||
"author": "JeremyRuston",
|
||||
"version": "0.0.0",
|
||||
"coreVersion": ">=5.0.0"
|
||||
}
|
57
plugins/tiddlywiki/tahoelafs/saver.js
Normal file
57
plugins/tiddlywiki/tahoelafs/saver.js
Normal file
@@ -0,0 +1,57 @@
|
||||
/*\
|
||||
title: $:/plugins/tiddlywiki/tahoelafs/saver.js
|
||||
type: application/javascript
|
||||
module-type: saver
|
||||
|
||||
A bare bones saver for Tahoe-LAFS. It just PUTs the new HTML file back to the server at the same URL.
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
Select the appropriate saver module and set it up
|
||||
*/
|
||||
var TahoeSaver = function(wiki) {
|
||||
this.wiki = wiki;
|
||||
};
|
||||
|
||||
TahoeSaver.prototype.save = function(text) {
|
||||
// Do the HTTP post
|
||||
var http = new XMLHttpRequest();
|
||||
http.open("PUT",document.location.toString(),true);
|
||||
http.onreadystatechange = function() {
|
||||
if(http.readyState == 4 && http.status == 200) {
|
||||
window.alert("Saved to Tahoe-LAFS: " + http.responseText);
|
||||
}
|
||||
};
|
||||
http.send(text);
|
||||
return true;
|
||||
};
|
||||
|
||||
/*
|
||||
Information about this saver
|
||||
*/
|
||||
TahoeSaver.prototype.info = {
|
||||
name: "tahoelafs",
|
||||
priority: 1000
|
||||
};
|
||||
|
||||
/*
|
||||
Static method that returns true if this saver is capable of working
|
||||
*/
|
||||
exports.canSave = function(wiki) {
|
||||
return true;
|
||||
};
|
||||
|
||||
/*
|
||||
Create an instance of this saver
|
||||
*/
|
||||
exports.create = function(wiki) {
|
||||
return new TahoeSaver(wiki);
|
||||
};
|
||||
|
||||
})();
|
Reference in New Issue
Block a user