From 5322d3cdfdda0f4ba0d8778e83f1ad3ea4396097 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Fri, 8 Jun 2012 10:41:58 +0100 Subject: [PATCH] Added library modules to browser template Now we can include things like jQuery easily --- core/boot.js | 1 + core/modules/serializers.js | 17 +++++++++++++++++ core/templates/tiddlywiki5.template.html.tid | 6 +++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/core/boot.js b/core/boot.js index f7c10478b..6130b6e01 100644 --- a/core/boot.js +++ b/core/boot.js @@ -518,6 +518,7 @@ $tw.plugins.registerPlugin($tw.config.root + "/kernel/tiddlerdeserializer/dom"," $tw.plugins.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerPlugins); // Load the JavaScript system tiddlers from the DOM +$tw.wiki.addTiddlers($tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("libraryModules")),true); $tw.wiki.addTiddlers($tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("pluginModules")),true); $tw.wiki.addTiddlers($tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernelPrefix")),true); $tw.wiki.addTiddlers($tw.wiki.deserializeTiddlers("(DOM)",document.getElementById("bootKernel")),true); diff --git a/core/modules/serializers.js b/core/modules/serializers.js index 5dd3b0222..47788e2d5 100644 --- a/core/modules/serializers.js +++ b/core/modules/serializers.js @@ -68,6 +68,23 @@ exports["application/x-tiddler-module"] = function(tiddler) { ).render("text/html"); }; +exports["application/x-tiddler-library"] = function(tiddler) { + var attributes = { + type: "text/javascript" + }, // The script type is set to text/javascript for compatibility with old browsers + text = tiddler.fields.text; + for(var f in tiddler.fields) { + if(f !== "text") { + attributes["data-tiddler-" + f] = tiddler.getFieldString(f); + } + } + return $tw.Tree.Element( + "script", + attributes, + [$tw.Tree.Raw(text)] + ).render("text/html"); +}; + exports["application/x-tiddler-html-div"] = function(tiddler) { var result = [], fields = [], diff --git a/core/templates/tiddlywiki5.template.html.tid b/core/templates/tiddlywiki5.template.html.tid index dbb0257b6..68520bc5b 100644 --- a/core/templates/tiddlywiki5.template.html.tid +++ b/core/templates/tiddlywiki5.template.html.tid @@ -31,12 +31,16 @@ type: text/x-tiddlywiki-html + +