link_to_social 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3954c95c6fb8bd578ed0fc84439fa6ee2ee1aa39
4
+ data.tar.gz: 83aa0f2d2334605c8dde578aa771ed8f4e058909
5
+ SHA512:
6
+ metadata.gz: 91f5071d640efb8fbe146543798df30919d60f8eb7453feed6cb7bc68ac95967691bbf1b3d6b61308dfae1c94c26f4f706d044ab5237cf7eb592ac9200953663
7
+ data.tar.gz: 597ca33328945965038e3c999561d35334aabc77fe419be1fbc56f5cb0a390bdb6dd1a29d61f2282d9c4e26433ab22fa0e0ed5b765ad326b2c7df3fb94a9b241
@@ -0,0 +1,59 @@
1
+ # link_to_social
2
+
3
+ This gem adds a special link_to_social method to the Rails view helpers to easily make a regular link into a social sharing link.
4
+
5
+ If you're unsure of what this means, try clicking on of these example links:
6
+
7
+ [Share link_to_social on LinkedIn](http://www.linkedin.com/shareArticle?url=http%3A%2F%2Fgithub.com%2Fzachfeldman%2Flink_to_social&title=link_to_social&source=http%3A%2F%2Fzfeldman.com)
8
+
9
+ [Share link_to_social on Facebook](http://www.facebook.com/sharer.php?u=http%3A%2F%2Fgithub.com%2Fzachfeldman%2Flink_to_social)
10
+
11
+ ## Usage
12
+
13
+ Add the gem to your Rails project's Gemfile, then bundle install to get started.
14
+
15
+ `gem 'link_to_social'`
16
+
17
+
18
+ To use link_to_social inside your views:
19
+
20
+ `link_to_social "Share Google on Facebook", "http://google.com", network: :facebook`
21
+
22
+ `link_to_social "Share Google on Twitter", "http://google.com", network: :twitter`
23
+
24
+ Network options are passed as symbols. Acceptable network options include:
25
+
26
+ :facebook
27
+ :twitter
28
+ :linkedin
29
+ :googleplus
30
+ :tumblr
31
+
32
+ Some social networks also include optional parameters to include more information with your link, which have been added explicitly as options to link_to_social. Here are some examples:
33
+
34
+ `link_to_social "Share Google on Twitter", "http://google.com", network: :twitter, text: "Google is awesome."`
35
+
36
+ `link_to_social "Share Google on LinkedIn", "http://google.com", network: :linkedin, title: "Great Pandas", source: "http://pandafarm.com"`
37
+
38
+ `link_to_social("Share Google on Tumblr", "http://google.com", network: :tumblr, name: "A great post.", source: "http://zfeldman.com"`
39
+
40
+
41
+ ## Contributing to link_to_social
42
+
43
+ Pull requests welcome.
44
+
45
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
46
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
47
+ * Fork the project.
48
+ * Start a feature/bugfix branch.
49
+ * Commit and push until you are happy with your contribution.
50
+ * Make sure to add tests for it. This is important so we don't break it in a future version unintentionally.
51
+ * Send in a pull request!
52
+
53
+
54
+ ## Credits
55
+
56
+ * Zach Feldman [@zachfeldman](http://zfeldman.com)
57
+
58
+
59
+ [![githalytics.com alpha](https://cruel-carlota.pagodabox.com/a97e33716355e4d66ceff72b4e102dc3 "githalytics.com")](http://githalytics.com/zachfeldman/link_to_social)
@@ -0,0 +1 @@
1
+ require 'link_to_social/railtie' if defined?(Rails)
@@ -0,0 +1,8 @@
1
+ require "link_to_social/view_helper"
2
+ module LinkToSocial
3
+ class Railtie < Rails::Railtie
4
+ initializer "link_to_social.view_helper" do
5
+ ActionView::Base.send :include, ViewHelper
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module LinkToSocial
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ module LinkToSocial
2
+ module ViewHelper
3
+ def link_to_social(name = nil, url = nil, options = nil)
4
+ case options[:network]
5
+ when :facebook
6
+ url = "http://www.facebook.com/sharer.php?u=#{CGI.escape(url)}"
7
+ when :twitter
8
+ url = "http://twitter.com/home?status=#{(CGI.escape(options[:text])+"%20" if options[:text])}#{CGI.escape(url)}"
9
+ when :linkedin
10
+ url = "http://www.linkedin.com/shareArticle?url=#{CGI.escape(url)}"
11
+ url += "&title=#{CGI.escape(options[:title])}" if options[:title]
12
+ url += "&source=#{CGI.escape(options[:source])}" if options[:source]
13
+ when :googleplus
14
+ url = "https://plus.google.com/share?url=#{CGI.escape(url)}"
15
+ when :tumblr
16
+ url = "http://www.tumblr.com/share/link?url=#{CGI.escape(url)}"
17
+ url += "&name=#{CGI.escape(options[:name])}" if options[:name]
18
+ url += "&source=#{CGI.escape(options[:source])}" if options[:source]
19
+ end
20
+ options.delete(:network)
21
+ options.delete(:title) if options[:title]
22
+ options.delete(:source) if options[:source]
23
+ options.delete(:name) if options[:name]
24
+ options.delete(:text) if options[:text]
25
+ link_to name, url, options
26
+ end
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: link_to_social
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Zach Feldman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-15 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: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Easily create sharing links for all of the major social networks using
56
+ a simple link_to_social tag.
57
+ email:
58
+ - zachfeldman@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - lib/link_to_social/railtie.rb
64
+ - lib/link_to_social/version.rb
65
+ - lib/link_to_social/view_helper.rb
66
+ - lib/link_to_social.rb
67
+ - README.md
68
+ homepage: http://github.com/zachfeldman/link_to_social
69
+ licenses: []
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.0.3
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Social link_to helper for Rails.
91
+ test_files: []