skip to main |
skip to sidebar
The previous post was about merge of the StickyNotes app with WebMachine. The release 0.1 was deployed on BitBucket
That was the "don't touch anything" approach. The solution was elegant, but the data flow mechanisms were all hidden by the POST.
- In the release 0.2 the create, update, delete, read operations were made explicit through the HTTP POST, PUT, DELETE and GET which potentially allows the web server to cache the data and reduce the load.
- The home page allows you to check / turn on / turn off / view the WebMachine TRACE without any extra coding. All functionality is already supplied in the admin resource.
- The JQuery was extended for PUT and DELETE in the application.js - some say that the next JQuery release will have it all. Anyway, it was pretty straitforward copy/paste.
- The notes.erl was slightly edited for the read method to put the data structure inline with the other access methods.
The release 0.2 code with pre-compiled binaries is platform-independent and ready to run. You have to install Erlang/OTP first.
After downloading and unpacking the zip, use the start.sh (or start.cmd on Windows) and point your browser to http://127.0.0.1:8000/
[Edit] The story continues with release 0.2: the application goes RESTful. Plus, you can now turn the webmachine TRACE ON/OFF right from your browser. [/Edit]
Kevin Smith from Hypothetical labs has recently stressed the value of the WebMachine. It happened to be not just yet another "cool" stuff, but the real thing.
Thanks, Kevin!
The best way for me to play with and learn it is to use the real working application. That one happened to be the very nice StickyNotes created by the Hughes Waroquers of BeeBole. Actually, the BeeBole itself has a trailer which looks inspiring and I see where the roots of coolness come from.
The post by Justin Sheehy shows how to integrate the StickyNotes with the original design of the WebMachine. He took the StickyNotes "as-is" and put them under the Webmachine layer.
But the snippets given there which add up to the resource module, do not work with the newest WebMachine releases. They added the wrq module to encapsulate the Request Data manipulation. The calling convention is updated as well.
So, to make it up and go a bit further, I have created a new repository in bitbucket.
It took the StickyNotes client and DB parts "as is" and on the protocol level (as was suggested by Justin):
- separate static pages and dynamic traffic between different resources
- restrict access methods for each resource
- send read requests through GET, not POST (coming soon)
The distribution, when downloaded is ready to launch (use the run.cmd on Windows) . It only needs working Erlang/OTP.
The home page is now a "pure" AJAX web client, allowing to switch GET/POST.... and Content Type and see the results in detail, very much like Curl (not that powerful, but handy).
I left some debug prints on the server to see how the data reflects in the back-end.
The (PUT,Authorization,ETAGS,DELETE) posts of Bryan Fink were extremely helpful to get the concept. Well, POST is not there, but it is here now! And last, but not the least is the the very Justin's screencast, which is was very inspiring for me.