SocialLinker (a new rubygem)

I had a few projects that I thought could use some share ‘buttons’, but I didn’t like to include the JavaScript loaded and privacy invading share buttons that the networks try to sell you by default. Neither did I like to concatenate the links with all variables required for each project… so I wrote a small rubygem on a back and forth train trip (#ilovetrains ;)): social_linker.

The idea is that you share something about a certain subject, hence you initalize the SocialLinker::Subject and then you’ll be able to generate share links from it:

subject.share_link(:facebook)

How it works

Initialize the subject with enough material to generate links from, such as the page’s url, maybe the media url (mainly for Pinterest type-shares), a description, tags etc.

For example, initialize the SocialLinker::Subject as follows:

social_linker_subject = SocialLinker::Subject.new(
  media: "http://example.com/img.jpg", 
  url: "http://example.com/", 
  title: "Example website", 
  description: "Example.com is the typical URL you would want to use in explanations anyway."
)

You’ll get the e-mail share url by calling:

social_linker_subject.share_link(:email)

Which will deliver you the following url:

mailto:emailaddress?subject=Example%20website&body=Example.com%20is%20the%20typical%20URL%20you%20would%20want%20to%20use%20in%20explanations%20anyway.%0A%0Ahttp%3A%2F%2Fexample.com%2F

Or to save you the copy-paste:

TestMailLink

The supported options are:

  • url
  • media (media url, e.g. an image (now only Pinterest))
  • summary
  • description
  • title
  • tags

I’ve tried to map them as good as possible to the different share tools. Sometimes by combining several values. You may also pass along link-specific parameters such as :status (for twitter), so no status is generated from the link, the title and the tags (make sure that you include a link though).

You’ll find the MIT-licensed source on Github, suggestions for improvements are welcome (do make sure you write nice tests for them, everything is rspec’d)!

Eat your own dogfood

An article, posted about 8 years ago filed in social_linker, gem, ruby, ruby on rails & update.

Eat your own dogfood

Just a small note that I've made some improvements to my SocialLinker-gem lately and while I've been using it on a few sites already, I wasn't using it on my very own blog. Today I found some time to change exactly that: you've got to eat your own dog food. If you want to have a taste of it: murb/social_linker (if you're a ruby-dev) or just click the share icons below :)

Image CC-licensed BY: Sh4rp_i