plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

Add cache-busting string to comment moderation action

Open jywarren opened this issue 7 years ago • 20 comments

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:

https://github.com/publiclab/plots2/blob/a0861eb62c70e819f7b4804a5608c8e7d13c6530/app/controllers/admin_controller.rb#L32

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

https://github.com/publiclab/plots2/blob/a0861eb62c70e819f7b4804a5608c8e7d13c6530/app/controllers/admin_controller.rb#L154

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 avatar Oct 11 '19 13:10 jywarren

This is for @vishakhanihore ! Than you!

jywarren avatar Oct 11 '19 13:10 jywarren

@jywarren Is this being worked on? Thanks!

klaffert avatar Nov 01 '19 22:11 klaffert

It doesn't look like it - we'd love your help! Thanks!

jywarren avatar Nov 04 '19 20:11 jywarren

Oops, closed by accident! 😄

jywarren avatar Nov 04 '19 20:11 jywarren

Looks like @klaffert already submitted a PR for a FTO issues. So, can I work on the issue? Thanks @jywarren

Ugtan avatar Nov 06 '19 20:11 Ugtan

Hello, you have already done a First timer issue. So, you can help us with other issues. Thanks for your help!

SidharthBansal avatar Nov 22 '19 19:11 SidharthBansal

Published on GCI dashboard

SidharthBansal avatar Nov 22 '19 19:11 SidharthBansal

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

pianeta051 avatar Dec 15 '19 19:12 pianeta051

We'd love help with it if nobody is actively working on it! Thanks!

On Sun, Dec 15, 2019 at 2:55 PM Carlos P [email protected] wrote:

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/6444?email_source=notifications&email_token=AAAF6J4OW7ZL7BGHZZE3J4TQY2DR7A5CNFSM4I72AXAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG5AZRQ#issuecomment-565841094, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF6J3D7A7N2WKXB2NGEJTQY2DR7ANCNFSM4I72AXAA .

jywarren avatar Dec 16 '19 16:12 jywarren

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

Srija616 avatar Mar 12 '20 11:03 Srija616

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

Alexjake660 avatar Mar 14 '20 17:03 Alexjake660

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

jywarren avatar Apr 28 '20 19:04 jywarren

@jywarren thanks

Alexjake660 avatar Apr 28 '20 20:04 Alexjake660

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

jaibhavaya avatar May 15 '20 02:05 jaibhavaya

I am working on this.

Alexjake660 avatar May 15 '20 08:05 Alexjake660

@SidharthBansal this has already been done.

Alexjake660 avatar May 15 '20 09:05 Alexjake660

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

https://github.com/publiclab/plots2/blob/a0861eb62c70e819f7b4804a5608c8e7d13c6530/app/controllers/admin_controller.rb#L154

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

jywarren avatar Sep 29 '20 14:09 jywarren

Working on this, thanks @avats-dev!

mlwalters avatar Oct 10 '20 14:10 mlwalters

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)?

mlwalters avatar Oct 13 '20 17:10 mlwalters

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 avatar Dec 01 '20 17:12 jywarren