social_share_hub 0.0.1

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,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in social_share_hub.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jerry Shen
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,29 @@
1
+ # SocialShareHub
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'social_share_hub'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install social_share_hub
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
Binary file
@@ -0,0 +1,41 @@
1
+ /*
2
+
3
+ Creating a sprite from following images:
4
+
5
+ images/douban.png (24x24)
6
+ images/douban_disabled.png (24x24)
7
+ images/renren.png (24x24)
8
+ images/renren_disabled.png (24x24)
9
+ images/weibo.png (24x24)
10
+ images/weibo_disabled.png (24x24)
11
+
12
+ Output files:
13
+ images.png
14
+ images.css
15
+
16
+ Output size:
17
+ 144x24
18
+
19
+
20
+ */
21
+ .clearfix:before, .clearfix:after {
22
+ content:"\0020";
23
+ display:block;
24
+ height:0;
25
+ visibility:hidden;
26
+ }
27
+ .clearfix:after {
28
+ clear:both;
29
+ }
30
+
31
+ .social-share-hub a {
32
+ float: left;
33
+ margin-right: 3px;
34
+ }
35
+
36
+ .social_share_hub_douban { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") 0px 0px no-repeat; }
37
+ .social_share_hub_douban.disabled { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -24px 0px no-repeat; }
38
+ .social_share_hub_renren { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -48px 0px no-repeat; }
39
+ .social_share_hub_renren.disabled { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -72px 0px no-repeat; }
40
+ .social_share_hub_weibo { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -96px 0px no-repeat; }
41
+ .social_share_hub_weibo_disabled { width: 24px; height: 24px; background: image-url("sprites/social_share_hub_sprites.png") -120px 0px no-repeat; }
@@ -0,0 +1,9 @@
1
+ en:
2
+ social_share_hub:
3
+ share_to: Share to %{name}
4
+ weibo: Sina Weibo
5
+ twitter: Twitter
6
+ facebook: Facebook
7
+ douban: Douban
8
+ qq: QQ
9
+ renren: Renren
@@ -0,0 +1,9 @@
1
+ en:
2
+ social_share_hub:
3
+ share_to: Share to %{name}
4
+ weibo: Sina Weibo
5
+ twitter: Twitter
6
+ facebook: Facebook
7
+ douban: Douban
8
+ qq: QQ
9
+ renren: Renren
@@ -0,0 +1,9 @@
1
+ en:
2
+ social_share_hub:
3
+ share_to: Share to %{name}
4
+ weibo: Sina Weibo
5
+ twitter: Twitter
6
+ facebook: Facebook
7
+ douban: Douban
8
+ qq: QQ
9
+ renren: Renren
@@ -0,0 +1,12 @@
1
+ module SocialShareHub
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ desc "Copy Social Share Hub 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
+ SocialShareHub.configure do |config|
2
+ config.allowed_sites = %w(twitter facebook weibo douban qq renren)
3
+ end
@@ -0,0 +1,23 @@
1
+ module SocialShareHub
2
+ class << self
3
+ attr_accessor :config
4
+
5
+ def configure
6
+ yield self.config ||= Config.new
7
+ end
8
+ end
9
+
10
+ class Config
11
+ # enable social sites to share,
12
+ # * default : twitter facebook weibo douban
13
+ # * site support: twitter facebook weibo douban
14
+ attr_accessor :allowed_sites
15
+
16
+ def initialize
17
+ end
18
+ end
19
+ end
20
+
21
+ SocialShareHub.configure do |conf|
22
+ conf.allowed_sites = %w(twitter facebook weibo douban qq renren)
23
+ end
@@ -0,0 +1,6 @@
1
+ module SocialShareHub
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,36 @@
1
+ module SocialShareHub
2
+ module Helper
3
+ def social_share_hub_tag(message, link, options = {})
4
+ html = []
5
+ html << "<div class='social-share-hub clearfix'>"
6
+
7
+ SocialShareHub.config.allowed_sites.each do |name|
8
+ title = t "social_share_hub.share_to", :name => t("social_share_hub.#{name.downcase}")
9
+
10
+ case name.to_sym
11
+ when :weibo
12
+ html << social_share_hub_weibo_link(message, link, options)
13
+ when :douban
14
+ html << social_share_hub_douban_link(message, link, options)
15
+ when :renren
16
+ html << social_share_hub_renren_link(message, link, options)
17
+ end
18
+
19
+ end
20
+ html << "</div>"
21
+ raw html.join("\n")
22
+ end
23
+
24
+ def social_share_hub_weibo_link(message, link, options)
25
+ "<a class=\"social_share_hub_weibo\" href=\"javascript:void((function(s,d,e){var f='http://v.t.sina.com.cn/share/share.php?url=',u=d.location,l=d.title,p=[e('#{link}'),'&title=',e('#{message}')].join('');function%20a(){if(!window.open([f,p].join(''),'weibo',['toolbar=0,status=0,resizable=1,width=626,height=436,left=',(s.width-626)/2,',top=',(s.height-436)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent));\" title=\"Sina Weibo\">&nbsp;</a>".html_safe
26
+ end
27
+
28
+ def social_share_hub_douban_link(message, link, options)
29
+ "<a class=\"social_share_hub_douban\" href=\"javascript:void(function(){var d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:'',r='http://www.douban.com/recommend/?url='+e('#{link}')+'&title='+e('#{message}')+'&sel='+e(s)+'&v=1',x=function(){if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'};if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}})()\" title=\"Douban\">&nbsp;</a>".html_safe
30
+ end
31
+
32
+ def social_share_hub_renren_link(message, link, options)
33
+ "<a class=\"social_share_hub_renren\" href=\"javascript:void((function(s,d,e){if(/renren\.com/.test(d.location))return;var f='http://share.renren.com/share/buttonshare?link=',u=d.location,l=d.title,p=[e('#{link}'),'&title=',e(l)].join('');function%20a(){if(!window.open([f,p].join(''),'xnshare',['toolbar=0,status=0,resizable=1,width=626,height=436,left=',(s.width-626)/2,',top=',(s.height-436)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent));\" title=\"Renren\">&nbsp;</a>".html_safe
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,6 @@
1
+ module SocialShareHub
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module SocialShareHub
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,15 @@
1
+ require "social_share_hub/version"
2
+ require "social_share_hub/config"
3
+ require "social_share_hub/helper"
4
+
5
+ module SocialShareHub
6
+ module Rails
7
+ if ::Rails.version < "3.1"
8
+ require "social_share_hub/railtie"
9
+ else
10
+ require "social_share_hub/engine"
11
+ end
12
+ end
13
+ end
14
+
15
+ ActionView::Base.send :include, SocialShareHub::Helper
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/social_share_hub/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jerry Shen"]
6
+ gem.email = ["jerry@ekohe.com"]
7
+ gem.description = %q{Social Share Hub}
8
+ gem.summary = %q{Social Share Hub}
9
+ gem.homepage = ""
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_share_hub"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = SocialShareHub::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: social_share_hub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jerry Shen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-26 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Social Share Hub
15
+ email:
16
+ - jerry@ekohe.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - app/assets/images/sprites/douban.png
27
+ - app/assets/images/sprites/douban_disabled.png
28
+ - app/assets/images/sprites/renren.png
29
+ - app/assets/images/sprites/renren_disabled.png
30
+ - app/assets/images/sprites/social_share_hub_sprites.png
31
+ - app/assets/images/sprites/weibo.png
32
+ - app/assets/images/sprites/weibo_disabled.png
33
+ - app/assets/stylesheets/social_share_hub.css.scss
34
+ - config/locales/social_share_hub.en.yml
35
+ - config/locales/social_share_hub.zh-CN.yml
36
+ - config/locales/social_share_hub.zh-TW.yml
37
+ - lib/generators/social_share_hub/install_generator.rb
38
+ - lib/generators/social_share_hub/templates/config/initializers/social_share_hub.rb
39
+ - lib/social_share_hub.rb
40
+ - lib/social_share_hub/config.rb
41
+ - lib/social_share_hub/engine.rb
42
+ - lib/social_share_hub/helper.rb
43
+ - lib/social_share_hub/railtie.rb
44
+ - lib/social_share_hub/version.rb
45
+ - social_share_hub.gemspec
46
+ homepage: ''
47
+ licenses: []
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.16
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Social Share Hub
70
+ test_files: []