Add support for serializing tiddlers to text

print-window-tiddler
Jeremy Ruston 2012-05-05 13:15:19 +01:00
rodzic 6df17a9226
commit 079e0e2d1e
2 zmienionych plików z 17 dodań i 5 usunięć

Wyświetl plik

@ -16,17 +16,19 @@ exports.startup = function() {
var modules,n,m,f,commander; var modules,n,m,f,commander;
// Set up additional global objects // Set up additional global objects
$tw.plugins.applyMethods("global",$tw); $tw.plugins.applyMethods("global",$tw);
// Reinstall the plugin categories that were installed during the kernel boot process // Wire up plugin modules
$tw.Tiddler.fieldPlugins = $tw.plugins.getPluginsByTypeAsHashmap("tiddlerfield");
$tw.plugins.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerPlugins);
// Wire up other plugin modules
$tw.plugins.applyMethods("config",$tw.config); $tw.plugins.applyMethods("config",$tw.config);
$tw.plugins.applyMethods("utils",$tw.utils); $tw.plugins.applyMethods("utils",$tw.utils);
$tw.version = $tw.utils.extractVersionInfo(); $tw.Tiddler.fieldPlugins = $tw.plugins.getPluginsByTypeAsHashmap("tiddlerfield");
$tw.plugins.applyMethods("tiddlermethod",$tw.Tiddler.prototype); $tw.plugins.applyMethods("tiddlermethod",$tw.Tiddler.prototype);
$tw.plugins.applyMethods("wikimethod",$tw.Wiki.prototype); $tw.plugins.applyMethods("wikimethod",$tw.Wiki.prototype);
$tw.plugins.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerPlugins);
$tw.Wiki.tiddlerSerializerPlugins = {};
$tw.plugins.applyMethods("tiddlerserializer",$tw.Wiki.tiddlerSerializerPlugins);
$tw.plugins.applyMethods("treeutils",$tw.Tree); $tw.plugins.applyMethods("treeutils",$tw.Tree);
$tw.plugins.applyMethods("treenode",$tw.Tree); $tw.plugins.applyMethods("treenode",$tw.Tree);
// Get version information
$tw.version = $tw.utils.extractVersionInfo();
// Load up the tiddlers in the root of the core directory (we couldn't do before because we didn't have the serializers installed) // Load up the tiddlers in the root of the core directory (we couldn't do before because we didn't have the serializers installed)
if(!$tw.isBrowser) { if(!$tw.isBrowser) {
$tw.plugins.loadPluginsFromFolder($tw.boot.bootPath,"$:/core",/^\.DS_Store$|.meta$|^modules$/); $tw.plugins.loadPluginsFromFolder($tw.boot.bootPath,"$:/core",/^\.DS_Store$|.meta$|^modules$/);

Wyświetl plik

@ -118,6 +118,16 @@ exports.addTiddler = function(tiddler) {
this.touchTiddler(title); this.touchTiddler(title);
}; };
exports.serializeTiddler = function(title,type) {
var serializer = $tw.Wiki.tiddlerSerializerPlugins[type],
tiddler = this.getTiddler(title);
if(serializer) {
return serializer.call(this,tiddler);
} else {
return null;
}
};
/* /*
Return a sorted array of tiddler titles, optionally filtered by a tag Return a sorted array of tiddler titles, optionally filtered by a tag
*/ */