How to Create Easily Customisable Widget With Rails
We just had our monthly Ruby Brigade meeting last night, and I shared for about how to create an easily customisable widget with Ruby On Rails (RoR).
A simple framework that I used when creating BookJetty widget. Web widget has been like bread and butter for web 2.0 sites, it’s an amazing tool that will help to spread the word for your site, and with a good implementation will nurture happy and active users.
Creating a simple widget is easy, but how can you create one that can easily extended and customised to cater for more customisation and different types widgets in the future.
The easy way to create customisation parameters is by using URL paramters, but that can be confusing for your users, and make it hard for your users to customise it on the fly without having to use your widget customisation form.
Compare this widget URL:
<script language="javascript" type="text/javascript" src="http://www.domain.com/widget.php?username=nicky&show=random &header=1&num=5&covers=small&text=all&tag=alltags&css=1&style=1&charset=&version=1"> </script>
And Google Adsense widget URL:
<script type="text/javascript"><!-- google_ad_client = "pub-32432432432432"; google_ad_width = 468; google_ad_height = 60; google_ad_type = "text"; google_color_border = "ffffff"; google_color_bg = "ffffff"; google_color_link = "1465b7"; google_color_url = "1465b7"; google_color_text = "000000"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
Google Adsense widget approach is just like the Amazon widget approach, it is using Javascript variables, and they are so much easier to customise, as compared to URL parameters.
These slides will help you to look at how I approached the widget creation following the best practices of the big guys, Google and Amazon widgets, and hope they will shed some lights. And happy widgeting.



BookJetty now supports four different views, i.e. library view, default view, cover view, and simple view. 


Sometimes it’s just nicer to look at the book covers, you know what I mean, just like this cover. :) The rest of the attributes are moved to the tooltip area.

