Twoter: TiddlyWeb Based Web Clippings
In the continuing saga of demonstrating ways that TiddlyWeb can be extended I did some work today that shows what you can do if you use the existing WSGI stack and add to the available URLs.
Previous experiments added to the WSGI stack, added a serialization and added a store. None of these changes add to the fundamental resources that the TiddlyWeb system presents.
Adding to the available URLs in the system adds, by definition, more resources to the system. What we’re going to add is a /twoter. Twoter is a cute little system to take web clippings from around the internet and store them in Tiddlers that can later be used in TiddlyWikis. There’s a demo system running on google app engine: http://tiddlyweb.appspot.com/twoter
Twoter gets its special sauce by having a handy little bookmarklet so you can be viewing anything, highlight some text, click the bookmarklet and presto, instant saved Tiddler. The roundabout process of creating that bookmarklet probably deserves its own posting.
Note: You will be asked to log in using your google account. This identifies your content and make it possible to restrict access so your clippings are only viewable by you and only you can add to your clippings. However, it will be possible for other users to see that you are using the system. They won’t know what you’re clipping, but they’ll be able to see that you have content there.
Bigger Note: Don’t rely on the security of this system, nor on the available of the content at some future date. This is an experiment. If it proves useful to you, let me know, and I’ll try to make it into a useful thing. One of the motivations for creating twoter was so it would expose bugs in TiddlyWeb. It’s doing that very well, already, so expect problems.
Some code has been checked in at: http://trac.tiddlywiki.org/browser/Trunk/contributors/ChrisDent/experimental/twoter
Way down in the center of TiddlyWeb’s pile of WSGI stuff is Luke Arno’s selector. It maps URLs to Python callables. In TiddlyWeb a text file called urls.map is used as input to selector. So adding a URL is just a matter of adding to that file:
# a fun little interface to do bookmarks
/twoter
GET twoter:base
/twoter/{username:segment}
GET twoter:user
POST twoter:submit
/twoter provides an entry point for the system. All it does is redirect to get user information. After a successful authentication the browser will land at /twoter/{username} and be presented with some information for the user.
When called with GET twoter shows that information. When hit with a POST it is looking for form data with title, url and snip fields. That data is transformed into a Tiddler and saved to a personal and secure (only the user can read, write, create or delete) bag for the user.
Each user gets two recipes, one for all their “twotes” and one for their most recent. Each recipe includes another bag that includes some TiddlyWeb plugins so that if they choose to create a TiddlyWiki of their twotes they will be able to save them back to the server without any difficulty. Links to those recipes are shown on the GET page.
So here’s the thing: twoter.py is quite small:
enough:tiddlywebappengine cdent$ wc twoter.py
164 479 4779 twoter.py
It turns out that TiddlyWeb’s existing WSGI middleware does most of the necessary work already: authentication handling, data storage, Bags, Recipes and Tiddlers. All twoter really is is a simple CGI to access some data and make sure some stuff is created.
I, the framework hater, accidently made a framework. I don’t know whether to be proud or ashamed.
If you try twoter and have some comments, please send them my way.
Update: I should probably mention that this has not been tested in IE and the bookmarklet is unlikely to work there.