16th
S5 For TiddlyWeb
This evening FND and I were discussing how one of these days I’ll have to do a TiddlyWeb presentation: make slides, talk to people, gesticulate in awkward ways while standing in front of people and moving around for no particular reason. I remarked that I was going to use 3x5 cards to lay out my thoughts because they are physical and I think better with physical stuff.
This led to more discussion about how in the TiddlyWiki universe slide presentation systems are a bit of theme or motif. I said I had considered making a tool to present slides out of TiddlyWeb but figured I would do such a thing when I really needed it. What I had in mind was some kind of jQuery thing that retrieved content from the server as needed. In other words, a project, an investment of some kind. FND brilliantly suggested that an S5 serializer would be the ticket.
I had heard of S5 before, but never really knew what it was. So I went digging around and saw that the basics of S5 are not only incredibly straightforward, the fine folks at meyerweb.com have packaged it all up nice and easy.
So I thought to myself: All TiddlyWeb needs to do is make the s5 javascript and CSS available (either via the hosting web server, or the static plugin), gather some tiddlers, and push them into the HTML file provided for S5. I set about doing that and lo and behold it works! Here’s an example. Go have a look, it gives a bit of an idea of what’s going on.
And here’s the code.
The serializer architecture in TiddlyWeb has been designed from the start to be extensible. By configuration or a plugin you can associate a MIME type or a file extension with a Python module that implements at least some of the SerializationInterface. A serializer takes TiddlyWeb objects, such as a tiddler or collection of tiddlers, and turns them into some stringified form of some type (HTML, JSON, an S5 file, etc.). Some serializers go the other way as well (e.g. turning a JSON string into a Tiddler object).
The S5 serializer checks for some special tiddlers to set meta-presentation-stuff like title and presenter name, and then renders each of the tiddlers it has been provided into HTML. This HTML is then pushed into the template file (jinja2 is used) and the results are sent out over the web as an HTML file. That HTML file requests back to the server for the necessary javascript and CSS.
Because TiddlyWeb already has all the bits for generating the list of tiddlers and getting them to the serializer, the serializer itself can be quite small and concentrate on just the work it is supposed to do. The code is only 55 lines long, including whitespace. And I like whitespace.
There are still some things to clean up, but I reckon it is nice start.
- A demo
- The code
- TiddlyWeb’s home site
- An old posting about TiddlyWeb serializers. That one involves cake rather than presentation slideshows.
Update: I updated the link to the demo to a new location to reflect that there’s now support for ordering slides in the presentation.
