Ruby on Rails - Social Share Button Gem; Modifying what is filled automatically












0















Question: How can I use the social share button gem to auto filled certain social media text areas I want?



Since there isn't much documentation regarding the social share button gem (https://github.com/huacnlee/social-share-button), I would like some help in trying to create some custom, auto-filled entries when users click each button, namely for FaceBook and Reddit.



Basically, when I have an item displayed, I want a user to click the appropriate social media button to say something like, "I just bought this item from this website".



This is the code I have:



<%= social_share_button_tag('I have bought, '+ @item.name + ' , from The Store: ', :allow_sites => %w(twitter)) %>


This code works perfectly for twitter. As it says:



I have bought, Book, from The Store: http://localhost:3000/items/57#


That was simple enough, but trying to have autofilled areas for Reddit or Facebook is just not working.



This is the FB code I've got:



<%= social_share_button_tag('Share to Facebook', :url => item_path(@item), desc:  @donate_item.name, :allow_sites => %w(facebook)) %>


And what this code does is puts the url and the title of the item in the link, as shown:



FB Image



I want to have an auto filled text in the "Say something about this", and I am not sure what to do.



Regarding the Reddit shareable link, I've got this:



<%= social_share_button_tag(@item.name, :allow_sites => %w(reddit)) %>


And it produces:



RedditImage



Similar to the FB sharing, I want to be able to automatically fill in the "title" area. I have modified the code such as:



<%= social_share_button_tag(@item.name, title: "This item is great!", :allow_sites => %w(reddit)) %>


And it doesn't work.



Any help would be great, as I just don't know what to look for in the actual source.










share|improve this question























  • Haven't used the library so can't provide too much guidance but it looks like this is where the social_share_button_tag helper is defined: github.com/huacnlee/social-share-button/blob/master/lib/…

    – Mic Fok
    Nov 23 '18 at 6:48
















0















Question: How can I use the social share button gem to auto filled certain social media text areas I want?



Since there isn't much documentation regarding the social share button gem (https://github.com/huacnlee/social-share-button), I would like some help in trying to create some custom, auto-filled entries when users click each button, namely for FaceBook and Reddit.



Basically, when I have an item displayed, I want a user to click the appropriate social media button to say something like, "I just bought this item from this website".



This is the code I have:



<%= social_share_button_tag('I have bought, '+ @item.name + ' , from The Store: ', :allow_sites => %w(twitter)) %>


This code works perfectly for twitter. As it says:



I have bought, Book, from The Store: http://localhost:3000/items/57#


That was simple enough, but trying to have autofilled areas for Reddit or Facebook is just not working.



This is the FB code I've got:



<%= social_share_button_tag('Share to Facebook', :url => item_path(@item), desc:  @donate_item.name, :allow_sites => %w(facebook)) %>


And what this code does is puts the url and the title of the item in the link, as shown:



FB Image



I want to have an auto filled text in the "Say something about this", and I am not sure what to do.



Regarding the Reddit shareable link, I've got this:



<%= social_share_button_tag(@item.name, :allow_sites => %w(reddit)) %>


And it produces:



RedditImage



Similar to the FB sharing, I want to be able to automatically fill in the "title" area. I have modified the code such as:



<%= social_share_button_tag(@item.name, title: "This item is great!", :allow_sites => %w(reddit)) %>


And it doesn't work.



Any help would be great, as I just don't know what to look for in the actual source.










share|improve this question























  • Haven't used the library so can't provide too much guidance but it looks like this is where the social_share_button_tag helper is defined: github.com/huacnlee/social-share-button/blob/master/lib/…

    – Mic Fok
    Nov 23 '18 at 6:48














0












0








0








Question: How can I use the social share button gem to auto filled certain social media text areas I want?



Since there isn't much documentation regarding the social share button gem (https://github.com/huacnlee/social-share-button), I would like some help in trying to create some custom, auto-filled entries when users click each button, namely for FaceBook and Reddit.



Basically, when I have an item displayed, I want a user to click the appropriate social media button to say something like, "I just bought this item from this website".



This is the code I have:



<%= social_share_button_tag('I have bought, '+ @item.name + ' , from The Store: ', :allow_sites => %w(twitter)) %>


This code works perfectly for twitter. As it says:



I have bought, Book, from The Store: http://localhost:3000/items/57#


That was simple enough, but trying to have autofilled areas for Reddit or Facebook is just not working.



This is the FB code I've got:



<%= social_share_button_tag('Share to Facebook', :url => item_path(@item), desc:  @donate_item.name, :allow_sites => %w(facebook)) %>


And what this code does is puts the url and the title of the item in the link, as shown:



FB Image



I want to have an auto filled text in the "Say something about this", and I am not sure what to do.



Regarding the Reddit shareable link, I've got this:



<%= social_share_button_tag(@item.name, :allow_sites => %w(reddit)) %>


And it produces:



RedditImage



Similar to the FB sharing, I want to be able to automatically fill in the "title" area. I have modified the code such as:



<%= social_share_button_tag(@item.name, title: "This item is great!", :allow_sites => %w(reddit)) %>


And it doesn't work.



Any help would be great, as I just don't know what to look for in the actual source.










share|improve this question














Question: How can I use the social share button gem to auto filled certain social media text areas I want?



Since there isn't much documentation regarding the social share button gem (https://github.com/huacnlee/social-share-button), I would like some help in trying to create some custom, auto-filled entries when users click each button, namely for FaceBook and Reddit.



Basically, when I have an item displayed, I want a user to click the appropriate social media button to say something like, "I just bought this item from this website".



This is the code I have:



<%= social_share_button_tag('I have bought, '+ @item.name + ' , from The Store: ', :allow_sites => %w(twitter)) %>


This code works perfectly for twitter. As it says:



I have bought, Book, from The Store: http://localhost:3000/items/57#


That was simple enough, but trying to have autofilled areas for Reddit or Facebook is just not working.



This is the FB code I've got:



<%= social_share_button_tag('Share to Facebook', :url => item_path(@item), desc:  @donate_item.name, :allow_sites => %w(facebook)) %>


And what this code does is puts the url and the title of the item in the link, as shown:



FB Image



I want to have an auto filled text in the "Say something about this", and I am not sure what to do.



Regarding the Reddit shareable link, I've got this:



<%= social_share_button_tag(@item.name, :allow_sites => %w(reddit)) %>


And it produces:



RedditImage



Similar to the FB sharing, I want to be able to automatically fill in the "title" area. I have modified the code such as:



<%= social_share_button_tag(@item.name, title: "This item is great!", :allow_sites => %w(reddit)) %>


And it doesn't work.



Any help would be great, as I just don't know what to look for in the actual source.







ruby-on-rails ruby






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 6:10









JamesWuJamesWu

77112




77112













  • Haven't used the library so can't provide too much guidance but it looks like this is where the social_share_button_tag helper is defined: github.com/huacnlee/social-share-button/blob/master/lib/…

    – Mic Fok
    Nov 23 '18 at 6:48



















  • Haven't used the library so can't provide too much guidance but it looks like this is where the social_share_button_tag helper is defined: github.com/huacnlee/social-share-button/blob/master/lib/…

    – Mic Fok
    Nov 23 '18 at 6:48

















Haven't used the library so can't provide too much guidance but it looks like this is where the social_share_button_tag helper is defined: github.com/huacnlee/social-share-button/blob/master/lib/…

– Mic Fok
Nov 23 '18 at 6:48





Haven't used the library so can't provide too much guidance but it looks like this is where the social_share_button_tag helper is defined: github.com/huacnlee/social-share-button/blob/master/lib/…

– Mic Fok
Nov 23 '18 at 6:48












1 Answer
1






active

oldest

votes


















-1














Checking the gem itself, I don't think it supports passing titles through to Reddit.



If we look at where social_share_button_tag comes from: https://github.com/huacnlee/social-share-button/blob/master/lib/social_share_button/helper.rb, we can see that it calls SocialShareButton.share(this); on click.



In https://github.com/huacnlee/social-share-button/blob/6d329c9fadddd159e2b78310f8220f7e56a8d701/app/assets/javascripts/social-share-button.coffee, we can then see the actual URL it generates for each different social media platform and when we look for Reddit, we see:



# line 95
when "reddit"
SocialShareButton.openUrl("http://www.reddit.com/submit?url=#{url}&newwindow=1", 555, 400)


You'll notice the url param is present but title is not (compared to the other urls where the title IS passed through.



At the same time, looking at Reddit's API: https://github.com/reddit-archive/reddit/wiki/API:-submit submitting a pull request for the gem to support the title params doesn't look like it'd be too much work and might be your best bet.






share|improve this answer





















  • 1





    This should be a comment, not an answer. Downvoted.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:42











  • @AlekseiMatiushkin Oh my bad, changed to a comment. Should I delete my answer?

    – Mic Fok
    Nov 23 '18 at 6:49











  • Well, it’s up to you, but it sorta violates the guidelines on How To Answer here since it does not indeed contains the answer.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:56













  • @MichaelFok you should. Unless you dig into the helper yourself and you'll provide code that will do what has been asked, stick to making a comment.

    – Marcin Kołodziej
    Nov 23 '18 at 7:01











  • Thanks @MarcinKołodziej, I'll go ahead and delete it then

    – Mic Fok
    Nov 23 '18 at 7:08











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441428%2fruby-on-rails-social-share-button-gem-modifying-what-is-filled-automatically%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









-1














Checking the gem itself, I don't think it supports passing titles through to Reddit.



If we look at where social_share_button_tag comes from: https://github.com/huacnlee/social-share-button/blob/master/lib/social_share_button/helper.rb, we can see that it calls SocialShareButton.share(this); on click.



In https://github.com/huacnlee/social-share-button/blob/6d329c9fadddd159e2b78310f8220f7e56a8d701/app/assets/javascripts/social-share-button.coffee, we can then see the actual URL it generates for each different social media platform and when we look for Reddit, we see:



# line 95
when "reddit"
SocialShareButton.openUrl("http://www.reddit.com/submit?url=#{url}&newwindow=1", 555, 400)


You'll notice the url param is present but title is not (compared to the other urls where the title IS passed through.



At the same time, looking at Reddit's API: https://github.com/reddit-archive/reddit/wiki/API:-submit submitting a pull request for the gem to support the title params doesn't look like it'd be too much work and might be your best bet.






share|improve this answer





















  • 1





    This should be a comment, not an answer. Downvoted.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:42











  • @AlekseiMatiushkin Oh my bad, changed to a comment. Should I delete my answer?

    – Mic Fok
    Nov 23 '18 at 6:49











  • Well, it’s up to you, but it sorta violates the guidelines on How To Answer here since it does not indeed contains the answer.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:56













  • @MichaelFok you should. Unless you dig into the helper yourself and you'll provide code that will do what has been asked, stick to making a comment.

    – Marcin Kołodziej
    Nov 23 '18 at 7:01











  • Thanks @MarcinKołodziej, I'll go ahead and delete it then

    – Mic Fok
    Nov 23 '18 at 7:08
















-1














Checking the gem itself, I don't think it supports passing titles through to Reddit.



If we look at where social_share_button_tag comes from: https://github.com/huacnlee/social-share-button/blob/master/lib/social_share_button/helper.rb, we can see that it calls SocialShareButton.share(this); on click.



In https://github.com/huacnlee/social-share-button/blob/6d329c9fadddd159e2b78310f8220f7e56a8d701/app/assets/javascripts/social-share-button.coffee, we can then see the actual URL it generates for each different social media platform and when we look for Reddit, we see:



# line 95
when "reddit"
SocialShareButton.openUrl("http://www.reddit.com/submit?url=#{url}&newwindow=1", 555, 400)


You'll notice the url param is present but title is not (compared to the other urls where the title IS passed through.



At the same time, looking at Reddit's API: https://github.com/reddit-archive/reddit/wiki/API:-submit submitting a pull request for the gem to support the title params doesn't look like it'd be too much work and might be your best bet.






share|improve this answer





















  • 1





    This should be a comment, not an answer. Downvoted.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:42











  • @AlekseiMatiushkin Oh my bad, changed to a comment. Should I delete my answer?

    – Mic Fok
    Nov 23 '18 at 6:49











  • Well, it’s up to you, but it sorta violates the guidelines on How To Answer here since it does not indeed contains the answer.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:56













  • @MichaelFok you should. Unless you dig into the helper yourself and you'll provide code that will do what has been asked, stick to making a comment.

    – Marcin Kołodziej
    Nov 23 '18 at 7:01











  • Thanks @MarcinKołodziej, I'll go ahead and delete it then

    – Mic Fok
    Nov 23 '18 at 7:08














-1












-1








-1







Checking the gem itself, I don't think it supports passing titles through to Reddit.



If we look at where social_share_button_tag comes from: https://github.com/huacnlee/social-share-button/blob/master/lib/social_share_button/helper.rb, we can see that it calls SocialShareButton.share(this); on click.



In https://github.com/huacnlee/social-share-button/blob/6d329c9fadddd159e2b78310f8220f7e56a8d701/app/assets/javascripts/social-share-button.coffee, we can then see the actual URL it generates for each different social media platform and when we look for Reddit, we see:



# line 95
when "reddit"
SocialShareButton.openUrl("http://www.reddit.com/submit?url=#{url}&newwindow=1", 555, 400)


You'll notice the url param is present but title is not (compared to the other urls where the title IS passed through.



At the same time, looking at Reddit's API: https://github.com/reddit-archive/reddit/wiki/API:-submit submitting a pull request for the gem to support the title params doesn't look like it'd be too much work and might be your best bet.






share|improve this answer















Checking the gem itself, I don't think it supports passing titles through to Reddit.



If we look at where social_share_button_tag comes from: https://github.com/huacnlee/social-share-button/blob/master/lib/social_share_button/helper.rb, we can see that it calls SocialShareButton.share(this); on click.



In https://github.com/huacnlee/social-share-button/blob/6d329c9fadddd159e2b78310f8220f7e56a8d701/app/assets/javascripts/social-share-button.coffee, we can then see the actual URL it generates for each different social media platform and when we look for Reddit, we see:



# line 95
when "reddit"
SocialShareButton.openUrl("http://www.reddit.com/submit?url=#{url}&newwindow=1", 555, 400)


You'll notice the url param is present but title is not (compared to the other urls where the title IS passed through.



At the same time, looking at Reddit's API: https://github.com/reddit-archive/reddit/wiki/API:-submit submitting a pull request for the gem to support the title params doesn't look like it'd be too much work and might be your best bet.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 7:45

























answered Nov 23 '18 at 6:41









Mic FokMic Fok

7781011




7781011








  • 1





    This should be a comment, not an answer. Downvoted.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:42











  • @AlekseiMatiushkin Oh my bad, changed to a comment. Should I delete my answer?

    – Mic Fok
    Nov 23 '18 at 6:49











  • Well, it’s up to you, but it sorta violates the guidelines on How To Answer here since it does not indeed contains the answer.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:56













  • @MichaelFok you should. Unless you dig into the helper yourself and you'll provide code that will do what has been asked, stick to making a comment.

    – Marcin Kołodziej
    Nov 23 '18 at 7:01











  • Thanks @MarcinKołodziej, I'll go ahead and delete it then

    – Mic Fok
    Nov 23 '18 at 7:08














  • 1





    This should be a comment, not an answer. Downvoted.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:42











  • @AlekseiMatiushkin Oh my bad, changed to a comment. Should I delete my answer?

    – Mic Fok
    Nov 23 '18 at 6:49











  • Well, it’s up to you, but it sorta violates the guidelines on How To Answer here since it does not indeed contains the answer.

    – Aleksei Matiushkin
    Nov 23 '18 at 6:56













  • @MichaelFok you should. Unless you dig into the helper yourself and you'll provide code that will do what has been asked, stick to making a comment.

    – Marcin Kołodziej
    Nov 23 '18 at 7:01











  • Thanks @MarcinKołodziej, I'll go ahead and delete it then

    – Mic Fok
    Nov 23 '18 at 7:08








1




1





This should be a comment, not an answer. Downvoted.

– Aleksei Matiushkin
Nov 23 '18 at 6:42





This should be a comment, not an answer. Downvoted.

– Aleksei Matiushkin
Nov 23 '18 at 6:42













@AlekseiMatiushkin Oh my bad, changed to a comment. Should I delete my answer?

– Mic Fok
Nov 23 '18 at 6:49





@AlekseiMatiushkin Oh my bad, changed to a comment. Should I delete my answer?

– Mic Fok
Nov 23 '18 at 6:49













Well, it’s up to you, but it sorta violates the guidelines on How To Answer here since it does not indeed contains the answer.

– Aleksei Matiushkin
Nov 23 '18 at 6:56







Well, it’s up to you, but it sorta violates the guidelines on How To Answer here since it does not indeed contains the answer.

– Aleksei Matiushkin
Nov 23 '18 at 6:56















@MichaelFok you should. Unless you dig into the helper yourself and you'll provide code that will do what has been asked, stick to making a comment.

– Marcin Kołodziej
Nov 23 '18 at 7:01





@MichaelFok you should. Unless you dig into the helper yourself and you'll provide code that will do what has been asked, stick to making a comment.

– Marcin Kołodziej
Nov 23 '18 at 7:01













Thanks @MarcinKołodziej, I'll go ahead and delete it then

– Mic Fok
Nov 23 '18 at 7:08





Thanks @MarcinKołodziej, I'll go ahead and delete it then

– Mic Fok
Nov 23 '18 at 7:08


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441428%2fruby-on-rails-social-share-button-gem-modifying-what-is-filled-automatically%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Futebolista

Feedback on college project

Albești (Vaslui)