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 button to report answers spams to Comments upon Answers #2733

Closed
wants to merge 476 commits into from
Closed

Add button to report answers spams to Comments upon Answers #2733

wants to merge 476 commits into from

Conversation

Toiya
Copy link

@Toiya Toiya commented May 16, 2018

Fixes #2732

@PublicLabBot
Copy link

PublicLabBot commented May 16, 2018

1 Warning
⚠️ New migrations added. Please update schema.rb.example by overwriting it with a copy of the up-to-date db/schema.rb. Also, be aware to preserve the MySQL-specific conditions for full-text indices.
1 Message
📖 @Toiya Thank you for your pull request! I’m here to help with some tips and recommendations. Please take a look at the list provided and help us review and accept your contribution! And don’t be discouraged if you see errors – we’re here to help.

Generated by 🚫 Danger

<a rel="tooltip" title="Flag as spam" class="btn btn-sm btn-default btn-flag-spam-<%= comment.id %>" href="mailto:moderators@publiclab.org?subject=Reporting+spam+on+Public+Lab&body=Hi,+I+found+this+comment+that+looks+like+spam+or+needs+to+be+moderated:+https://publiclab.org/<%= comment.parent.path %>#c<%= comment.cid %>+by+https://publiclab.org/profile/<%= comment.author.username %>+Thanks!">
<i class="fa fa-flag"></i>
</a>
<p><% if answer_id == 0 && current_user && (current_user.role == "admin" || current_user.role == "moderator" || comment.uid == current_user.uid)%>
Copy link
Member

Choose a reason for hiding this comment

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

hi @Toiya , changes are looking great! Could you please attach a screenshot of the updated view? Thanks.

Copy link
Author

Choose a reason for hiding this comment

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

I'm a little unsure if this is what you want but here are three screenshots of the flag button created, if I understand correctly. As you can see in the third one with the email, the words are currently seperated by plus-signs, which I guess is not what we want. I could try to fix this with my semi-limited HTML-skills, if you want to :)

final-screenshot-flag-button

Copy link
Member

Choose a reason for hiding this comment

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

hi @Toiya, actually, these are the screenshot of the dashboard I guess and the flag is already implemented there. Changes from your code should appear in a question's comment. So, first you need to install plots2 and after that run localhost, and generate a question. After generating the question, generate test comments on that. And, with each of those comments, you should be able to see a flag button.

If you have not installed plots2 repo, then we can help you in installation. You can ask us anytime. Thanks.

Copy link
Author

Choose a reason for hiding this comment

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

Hello! Sorry for getting it wrong, and thank you for being so patient. I'm currently following the installation guide in the README, but I'm stuck on step 4. Do you want me to rename db/schema.rb.example to db/schema.rb? Since they are both files, I don't understand how I'm supposed to make a copy of a file and place it "at" another file. Again, thank you so much for your patience!

Copy link
Member

Choose a reason for hiding this comment

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

You should be able to delete the existing db/schema.rb and replace it with a copy of the example file. Sorry that wasn't as clear as it could be!

@grvsachdeva
Copy link
Member

grvsachdeva commented May 17, 2018 via email

@Toiya
Copy link
Author

Toiya commented May 23, 2018

Hi again, sorry for the delay! I've been trying to install plots2 but when I get to point 3: "Install gems with 'bundle install --without production mysql' ", I get an error when the installer gets to libv8. I've been looking around for a fix but I can't seem to find anything. Below is the full error message:

An error occurred while installing libv8 (3.16.14.19), and Bundler cannot
continue.
Make sure that gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/' succeeds before bundling.

In Gemfile:
therubyracer was resolved to 0.12.3, which depends on
libv8

and if I run gem install libv8 -v '3.16.14.19' --source 'https://rubygems.org/'
I get this:

ERROR: Error installing libv8:
ERROR: Failed to build gem native extension.

followed by a lot of lines where it seems to try and fix it, but then it ends up with

extconf failed, exit code 1

Sorry for my messy way of trying to explain the problem. I'm very grateful for any help I can get!

@grvsachdeva
Copy link
Member

@Toiya
Copy link
Author

Toiya commented May 24, 2018

Hi @Gauravano! Thank you for your quick response. After having tried all the relevant fixes (i.e. excluding the ones using homebrew since I'm on Windows) from the Stack Overflow thread, some of them similar to what I've already tried, nothing still seems to be working. I'll keep looking around and will give you an update if I find a solution

@grvsachdeva
Copy link
Member

Hmm, I guess @jywarren or @publiclab/reviewers could help us.

@jywarren
Copy link
Member

Hi, I think you should be able to comment out that gem in the Gemfile, and try again. I'm not sure why it's not working -- what operating system and version are you using? But that gem is for testing JavaScript and those tests usually aren't run locally anyways.

@Toiya
Copy link
Author

Toiya commented May 25, 2018

Hi! I'm using Windows 10 version 1709, which might be an issue since from what I understand after reading countless Stack Overflow threads, rails development in Windows can be quite problematic. I've previously used Bash on Ubuntu on Windows for this issue, but as all else has failed I retried the whole installation process with Git Shell (Windows Powershell), but the problem is still there. There is also no gem in Gemfile with either libv8 or v8, but that might just be me misunderstanding which gem to comment out. I tried commenting out therubyracer instead since that seems to be part of the problem, but Less requires that and if I then comment out Less (really trying everything now haha), it still doesn't work. I've checked for information on Windows support in the repo for libv8 here: rubyjs/libv8#217 and it's ironic because what they're suggesting is using Bash on Ubuntu on Windows. Again, thank you guys so much for all the patience and guidance and for being so welcoming to beginners like me! It is very, very appreciated :)

@grvsachdeva
Copy link
Member

@jywarren any hint about this issue with windows? Thank you so much for trying @Toiya! I can run your branch on my pc and add the screenshot here.

@grvsachdeva
Copy link
Member

hi @Toiya sorry for the delay, my exams are going on so can't run this. Running your code now. Also, I found an article on gorails about starting rails development on windows, see if it may help https://gorails.com/setup/windows/10 . Thanks.

@jywarren
Copy link
Member

Hi @Toiya -- thanks for sticking with this! I do think doing this on Windows may be a tough one... I think Bash on Ubuntu on Windows is probably a more promising way forward. But can you paste the output of the libv8 gem install into a gist in https://gist.github.com and paste the link here so we can read through that?

Some clues here: rubyjs/libv8#29

and something promising here: https://stackoverflow.com/questions/16514758/gem-install-libv8-version-3-11-8-17-on-ruby-windows

it recommends:

gem install libv8 -v '3.11.8.17' -- --with-system-v8

That may assume you have the v8 library installed though! But see the libv8 library link above to see about that.

This may also be an alternative: https://github.com/eakmotion/therubyracer_for_windows

I hope some of this helps! I don't have windows myself and I'm sorry it has been frusturating. The other thing is that if you want to just complete this PR we can take the screenshots for you. But we're hoping to help you get the system installed so that you can contribute more with us!

Thanks for your hard work and patience!!!

@Toiya
Copy link
Author

Toiya commented May 30, 2018

Hi!
I have finally seemingly gotten around to installing libv8 after following the tutorial from the link @Gauravano sent above, so I think the problem must have come from me doing a mistake when installing ruby. However, I've gotten through the installation process until step 8, and running "passenger start" gives me the following output:

C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/passenger-5.3.1/src/ruby_supportlib/phusion_passenger.rb:269:in `infer_install_spec': undefined method `dir' for nil:NilClass (NoMethodError)
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/passenger-5.3.1/src/ruby_supportlib/phusion_passenger.rb:102:in `locate_directories'
        from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/passenger-5.3.1/bin/passenger:36:in `<top (required)>'
        from C:/Ruby24-x64/bin/passenger:23:in `load'
        from C:/Ruby24-x64/bin/passenger:23:in `<main>'

and when trying to open localhost:3000 in browser it gives an "ERR_CONNECTION_REFUSED". Having viewed this: https://stackoverflow.com/questions/999532/passenger-on-windows, I'm thinking of just getting rid of Windows and get Ubuntu instead, which is something I have thought of for a while and would probably have done in the future anyways. For personal reasons, that will have to wait a few days tho, but I'll give you an update once that's done. Having seen how great you've been through all of this, I'd love to keep contributing in the future! Thank you so much :)

@grvsachdeva
Copy link
Member

hi @Toiya, thanks for trying so hard, could you try rails s instead of passenger start and let us know the output. Thanks.

@Toiya
Copy link
Author

Toiya commented May 30, 2018

Thank you, that seemed to do something at least! 💯 The output is extremely long, do you want me to send it anyway? Otherwise, localhost now shows this:
localhost-plots2
EDIT: Sorry, just saw in an old issue that this is connected to bower install, so it seems that there's a small issue there for me right now. Will try to fix and get back to you

@Toiya
Copy link
Author

Toiya commented May 31, 2018

Up and running! 🙌 Here are some screenshots, if there are any missing that you would like, just say the word! 😄

screenshot-all-final

@grvsachdeva
Copy link
Member

Awesome @Toiya ! Thanks for going from all troubles. Reviewing your PR. Thanks.

<a rel="tooltip" title="Flag as spam" class="btn btn-sm btn-default btn-flag-spam-<%= comment.id %>" href="mailto:moderators@publiclab.org?subject=Reporting+spam+on+Public+Lab&body=Hi,+I+found+this+comment+that+looks+like+spam+or+needs+to+be+moderated:+https://publiclab.org/<%= comment.parent.path %>#c<%= comment.cid %>+by+https://publiclab.org/profile/<%= comment.author.username %>+Thanks!">
<i class="fa fa-flag"></i>
</a>
<p><% if answer_id == 0 && current_user && (current_user.role == "admin" || current_user.role == "moderator" || comment.uid == current_user.uid)%>
Copy link
Member

Choose a reason for hiding this comment

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

Code seems fine ..

Copy link
Member

Choose a reason for hiding this comment

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

Do you think we can do some changes to make view cleaner by aligning all three buttons in a line? Actually, the delete button is visible to you because you are currently logged in as 'moderator' from localhost. And, I think as moderator already has the power to delete the comment, so flag option is not needed for moderator and admin. So, here's what you can do -

  1. Add if statement so that button will appear only if the current user is not admin or moderator. The if statement would look something like this- !current_user || current_user.role != "admin" && current_user.role != "moderator"

  2. Paste the screenshot logging in as user and moderator, and view without logging in.

Thanks!

@jywarren
Copy link
Member

jywarren commented May 31, 2018 via email

@grvsachdeva
Copy link
Member

Hi @Toiya , this PR is very close to completion, do you want any help with this ? Thanks.

@jywarren
Copy link
Member

Hi, just checking if you've gotten stuck on this at all, or if I could help in any way? Thanks!

@grvsachdeva grvsachdeva mentioned this pull request Jul 9, 2018
5 tasks
derek-allen and others added 7 commits August 1, 2018 18:29
* #3143 added related tags to tag page

* #3143 distinguished power tags, added link to tags in related tags

* #3143 inline related tags label
* Notifications field added in users

* Rails migration rollback and new migration added

* Migrations corrected

* Added documentation

* Two migrations merged into one
* improve UI of digest email

* minor changes

* added links to settings and subscriptions
jywarren and others added 25 commits November 6, 2018 17:14
* move emoji.js from public/lib/ to public/

* update path to emoji.js
…3855)

* fix erro #3831 by junhouse

* add junhouse fix 2 for error 3831

* fix 3 junhouse

* add fix 4

* fix 5 with config update
* Bump rubocop from 0.52.1 to 0.60.0

Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.52.1 to 0.60.0.
- [Release notes](https://github.com/rubocop-hq/rubocop/releases)
- [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md)
- [Commits](rubocop/rubocop@v0.52.1...v0.60.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Update .rubocop.yml
+<em class="italics"><a href="/tags">Tags</a> organize our knowledge base. Click to learn more or subscribe to a topic.</em>
* Handle case in which node doesn't exist

* Remove check for node.body

* Fix SQL injection in the Node.exists
)

* Update en.yml

Moved only_author_use_powertag line from node to root en.yml file

* Update en.yml
* Added is_verified column to users with default value false

* added helper functions for generation and validation of tokens

* Delete 20181103114645_add_is_verified_to_users.rb

* Minor code fixes

* Added tests for implemented helper functions

* Added failing tests for helper functions

* Added test to make sure that a token is not validated 24 hours after gen

* Code quality changes
* Update _advanced_tagging.html.erb

* Update tagging.js

* Update show.html.erb

* Update show.html.erb

* Update tagging.js
* Split create function into two login paths

* Ensure preservation of return_to through OAuth login flow (#3884)
@grvsachdeva
Copy link
Member

Hi everyone, as we don't render question's comment from questions/_comment and use notes/_comment instead so I am going to close this PR now. Although, I would like to thank 🥇 💯 @Toiya for the work done and I hope that it was learning experience for her too. Thank you!

@ghost ghost removed the ready label Nov 12, 2018
@grvsachdeva
Copy link
Member

Also, your branch got little disrupted by me during rebase sorry for that, but you can clean it, by running these commands
git reset --hard a7e94fdc5b4d56e14b37c8d5871d50341455158e
git cherry-pick a50aca6

Running the above commands will clean up the branch. Also, if you are interested, you can raise the same fix against this file notes/_comment . Thanks!

@jywarren
Copy link
Member

Thank you @Toiya and @gauravano for your work on this. It's much appreciated!!!

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.