Deki Wiki uses a simple, but powerful HTML composition format that makes it possible to embed rich content into wiki pages. By rich content, we mean CSS definitions, java script inclusions, and code to be run once the document has loaded.
This is done by responding with an XML value that mimics a HTML document. For example, the following response would be processed according to Deki Wiki's HTML composition rules.
<value type="xml>
<html>
<head>
<script type="text/javascript" src="http://my-server/my-script.js" />
</head>
<body>
<div id="alerter">Click Me</div>
</body>
<tail>
<script type="text/javascript">
DekiWiki.$("alerter").click(function() {
alert("you clicked");
});
</script>
</tail>
</html>
</value> NOTE: Deki Wiki requires that the HTML response be wrapped in an XML value.
The HTML composition is done by appending all <head> elements from all HTML responses and discarding duplicates. This avoids loading the same javascript libraries over-and-over again. The same is done for the <tail> elements, except that they are further converted to be only executed once the document has been fully loaded in the browser. Finally, the contents of the <body> element are injected into the outer document replacing the function call-site.
In short, here are the steps that occur:
These few steps allow you to embed very rich content that may have dependencies on javascript and CSS files, without requiring the outer document to be aware of them ahead of time.