![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
SocialShareRails is a Ruby on Rails gem that simplifies the process of adding social sharing buttons to your Rails applications. It supports multiple social platforms, customizable styles, and an easy-to-use API for sharing.
Add this line to your application's Gemfile
:
gem 'social_share_rails'
Then, execute:
bundle install
You can require the CSS and JavaScript files directly in your application.js
and application.css
(or .scss
) files:
In app/assets/stylesheets/application.css
(or application.scss
):
@import "social_share_rails/social_share";
In app/assets/javascripts/application.js
:
//= require social_share_rails/social_share
If you're using Rails 7 with importmap
, pin the JavaScript in your config/importmap.rb
:
pin "social_share_rails", to: "social_share_rails/social_share.js"
And import it in your app/javascript/application.js
:
import "social_share_rails"
Add the social_share
helper to your views:
<%= social_share("Share this post", {
url: "https://example.com",
allow_sites: %w[twitter facebook linkedin],
rounded: true
}) %>
If no url is provided, the helper will automatically use the current page URL (window.location.href) as the fallback. For example:
<%= social_share("Share this post", {
allow_sites: %w[twitter facebook linkedin],
rounded: true
}) %>
In this case, the current page URL will be shared.
true
, uses rounded icon styles.Example with more options:
<%= social_share("Check out this article", {
url: "https://example.com/article",
desc: "This is an amazing article!",
allow_sites: %w[twitter facebook pinterest],
rounded: false
}) %>
SocialShareRails supports multiple languages using Rails' built-in I18n system. The gem provides default translations for the following keys:
en:
social_share_rails:
share_to: Share to %{name}
twitter: Twitter
facebook: Facebook
google_bookmark: Google Bookmark
pinterest: Pinterest
email: Email
linkedin: Linkedin
vkontakte: Vkontakte
reddit: Reddit
telegram: Telegram
whatsapp_app: WhatsApp
whatsapp_web: WhatsApp
To customize or add translations, create or modify the appropriate YAML file in your Rails application under config/locales
. For example, to add translations in Portuguese:
pt-BR:
social_share_rails:
share_to: Compartilhar no %{name}
twitter: Twitter
facebook: Facebook
google_bookmark: Favoritos do Google
pinterest: Pinterest
email: Email
linkedin: LinkedIn
vkontakte: VKontakte
reddit: Reddit
telegram: Telegram
whatsapp_app: WhatsApp (App)
whatsapp_web: WhatsApp (Web)
After adding your translations, Rails will automatically use them based on the current locale.
You can override the default styles provided by the gem. Add your own styles in app/assets/stylesheets/application.scss
:
.social-share .share-icon {
width: 30px;
height: 30px;
background-size: cover;
}
.social-share .share-twitter {
background-image: url('/path/to/your/custom-twitter-icon.svg');
}
To run the tests locally, use:
bundle exec rspec
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that social_share_rails demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.