I am a big fan of using static html pages in my web sites where possible.

Most of my web sites use some custom coded Ruby scripts as my personal content management systems or CMS to generate my various and sundry web sites.

One of the functions inside my CMS is used to generate a bookmark bar so anyone can mark the page on a number of popular sites.

Side Note: This article was written in 2008 so some of the references may be out-of-date. In fact, most of the referenced sites for bookmarking no longer exist.

The Build Bookmarks Procedure

This particular procedure – named buildBookmarks() – needs to encode the web page url and title. It uses the available escape function in Ruby’s CGI library.

require 'cgi'

Here is the basic function to create bookmarking code for several popular sites.

#----------------------------------------------------------------------
#-- use $gSiteUrl, $gUrl and $gTitle.
#----------------------------------------------------------------------
def buildBookmarks()
  eUrl = CGI::escape($gSiteUrl + $gUrl)
  eTitle = CGI::escape($gTitle)

  res =  "Share: "
  res << "<a href=\"http://del.icio.us/post?url={url}&title={title}\">Del.icio.us</a> | "
  res << "<a href=\"http://digg.com/submit?phase=2&url={url}&title={title}\">Digg</a> | "
  res << "<a href=\"http://www.facebook.com/sharer.php?u={url}&t={title}\">Facebook</a> | "
  res << "<a href=\"http://www.google.com/bookmarks/mark?op=edit&bkmk={url}&title={title}\">Google Bookmarks</a> | "
  res << "<a href=\"http://reddit.com/submit?url={url}&title={title}\">Reddit</a> | "
  res << "<a href=\"http://www.technorati.com/faves?add={url}\">Technorati</a> | "
  res << "<a href=\"https://favorites.live.com/quickadd.aspx?url={url}&title={title}\">Windows Live</a> | "
  res << "<a href=\"http://myweb2.search.yahoo.com/myresults/bookmarklet?u={url}&t={title}\">Yahoo! My Web</a>"
  res = res.gsub('{url}',eUrl)
  res = res.gsub('{title}',eTitle)  

  return res
end

Here is some sample code to call the buildBookmarks() procedure:

$gSiteUrl = "http://www.bradtrupp.com/"
$gUrl = "ruby-build-social-bookmarks.html"
$gTitle = "Using Ruby to generate Social Bookmarks for your Web Pages"

mybookmark = buildBookmarks();

Now the mybookmark variable has social bookmarking code ready to insert into your html page.

The resulting html code will look something like this:

Share: 
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.bradtrupp.com%2Fruby-build-social-bookmarks.html&title=Using+Ruby+to+generate+Social+Bookmarks+for+your+Web+Pages">Del.icio.us</a> |
<a href="http://digg.com/submit?phase=2&url=http%3A%2F%2Fwww.bradtrupp.com%2Fruby-build-social-bookmarks.html&title=Using+Ruby+to+generate+Social+Bookmarks+for+your+Web+Pages">Digg</a> |
<a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.bradtrupp.com%2Fruby-build-social-bookmarks.html&t=Using+Ruby+to+generate+Social+Bookmarks+for+your+Web+Pages">Facebook</a> |
<a href="http://www.google.com/bookmarks/mark?op=edit&bkmk=http%3A%2F%2Fwww.bradtrupp.com%2Fruby-build-social-bookmarks.html&title=Using+Ruby+to+generate+Social+Bookmarks+for+your+Web+Pages">Google Bookmarks</a> |
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.bradtrupp.com%2Fruby-build-social-bookmarks.html&title=Using+Ruby+to+generate+Social+Bookmarks+for+your+Web+Pages">Reddit</a> |
<a href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.bradtrupp.com%2Fruby-build-social-bookmarks.html">Technorati</a> |
<a href="https://favorites.live.com/quickadd.aspx?url=http%3A%2F%2Fwww.bradtrupp.com%2Fruby-build-social-bookmarks.html&title=Using+Ruby+to+generate+Social+Bookmarks+for+your+Web+Pages">Windows Live</a> |
<a href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.bradtrupp.com%2Fruby-build-social-bookmarks.html&t=Using+Ruby+to+generate+Social+Bookmarks+for+your+Web+Pages">Yahoo! My Web</a>

List of Social Bookmarking Sites

Here is a short list of sites you can submit to – as of early 2008.

Just substitute the [URL] and [TITLE] variables with the correct values for your web pages,

Ask
  • http://myjeeves.ask.com/mysearch/BookmarkIt?v=1.2&t=webpages&url=[URL]&title=[TITLE]
Blinkbits
  • http://www.blinkbits.com/bookmarklets/save.php?v=1&source_url=[URL]
BlinkList
  • http://blinklist.com/index.php?Action=Blink/addblink.php&Url=[URL]&Title=[TITLE]
Blogmarks
  • http://blogmarks.net/my/new.php?mini=1&simple=1&url=[URL]&title=[TITLE]
Bluedot
  • http://bluedot.us/Authoring.aspx?u=[URL]&t=[TITLE]
Connotea
  • http://www.connotea.org/addpopup?continue=confirm&uri=[URL]&title=[TITLE]
del.icio.us
  • http://del.icio.us/post?url=[URL]&title=[TITLE]
Digg
  • http://digg.com/submit?phase=2&url=[URL]&title=[TITLE]
Diigo
  • http://www.diigo.com/post?url=[URL]&title=[TITLE]
dzone
  • http://www.dzone.com/links/add.html?url=[URL]&title=[TITLE]
Facebook
  • http://www.facebook.com/sharer.php?u=[URL]&t=[TITLE]
Fark
  • http://cgi.fark.com/cgi/fark/submit.pl?new_url=[URL]&new_comment=[TITLE]&linktype=
Furl
  • http://furl.net/storeIt.jsp?u=[URL]&t=[TITLE]
Google Bookmarks
  • http://www.google.com/bookmarks/mark?op=edit&bkmk=[URL]&title=[TITLE]
ma.gnolia
  • http://ma.gnolia.com/bookmarklet/add?url=[URL]&title=[TITLE]
Newsvine
  • http://www.newsvine.com/_wine/save?u=[URL]&h=[TITLE]
Rawsugar
  • http://www.rawsugar.com/tagger/?turl=[URL]&tttl=[TITLE]&editorInitialized=1
reddit
  • http://reddit.com/submit?url=[URL]&title=[TITLE]
Shoutwire
  • http://www.shoutwire.com/?p=submit&&link=[URL]
Simpy
  • http://www.simpy.com/simpy/LinkAdd.do?href=[URL]&title=[TITLE]
Slashdot
  • http://slashdot.org/bookmark.pl?url=[URL]&title=[TITLE]
Smarking
  • http://smarking.com/editbookmark/?url=[URL]
Spurl
  • http://www.spurl.net/spurl.php?url=[URL]&title=[TITLE]
Squidoo
  • http://www.squidoo.com/lensmaster/bookmark?[URL]
StumbleUpon
  • http://www.stumbleupon.com/submit?url=[URL]&title=[TITLE]
SWiK
  • http://stories.swik.net/?submitUrl&url=[URL]
Tailrank
  • http://tailrank.com/share/?link_href=[URL]&title=[TITLE]
Technorati
  • http://www.technorati.com/faves?add=[URL]
Windows Live
  • https://favorites.live.com/quickadd.aspx?url=[URL]&title=[TITLE]
Wists
  • http://wists.com/r.php?c=&r=[URL]&tot;e=[TITLE]
Yahoo! My Web
  • http://myweb2.search.yahoo.com/myresults/bookmarklet?u=[URL]&t=[TITLE]