Giter VIP home page Giter VIP logo

social-url's Introduction

✨ social-url

A simple gem to generate social media sharing URLs.

Build Status Gem Version Maintainability Test Coverage

Supported networks: Google+, Facebook, Pinterest, Twitter and mailto:.

Introduction

This gem was created to help you create social media sharing URLs. Create a message once and make it sharable on multiple networks with each their own specific parameters.

Use this to create fast sharing links as opposed to performance-heavy third-party sharing widgets.

Read more about Responsible Social Share Links (by @jonsuh).

Usage

Setup a new message to share on social networks using the Message class:

message = SocialUrl::Message.new({
  text: 'Hello World',
  url: 'http://example.com',
  hashtags: %w(nature sunset)
})

Use the message's network methods to get the sharing URLs:

  • facebook_url
  • google_url
  • mailto_url
  • pinterest_url
  • twitter_url
message.twitter_url #=> 'https://twitter.com/intent/tweet/?text=Hello%20World&url=http%3A%2F%2Fexample.com&hashtags=nature,sunset'
message.facebook_url #=> 'https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fexample.com'
...

Parameters

This gem translates the options passed to the SocialUrl::Message into the correct parameters for each network. Supported options are:

Network Supported parameters
Facebook url (String)
Google url (String)
mailto url (String)
text (String)
Pinterest url (String)
text (String)
media (String)
Twitter url (String)
text (String)
hashtags (Array of Strings)
via (String)
related (Array of Strings)

Utilities

The SocialUrl class provides normalization functionality for URL parameters and exposes the available networks:

SocialUrl.networks #=> [:facebook, :google, :twitter, ...]

SocialUrl.normalize_string('Hello World') #=> 'Hello%20World'
SocialUrl.normalize_array(%w(nature sunset)) #=> 'nature,sunset'
SocialUrl.normalize_array(['twitter:Twitter News', 'twitterapi:Twitter API News']) #=> 'twitter%3ATwitter%20News,twitterapi%3ATwitter%20API%20News'

Installation

This library is test with the following Rubies: 2.3.8, 2.4.5, 2.5.3.

Add this line to your application's Gemfile:

gem 'social-url'

And then execute:

$ bundle

Or install it yourself as:

$ gem install social-url

Contributing

I'm happy to accept any pull requests for new networks. Adding a new network is relatively easy. Say you'd want to add mynetwork support:

  1. Create lib/social_url/networks/mynetwork.rb and test/lib/social_url/networks/mynetwork_test.rb
  2. Add tests and implementation (take a look at the current networks)

License

This library is released under the MIT License.

social-url's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar richardvenneman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

social-url's Issues

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "formatador":
  In Gemfile:
    guard (>= 2.14, <= 2.15.0) was resolved to 2.15.0, which depends on
      formatador (>= 0.2.4)

Could not find gem 'formatador (>= 0.2.4)', which is required by gem 'guard (>= 2.14, <= 2.15.0)', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Dependabot can't resolve your Ruby dependency files

Dependabot can't resolve your Ruby dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Bundler::VersionConflict with message: Bundler could not find compatible versions for gem "formatador":
  In Gemfile:
    guard (~> 2.14) was resolved to 2.15.0, which depends on
      formatador (>= 0.2.4)

Could not find gem 'formatador (>= 0.2.4)', which is required by gem 'guard (~> 2.14)', in any of the sources.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.