This may seem like a simple question, but how do I implement basic social share buttons with Font Awesome in my Rails App.
I want to implement them on my PostsController#Show
.
I began looking into it, thinking it was as simple as just adding a link_to
- but quickly realized it isn't as simple as that.
For Twitter, you will want the title of the post to be included in the body of the tweet along with the URL. I imagine Facebook is similar.
Bonus points for anyone that can also give a tip for how to include WhatsApp sharing - per this: http://whatsapp-sharing.com/ - on each post also.
I had just finished up a small article on my site in response to your comment when i saw your reply.
Use the following HTML:
<!-- Twitter -->
<a href="http://twitter.com/home?status=SHAREMESSAGE" title="Share on Twitter" target="_blank" class="btn btn-twitter"><i class="fa fa-twitter"></i> Twitter</a>
<!-- Facebook -->
<a href="https://www.facebook.com/sharer/sharer.php?u=SHAREMESSAGE" title="Share on Facebook" target="_blank" class="btn btn-facebook"><i class="fa fa-facebook"></i> Facebook</a>
<!-- Google+ -->
<a href="https://plus.google.com/share?url=SHAREMESSAGE" title="Share on Google+" target="_blank" class="btn btn-googleplus"><i class="fa fa-google-plus"></i> Google+</a>
<!-- StumbleUpon -->
<a href="http://www.stumbleupon.com/submit?url=SHAREMESSAGE" title="Share on StumbleUpon" target="_blank" data-placement="top" class="btn btn-stumbleupon"><i class="fa fa-stumbleupon"></i> Stumbleupon</a>
<!-- LinkedIn -->
<a href="http://www.linkedin.com/shareArticle?mini=true&url=&title=&summary=SHAREMESSAGE" title="Share on LinkedIn" target="_blank" class="btn btn-linkedin"><i class="fa fa-linkedin"></i> LinkedIn</a>
Replace SHAREMESSAGE with your share message. For WhatsApp and IOS you can use this:
<a href="whatsapp://send?text=SHAREMESSAGE">Share on WhatsApp</a>
However I've read elsewhere on Stack Overflow that this doesn't work on Android. Good luck!
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments