Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.
/ social_sharer Public archive

A simple set of view helpers to create sharing buttons that include a source parameter

License

Notifications You must be signed in to change notification settings

mattrayner/social_sharer

Repository files navigation

Social Sharer Logo

By BD Network.

Social Sharer is a Ruby on Rails Gem, allowing you to easily create Twitter and Facebook share dialogues.

Build status Gem Version Code Coverage License

Key Features

  • Easy to configure
  • Easy to style
  • Kept up to date with changes share systems.

Getting Started

Installation

Add this to your gemfile within your Rails project:

gem 'social_sharer', '0.1.4'

Options

Single share URL

If you require a single URL to be shared across both social networks but require simple tracking, e.g. for Google Analytics you can use the options listed below:

{
  url: 'http://thisisbd.com/',
  twitter_message: 'This%20is%20BD'
}

This would have Facebook link to: http://thisisbd.com/?src=fb and your tweet contents would be: This is BD http://thisisbd.com/?src=tw

You may also add an (optional) Twitter handle to be included into the message:

{
  url: 'http://thisisbd.com/',
  twitter_handle: '@thisisbd',
  twitter_message: 'This%20is%20BD'
}

Your tweet contents would be: This is BD via @thisisbd http://thisisbd.com/?src=tw

Multiple share URLs

If you provide different URLs for each social network, or want more flexible control over the URLs users are sharing, these options are for you:

{
  individual_settings: true,

  twitter: {
    url: 'http://thisisbd.com/twitter_url',
    message: 'This%20is%20BD'
  },

  facebook: {
    url: 'http://thisisbd.com/facebook_url'
  }
}

This would have Facebook link to: http://thisisbd.com/facebook_url and your tweet contents would be: This is BD http://thisisbd.com/twitter_url

You may also add an (optional) Twitter handle to be included into the message:

{
  individual_settings: true,

  twitter: {
    url: 'http://thisisbd.com/twitter_url',
    handle: '@thisisbd',
    message: 'This%20is%20BD'
  },

  facebook: {
    url: 'http://thisisbd.com/facebook_url'
  }
}

This would have Facebook link to: http://thisisbd.com/facebook_url and your tweet contents would be: This is BD via @thisisbd http://thisisbd.com/twitter_url

View Helper

Within your view:

<%= social_share_tags( @social_sharer_options ) %>

Requirements

Social Sharer requires Ruby on Rails and has been tested on 4.x.

Contributing

If you wish to submit a bug fix or feature, you can create a pull request and it will be merged pending a code review.

  1. Clone it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

License

Social Sharer is licensed under the MIT License.

About

A simple set of view helpers to create sharing buttons that include a source parameter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages