![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Small sharing buttons helpers lib.
Note : Templates markup is written with
Twitter Bootstrap v3 in mind and the javascript for
the link_share_button
helper uses Bootsrap's collapse
plugin.
You can override the plugin's view markup for every helper and delete the
[data-link-button]
attribute for the link_share_button
helper to avoid
the associated javascript to run.
Add to your Gemfile and bundle install
:
gem 'share_buttons'
Use the included generator to generate the initializer file and the customizable views :
rails generate share_buttons:install
At last, include the javascript file in your application.js
with :
//= require share_buttons
For Facebook sharing, you need to set the FACEBOOK_APP_ID
environment variable
or add your Facebook App Id to the generated initializer configuration file at
config/initializers/share_buttons.rb
:
ShareButtons.configure do |config|
config.facebook.app_id = 'YOUR_APP_ID'
end
In your views, use any of the included helpers :
<%= facebook_share_button(resource_url(resource), title: resource.title) %>
<%= twitter_share_button(resource_url(resource), title: resource.title) %>
<%= google_plus_share_button(resource_url(resource), title: resource.title) %>
<%= pinterest_share_button(resource_url(resource), title: resource.title, image_url: resource.image.url) %>
<%= email_share_button(resource_url(resource), title: resource.title) %>
<%= link_share_button(resource_url(resource), title: resource.title) %>
And customize the generated views to your needs in app/views/share_buttons/_<provider>.html.haml
Note : Do not forget to use URL helpers and not Path helpers since the final URL is to be shared on other websites.
Facebook's redirect_uri
parameter will be set to request.original_url
by
default but you can pass a custom URL as follow
<%= facebook_share_button(resource_path(resource), title: resource.title, redirect_uri: a_custom_url) %>
Useful if you want to handle when user cancelled dialog (e.g. close popup) or successfully shared on his wall (e.g. track sharing hits)
Sometimes you need to manually initialize the javascript plugins, like when the buttons where added to the page after the actual page loading, in a modal or in some other way.
All you need to do, is find the newly loaded container, and initialize the
.shareButtons()
plugin on it. This way, all the contained share buttons will
be initialized.
// Let's imagine you're loading a modal through ajax
$.get('/lodal/modal').then(function(response) {
$response = $(response);
$response.appendTo('body').modal();
// Now that you have the jQuery object containing the share buttons,
// just initialize the plugin on it
$response.shareButtons();
})
This project rocks and uses MIT-LICENSE.
FAQs
Unknown package
We found that share_buttons demonstrated a not healthy version release cadence and project activity because the last version was released 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
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.