SocialLinker (a new rubygem)

An article, posted almost 8 years ago filed in ruby, rubygem, gem, social_linker, rails, rubygems by murb, share, privacy, google+, facebook, google & twitter.

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:

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)!

Op de hoogte blijven?

Maandelijks maak ik een selectie artikelen en zorg ik voor wat extra context bij de meer technische stukken. Schrijf je hieronder in:

Mailfrequentie = 1x per maand. Je privacy wordt serieus genomen: de mailinglijst bestaat alleen op onze servers.