1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-12 05:23:00 +00:00

Update savers to specify variables, including filename

Now the `tm-download-file` and `tm-save-file` messages use the hashmap
to specify variables to be applied when rendering the tiddler.

We also add a convention that the variable “filename” is used to
specify a filename for the download.
This commit is contained in:
Jermolene
2014-11-10 19:54:19 +00:00
parent b70b85aa9e
commit b520efdeb8
4 changed files with 49 additions and 9 deletions

View File

@@ -18,12 +18,17 @@ Select the appropriate saver module and set it up
var DownloadSaver = function(wiki) {
};
DownloadSaver.prototype.save = function(text,method,callback) {
DownloadSaver.prototype.save = function(text,method,callback,options) {
options = options || {};
// Get the current filename
var filename = "tiddlywiki.html",
p = document.location.pathname.lastIndexOf("/");
if(p !== -1) {
filename = document.location.pathname.substr(p+1);
var filename = options.variables.filename;
if(!filename) {
var p = document.location.pathname.lastIndexOf("/");
if(p !== -1) {
filename = document.location.pathname.substr(p+1);
} else {
filename = "tiddlywiki.html";
}
}
// Set up the link
var link = document.createElement("a");