POSTing to TiddlyWeb
Following on with my current theme of making TiddlyWeb easier to use, especially without Javascript, I thought I'd introduce another little plugin that I've written. To sum it up in a sentence, it adds POST support to TiddlyWeb.
What this means in practise, is that you can put an HTML form in your page (TiddlyWebPages is a good place to put it), and when somebody clicks submit, the data they entered is POSTed to TiddlyWeb, which then stores it, all with no JavaScript whatsoever. Sounds simple right? Well yes, that's kind of the point.
To use it properly, you can POST to the following urls:
Essentially, you could POST any set of values you like to the above URLs, and they'd get put in the right bag as tiddlers, but some names are reserved for specific tiddler attributes. They are as follows:
There is one exception to this though - binary files. If you include a file input box and give it a name of "file", then TiddlyWeb will use that instead, and put that file into the correct bag (or recipe), as a tiddler. You can then both navigate to and view it in the usual way.
The following would be a simple example of how to use this plugin. It assumes that the plugin has been installed already (ie - added to tiddlywebconfig.py)
Its that simple. If you want this plugin, its on GitHub at http://github.com/bengillies/TiddlyWeb-Plugins/tree/master/form/
You can test it out by leaving me a comment. :)
What this means in practise, is that you can put an HTML form in your page (TiddlyWebPages is a good place to put it), and when somebody clicks submit, the data they entered is POSTed to TiddlyWeb, which then stores it, all with no JavaScript whatsoever. Sounds simple right? Well yes, that's kind of the point.
To use it properly, you can POST to the following urls:
- /bags/<bag_name>/tiddlers/<tiddler_name>
- /recipes/<recipe_name>/tiddlers/<tiddler_name>
- /bags/<bag_name>/tiddlers
- /recipes/<recipe_name>/tiddlers
Fields and Values
Essentially, you could POST any set of values you like to the above URLs, and they'd get put in the right bag as tiddlers, but some names are reserved for specific tiddler attributes. They are as follows:
- Title - this specifies the tiddler title
- Text - this specifies the text (or content) of the tiddler
- tags - this specifies the tags that you want the tiddler to have (specify these as a TiddlyWiki style space/double square bracket delimited list)
Binary Files
There is one exception to this though - binary files. If you include a file input box and give it a name of "file", then TiddlyWeb will use that instead, and put that file into the correct bag (or recipe), as a tiddler. You can then both navigate to and view it in the usual way.
Example
The following would be a simple example of how to use this plugin. It assumes that the plugin has been installed already (ie - added to tiddlywebconfig.py)
<form method="POST" action="/bags/foo/tiddlers">
<input type="text" name="title" value="Insert title here" /><br>
<textarea rows="5" cols="40" name="text">Insert text here</textarea><br>
<input type="tags" name="tags" value="tags" /><br>
<input type="submit" value="Send to TiddlyWeb" />
</form>
--- or for binary files (like images) ---
<form method="POST" action="/bags/foo/tiddlers" enctype="multipart/form-data">
<input type="file" name="file" /><br>
<input type="submit" value="Send to TiddlyWeb" />
</form>
<input type="text" name="title" value="Insert title here" /><br>
<textarea rows="5" cols="40" name="text">Insert text here</textarea><br>
<input type="tags" name="tags" value="tags" /><br>
<input type="submit" value="Send to TiddlyWeb" />
</form>
--- or for binary files (like images) ---
<form method="POST" action="/bags/foo/tiddlers" enctype="multipart/form-data">
<input type="file" name="file" /><br>
<input type="submit" value="Send to TiddlyWeb" />
</form>
Its that simple. If you want this plugin, its on GitHub at http://github.com/bengillies/TiddlyWeb-Plugins/tree/master/form/
You can test it out by leaving me a comment. :)
Comments