Permalink
Browse files

Bumping version to 0.1

  • Loading branch information...
1 parent 1da27ac commit aabfa95cf26b5cbda3debd858f7fbbfb934fe3e5 Nitesh Goel committed Oct 16, 2012
Showing with 76 additions and 7 deletions.
  1. +5 −2 README.md
  2. +66 −1 lib/unbutton.rb
  3. +1 −1 lib/unbutton/version.rb
  4. +4 −3 unbutton.gemspec
View
@@ -1,6 +1,6 @@
# Unbutton
-TODO: Write a gem description
+Unbutton provides a set of helper methods to share content on the web without crappy buttons.
## Installation
@@ -18,7 +18,10 @@ Or install it yourself as:
## Usage
-TODO: Write usage instructions here
+ require 'unbutton'
+ 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' }
+
+Supported services are `facebook`, `twitter`, `pinterest`, `tumblr`, `googleplus`, and `linkedin`.
## Contributing
View
@@ -1,5 +1,70 @@
+require "uri"
require "unbutton/version"
module Unbutton
- # Your code goes here...
+ def self.facebook_link(url, options={})
+ base = "http://www.facebook.com/sharer.php"
+ params = params = { u: url }
+ options.has_key?(:title) && params[:t] = options[:title]
+ create_url base, params
+ end
+
+ def self.linkedin_link(url, options)
+ base = "http://www.linkedin.com/shareArticle"
+ params = params = { url: url, mini: true }
+ options.has_key?(:title) && params[:title] = options[:title]
+ options.has_key?(:description) && params[:summary] = options[:description]
+ options.has_key?(:source) && params[:source] = options[:source]
+
+ create_url base, params
+ end
+
+ def self.pinterest_link(url, options)
+ base = "http://pinterest.com/pin/create/button/"
+ params = { url: url }
+ options.has_key?(:media) && params[:media] = options[:media]
+ options.has_key?(:title) && params[:description] = options[:title]
+ create_url base, params
+ end
+
+ def self.twitter_link(url, options={})
+ base = "http://twitter.com/intent/tweet"
+ params = { url: url }
+ options.has_key?(:title) && params[:text] = options[:title]
+ options.has_key?(:source) && params[:via] = options[:source]
+ create_url base, params
+ end
+
+ def self.tumblr_link(url, options={})
+ base = "http://www.tumblr.com/share/link"
+ params = { url: url }
+ options.has_key?(:title) && params[:name] = options[:title]
+ options.has_key?(:description) && params[:description] = options[:description]
+ create_url base, params
+ end
+
+ def self.googleplus_link(url, options={})
+ base = "https://plus.google.com/share"
+ params = { url: url }
+ options.has_key?(:title) && params[:t] = options[:title]
+ create_url base, params
+ end
+
+ def self.mailto_link(url, options={})
+ base = "mailto:"
+ params = {
+ subject: 'Shared',
+ body: url
+ }
+ options.has_key?(:title) && params[:subject] = options[:title]
+ options.has_key?(:source) && params[:subject] += " via #{options[:source]}"
+ create_url base, params
+ end
+
+ private
+
+ def self.create_url(base, params)
+ query_string = URI.encode_www_form(params)
+ "#{base}?#{query_string}"
+ end
end
View
@@ -1,3 +1,3 @@
module Unbutton
- VERSION = "0.0.1"
+ VERSION = "0.1"
end
View
@@ -8,12 +8,13 @@ Gem::Specification.new do |gem|
gem.version = Unbutton::VERSION
gem.authors = ["Nitesh Goel"]
gem.email = ["nitesh@wallwisher.com"]
- gem.description = %q{TODO: Write a gem description}
- gem.summary = %q{TODO: Write a gem summary}
- gem.homepage = ""
+ gem.description = %q{Unbutton provides a set of helper methods to share content on the web without crappy buttons}
+ gem.summary = %q{Generate facebook, twitter, linkedin, pinterest share links}
+ gem.homepage = "http://github.com/wallwisher/unbutton"
gem.files = `git ls-files`.split($/)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]
+ gem.required_ruby_version = '>= 1.9.0'
end

0 comments on commit aabfa95

Please sign in to comment.