mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-07-21 19:32:50 +00:00
Fix incorrect downloaded file extension
This commit is contained in:
parent
76f40208af
commit
aa422d83ca
@ -232,10 +232,10 @@ $tw.utils.error = function(err) {
|
|||||||
var link = dm("a"),
|
var link = dm("a"),
|
||||||
text = JSON.stringify(tiddlers);
|
text = JSON.stringify(tiddlers);
|
||||||
if(Blob !== undefined) {
|
if(Blob !== undefined) {
|
||||||
var blob = new Blob([text], {type: "text/html"});
|
var blob = new Blob([text], {type: "application/json"});
|
||||||
link.setAttribute("href", URL.createObjectURL(blob));
|
link.setAttribute("href", URL.createObjectURL(blob));
|
||||||
} else {
|
} else {
|
||||||
link.setAttribute("href","data:text/html," + encodeURIComponent(text));
|
link.setAttribute("href","data:application/json," + encodeURIComponent(text));
|
||||||
}
|
}
|
||||||
link.setAttribute("download","emergency-tiddlers-" + (new Date()) + ".json");
|
link.setAttribute("download","emergency-tiddlers-" + (new Date()) + ".json");
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
|
@ -185,7 +185,7 @@ SaverHandler.prototype.saveWiki = function(options) {
|
|||||||
// Call the highest priority saver that supports this method
|
// Call the highest priority saver that supports this method
|
||||||
for(var t=this.savers.length-1; t>=0; t--) {
|
for(var t=this.savers.length-1; t>=0; t--) {
|
||||||
var saver = this.savers[t];
|
var saver = this.savers[t];
|
||||||
if(saver.info.capabilities.indexOf(method) !== -1 && saver.save(text,method,callback,{variables: {filename: variables.filename}})) {
|
if(saver.info.capabilities.indexOf(method) !== -1 && saver.save(text,method,callback,{variables: {filename: variables.filename, type: variables.type}})) {
|
||||||
this.logger.log("Saving wiki with method",method,"through saver",saver.info.name);
|
this.logger.log("Saving wiki with method",method,"through saver",saver.info.name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ DownloadSaver.prototype.save = function(text,method,callback,options) {
|
|||||||
options = options || {};
|
options = options || {};
|
||||||
// Get the current filename
|
// Get the current filename
|
||||||
var filename = options.variables.filename;
|
var filename = options.variables.filename;
|
||||||
|
var type = options.variables.type;
|
||||||
if(!filename) {
|
if(!filename) {
|
||||||
var p = document.location.pathname.lastIndexOf("/");
|
var p = document.location.pathname.lastIndexOf("/");
|
||||||
if(p !== -1) {
|
if(p !== -1) {
|
||||||
@ -32,13 +33,16 @@ DownloadSaver.prototype.save = function(text,method,callback,options) {
|
|||||||
if(!filename) {
|
if(!filename) {
|
||||||
filename = "tiddlywiki.html";
|
filename = "tiddlywiki.html";
|
||||||
}
|
}
|
||||||
|
if(!type) {
|
||||||
|
type = "text/html";
|
||||||
|
}
|
||||||
// Set up the link
|
// Set up the link
|
||||||
var link = document.createElement("a");
|
var link = document.createElement("a");
|
||||||
if(Blob !== undefined) {
|
if(Blob !== undefined) {
|
||||||
var blob = new Blob([text], {type: "text/html"});
|
var blob = new Blob([text], {type: type});
|
||||||
link.setAttribute("href", URL.createObjectURL(blob));
|
link.setAttribute("href", URL.createObjectURL(blob));
|
||||||
} else {
|
} else {
|
||||||
link.setAttribute("href","data:text/html," + encodeURIComponent(text));
|
link.setAttribute("href","data:" + type + "," + encodeURIComponent(text));
|
||||||
}
|
}
|
||||||
link.setAttribute("download",filename);
|
link.setAttribute("download",filename);
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
|
@ -2,5 +2,6 @@ title: $:/core/templates/exporters/CsvFile
|
|||||||
tags: $:/tags/Exporter
|
tags: $:/tags/Exporter
|
||||||
description: {{$:/language/Exporters/CsvFile}}
|
description: {{$:/language/Exporters/CsvFile}}
|
||||||
extension: .csv
|
extension: .csv
|
||||||
|
file-type: text/csv
|
||||||
|
|
||||||
<$macrocall $name="csvtiddlers" filter=<<exportFilter>> format="quoted-comma-sep" $output="text/raw"/>
|
<$macrocall $name="csvtiddlers" filter=<<exportFilter>> format="quoted-comma-sep" $output="text/raw"/>
|
||||||
|
@ -2,5 +2,6 @@ title: $:/core/templates/exporters/JsonFile
|
|||||||
tags: $:/tags/Exporter
|
tags: $:/tags/Exporter
|
||||||
description: {{$:/language/Exporters/JsonFile}}
|
description: {{$:/language/Exporters/JsonFile}}
|
||||||
extension: .json
|
extension: .json
|
||||||
|
file-type: application/json
|
||||||
|
|
||||||
<$macrocall $name="jsontiddlers" filter=<<exportFilter>> $output="text/raw"/>
|
<$macrocall $name="jsontiddlers" filter=<<exportFilter>> $output="text/raw"/>
|
||||||
|
@ -2,6 +2,7 @@ title: $:/core/templates/exporters/TidFile
|
|||||||
tags: $:/tags/Exporter
|
tags: $:/tags/Exporter
|
||||||
description: {{$:/language/Exporters/TidFile}}
|
description: {{$:/language/Exporters/TidFile}}
|
||||||
extension: .tid
|
extension: .tid
|
||||||
|
file-type: text/vnd.tiddlywiki
|
||||||
condition: [<count>compare:lte[1]]
|
condition: [<count>compare:lte[1]]
|
||||||
|
|
||||||
\define renderContent()
|
\define renderContent()
|
||||||
|
@ -39,6 +39,7 @@ tags: $:/tags/Macro
|
|||||||
$param=<<currentTiddler>>
|
$param=<<currentTiddler>>
|
||||||
exportFilter=<<exportFilter>>
|
exportFilter=<<exportFilter>>
|
||||||
filename={{{ [<baseFilename>addsuffix{!!extension}] }}}
|
filename={{{ [<baseFilename>addsuffix{!!extension}] }}}
|
||||||
|
type={{!!file-type}}
|
||||||
/>
|
/>
|
||||||
<$action-deletetiddler $tiddler=<<qualify "$:/state/popup/export">>/>
|
<$action-deletetiddler $tiddler=<<qualify "$:/state/popup/export">>/>
|
||||||
<$transclude field="description"/>
|
<$transclude field="description"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user