icon-social-share-button 0.0.2

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8f373c3fd259b8edabb07f6bb83597b2a55fc2f1
4
+ data.tar.gz: 5458d1edfaca967d4e47145b9c607ecbcc514e23
5
+ SHA512:
6
+ metadata.gz: de85637f7a4f9958e098b918b3f2b735c39098d189c2693c282f5c0d4d57cd27e6ce8aca91feb0765a07d67f84522e2a78b4d104891bf5e3d246de738de92c15
7
+ data.tar.gz: 6d5ef1ab36b90b48b8239e615a294bb8090f1f43281b61537243e75ab5d8a827310daa3dbed12c0c9701ec1f02873bc435982f56d7a3c7d0e61f1c7621774af6
data/Changelogs.md ADDED
@@ -0,0 +1,68 @@
1
+ == 0.1.9
2
+
3
+ * Add `data-via` to allow `{ via: "MyTwitter" }`
4
+ * Add the special title for the corresponding social network by `{ 'data-twitter-title' => 'TheTitleForTwitter'}`
5
+
6
+ == 0.1.8
7
+
8
+ * Allow you custom appKey.
9
+
10
+ == 0.1.7
11
+
12
+ * Add desc support;
13
+
14
+ == 0.1.5
15
+
16
+ * Add Tumblr;
17
+
18
+ == 0.1.4
19
+
20
+ * Add Plurk support;
21
+ * Fix Renren share link;
22
+
23
+ == 0.1.3
24
+
25
+ * Support Rails 4;
26
+
27
+ == 0.1.2
28
+
29
+ * Add tumblr.
30
+
31
+ == 0.1.1
32
+
33
+ * Add delicious.
34
+ * Use new version of Weibo, Douban share URL to speed up page open.
35
+
36
+ == 0.1.0
37
+
38
+ * Retina support.
39
+
40
+ == 0.0.9
41
+
42
+ * Allow to give :url option to custom url.
43
+
44
+ == 0.0.8
45
+
46
+ * Add Google Bookmark;
47
+ * Improve Google+ icon.
48
+
49
+ == 0.0.7
50
+
51
+ * Douban, TQQ add image support.
52
+
53
+ == 0.0.6
54
+
55
+ * Transparent icon fix
56
+
57
+ == 0.0.5
58
+
59
+ * Transparent icon
60
+ * More site added (Renren,TQQ, Google+, Baidu, Kaixin001)
61
+
62
+ == 0.0.4
63
+
64
+ * Add image support for Weibo share.
65
+
66
+ == 0.0.3
67
+
68
+ * Facebook, Twitter, Weibo, Douban, QQZone 分享功能;
data/README.md ADDED
@@ -0,0 +1,148 @@
1
+ # Social Share Button
2
+
3
+ This gem is forks from [social-share-button]()
4
+ It used to share url to chinese social apps
5
+
6
+ # Support Apps list
7
+
8
+ * Weibo
9
+ * QZone
10
+ * Tencent Weibo
11
+ * QQ Friend
12
+ * Wechat(weixin)
13
+ ## Screenshot
14
+
15
+ ## Install
16
+
17
+ In your `Gemfile`:
18
+
19
+ ```ruby
20
+ gem 'icon-social-share-button'
21
+ ```
22
+
23
+ And install it:
24
+
25
+ ```bash
26
+ $ bundle install
27
+ $ rails generate icon_social_share_button:install
28
+ ```
29
+
30
+ ## Configure
31
+
32
+ You can config `config/initializes/icon_social_share_button.rb` to choose which site do you want to use:
33
+
34
+ ```ruby
35
+ IconSocialShareButton.configure do |config|
36
+ config.allow_sites = %w(weibo tqq qq qqzone wechat)
37
+ end
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ You need add require css,js file in your app assets files:
43
+
44
+ `app/assets/javascripts/application.js`
45
+
46
+ ```
47
+ //= require icon-social-share-button
48
+ ```
49
+
50
+ ```sh
51
+ mkdir /to/your_app_project_path/app/assets/fonts
52
+ cp fonts/* /to/your_app_project_path/app/assets/fonts
53
+ ```
54
+
55
+ `app/assets/stylesheets/application.css.scss`
56
+
57
+ ```scss
58
+ /* You can extend css base on the below code */
59
+ @font-face {font-family: "generial-iconfont";
60
+ src: font-url('iconfont.eot'); /* IE9*/
61
+ src: font-url('iconfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
62
+ font-url('iconfont.woff') format('woff'), /* chrome、firefox */
63
+ font-url('iconfont.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
64
+ font-url('iconfont.svg#iconfont') format('svg'); /* iOS 4.1- */
65
+ }
66
+
67
+ .generial-iconfont {
68
+ font-family:"generial-iconfont" !important;
69
+ font-size:18px;
70
+ font-style:normal;
71
+ line-height:15px;
72
+ -webkit-font-smoothing: antialiased;
73
+ -webkit-text-stroke-width: 0.2px;
74
+ -moz-osx-font-smoothing: grayscale;
75
+ }
76
+
77
+ .social-share-button {
78
+ position: relative;
79
+ left: 50px;
80
+ top: 5px;
81
+ }
82
+
83
+ .social-share-button a {
84
+ margin: auto 10px;
85
+ }
86
+
87
+ .icon-social-share-button-qqzone:before {
88
+ content: "\e605";
89
+ background-color: #E9AC40;
90
+ border-radius: 5px;
91
+ font-size: 38px;
92
+ display: inline-block;
93
+ padding: 2px;
94
+ color: #FFF;
95
+ text-decoration: blink;
96
+ line-height: 38px;
97
+ }
98
+
99
+ .icon-social-share-button-tqq:before {
100
+ content: "\e607";
101
+ background-color: #40B6CA;
102
+ border-radius: 5px;
103
+ font-size: 38px;
104
+ display: inline-block;
105
+ padding: 2px;
106
+ color: #FFF;
107
+ text-decoration: blink;
108
+ line-height: 38px;
109
+ }
110
+
111
+ .icon-social-share-button-qq:before {
112
+ content: "\e601";
113
+ background-color: #338edd;
114
+ border-radius: 5px;
115
+ font-size: 38px;
116
+ display: inline-block;
117
+ padding: 2px;
118
+ color: #FFF;
119
+ text-decoration: blink;
120
+ line-height: 38px;
121
+ }
122
+
123
+ .icon-social-share-button-weibo:before {
124
+ content: "\e603";
125
+ background-color: #BE3724;
126
+ border-radius: 5px;
127
+ font-size: 38px;
128
+ display: inline-block;
129
+ padding: 2px;
130
+ color: #FFF;
131
+ text-decoration: blink;
132
+ line-height: 38px;
133
+ }
134
+
135
+ ```
136
+
137
+ Then you can use `icon_social_share_button_tag` helper in views, for example `app/views/posts/show.html.erb`
138
+
139
+ Generate icon_social_share_button on views
140
+ ```erb
141
+ <%= icon_social_share_button_tag '23333', :url => request.original_url, :desc => '😄哈哈哈哈哈哈哈' %>
142
+ ```
143
+
144
+ Generate Qr_code on views
145
+ Default url is this repository
146
+ ```erb
147
+ <%= wechat_image_tag %>
148
+ ```
@@ -0,0 +1,87 @@
1
+ window.IconSocialShareButton =
2
+ openUrl : (url,popup) ->
3
+ if popup == "true"
4
+ window.open(url,'popup','height=500,width=500')
5
+ else
6
+ window.open(url)
7
+ false
8
+
9
+ share : (el) ->
10
+ site = $(el).data('site')
11
+ appkey = $(el).data('appkey') || ''
12
+ $parent = $(el).parent()
13
+ title = encodeURIComponent($(el).data(site + '-title') || $parent.data('title') || '')
14
+ img = encodeURIComponent($parent.data("img") || '')
15
+ url = encodeURIComponent($parent.data("url") || '')
16
+ via = encodeURIComponent($parent.data("via") || '')
17
+ desc = encodeURIComponent($parent.data("desc") || ' ')
18
+ popup = encodeURIComponent($parent.data("popup") || 'false')
19
+ videos = encodeURIComponent($parent.data("videos") || '')
20
+
21
+ if url.length == 0
22
+ url = encodeURIComponent(location.href)
23
+ switch site
24
+ when "email"
25
+ location.href = "mailto:?to=&subject=#{title}&body=#{url}"
26
+ when "weibo"
27
+ IconSocialShareButton.openUrl("http://service.weibo.com/share/share.php?url=#{url}&type=3&pic=#{img}&title=#{title}&appkey=#{appkey}",popup)
28
+ when "twitter"
29
+ via_str = ''
30
+ via_str = "&via=#{via}" if via.length > 0
31
+ IconSocialShareButton.openUrl("https://twitter.com/intent/tweet?url=#{url}&text=#{title}#{via_str}",popup)
32
+ when "douban"
33
+ IconSocialShareButton.openUrl("http://shuo.douban.com/!service/share?href=#{url}&name=#{title}&image=#{img}&sel=#{desc}",popup)
34
+ when "facebook"
35
+ IconSocialShareButton.openUrl("http://www.facebook.com/sharer.php?u=#{url}",popup)
36
+ when "qq"
37
+ IconSocialShareButton.openUrl("http://connect.qq.com/widget/shareqq/index.html?url=#{url}&title=#{title}&videos=#{videos}&desc=#{desc}&summary=#{desc}&site=#{appkey}", popup)
38
+ when "qqzone"
39
+ IconSocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}&summary=#{desc}&site=#{appkey}", popup)
40
+ when "tqq"
41
+ IconSocialShareButton.openUrl("http://share.v.t.qq.com/index.php?c=share&a=index&url=#{url}&title=#{title}&pic=#{img}&appkey=#{appkey}", popup)
42
+ when "baidu"
43
+ IconSocialShareButton.openUrl("http://hi.baidu.com/pub/show/share?url=#{url}&title=#{title}&content=#{desc}", popup)
44
+ when "kaixin001"
45
+ IconSocialShareButton.openUrl("http://www.kaixin001.com/rest/records.php?url=#{url}&content=#{title}&style=11&pic=#{img}&aid=#{appkey}", popup)
46
+ when "renren"
47
+ IconSocialShareButton.openUrl("http://widget.renren.com/dialog/share?resourceUrl=#{url}&srcUrl=#{url}&title=#{title}&pic=#{img}&description=#{desc}", popup)
48
+ when "google_plus"
49
+ IconSocialShareButton.openUrl("https://plus.google.com/share?url=#{url}", popup)
50
+ when "google_bookmark"
51
+ IconSocialShareButton.openUrl("https://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=#{url}&title=#{title}", popup)
52
+ when "delicious"
53
+ IconSocialShareButton.openUrl("http://www.delicious.com/save?url=#{url}&title=#{title}&jump=yes&pic=#{img}", popup)
54
+ when "plurk"
55
+ IconSocialShareButton.openUrl("http://www.plurk.com/?status=#{title}: #{url}&qualifier=shares", popup)
56
+ when "pinterest"
57
+ IconSocialShareButton.openUrl("http://www.pinterest.com/pin/create/button/?url=#{url}&media=#{img}&description=#{title}", popup)
58
+ when "tumblr"
59
+ get_tumblr_extra = (param) ->
60
+ cutom_data = $(el).attr("data-#{param}")
61
+ encodeURIComponent(cutom_data) if cutom_data
62
+
63
+ tumblr_params = ->
64
+ path = get_tumblr_extra('type') || 'link'
65
+
66
+ params = switch path
67
+ when 'text'
68
+ title = get_tumblr_extra('title') || title
69
+ "title=#{title}"
70
+ when 'photo'
71
+ title = get_tumblr_extra('caption') || title
72
+ source = get_tumblr_extra('source') || img
73
+ "caption=#{title}&source=#{source}"
74
+ when 'quote'
75
+ quote = get_tumblr_extra('quote') || title
76
+ source = get_tumblr_extra('source') || ''
77
+ "quote=#{quote}&source=#{source}"
78
+ else # actually, it's a link clause
79
+ title = get_tumblr_extra('title') || title
80
+ url = get_tumblr_extra('url') || url
81
+ "name=#{title}&url=#{url}"
82
+
83
+
84
+ "/#{path}?#{params}"
85
+
86
+ IconSocialShareButton.openUrl("http://www.tumblr.com/share#{tumblr_params()}", popup)
87
+ false
@@ -0,0 +1,3 @@
1
+ /*
2
+ You can write here to extend css code
3
+ */
@@ -0,0 +1,12 @@
1
+ module IconSocialShareButton
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ desc "Copy IconSocialShareButton default files"
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def copy_config
8
+ directory 'config'
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ IconSocialShareButton.configure do |config|
2
+ config.allow_sites = %w(weibo tqq qqzone qq wechat)
3
+ end
@@ -0,0 +1,8 @@
1
+ en:
2
+ icon_social_share_button:
3
+ share_to: Share to %{name}
4
+ weibo: Sina Weibo
5
+ qq: QQ
6
+ qqzone: QQzone
7
+ tqq: Tqq
8
+ wechat: wechat
@@ -0,0 +1,8 @@
1
+ 'zh-CN':
2
+ icon_social_share_button:
3
+ share_to: 分享到 %{name}
4
+ weibo: 新浪微博
5
+ qq: QQ好友
6
+ qqzone: QQ空间
7
+ tqq: 腾讯微博
8
+ wechat: 微信
@@ -0,0 +1,8 @@
1
+ 'zh-TW':
2
+ icon_social_share_button:
3
+ share_to: 分享到 %{name}
4
+ weibo: 新浪微博
5
+ qq: QQ好友
6
+ qqzone: QQ空間
7
+ tqq: 腾讯微博
8
+ wechat: 微信
@@ -0,0 +1,17 @@
1
+ require "icon_social_share_button/version"
2
+ require "icon_social_share_button/config"
3
+ require "icon_social_share_button/helper"
4
+
5
+ I18n.load_path += Dir.glob( File.dirname(__FILE__) + "lib/locales/*.{rb,yml}" )
6
+
7
+ module IconSocialShareButton
8
+ module Rails
9
+ if ::Rails.version < "3.1"
10
+ require "icon_social_share_button/railtie"
11
+ else
12
+ require "icon_social_share_button/engine"
13
+ end
14
+ end
15
+ end
16
+
17
+ ActionView::Base.send :include, IconSocialShareButton::Helper
@@ -0,0 +1,18 @@
1
+ module IconSocialShareButton
2
+ class << self
3
+ attr_accessor :config
4
+ def configure
5
+ yield self.config ||= Config.new
6
+ end
7
+ end
8
+
9
+ class Config
10
+ # enable social sites to share,
11
+ # * default : twitter facebook weibo douban
12
+ # * site support: twitter facebook weibo douban
13
+ attr_accessor :allow_sites
14
+
15
+ def initialize
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ # coding: utf-8
2
+ module IconSocialShareButton
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+ require 'rqrcode'
3
+ module IconSocialShareButton
4
+ module Helper
5
+ def icon_social_share_button_tag(title = "", opts = {})
6
+ extra_data = {}
7
+ rel = opts[:rel]
8
+ html = []
9
+ html << "<div class='icon-social-share-button' id='#{opts[:id]}' data-title='#{h title}' data-img='#{opts[:image]}'"
10
+ html << "data-url='#{opts[:url]}' data-desc='#{opts[:desc]}' data-popup='#{opts[:popup]}' data-via='#{opts[:via]}'>"
11
+
12
+ IconSocialShareButton.config.allow_sites.each do |name|
13
+ extra_data = opts.select { |k, _| k.to_s.start_with?('data') } if name.eql?('tumblr')
14
+ special_data = opts.select { |k, _| k.to_s.start_with?('data-' + name) }
15
+
16
+ link_title = t "icon_social_share_button.share_to", :name => t("icon_social_share_button.#{name.downcase}")
17
+ html << link_to("","#", {:rel => ["nofollow", rel],
18
+ "data-site" => name,
19
+ :class => "generial-iconfont icon-social-share-button-#{name}",
20
+ :onclick => "return IconSocialShareButton.share(this);",
21
+ :title => h(link_title)}.merge(extra_data).merge(special_data))
22
+ end
23
+ html << "</div>"
24
+ raw html.join("\n")
25
+ end
26
+
27
+ def wechat_image_tag(opts = {})
28
+ default_img_options = {
29
+ :class => 'default-wechat-share-style',
30
+ :size => 250,
31
+ :url => 'http://t.cn/RLu4RKd'
32
+ }
33
+ options = default_img_options.merge(opts) # reverse_merge
34
+ image_tag generate_qr_code(options[:url]).as_png(:size => options[:size]).to_data_url
35
+ end
36
+
37
+ private
38
+
39
+ def short_url(url)
40
+ if url
41
+
42
+ else
43
+ raise "url must not be nil"
44
+ end
45
+ end
46
+
47
+ def generate_qr_code(url)
48
+ if url
49
+ RQRCode::QRCode.new(url, :size => 4, :level => :h)
50
+ else
51
+ raise "url must not be nil"
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ # coding: utf-8
2
+ module IconSocialShareButton
3
+ module Rails
4
+ class Railtie < ::Rails::Railtie
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module IconSocialShareButton
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icon-social-share-button
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Matrixbirds
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coffee-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sass-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rqrcode
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Helper for add social share feature in your Rails app. Weibo, QQ ...
70
+ email:
71
+ - yooobuntu@163.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/generators/icon_social_share_button/install_generator.rb
77
+ - lib/generators/icon_social_share_button/templates/config/initializers/icon_social_share_button.rb
78
+ - lib/generators/icon_social_share_button/templates/config/locales/icon_social_share_button.en.yml
79
+ - lib/generators/icon_social_share_button/templates/config/locales/icon_social_share_button.zh-CN.yml
80
+ - lib/generators/icon_social_share_button/templates/config/locales/icon_social_share_button.zh-TW.yml
81
+ - lib/icon-social-share-button.rb
82
+ - lib/icon_social_share_button/config.rb
83
+ - lib/icon_social_share_button/engine.rb
84
+ - lib/icon_social_share_button/helper.rb
85
+ - lib/icon_social_share_button/railtie.rb
86
+ - lib/icon_social_share_button/version.rb
87
+ - app/assets/javascripts/icon-social-share-button.coffee
88
+ - app/assets/stylesheets/icon=social-share-button.scss
89
+ - README.md
90
+ - Changelogs.md
91
+ homepage: https://github.com/Matrixbirds/icon-social-share-button
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.0.14
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Helper for add social share feature in your Rails app. Weibo, QQ ...
115
+ test_files: []