Skip to content

Commit

Permalink
New command line switch to save wiki as a folder of static HTML files
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Ruston committed Mar 3, 2012
1 parent 193365c commit d6397e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tiddlywiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,37 @@ var commandLineSwitches = {
savetiddler: {
args: {min: 2, max: 3},
handler: function(args,callback) {
var type = args[2] || "text/html";
fs.writeFileSync(args[1],app.store.renderTiddler(type,args[0]),"utf8");
var title = args[0],
filename = args[1],
type = args[2] || "text/html";
fs.writeFileSync(filename,app.store.renderTiddler(type,title),"utf8");
}
},
savetiddlers: {
args: {min: 1, max: 1},
args: {min: 1, max: 2},
handler: function(args,callback) {
var recipe = [];
var outdir = args[0],
recipe = [];
app.store.forEachTiddler(function(title,tiddler) {
var filename = encodeURIComponent(tiddler.title.replace(/ /g,"_")) + ".tid";
fs.writeFileSync(path.resolve(args[0],filename),app.store.serializeTiddler("application/x-tiddler",tiddler),"utf8");
fs.writeFileSync(path.resolve(outdir,filename),app.store.serializeTiddler("application/x-tiddler",tiddler),"utf8");
recipe.push("tiddler: " + filename + "\n");
});
fs.writeFileSync(path.join(args[0],"split.recipe"),recipe.join(""));
process.nextTick(function() {callback(null);});
}
},
savehtml: {
args: {min: 1, max: 1},
handler: function(args,callback) {
var outdir = args[0];
app.store.forEachTiddler(function(title,tiddler) {
var filename = encodeURIComponent(title.replace(/ /g,"_")) + ".html";
fs.writeFileSync(path.resolve(outdir,filename),app.store.renderTiddler("text/html",title),"utf8");
});
process.nextTick(function() {callback(null);});
}
},
servewiki: {
args: {min: 0, max: 1},
handler: function(args,callback) {
Expand Down
3 changes: 3 additions & 0 deletions tw5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ mkdir -p tmp/tw5
# cook TiddlyWiki5
node tiddlywiki.js --recipe $PWD/tiddlywiki5/tiddlywiki5.recipe --savewiki tmp/tw5 --savetiddler ReadMe readme.md || exit 1

# cook a static version too
#mkdir -p tmp/tw5/static
#node tiddlywiki.js --recipe $PWD/tiddlywiki5/tiddlywiki5.recipe --savehtml tmp/tw5/static

# open the result
#open -a /Applications/Google\ Chrome.app tmp/tw5/index.html

0 comments on commit d6397e9

Please sign in to comment.