unbutton 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
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 unbutton.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Nitesh Goel
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,32 @@
1
+ # Unbutton
2
+
3
+ Unbutton provides a set of helper methods to share content on the web without crappy buttons.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'unbutton'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install unbutton
18
+
19
+ ## Usage
20
+
21
+ require 'unbutton'
22
+ Unbutton.facebook_link "http://wallwisher.com", { title: 'Paper for the web', description: 'Simplest way to put content on the web', media: 'http://wallwisher.com/assets/wallwisher-big-crane.png' }
23
+
24
+ Supported services are `facebook`, `twitter`, `pinterest`, `tumblr`, `googleplus`, and `linkedin`.
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/unbutton.rb ADDED
@@ -0,0 +1,70 @@
1
+ require "uri"
2
+ require "unbutton/version"
3
+
4
+ module Unbutton
5
+ def self.facebook_link(url, options={})
6
+ base = "http://www.facebook.com/sharer.php"
7
+ params = params = { u: url }
8
+ options.has_key?(:title) && params[:t] = options[:title]
9
+ create_url base, params
10
+ end
11
+
12
+ def self.linkedin_link(url, options)
13
+ base = "http://www.linkedin.com/shareArticle"
14
+ params = params = { url: url, mini: true }
15
+ options.has_key?(:title) && params[:title] = options[:title]
16
+ options.has_key?(:description) && params[:summary] = options[:description]
17
+ options.has_key?(:source) && params[:source] = options[:source]
18
+
19
+ create_url base, params
20
+ end
21
+
22
+ def self.pinterest_link(url, options)
23
+ base = "http://pinterest.com/pin/create/button/"
24
+ params = { url: url }
25
+ options.has_key?(:media) && params[:media] = options[:media]
26
+ options.has_key?(:title) && params[:description] = options[:title]
27
+ create_url base, params
28
+ end
29
+
30
+ def self.twitter_link(url, options={})
31
+ base = "http://twitter.com/intent/tweet"
32
+ params = { url: url }
33
+ options.has_key?(:title) && params[:text] = options[:title]
34
+ options.has_key?(:source) && params[:via] = options[:source]
35
+ create_url base, params
36
+ end
37
+
38
+ def self.tumblr_link(url, options={})
39
+ base = "http://www.tumblr.com/share/link"
40
+ params = { url: url }
41
+ options.has_key?(:title) && params[:name] = options[:title]
42
+ options.has_key?(:description) && params[:description] = options[:description]
43
+ create_url base, params
44
+ end
45
+
46
+ def self.googleplus_link(url, options={})
47
+ base = "https://plus.google.com/share"
48
+ params = { url: url }
49
+ options.has_key?(:title) && params[:t] = options[:title]
50
+ create_url base, params
51
+ end
52
+
53
+ def self.mailto_link(url, options={})
54
+ base = "mailto:"
55
+ params = {
56
+ subject: 'Shared',
57
+ body: url
58
+ }
59
+ options.has_key?(:title) && params[:subject] = options[:title]
60
+ options.has_key?(:source) && params[:subject] += " via #{options[:source]}"
61
+ create_url base, params
62
+ end
63
+
64
+ private
65
+
66
+ def self.create_url(base, params)
67
+ query_string = URI.encode_www_form(params)
68
+ "#{base}?#{query_string}"
69
+ end
70
+ end
@@ -0,0 +1,3 @@
1
+ module Unbutton
2
+ VERSION = "0.0.8"
3
+ end
data/unbutton.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'unbutton/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "unbutton"
8
+ gem.version = Unbutton::VERSION
9
+ gem.authors = ["Nitesh Goel"]
10
+ gem.email = ["nitesh@wallwisher.com"]
11
+ gem.description = %q{Unbutton provides a set of helper methods to share content on the web without crappy buttons}
12
+ gem.summary = %q{Generate facebook, twitter, linkedin, pinterest share links}
13
+ gem.homepage = "http://github.com/wallwisher/unbutton"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.required_ruby_version = '>= 1.9.0'
20
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: unbutton
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nitesh Goel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-16 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Unbutton provides a set of helper methods to share content on the web
15
+ without crappy buttons
16
+ email:
17
+ - nitesh@wallwisher.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - lib/unbutton.rb
28
+ - lib/unbutton/version.rb
29
+ - unbutton.gemspec
30
+ homepage: http://github.com/wallwisher/unbutton
31
+ licenses: []
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: 1.9.0
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubyforge_project:
50
+ rubygems_version: 1.8.24
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: Generate facebook, twitter, linkedin, pinterest share links
54
+ test_files: []