social_buttons 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .rvmrc*
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in social_buttons.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Alex Kojin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # SocialButtons
2
+
3
+ Helper methods for to easy integrate social buttons 'Pin It', 'Like', 'Tweet it', 'G+'
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'social_buttons'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ In application.js add:
18
+
19
+ //= require social_buttons
20
+
21
+ In view:
22
+
23
+ <%= pin_it_button url: @product.url, media: @product.large_image_url, description: @product.description %>
24
+
25
+ <%= fb_like_button %>
26
+
27
+ <%= twitter_share_button count: 'none' %>
28
+
29
+ <%= google_plus_button size: 'medium', annotation: 'none' %>
30
+
31
+ More details you can find in the [code][1]
32
+
33
+ [1]: https://github.com/alexkojin/social_buttons/blob/master/lib/social_buttons/helper.rb
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,11 @@
1
+ require "social_buttons/version"
2
+ require "social_buttons/helper"
3
+
4
+ module SocialButtons
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
10
+
11
+ ActionView::Base.send :include, SocialButtons::Helper
@@ -0,0 +1,60 @@
1
+ module SocialButtons
2
+ module Helper
3
+ # Pinterest button
4
+ # http://pinterest.com/about/goodies/
5
+ def pin_it_button(options={})
6
+ params = options.slice(:url, :media, :description)
7
+ params[:url] ||= request.url
8
+ img = tag :img, :src => "//assets.pinterest.com/images/PinExt.png", :title => "Pin It", :border => "0"
9
+ content_tag :a, img, "href" => "http://pinterest.com/pin/create/button/?#{params.to_query}",
10
+ "class" => "pin-it-button",
11
+ "count-layout" => "none"
12
+ end
13
+
14
+ # Facebook like button
15
+ # http://developers.facebook.com/docs/reference/plugins/like/
16
+ def fb_like_button(options={})
17
+ href = options[:url] || request.url
18
+ params = options.slice(:layout, :send, :width, :height, :show_faces, :action, :colorscheme, :font, :appId)
19
+ params.reverse_merge!({:href => href,
20
+ :layout => 'button_count',
21
+ :send => false,
22
+ :width => 450,
23
+ :height => 21,
24
+ :show_faces => false,
25
+ :action => 'like',
26
+ :colorscheme => 'light',
27
+ :font => 'verdana'
28
+ })
29
+
30
+ style = "border:none; overflow:hidden; width:#{params[:width]}px; height:#{params[:height]}px;"
31
+
32
+ content_tag :iframe, '', :src => "//www.facebook.com/plugins/like.php?#{params.to_query}",
33
+ :scrolling => 'no',
34
+ :frameborder => 0,
35
+ :allowTransparency => true,
36
+ :style => style,
37
+ :class => 'fb-like-btn'
38
+ end
39
+
40
+ # Twitter button
41
+ # https://twitter.com/about/resources/buttons
42
+ # Options: url, via, lang, size, related, hashtags, count
43
+ def twitter_share_button(options={})
44
+ options = Hash[options.map {|k, v| ["data-#{k}", v] }]
45
+ options.merge!({:href => 'https://twitter.com/share', :class => 'twitter-share-button'})
46
+
47
+ content_tag :a, 'Tweet', options
48
+ end
49
+
50
+ # Google +1 button
51
+ # http://www.google.com/webmasters/+1/button/
52
+ def google_plus_button(options={})
53
+ href = options[:url] || request.url
54
+ options = Hash[options.map {|k, v| ["data-#{k}", v] }]
55
+ options.merge!({:class => 'g-plusone', 'data-href' => href})
56
+
57
+ content_tag :div, '', options
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module SocialButtons
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/social_buttons/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Alex Kojin"]
6
+ gem.email = ["alexkojin@gmail.com"]
7
+ gem.description = "Helper methods to easy integrate social buttons 'Pin It', 'Like', 'Tweet it', 'G+' in Rails application"
8
+ gem.summary = "Helper methods for 'Pin It', 'Like', 'Tweet it', 'G+' buttons"
9
+ gem.homepage = "https://github.com/alexkojin/social_buttons.git"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "social_buttons"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = SocialButtons::VERSION
17
+
18
+ gem.add_dependency "rails", ">=3.0.0"
19
+ end
@@ -0,0 +1,22 @@
1
+ (function() {
2
+ function async_load(){
3
+ js_async_load('//assets.pinterest.com/js/pinit.js');
4
+ js_async_load('//platform.twitter.com/widgets.js', 'twitter-wjs');
5
+ js_async_load('https://apis.google.com/js/plusone.js');
6
+ }
7
+
8
+ function js_async_load(src, id){
9
+ var s = document.createElement('script');
10
+ s.type = 'text/javascript';
11
+ s.async = true;
12
+ s.id = id;
13
+ s.src = src;
14
+ var x = document.getElementsByTagName('script')[0];
15
+ x.parentNode.insertBefore(s, x);
16
+ }
17
+
18
+ if (window.attachEvent)
19
+ window.attachEvent('onload', async_load);
20
+ else
21
+ window.addEventListener('load', async_load, false);
22
+ })();
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: social_buttons
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Alex Kojin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-06-29 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rails
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.0.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: Helper methods to easy integrate social buttons 'Pin It', 'Like', 'Tweet it', 'G+' in Rails application
27
+ email:
28
+ - alexkojin@gmail.com
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - .gitignore
37
+ - Gemfile
38
+ - LICENSE
39
+ - README.md
40
+ - Rakefile
41
+ - lib/social_buttons.rb
42
+ - lib/social_buttons/helper.rb
43
+ - lib/social_buttons/version.rb
44
+ - social_buttons.gemspec
45
+ - vendor/assets/javascripts/social_buttons.js
46
+ homepage: https://github.com/alexkojin/social_buttons.git
47
+ licenses: []
48
+
49
+ post_install_message:
50
+ rdoc_options: []
51
+
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.8.21
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Helper methods for 'Pin It', 'Like', 'Tweet it', 'G+' buttons
73
+ test_files: []
74
+