
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
This gem is a Rails 3+ engine (but can be used without the engine).
Currently there is support for the following social buttons:
Add the gem to your Gemfile and use Bundler to install the gem.
gem "social-buttons", '~> 0.3'
This gem is a Rails 3+ compatible engine and now automatically includes all the view helper modules into ActionView::Base
This gem includes the following view helper modules in social_buttons/view_helpers
:
Tweet
Like
Pinit
GooglePlus
Using SocialButtons is as simple as adding a single method call to your views:
ERB example:
<%= tweet_button %>
<%= like_button(app_id) %>
<%= pinit_button %>
<%= google_plus_button %>
HAML example:
= tweet_button
= like_button(app_id)
= pinit_button
= google_plus_button
Bam. Done. You'll have a sweet lookin' Social Buttons all up in your view.
Of course, you can customize it. Depending on the type of button, there are different options.
:url
- The URL to share; the default is the current URL.:text
- The text that will appear in the tweet; the default is "Check this out!":via
- The attribution. Defaults to "tweetbutton", but you should change that.:lang
- Set the language for the tweet (no default).:related
- Related Twitter accounts (no default).:count
- The tweet count box position (values can be "none", "horizontal", or "vertical"; default is "vertical").More information can be found from Twitter
So, if you wanted to tweet about Hacker News, attribute it to Peter Cooper, and add some custom text, all from a tweet button with a horizontal counter, you'd do this:
<%= tweet_button(via: "peterc", url: "http://news.ycombinator.com", text: "AWESOME.") %>
NOTE: Facebook App Id is mandatory
:href
- The URL to like, the default is the current URL.:send
- Whether to add a send button or not.:layout
- Size and amount of social context next to button. Has 3 options :standard
, :button_count
, and :box_count
:width
- Width of the button"show-faces"
- Show profile photos:action
- Action name like 'like' or 'recommend':font
- Font for the button:colorscheme
- Current colorschemeMore information can be found from Facebook
So, a simple like button can be added like this:
<%= like_button(app_id) %>
:url
- The URL to share; the default is the current URL.:media
- The image to be shared.:description
- Description for the link."count-layout"
- Specify pinit count. It can be horizontal
, vertical
or none
.More information can be found from Pinterest
So, a simple pinit button can be added like this:
<%= pinit_button(url: request.url, media: @picture.image.url, description: "Amazing Picture") %>
Before using you should include in the head:
<script src="http://vkontakte.ru/js/api/openapi.js" type="text/javascript" charset="windows-1251"></script>
:appId
- AppIp of your application or site:type
- full, button, mini, vertical, vertical by default:width
- only if full. Should be > 200:height
- only 18, 20, 22, 24:verb
- 0 or 1See Vk like for more info
:href
- The URL to share; the default is the current URL.:size
- Size of button: 'small', 'tall' or 'medium':annotation
- The style of button: 'inline', 'bubble', 'none':lang
- The locale, fx 'es' for Spanish (alias :locale)See Google+ button for more info.
You can set a new default for any option in your social_buttons.rb
initializer (in config/initializers
.
Set the default_options
on any of the social view helper modules.
For example:
# config/initializers/social_buttons.rb
SocialButtons::Tweet.default_options = {:via => "myself"}
Or even sweeter...
# config/initializers/social_buttons.rb
SocialButtons.config :tweet do |tweet|
tweet.default_options = {:via => "myself"}
end
# or
SocialButtons.config(:tweet).default_options = {:via => "myself"}
Or simply :)
# config/initializers/social_buttons.rb
SocialButtons.config do |social|
social.tweet do |tweet|
tweet.default_options = {:via => "myself"}
end
social.like.default_options = {:via => "myself"}
end
end
This little DSL makes the configuration more extensible for the future ;)
Only the options you specify will be overridden; so if you only specify a new default :via
, then the other defaults will stay intact.
We have started adding suport for help directly in the api:
puts SocialButtons.config(:google_plus).help
Should output some help info on how to use that particular method, options available etc. So far only works for Google+ button.
Copyright (c) 2012 Kristian Mandrup & Yuva Kumar Copyright (c) 2010 Jeremy McAnally.
See LICENSE for details.
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.