Add support for downloading files

We were re-using the `tw-save-wiki` message both for saving the current
wiki and downloading a new wiki. Now we’ll use the separate
`tw-download-file` message for downloading.

Fixes #236
This commit is contained in:
Jermolene
2013-11-27 20:51:08 +00:00
parent 7175f1cbf1
commit 0956ae10a0
10 changed files with 36 additions and 11 deletions
+5 -1
View File
@@ -15,7 +15,11 @@ Handles saving changes via the AndTidWiki Android app
var AndTidWiki = function(wiki) {
};
AndTidWiki.prototype.save = function(text,callback) {
AndTidWiki.prototype.save = function(text,method,callback) {
// Bail out unless this is a save (rather than a download)
if(method !== "save") {
return false;
}
// Get the pathname of this document
var pathname = decodeURIComponent(document.location.toString());
// Strip the file://
+1 -1
View File
@@ -18,7 +18,7 @@ Select the appropriate saver module and set it up
var DownloadSaver = function(wiki) {
};
DownloadSaver.prototype.save = function(text) {
DownloadSaver.prototype.save = function(text,method,callback) {
// Get the current filename
var filename = "tiddlywiki.html",
p = document.location.pathname.lastIndexOf("/");
+1 -1
View File
@@ -21,7 +21,7 @@ Select the appropriate saver module and set it up
var ManualDownloadSaver = function(wiki) {
};
ManualDownloadSaver.prototype.save = function(text) {
ManualDownloadSaver.prototype.save = function(text,method,callback) {
$tw.modal.display(downloadInstructionsTitle,{
downloadLink: "data:text/html," + encodeURIComponent(text)
});
+1 -1
View File
@@ -18,7 +18,7 @@ Select the appropriate saver module and set it up
var MsDownloadSaver = function(wiki) {
};
MsDownloadSaver.prototype.save = function(text) {
MsDownloadSaver.prototype.save = function(text,method,callback) {
// Get the current filename
var filename = "tiddlywiki.html",
p = document.location.pathname.lastIndexOf("/");
+5 -1
View File
@@ -15,7 +15,11 @@ Handles saving changes via the TiddlyFox file extension
var TiddlyFoxSaver = function(wiki) {
};
TiddlyFoxSaver.prototype.save = function(text,callback) {
TiddlyFoxSaver.prototype.save = function(text,method,callback) {
// Bail out unless this is a save (rather than a download)
if(method !== "save") {
return false;
}
var messageBox = document.getElementById("tiddlyfox-message-box");
if(messageBox) {
// Get the pathname of this document
+5 -1
View File
@@ -15,7 +15,11 @@ Handles saving changes via the TWEdit iOS app
var TWEditSaver = function(wiki) {
};
TWEditSaver.prototype.save = function(text,callback) {
TWEditSaver.prototype.save = function(text,method,callback) {
// Bail out unless this is a save (rather than a download)
if(method !== "save") {
return false;
}
// Bail if we're not running under TWEdit
if(typeof DeviceInfo !== "object") {
return false;
+5 -1
View File
@@ -21,7 +21,11 @@ var UploadSaver = function(wiki) {
this.wiki = wiki;
};
UploadSaver.prototype.save = function(text,callback) {
UploadSaver.prototype.save = function(text,method,callback) {
// Bail out unless this is a save (rather than a download)
if(method !== "save") {
return false;
}
// Get the various parameters we need
var backupDir = ".",
username = this.wiki.getTextReference("$:/UploadName"),