Skip to content
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

Add cache-busting string to comment moderation action #6444

Closed
5 tasks
jywarren opened this issue Oct 11, 2019 · 20 comments
Closed
5 tasks

Add cache-busting string to comment moderation action #6444

jywarren opened this issue Oct 11, 2019 · 20 comments
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute Ruby

Comments

@jywarren
Copy link
Member

jywarren commented Oct 11, 2019

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

We know that the process of creating a pull request is the biggest barrier for new contributors. This issue is for you 💝

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

🤔 What you will need to know.

Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.

📋 Step by Step

  • 🙋 Claim this issue: Comment below. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!

  • 📝 Update the file shown below as described

See this page for some help in taking your first steps!

When you moderate a comment, it redirects you back to where you were -- often the page upon which the comment was made. But, because of browser caching, you often still see the comment there. We need to introduce some random characters at the end of the URL in order to force the browser to actually refresh the page, and show it with the comment removed.

Here's an example of adding a timestamp to the end of a URL in order to break the cache:

redirect_to '/profile/' + @user.username + '?_=' + Time.now.to_i.to_s

See how where we currently do the redirect, we don't add such extra characters:

redirect_back(fallback_location: root_path)

According to this blog, in redirect_back, Rails uses request.env['HTTP_REFERER'] to go back where you were before. We're going to have to do this manually because we can't insert the cache-busting characters using redirect_back.

So it'd be like this:

back_url = request.env['HTTP_REFERER'] || root_path
redirect_to back_url + '?_=' + Time.now.to_i.to_s

We'd love help making this change! Just note that it may require a test change as well, but we can help you with that if any tests fail and modifications are needed. Thanks!

  • 💾 Commit your changes

  • 🔀 Start a Pull Request. There are two ways how you can start a pull request:

  1. If you are familiar with the terminal or would like to learn it, here is a great tutorial on how to send a pull request using the terminal.

  2. You can also edit files directly in your browser and open a pull request from there.

  • 🏁 Done Ask in comments for a review :)

Please keep us updated

💬⏰ - We encourage contributors to be respectful to the community and provide an update within a week of claiming a first-timers-only issue. We're happy to keep it assigned to you as long as you need if you update us with a request for more time or help, but if we don't see any activity a week after you claim it we may reassign it to give someone else a chance. Thank you in advance!

If this happens to you, don't sweat it! Grab another open issue.

Is someone else already working on this?

🔗- We encourage contributors to link to the original issue in their pull request so all users can easily see if someone's already started on it.

👥- If someone seems stuck, offer them some help! Otherwise, take a look at some other issues you can help with. Thanks!

🤔❓ Questions?

Leave a comment below!

@jywarren jywarren added help wanted requires help by anyone willing to contribute first-timers-only They need to be well-formatted using the First-timers_Issue_Template. Ruby labels Oct 11, 2019
@jywarren

This comment has been minimized.

@klaffert

This comment has been minimized.

@jywarren

This comment has been minimized.

@jywarren jywarren closed this as completed Nov 4, 2019
@jywarren jywarren reopened this Nov 4, 2019
@jywarren

This comment has been minimized.

@Ugtan

This comment has been minimized.

@SidharthBansal

This comment has been minimized.

@SidharthBansal
Copy link
Member

Published on GCI dashboard

@pianeta051
Copy link
Contributor

Is anyone working on this?
may i take this issue?

@jywarren
Copy link
Member Author

jywarren commented Dec 16, 2019 via email

@Srija616
Copy link
Contributor

@jywarren Can I work on this issue as an Outreachy applicant?

@Alexjake660
Copy link
Contributor

@SidharthBansal Can I work on this as my first issue?

@jywarren
Copy link
Member Author

Hi, i'm sorry, but @Alexjake660 or @Srija616 yes please go ahead! We definitely would like help with this.

@Alexjake660
Copy link
Contributor

@jywarren thanks

@jaibhavaya
Copy link

What is the status of this? I'd like to work on it if no one else is. :)

@Alexjake660
Copy link
Contributor

I am working on this.

@Alexjake660
Copy link
Contributor

@SidharthBansal this has already been done.

@jywarren
Copy link
Member Author

Hi all! I believe this is still available -- see how the line here is still as it was before?

redirect_back(fallback_location: root_path)

We can change it following the instructions at top; we'd love some help!

@mlwalters
Copy link

Working on this, thanks @avats-dev!

@mlwalters
Copy link

mlwalters commented Oct 13, 2020

Hello, @avats-dev and @jywarren!
I tried using Gitpod to try and fix this issue, however when I examined line 154 (it is on line 164 now), it doesn't say redirect_back(fallback_location: root_path) anymore, but instead was changed to redirect_to @comment.node.path + '?_=' + Time.now.to_i.to_s .
I admittedly can not tell if this is a good alternative to the request.env['HTTP_REFERER'] because I have no knowledge of Ruby (I know JavaScript), should I change line 164 still (to back_url = request.env['HTTP_REFERER'] || root_path redirect_to back_url + '?_=' + Time.now.to_i.to_s)?

@jywarren
Copy link
Member Author

jywarren commented Dec 1, 2020

Hi, @carrimaxx - i'm so sorry for the slow reply; i believe that means this was already completed, and I'm sorry about that. If you're still interested in taking on a first-timers-only issue, there is now one at #8789 which you're welcome to claim! My apologies and thank you for your help!

@jywarren jywarren closed this as completed Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template. help wanted requires help by anyone willing to contribute Ruby
Projects
None yet
Development

No branches or pull requests

10 participants