Bookmark It! Rails plugin for adding bookmarklets.

Posted on Mon Dec 18 15:17:00 UTC 2006

A while back I wrote BookmarkIt! , a social bookmarllet plugin for Typo, and it worked for a while, but the Typo plugin API changed, and changed again, and again, and keeping up was no fun. So since then, I’ve already changed my approach for my TextLinkAds plugin and instead wrote a bona fide rails plugin, and since Typo 4.0.3 broke the plugin one more time, it was time to take the same route. Morevover, the previous version did not allow for putting the Bookmkarlets inline with the post and this new version addresses that also. It is now a real Rails plugin, useable in any Rails app.

How to Get the plugin

script/plugin install http://svn.nanorails.com/plugins/bookmarkit/
or to use svn:externals to get updates
script/plugin install -x http://svn.nanorails.com/plugins/bookmarkit/
The install will automatically copy the config file, the images, the css and the partial in their final location. If you delete these files, you can reinstall with:
script/plugin install --force http://svn.nanorails.com/plugins/bookmarkit/

How to configure the plugin

To configure, edit the file config/bookmarkit.yml to change the title and select which bookmarklets you want displayed.
title: Bookmark It!
delicious: true(default)/false
digg: true(default)/false
reddit: true(default)/false
blinklist: true(default)/false
dzone: true(default)/false
newsvine: true(default)/false
furl: true(default)/false
spurl: true(default)/false
simpy: true(default)/false
fark: true(default)/false
blogmarks: true(default)/false
myweb2: true(default)/false
wists: true(default)/false

How to use the plugin

To use, inside any view (.rhtml), use:

<%= render_BMI(title, url) %>

For example, in Typo, you would include the following in app/views/articles/read.rhtml

<%= render_BMI(@article.title, @article.location) %>
For finer control of the rendering, it also copies a css (bookmarkit.css) to public/stylesheets. To use, include in your main layout with:
<%= stylesheet_link_tag "/stylesheets/bookmarkit" %>

Adding more bookmarklets

All the bookmarklet html is in the _bookmarkit.rhtml partial.

For example, for BlinkList, I’ve used:
      <a style="font-size:22px;" title="Blink '<%= title %>'" href="http://www.blinklist.com/index.php?Action=Blink/addblink.php&Url=<%= url %>&Title=<%= title %>">
            <img style="border:0;" hspace="3" class="bookrmarkit" alt="Blink" title="Blink '<%= title %>'" src="/images/bookmarkit/blinklist.gif" />
      </a>
You should also add an entry in bookmarkit.yml

If you want more bookmakrlets included, submit your patches in the comments or send to psq_at_no_spam_nanorails_dot_no_spam_com.

Posted in html/css, Rails  |  Tags ,  |  3 comments

Comments

  1. Win Win said // Mar 18, 2008 at 08:20 PM

    I’d just like to thank you for the great little plugin! I am a rails newbie and am still learning the ropes. I had to update your config a bit, but it works beautifully otherwise.

  2. Gme Gme said // Mar 23, 2008 at 10:10 AM

    There is a little bug in installation script. It copies _bookmarkit.html partial to ‘app/views/shared’ file not a folder. At least on win xp.

  3. Pascal Pascal said // Mar 26, 2008 at 02:27 PM

    Maybe because the shared directory does no exist?

(leave url/email »)

Comment Markup Help