mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-03-24 04:16:56 +00:00
Added a saver for the TWEdit iPad/iPhone app
This commit is contained in:
parent
e65138085f
commit
c0683fd65c
90
core/modules/savers/twedit.js
Normal file
90
core/modules/savers/twedit.js
Normal file
@ -0,0 +1,90 @@
|
||||
/*\
|
||||
title: $:/core/modules/savers/twedit.js
|
||||
type: application/javascript
|
||||
module-type: saver
|
||||
|
||||
Handles saving changes via the TWEdit iOS app
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false, netscape: false, Components: false */
|
||||
"use strict";
|
||||
|
||||
var TWEditSaver = function(wiki) {
|
||||
};
|
||||
|
||||
TWEditSaver.prototype.save = function(text,callback) {
|
||||
// Bail if we're not running under TWEdit
|
||||
if(typeof DeviceInfo !== "object") {
|
||||
return false;
|
||||
}
|
||||
// Get the pathname of this document
|
||||
var pathname = decodeURIComponent(document.location.pathname);
|
||||
// Strip any query or location part
|
||||
var p = pathname.indexOf("?");
|
||||
if(p !== -1) {
|
||||
pathname = pathname.substr(0,p);
|
||||
}
|
||||
p = pathname.indexOf("#");
|
||||
if(p !== -1) {
|
||||
pathname = pathname.substr(0,p);
|
||||
}
|
||||
// Remove the leading "/Documents" from path
|
||||
var prefix = "/Documents";
|
||||
if(pathname.indexOf(prefix) === 0) {
|
||||
pathname = pathname.substr(prefix.length);
|
||||
}
|
||||
// Error handler
|
||||
var errorHandler = function(event) {
|
||||
// Error
|
||||
callback("Error saving to TWEdit: " + event.target.error.code);
|
||||
};
|
||||
// Get the file system
|
||||
window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(fileSystem) {
|
||||
// Now we've got the filesystem, get the fileEntry
|
||||
fileSystem.root.getFile(pathname, {create: true}, function(fileEntry) {
|
||||
// Now we've got the fileEntry, create the writer
|
||||
fileEntry.createWriter(function(writer) {
|
||||
writer.onerror = errorHandler;
|
||||
writer.onwrite = function() {
|
||||
callback(null);
|
||||
};
|
||||
writer.position = 0;
|
||||
writer.write(text);
|
||||
},errorHandler);
|
||||
}, errorHandler);
|
||||
}, errorHandler);
|
||||
return true;
|
||||
};
|
||||
|
||||
/*
|
||||
Information about this saver
|
||||
*/
|
||||
TWEditSaver.prototype.info = {
|
||||
name: "twedit",
|
||||
priority: 1600
|
||||
};
|
||||
|
||||
/*
|
||||
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 TWEditSaver(wiki);
|
||||
};
|
||||
|
||||
/////////////////////////// Hack
|
||||
// HACK: This ensures that TWEdit recognises us as a TiddlyWiki document
|
||||
if($tw.browser) {
|
||||
window.version = {title: "TiddlyWiki"};
|
||||
}
|
||||
|
||||
})();
|
@ -0,0 +1,20 @@
|
||||
title: How to use TiddlyWiki5 as a standalone HTML file with TWEdit
|
||||
tags: docs howto
|
||||
modified: 201305141919
|
||||
|
||||
The iPad/iPhone app ''TWEdit'' makes it possible to edit and save changes to TiddlyWiki5, including working offline without a network connection. [[Download it here|https://itunes.apple.com/gb/app/twedit/id409607956?mt=8]].
|
||||
|
||||
Instructions for use:
|
||||
|
||||
# Open TWEdit
|
||||
# Touch the title in the centre of the toolbar in order
|
||||
#* A text box should appear allowing you to enter a URL
|
||||
# Enter the URL `http://five.tiddlywiki.com/empty.html`
|
||||
# When the empty TiddlyWiki5 has loaded, touch the ''save'' icon (it's the second icon from the right on the top toolbar)
|
||||
#* An alert box should appear allowing you to enter a local filename
|
||||
# Enter the filename you wish to use for the document (ending with `.html`)
|
||||
# Edit your TiddlyWiki as normal
|
||||
# To save changes, click the ''save'' button in the sidebar
|
||||
#* A confirmation message should appear at the upper right
|
||||
|
||||
//Note that TWEdit is published independently of TiddlyWiki//
|
@ -1,10 +1,14 @@
|
||||
title: TiddlyWiki5 Editions
|
||||
tags: introduction
|
||||
title: TiddlyWiki5 Editions
|
||||
modified: 201305141912
|
||||
|
||||
The core TiddlyWiki5 code is packaged into several distinct editions designed for different situations:
|
||||
|
||||
* [[TiddlyWiki5 Standalone Edition]] for working purely within the browser
|
||||
** Including [[TiddlyWiki5 in the Sky for TiddlySpot|TiddlySpot]]
|
||||
** [[Using TiddlyFox|How to use TiddlyWiki5 as a standalone HTML file with TiddlyFox]]
|
||||
** [[Encrypting TiddlyWiki5|How to use TiddlyWiki5 as a standalone HTML file with encryption]]
|
||||
** [[Using TWEdit on iPad and iPhone|How to use TiddlyWiki5 as a standalone HTML file with TWEdit]]
|
||||
** [[Using TiddlyWiki5 with TiddlySpot|TiddlySpot]]
|
||||
* [[TiddlyWiki5 Node Edition]] for advanced command line work
|
||||
** Including [[TiddlyWiki5 Static Site Generation]]
|
||||
** Including [[Building classic TiddlyWiki with TiddlyWiki5]]
|
||||
|
Loading…
x
Reference in New Issue
Block a user