In Tiddlymap there is the Respawn-Plugin, that brings back the default Tiddlers if the storyriver is empty.
For building a LandingPagePlugin that makes use of Layouts, it would be good to have a more flexible version of this which allows to define actionswidgets stored in a config-tiddler to be excecuted in that case. How would I build that.
/*\
title: $:/plugins/felixhayashi/respawn/respawn.js
type: application/javascript
module-type: startup
@preserve
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var configTRef = "$:/plugins/felixhayashi/respawn/config";
var changeListener = function(changedTiddlers) {
if(!changedTiddlers["$:/StoryList"]) return;
var tObj = $tw.wiki.getTiddler("$:/StoryList");
if(tObj && !tObj.fields["list"].length) {
var confTObj = $tw.wiki.getTiddler(configTRef);
var config = confTObj ? confTObj.fields : {};
window.setTimeout(function() {
$tw.rootWidget.dispatchEvent({
type: "tm-home"
});
}, parseInt(config.delay) || 500);
}
};
exports.name = "respawn";
exports.platforms = ["browser"];
exports.after = ["story"];
exports.synchronous = true;
exports.startup = function() {
$tw.wiki.addEventListener("change", changeListener);
};
})();