SideComments Now integrates SideComments.js and the Drupal core commenting system, allowing users to add comments to content on a per-paragraph basis.

It differs from the other SideComments.js module in that it:

  • Is D7.
  • Uses the Drupal core commenting system.

I attempted to contact the maintainer of SideComments.js and received no response.

Project page

https://www.drupal.org/sandbox/melvix/2633590

git clone command

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/melvix/2633590.git sidecomments_now

Manual reviews of other projects

https://www.drupal.org/node/2575389#comment-10671462
https://www.drupal.org/node/2609480#comment-10667668
https://www.drupal.org/node/2267323#comment-10665026
https://www.drupal.org/node/2574753#comment-10806168
https://www.drupal.org/node/2652208#comment-10806778
https://www.drupal.org/node/2565825#comment-10806866

Features:

Mollom Integration

Mollom content moderation can be applied to sidecomment submission by activating the Mollom module and applying it to the comment form for the content type you're working with.

Customizable theme CSS

Change the look and feel of the side comment interface by providing your own theme css file, replacing (not overriding) the default theme CSS file.

Customizable callback for users without commenting permissions

What should happen when a user attempts to submit a comment but they don't have permissions to do so? You may want to display a login dialog or redirect to the login screen, for example.

Customizable feedback

Customize the feedback that is returned when a comment is spam-filtered (using Mollom) or when it is submitted to the comment approval queue.

Granular control over paragraph commentability

Prevent comments from being applied to any paragraph by giving it the "non-commentable-section" class. You can also define your own non-commentable classes.

CommentFileSizeAuthor
#24 coder-results.txt4.26 KBklausi

Comments

melvix created an issue. See original summary.

PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxmelvix2633590git

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

melvix’s picture

Issue summary: View changes

All the problems reported at http://pareview.sh/pareview/httpgitdrupalorgsandboxmelvix2633590git have been fixed.

melvix’s picture

Issue summary: View changes
melvix’s picture

Issue summary: View changes
melvix’s picture

Status: Needs work » Needs review
melvix’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
markconroy’s picture

Hi @melvix,

This looks really interesting. I'm a bit snowed under right now, but if I get a chance to install this later tonight I will.

It's the kind of module I could imagine being used on a lot of media sites.

andrewmacpherson’s picture

The <script> tag in sidecomments-now-wrapper.tpl.php appears to be a just a placeholder for some JS vars. Is this all the template is supposed to do? (i.e. is there a reason why a themer would expect to edit this template?)

If the template is just a way to inject some JS vars, it is probably better to do it using the Drupal.settings JS API (see https://www.drupal.org/node/304258#drupal-settings). Inside your Drupal.behaviors JS you'll be able to access Drupal.settings.sidecomments_now.sideCommentNid, instead of window.sideCommentNid. The advantage of doing this is that you'll be able to dispense with the sidecomments_now_wrapper entirely.

andrewmacpherson’s picture

The other sidecomments module doesn't appear to have had much work done on it, just a stub module really. However it does appear that the author intends it to use the core comment module; it's listed as a dependency.

andrewmacpherson’s picture

Since this module lets an admin user add executable JS code, you probably want to use the 'restrict access' => TRUE option in hook_permission().

moshnoi’s picture

maybe i have done something incorrectly while installing, but i got that error in console(i have installed side-comments from git):

side-comments.min.js?nzqero:1 Uncaught TypeError: this.$body.on is not a function
Drupal.behaviors.sidecomments_now.attach @ sidecomments_now.js?nzqero:16
(anonymous function) @ drupal.js?nzqero:76
b.extend.each @ jquery.js?v=1.4.4:33
Drupal.attachBehaviors @ drupal.js?nzqero:74
(anonymous function) @ drupal.js?nzqero:481
b.extend.ready @ jquery.js?v=1.4.4:30u @ jquery.js?v=1.4.4:38

feyp’s picture

Status: Needs review » Needs work
Issue tags: +PAreview: security

Automated Review

No automated tests, but this is not a requirement.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
As melvix mentioned above and has been discussed in the comments to this issue, there seems to be a person working on a Drupal 8 version, although it has not progressed very far and hasn't seen any commits recently.
So this would be a No: Causes module duplication and/or fragmentation.
On the other hand, I'd rather not block on this and leave it for the maintainers of the project applications to decide, what to do here.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
No: Doesn't meet the security requirements. See below for more information on the issue(s) identified.
Coding style & Drupal API usage
  1. (*) In hook_menu() you implement the sidecomments_now/delete/%, where you check for permission to edit own comments. The argument is a cid and in the callback you just call comment_delete(), so a user might actually delete any comment from the system. This is a security issue! Please check, that the comment was acutally posted by the current user, before you delete the comment.
  2. (*) As andrewmacpherson already said above in #9, you should set 'restrict access' => TRUE for your permission in hook_permission(), since you allow admins to add executable JS code to the page and this might be a security issue, if you don't trust those users.
  3. Since libraries module is listed as a dependency, why did you implement the fallback code in _sidecomments_now_get_library_path()?
  4. Line 106 of your module file: You probably want to call drupal_exit() instead of exit here.
  5. Typo on line 396 of your module file.
  6. Line 37 of admin.inc: As a best practice and to facilitate l10n, don't use !link to insert the link markup into t(). Use t('<a href="@link_url">Link title</a>'). See https://www.drupal.org/node/322774 for more info.
  7. The doc blocks of several functions are missing proper documentation of parameters and return values.
  8. Upon saving a node, which has sidecomments enabled, I get a notice: Notice: Undefined index: en in sidecomments_now_node_presave() (line 150 of sidecomments_now.module). This is, because $node->language is en, but the body field uses LANGUAGE_NONE. I was able to fix this by replacing $lang with LANGUAGE_NONE in lines 150 and 229 of your module.
  9. Next, I got $ is not defined with the latest stable release of sidecomments.js. It worked with the master version. You might want to document this requirement somewhere.
  10. Then I got section.data() is undefined, because the text format I was using was filtering the data attributes, so I had to switch to Full HTML to make it work. You might want to document somewhere, that in order for your module to work, you need to configure your text format to allow class and data attributes.
  11. Since I have disabled "Enable user pictures." at Configuration > People > Account settings > Personalization, I got an empty img path in the comment form. as I think this is the default, you might want to check for that setting and act accordingly. The same might happen, if the user did not upload a picture. I didn't test that, though.
  12. If I posted a comment and closed the comment box and later opened it again, the text of the comment was missing.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

melvix’s picture

@markconroy, @andrewmacpherson, @moshnoi and @FeyP: Thank you for your feedback. I have updated the module based on your comments, which I will respond to below, more or less in order received.

The < script > tag in sidecomments-now-wrapper.tpl.php appears to be a just a placeholder for some JS vars. Is this all the template is supposed to do? (i.e. is there a reason why a themer would expect to edit this template?)

I made the changes you suggested. Sidecomments javascript is now written to Drupal.settings and the template file eliminated.

(*) In hook_menu() you implement the sidecomments_now/delete/%, where you check for permission to edit own comments...

I added an access callback for sidecomments_now/delete, checking for comment ownership or comment administrative privileges. Additionally, the callback compares the referer and the comment's node url, which should always be identical (preventing someone from accessing sidecomments_now/delete directly).

(*) As andrewmacpherson already said above in #9, you should set 'restrict access' => TRUE for your permission in hook_permission()...

Added restrict access' => TRUE

Since libraries module is listed as a dependency, why did you implement the fallback code in _sidecomments_now_get_library_path()?

Even though libraries module is a dependency, it might not be fully installed at the time that _sidecomments_now_get_library_path() is called (at install), resulting in an error.

Line 106 of your module file: You probably want to call drupal_exit() instead of exit here.

Replaced exit() with drupal_exit().

Typo on line 396 of your module file.

I don't see a typo anywhere in this area. Can you elaborate?

Line 37 of admin.inc: As a best practice and to facilitate l10n, don't use !link to insert the link markup into t()...

I followed your example and changed !link to @link_url (inserting the url instead of the html link).

The doc blocks of several functions are missing proper documentation of parameters and return values.

I added more documentation, but I did not see any that were missing info about return values specifically. Please let me know if you are referring to a specific function.

Upon saving a node, which has sidecomments enabled, I get a notice: Notice: Undefined index: en in sidecomments_now_node_presave() ...

I fixed this by using field_language() to retrieve the correct body field language.

Next, I got $ is not defined with the latest stable release of sidecomments.js. It worked with the master version. You might want to document this requirement somewhere.

I added clarification to the Install instructions about using the master version. I believe this will also address the issue submitted by @moshnoi.

Then I got section.data() is undefined, because the text format I was using was filtering the data attributes, so I had to switch to Full HTML to make it work. You might want to document somewhere, that in order for your module to work, you need to configure your text format to allow class and data attributes.

I changed the configuration notes in README.txt to address the WYSIWYG settings more specifically:

Since I have disabled "Enable user pictures." at Configuration > People > Account settings > Personalization, I got an empty img path in the comment form...

I added a placeholder image that will be displayed as the user picture if the user has no picture and the default user picture isn't set.

If I posted a comment and closed the comment box and later opened it again, the text of the comment was missing.

I am not able to reproduce this. If the user's comment has not been moderated and published, this might explain it.

melvix’s picture

Status: Needs work » Needs review

Regarding the duplication with /project/sidecomments noted in #10 and #13, I have attempted to contact the maintainer again.

feyp’s picture

Status: Needs review » Reviewed & tested by the community

Hi melvix,

thank you for addressing all the issues and also for giving credit in the commit messages. That's very nice.

I didn't do a full review this time, but instead reviewed the git commits made since the last review. I verify, that the issues I identified – especially the blocker/security issues – have been fixed. I also checked your project again using preview.sh and it found a few minor issues, but this doesn't block the application.

I really appreciate your effort trying to work with the maintainer of the sidecomments module. I said before, that I'd rather not block on this, but leave it for a maintainer of the project applications to decide, what to do here. So...

... in my view, this module is RTBC :).

Regarding your questions:

I don't see a typo anywhere in this area. Can you elaborate?

I was probably referring to this comment // in a jsn object in the way that will make sidecomments.js happy., where jsn should read JSON, I guess. It's now on line 476.

I added more documentation, but I did not see any that were missing info about return values specifically. Please let me know if you are referring to a specific function.

That's definitely an improvement! However, here are a few functions I was referring to:

  • sidecomments_now_permalink(): Missing @params and @return
  • sidecomments_now_comment_reply(): Missing @params and @return
  • theme_sidecomments_now_user_picture(): Missing @return
  • sidecomments_now_save(): Missing @return
  • sidecomments_now_callback_js_default(): Missing @return
  • All functions in mollom.inc: Missing @param and @return
  • All functions in admin.inc: Missing at least @param
melvix’s picture

I added @param and @return tags where they were missing, fixed the spelling error and a number of documentation formatting errors found by pareview.sh.

@FeyP, thanks for your review!

melvix’s picture

I was able to contact the maintainer of the SideComments.js module via Twitter. He has granted me commit access to his project and says:

You can overwrite the work; 7 was not finished, and 8 was started on a D8 alpha build.

I asked him if he planned on remaining the project maintainer and he said:

It seems like this year there may be op to work on 8.x, merge in all you have, I don't mind

I am reluctant to "merge in all I have," for several reasons, the primary two being:

1. Communicating with the maintainer is difficult. (Does not respond to email, only Twitter.)

2. Merging my project into another at this point might not allow me to be granted permission to create full projects.

I am interested in any advice experienced members of the community have about how I should handle this.

klausi’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -PAreview: review bonus

Review of the 7.x-1.x branch (commit a80ca14):

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    FILE: /home/klausi/pareview_temp/sidecomments_now.module
    -----------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------
     120 | ERROR | Return type missing for @return tag in function comment
    -----------------------------------------------------------------------
    
  • DrupalPractice has found some issues with your code, but could be false positives.
    FILE: /home/klausi/pareview_temp/sidecomments_now.module
    ---------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------
     168 | WARNING | Doc comment indicates hook_form_alter() but function
         |         | signature is "sidecomments_now_form_node_type_form_alter"
         |         | instead of "sidecomments_now_form_alter". Did you mean
         |         | hook_form_FORM_ID_alter()?
    ---------------------------------------------------------------------------
    
  • No automated test cases were found, did you consider writing Simpletests or PHPUnit tests? This is not a requirement but encouraged for professional software development.

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

manual review:

  1. sidecomments_now_install(): do not juggle with module weights since that is unreliable. Use hook_module_implements_alter() if you need to run before/after a specific hook. And the comment does not tell me why you need to adjust the weight. Always document why you are doing something - what you are doing I can read from the code itself :-)
  2. Does this module only work on the default body fields or on other fields as well? Please add that to the project page.
  3. sidecomments_now_save() and sidecomments_now_delete() are vulnerable to CSRF attacks. You need to confirm user intent either with the Form API (which has built in CSRF tokens) or you need to validate CSRF tokens yourself. See http://epiqo.com/de/all-your-pants-are-danger-csrf-explained and https://docs.acquia.com/articles/protecting-your-drupal-module-against-c... . And please don't remove the security tag, we keep that for statistics and to show examples of security problems.

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

melvix’s picture

Issue summary: View changes
melvix’s picture

Issue summary: View changes
melvix’s picture

Issue summary: View changes
melvix’s picture

Status: Needs work » Needs review
Issue tags: +PAreview: review bonus

@klausi, thank you for your review.

sidecomments_now_install(): do not juggle with module weights since that is unreliable...

I removed the implementation of hook_install(). It wasn't necessary.

Does this module only work on the default body fields or on other fields as well? Please add that to the project page.

Currently it only works on body fields. I added a note to that effect on the project page and to the README file.

sidecomments_now_save() and sidecomments_now_delete() are vulnerable to CSRF attacks...

I added tokens to sidecomments_now_save() and sidecomments_now_delete() to prevent CSRF attacks. Thank you for including the links in your note about this.

Manual reviews of 3 more projects:

https://www.drupal.org/node/2574753#comment-10806168
https://www.drupal.org/node/2652208#comment-10806778
https://www.drupal.org/node/2565825#comment-10806866

klausi’s picture

Assigned: Unassigned » mpdonadio
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new4.26 KB

Review of the 7.x-1.x branch (commit f4a9025):

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

manual review:

  1. sidecomments_now.js: why do you need escapeHtml()? Should you use Drupal.checkPlain() instead?
  2. template_preprocess_sidecomments_now_js(): "$sidecomment->authorName = $comment->name;": could you add a comment here explaining why this does not have to be sanitized? I assume that sidecomments.js takes care of sanitizing it when it displays it?
  3. _sidecomments_now_get_library_path(): the module_exists() call is not needed here since the libraries module will always be there (it is a dependency).
  4. JS error: TypeError: this.$body.on is not a function. Does this module work in the default bartik theme on a standard Drupal install?

But otherwise looks good to me. Assigning to mpdonadio as he might have time to take a final look at this.

melvix’s picture

@klausi, thank you again for your review and comments.

sidecomments_now.js: why do you need escapeHtml()? Should you use Drupal.checkPlain() instead?

I did not know Drupal.checkPlain() existed! I removed escapeHtml() and replaced it with Drupal.checkPlain().

template_preprocess_sidecomments_now_js(): "$sidecomment->authorName = $comment->name;": could you add a comment here explaining why this does not have to be sanitized? I assume that sidecomments.js takes care of sanitizing it when it displays it?

I added check_plain($comment->name).

_sidecomments_now_get_library_path(): the module_exists() call is not needed here since the libraries module will always be there (it is a dependency).

During the install phase the libraries module is not necessarily installed yet. I want to prevent installation if the SideComments.js library is not found.

JS error: TypeError: this.$body.on is not a function. Does this module work in the default bartik theme on a standard Drupal install?

SideComments.js requires jQuery version 1.7 at a minimum because it uses jQuery.on(). I added a note about this in the README file and on the project page. I also changed admin-pages javascript so that it is compatible with jQuery version 1.4.4.

ESlint errors: The version of .eslintrc I am using is the one referenced here: https://www.drupal.org/node/1955232. I notice that it has one difference between it and the version I have in an installation of D8 - the D8 version has this line:

"quotes": [2, "single", "avoid-escape"],

Which is the correct version to use?

klausi’s picture

The correct ESLint config version ships with Drupal core, I fixed the project page at https://www.drupal.org/node/1955232

So your module should depend on jquery_update module if you need a higher jquery version?

melvix’s picture

I updated my version of .eslintrc and replaced double-quotes with single-quotes in javascript files.

I didn't add jquery_update module as a dependency because I thought it would be nicer to allow the site admin to use whatever method they liked for setting jquery. I listed it under "recommended modules." Is requiring it a better approach?

klausi’s picture

Status: Reviewed & tested by the community » Fixed

no objections for more than a week, so ...

Thanks for your contribution, Dagwood!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

melvix’s picture

Thanks klausi!

mpdonadio’s picture

Assigned: mpdonadio » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.