Skip to content

Facebook share button working #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

grvsachdeva
Copy link

@grvsachdeva grvsachdeva commented Oct 21, 2017

Resolves issue #112

  • I have used social-share-button gem only to get the facebook share functionality to work by changing some syntax. I have added URL and desc attributes.
    Example of the run at localhost

shareexp

@leesharma please have a look and suggest if any improvements required. Thank You.

Copy link
Collaborator

@leesharma leesharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gauravano Thanks for the PR! 🎉

This looks pretty good (especially that html fix–thanks for that!) I've got two requests before merging:

  1. It looks like you're using RubyMine/IntelliJ and checked in the config files by accident (the .idea directory). Could you please remove those from the commit? Feel free to add .idea to .gitignore if it helps.

  2. It looks like you've hard-coded the staging URL. We'll want this functionality to work locally, on staging, and (especially) in production, and all of those use different URLs. Is there a way to make that work without specifying a URL? If not, could we use environment variables?

Thanks again for the PR, and let me know if you have any questions about the review comments!

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the RubyMine files (.idea/*) from your PR? If it'd be helpful to add .idea to .gitignore, feel free to do that!

@@ -1,6 +1,6 @@
<div class="container">
<div class="header">
<h2>Create a New Wishlist</h1>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! 👍

@@ -1,7 +1,7 @@
<div class="container">
<h2>
<%= @wishlist.name %>
<%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!") %>
<%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!",:url => "https://project-playtime-staging.herokuapp.com/wishlists/#{@wishlist.id}",desc: "Are you a hero of play? #{@wishlist.name} needs your help!") %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This URL changes. Is there a way to do this without a url attribute? If not, can we get this using environment variables?

Copy link
Collaborator

@leesharma leesharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update! This is closer, but there are still some issues (details in comments):

  • It looks like this changes the ruby version to 2.3.3; we don't want to do that.
  • This still hard-codes URLs. Maybe the #wishlist_url helper would work here?
  • I also noted some style issues, but they should be easy fixes.

Again, thanks, and let me know if you have any questions!

<% url_share = "https://project-playtime-staging.herokuapp.com/wishlists/#{@wishlist.id}" %>
<% end %>

<%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!",:url => url_share,desc: "Are you a hero of play? #{@wishlist.name} needs your help!") %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some style nitpicks:

  • You're using two different hash formats here (:url => ... and desc: ...); let's stick to the second one (key: value).
  • For readability, either add spaces after the commas or break this up into multiple lines.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will take care of it

Gemfile.lock Outdated
@@ -305,7 +305,7 @@ DEPENDENCIES
webmock (~> 3.0)

RUBY VERSION
ruby 2.4.1p111
ruby 2.3.3p222
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to change our ruby version.

<% url_share = "https://project-playtime-staging.herokuapp.com/wishlists/#{@wishlist.id}" %>
<% else %>
<% url_share = "https://project-playtime-staging.herokuapp.com/wishlists/#{@wishlist.id}" %>
<% end %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still hard-codes URLs; we want this to work anywhere it's hosted.

Actually, looking at it, the url helpers would probably work: wishlist_url(@wishlist). Would that be an easier solution?

Copy link
Author

@grvsachdeva grvsachdeva Oct 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making helper is beneficial if wishlist_url has to be used at many placed otherwise I can optimise this URL generally too

@micahbales micahbales temporarily deployed to project-playtime-stagin-pr-152 November 6, 2017 02:48 Inactive
Copy link
Collaborator

@leesharma leesharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good! One last change request: rails actually has built-in _url helpers; could you remove the custom helper method? (more details in comments)

After that's done, I think this is ready to merge. 😄

@@ -11,6 +11,10 @@ def display_date(date)
date.to_formatted_s(:long_ordinal)
end

def wishlist_url(wishlist)
request.base_url+"/wishlists/#{wishlist.id}"
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually built into Rails, so you can remove this method. As an added bonus, the pre-included method will match your app configuration without extra work (ex. with subdomains, ports, friendly urls/slugs, etc.)

Here's a section of the official Rails Guides talking about _path and _url helpers.

<%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!",:url => url_share,desc: "Are you a hero of play? #{@wishlist.name} needs your help!") %>
<%= social_share_button_tag("Are you a hero of play? #{@wishlist.name} needs your help!",
url: wishlist_url(@wishlist),
desc: "Are you a hero of play? #{@wishlist.name} needs your help!") %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍 I like how you broke this up into multiple lines. Much easier to read!

Gemfile.lock Outdated
@@ -305,7 +305,7 @@ DEPENDENCIES
webmock (~> 3.0)

RUBY VERSION
ruby 2.3.3p222
ruby 2.4.1p111
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@micahbales micahbales temporarily deployed to project-playtime-stagin-pr-152 November 21, 2017 03:33 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants