Social Bookmarking added to Matilda

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article
Posted by John
on Monday, 05 January 2009

Along with all the other things, I couldn't let Digging and Submitting my posts go by without adding a feature for this to the Matilda engine.

The idea was simple, follow what others have done but put it in a way so it's not in-your-face and doesn't detract the user from the content.

So with some googling I found Yoast's Sociable Wordpress plugin, that basically adds a nice social bookmarking bar to all you're posts.

So with some hard work I quickly ported this over from PHP and minimized the JS needed (I really didn't want another js file sitting on my interface and slowing the loading so it had to be dynamic and off of Rails, the pages are all cached so speed isn't a problem).

After which that left me with a clean & simple partial, I then tiend that to Rails 2.1's new Locals feature which allows you to send local variables across as parameters to your partials which made things much more dynamic.

<%= render :partial => 'sociable',
:locals => {:s_url => @article.article_url_full, 
    :s_title => URI.escape(CGI.escape(@article.title.to_s),'.')}%>

Put in some escaping with the URI library, css improvements and you're done.

Escaping in Ruby

  • Digg this article
  • Sphinn this article
  • Stumble this article
  • Facebook
  • del.icio.us
  • LinkedIn
  • Twit this article
Posted by John
on Saturday, 08 November 2008

Really simple example for escaping your strings

require 'uri'
str = URI.escape(str) if str.length > 0