Bookmark It! Rails plugin for adding bookmarklets.

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.

Release 0.2 of BookmarkIt! Sidebar Plugin for Typo

Well, version 0.1 was shortlived. There was a critical difference between running with WEBrick and running in production environment with fastcgi.
The value of env[“REQUEST_URI”] did not contain “http://host”. So I found a quick solution and we’ll see if there is a better solution tomorrow.

Current solution consists of replacing

@article_url = request.env[&#8220;REQUEST_URI&#8221;]

with

@article_url = &#8216;http://&#8217;+request.env[&#8220;HTTP_HOST&#8221;]+
  request.env[&#8220;REQUEST_URI&#8221;]
  if @article_url.eql?(@article_url.gsub(/http:/,&#8221;).gsub(/HTTP:/,&#8221;))

You live and learn…

bookmarkit-0.2.zip and
bookmarkit-0.2.tgz

Release 0.1 of BookmarkIt! Plugin for Typo

First release (0.1) of BookmarkIt! for typo. Check back for new releases here on blog.nanorails.com

BookmarkIt! is a sidebar plugin for typo. With it, you can let people directly bookmark your blog, or an article dependending on the context. Try it for yourself on the right side of this page.

Installation
uncompress into a temporaty location and move the components and public directory onto your typo installation. On all OS I know, this will add the files in the right location. Then next time you go in the Sidebar section of Typo, you will be able to drag and drop the BookmarkIt! Item onto your Active items. Set the desired title and select the desired services, and then Publish your changes

Compatibility
Tested with typo revision 884. Should work with Typo 2.6.

Not all bookmarking services have been tested yet. I believe that the pages where I got the format for the links to be accurate, but I transcription could be flowed. Only the ones I had an account with. Post a comment on blog.nanorails.com if something doesn’t work.

Download the zip or the tgz file.