1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-11-13 05:47:17 +00:00

Revert "Merge pull request #1509 from welford/static_export_macro"

This reverts commit b2b8006b58, reversing
changes made to e7e16137b2.

@welford my apologies it turns out there are a couple of problems, I’ll
comment more on the pull request
This commit is contained in:
Jermolene
2015-02-20 18:39:13 +00:00
parent b2b8006b58
commit ead6eb00d4
3 changed files with 5 additions and 11 deletions

View File

@@ -35,8 +35,7 @@ Command.prototype.execute = function() {
wiki = this.commander.wiki,
filter = this.params[0],
template = this.params[1],
outputPath = this.commander.outputPath,
pathname = path.resolve(outputPath,this.params[2]),
pathname = path.resolve(this.commander.outputPath,this.params[2]),
type = this.params[3] || "text/html",
extension = this.params[4] || ".html",
deleteDirectory = (this.params[5] || "") != "noclean",
@@ -44,19 +43,14 @@ Command.prototype.execute = function() {
if(deleteDirectory){
$tw.utils.deleteDirectory(pathname);
}
$tw.utils.createDirectory(pathname);
$tw.utils.each(tiddlers,function(title) {
var parser = wiki.parseTiddler(template),
widgetNode = wiki.makeWidget(parser,{variables: {currentTiddler: title}});
var container = $tw.fakeDocument.createElement("div");
widgetNode.render(container,null);
var text = type === "text/html" ? container.innerHTML : container.textContent;
var export_path = null;
if($tw.utils.hop($tw.macros,"tv-get-export-path")) {
export_path = $tw.macros["tv-get-export-path"].run.apply(self,[title]);
}
var final_path = path.resolve(outputPath,(export_path || encodeURIComponent(title)) + extension);
$tw.utils.createDirectory(path.dirname(final_path));
fs.writeFileSync(final_path,text,"utf8");
fs.writeFileSync(path.resolve(pathname,encodeURIComponent(title) + extension),text,"utf8");
});
return null;
};