My First Typo Sidebar
I recently developed my very own plugin for this blog. To cut a short story even shorter, I wrote a Ruby class and an HTML template, and I was done.
The Plugin
Whilst wandering around the Google gadgets pages, I’d spotted Adam Bowman’s animated Treefrog. It appealed. I wanted one on my blog.
What did I have to do? The content required nothing complicated, nothing dynamic: just a static chunk of HTML. How difficult could it be?
Read the code, Not the manual
I’ve fiddled round with Typo before and found reading the code to be the best way to figure out what to do. In this case, I needed to look at an existing sidebar plugin. I guessed the best model for my new plugin would be the “Static” sidebar component which I use to list a collection of links to favourite web sites.
I soon found the controller for this plugin in the
components/plugins/sidebars/
subdirectory of my Typo
installation. It’s a simple Ruby class derived from
Sidebars::ComponentPlugin
:
class Plugins::Sidebars::StaticController < Sidebars::ComponentPlugin description "Static content, like links to other sites, advertisements, or blog meta-infomation" DEFAULT_TEXT = %q{ <ul> <li><a href="http://www.typosphere.org" title="Typo">Typo</a></li> .... </ul> } setting :title, 'Links' setting :body, DEFAULT_TEXT, :input_type => :text_area end
I also spotted a components/plugins/sidebars/static
subdirectory,
and in this subdirectory was a two-line HTML template.
<h3><%= @sb_config['title'] %></h3> <%= @sb_config['body'] %>
My Plugin
My plugin was even more simple than the static one. I created a class:
class Plugins::Sidebars::TreefrogController < Sidebars::ComponentPlugin description 'Treefrog' setting :title, 'Treefrog' end
and an HTML template:
<h3><%= @sb_config['title'] %></h3> <object type="application/x-shockwave-flash" data="files/treefrog.swf" width="150" height="200"> <param name="movie" value="files/treefrog.swf" /> </object>
and I was done. As before, I ran a local Typo session to check my plugin worked, then I copied the files over to my live site. Job done.
So What?
So what’s so amazing about this? Absolutely nothing. This is hardly rocket science.
Notice, though, that:
-
I didn’t have to restart my blog server
-
I didn’t have to change any existing part of my blog application — the changes were purely additive.
-
I didn’t reconfigure anything. I didn’t have to register my plugin. I didn’t have to tell my class where to find the HTML template. I didn’t have to write or generate loads of XML.
No, this isn’t amazing. So why do so many other application development frameworks get it so very wrong?
Feedback
-
Is there any chance to get the FLA-file of this cool gadget?
-
Is there any chance to get the FLA-file of this cool gadget?
-
Sorry... clicked twice :S
-
Marco - yes, it's very easy to click twice, since the comment takes a few seconds to be posted. You'll find all you need at the author's page: http://abowman.com/google-modules/tree-frog/ (Clicking on the little leaf icon will take you there too).
-
TREE FROGS ARE ......COOL AND I CAN PUT IT MY SPACE .AND I CAN SHARE WITH ALL MY FRIENDS.
-
What?????
-
It would be nice if you could change the colour of the treefrog and his background. Where is the html for that embedded - or is in a flash file?
Perhaps someone could adapt the script so it allowed you to click on the frog and it will rotate through different colour options e.g. green, blue, indigo, violet, red, orange, red
That would be a very elegant addition.