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

Move comment_render_body helper into Comment model #3552

Closed
jywarren opened this issue Oct 1, 2018 · 4 comments · Fixed by #3555
Closed

Move comment_render_body helper into Comment model #3552

jywarren opened this issue Oct 1, 2018 · 4 comments · Fixed by #3555
Labels
fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute refactorization Ruby

Comments

@jywarren
Copy link
Member

jywarren commented Oct 1, 2018

This has been marked as a good candidate for becoming a first-timers-only issue like these, meaning that it's simple, self-contained, and with some extra formatting, could be a great entry point for a new contributor. If you're familiar enough with this code, please consider reformatting or reposting it as a first-timers-only issue, and then ping @publiclab/reviewers to get it labelled. Or, if this is not your first time, try to solve it yourself!


# we should move this to the Comment model:
# returns the comment body which is to be shown in the comments section
def render_comment_body(comment)
raw RDiscount.new(
title_suggestion(comment),
:autolink
).to_html
end

Let's make this a method of Comment - in https://github.com/publiclab/plots2/blob/master/app/models/comment.rb - like:

def render_body

end

And remove it from application_helper.rb!

We'll also need to change this line:

<% comment_body = render_comment_body(comment) %>

To comment.render_body

Finally, the sanitize comment body test in https://github.com/publiclab/plots2/blob/master/test/unit/comment_test.rb could be updated to test comment.render_body instead of reproducing the code from the helper.

Glad to help with this one! Could be a first-timers issue!

@jywarren jywarren added help wanted requires help by anyone willing to contribute Ruby fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet refactorization labels Oct 1, 2018
@mauricetmeyer
Copy link
Contributor

I would like to take on this issue, it would be one of my first open source contributions. Also is there anything I would need to know before opening a pull request, like a special schema for commit messages?

@jywarren
Copy link
Member Author

jywarren commented Oct 1, 2018

Nope, there's a template in the pull request form, but it's always editable later, so we can help you out as you go! Welcome! 👍 🎉

@mauricetmeyer
Copy link
Contributor

@jywarren Thank you! Also those first timer issues are great to get to know the codebase, as I often don't have much time to read into large codebases. 👍

@jywarren
Copy link
Member Author

jywarren commented Oct 1, 2018 via email

jywarren pushed a commit that referenced this issue Oct 3, 2018
* Moved render_comment_body helper into Comment model. Addressing #3552

* Removed seconds empty new line

* Removed raw statement as it isn't needed/available from Comment
SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this issue May 5, 2019
* Moved render_comment_body helper into Comment model. Addressing publiclab#3552

* Removed seconds empty new line

* Removed raw statement as it isn't needed/available from Comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fto-candidate issues which are meant to be solved by first timers but aren't well-formatted yet help wanted requires help by anyone willing to contribute refactorization Ruby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants