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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user