1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-18 11:29:55 +00:00

Added library modules to browser template

Now we can include things like jQuery easily
This commit is contained in:
Jeremy Ruston 2012-06-08 10:41:58 +01:00
parent 2083b7959e
commit 5322d3cdfd
3 changed files with 23 additions and 1 deletions

View File

@ -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);

View File

@ -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 = [],

View File

@ -31,12 +31,16 @@ type: text/x-tiddlywiki-html
</noscript>
<!----------- Miscellaneous shadow tiddlers ----------->
<div id="shadowArea" style="display:none;">
<<include "[is[shadow]] -[type[text/css]] -[type[application/javascript]has[module-type]] -[[$:/core/boot.js]] -[[$:/core/bootprefix.js]]" application/x-tiddler-html-div>>
<<include "[is[shadow]] -[type[text/css]] -[type[application/javascript]has[module-type]] -[type[application/javascript]library[yes]] -[[$:/core/boot.js]] -[[$:/core/bootprefix.js]]" application/x-tiddler-html-div>>
</div>
<!----------- Ordinary tiddlers ----------->
<div id="storeArea" style="display:none;">
<<include "[!is[shadow]]" application/x-tiddler-html-div>>
</div>
<!----------- Library modules ----------->
<div id="libraryModules" style="display:none;">
<<include "[is[shadow]type[application/javascript]library[yes]]" application/x-tiddler-library>>
</div>
<!----------- Boot kernel prologue ----------->
<div id="bootKernelPrefix" style="display:none;">
<<include "$:/core/bootprefix.js" application/javascript>>