mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
New command line switch to save wiki as a folder of static HTML files
This commit is contained in:
parent
193365c450
commit
d6397e9d84
@ -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) {
|
||||
|
3
tw5.sh
3
tw5.sh
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user