diff --git a/bld.sh b/bld.sh index 92c1660d1..16d1744c2 100755 --- a/bld.sh +++ b/bld.sh @@ -19,6 +19,10 @@ echo "Using TW5_BUILD_OUTPUT as [$TW5_BUILD_OUTPUT]" echo "five.tiddlywiki.com" > $TW5_BUILD_OUTPUT/CNAME +# Create the `static` directory if necessary + +mkdir -p $TW5_BUILD_OUTPUT/static + # First, # readme.md: the readme file for GitHub # index.html: the main file, including content @@ -30,6 +34,7 @@ node ./tiddlywiki.js \ --savetiddler ReadMe ./readme.md text/html \ --savetiddler $:/core/templates/tiddlywiki5.template.html $TW5_BUILD_OUTPUT/index.html text/plain \ --savetiddler $:/core/templates/static.template.html $TW5_BUILD_OUTPUT/static.html text/plain \ + --savetiddlers [!is[shadow]] $:/core/templates/static.tiddler.html $TW5_BUILD_OUTPUT/static text/plain \ || exit 1 # Second, encrypted.html: a version of the main file encrypted with the password "password" diff --git a/core/modules/commands/savetiddlers.js b/core/modules/commands/savetiddlers.js new file mode 100644 index 000000000..b417112b7 --- /dev/null +++ b/core/modules/commands/savetiddlers.js @@ -0,0 +1,54 @@ +/*\ +title: $:/core/modules/commands/savetiddlers.js +type: application/javascript +module-type: command + +Command to save several tiddlers to a file + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +exports.info = { + name: "savetiddlers", + synchronous: false +}; + +var Command = function(params,commander,callback) { + this.params = params; + this.commander = commander; + this.callback = callback; +}; + +Command.prototype.execute = function() { + if(this.params.length < 2) { + return "Missing filename"; + } + var self = this, + fs = require("fs"), + path = require("path"), + wiki = this.commander.wiki, + filter = this.params[0], + template = this.params[1], + pathname = this.params[2], + type = this.params[3] || "text/html", + extension = this.params[4] || ".html", + parser = wiki.parseTiddler(template), + tiddlers = wiki.filterTiddlers(filter); + $tw.utils.each(tiddlers,function(title) { + var renderTree = new $tw.WikiRenderTree(parser,{wiki: wiki}); + renderTree.execute({tiddlerTitle: title}); + var text = renderTree.render(type); + fs.writeFile(path.resolve(pathname,title + extension),text,"utf8",function(err) { + self.callback(err); + }); + }); + return null; +}; + +exports.Command = Command; + +})(); diff --git a/core/templates/static.template.html.tid b/core/templates/static.template.html.tid index e37cc2379..da9b9553f 100644 --- a/core/templates/static.template.html.tid +++ b/core/templates/static.template.html.tid @@ -1,12 +1,13 @@ title: $:/core/templates/static.template.html type: text/vnd.tiddlywiki-html +\define tw-wikilink-template() static/$uri_encoded$.html \rules only filteredtranscludeinline transcludeinline - + {{$:/core/wiki/title}} diff --git a/core/templates/static.tiddler.html.tid b/core/templates/static.tiddler.html.tid new file mode 100644 index 000000000..38575c787 --- /dev/null +++ b/core/templates/static.tiddler.html.tid @@ -0,0 +1,36 @@ +title: $:/core/templates/static.tiddler.html + +\define tw-wikilink-template() $uri_encoded$.html +` + + + + + + +`{{$:/core/wiki/title}}` +
+`{{{ [is[shadow]type[text/css]] ||$:/core/templates/css-tiddler}}}` +
+ + + +
+
+ +`<$view field="title"/>` + +
`<$view field="modifier" format="link"/>` `<$view field="modified" format="date"/>`
+ +
`<$list filter="[is[current]tags[]]" template="$:/templates/TagTemplate" />`
+ +
+ `<$transclude template="$:/core/templates/html-tiddler" />` +
+
+
+ + +` \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/TiddlyWiki5_Editions.tid b/editions/tw5.com/tiddlers/TiddlyWiki5_Editions.tid index 196456c48..81821ffde 100644 --- a/editions/tw5.com/tiddlers/TiddlyWiki5_Editions.tid +++ b/editions/tw5.com/tiddlers/TiddlyWiki5_Editions.tid @@ -5,6 +5,7 @@ The core TiddlyWiki5 code is packaged into several distinct editions designed fo * [[TiddlyWiki5 Standalone Edition]] for working purely within the browser ** Including [[TiddlyWiki5 in the Sky for TiddlySpot|TiddlySpot]] +** And incorporating [[TiddlyWiki5 Static Site Generation]] * [[TiddlyWiki5 Node Edition]] for advanced command line work ** Including [[Building classic TiddlyWiki with TiddlyWiki5]] * [[TiddlyWiki5 in the Sky for TiddlyWeb]] (and TiddlySpace) diff --git a/editions/tw5.com/tiddlers/commands/SaveTiddlersCommand.tid b/editions/tw5.com/tiddlers/commands/SaveTiddlersCommand.tid new file mode 100644 index 000000000..8912f811f --- /dev/null +++ b/editions/tw5.com/tiddlers/commands/SaveTiddlersCommand.tid @@ -0,0 +1,14 @@ +title: SaveTiddlersCommand +tags: docs command + +Save a set of tiddlers matching a filter as separate files of a specified ContentType (defaults to `text/html`) and extension (defaults to `.html`). + +``` +--savetiddlers