Open Graph Comments module allows to show Open Graph meta tags (http://opengraphprotocol.org/) of first link available in comment. Its same kind of functionality used by facebook and twitter to show title(with link), image and description of particular external page if its link is added in any status or tweet.
Features
- Open Graph Comments module get link from comment body and fetches open graph meta tags information to show og:title, og:link, og:image and og:description attached to comment body.
- It also allows to enable or disable to display of open graph meta tags information for particular content type. It can be done from comment settings in content type edit page.
- Open Graph Comments module also uses drupal caching to cache comment's open graph meta tag information so that next time it does not go to external page to get those information.
Installation
- Install as usual, see https://drupal.org/documentation/install/modules-themes/modules-7 for further information.
- Enable open graphs in comments for particular content type from comment settings in content type edit form. This setting can be different for each content type.
Sandbox Link
https://drupal.org/sandbox/gulab.bisht/2104985
Git Clone
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/gulab.bisht/2104985.git open_graph_comments
Reviews of other projects:
https://www.drupal.org/node/2185761#comment-8798393
https://www.drupal.org/node/2275023#comment-8820059
https://www.drupal.org/node/2285195#comment-8881241
https://www.drupal.org/node/2297073#comment-8936779
https://www.drupal.org/node/2267323#comment-8936569
https://www.drupal.org/node/2283525#comment-8936855
Comments
Comment #1
gbisht commentedComment #2
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxgulabbisht2104985git
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.
Comment #3
gbisht commentedIssues show by pare view automatic review tools are fixed now.
Comment #4
kurtfoster commentedHi gulab.bisht,
great idea for a module, it look very simple and easy to use. Unfortunately this module also does not meet the minimum 5 functions and 120 lines of code for approval. You may need to think about any other features you may be able to add to this module before it canbe approved.
In the readme file could you add link to more detail about open graph meta tags, what they are and what they do?
I enabled the module and wrote a new comment on a basic page without any links and received this error:
Notice: Undefined offset: 0 in open_graph_comments_comment_view_alter() (line 47 of /path/to/drupal/sites/all/modules/contrib/open_graph_comments/open_graph_comments.module).
Comment #5
kurtfoster commentedThere are not enough functions or lines of code to review in line with the drupal standards.
Comment #6
gbisht commentedThanks Kafmil for suggestions. I will be adding some more configuration options for administrator to get more control over open graph comments.
Comment #7
PA robot commentedClosing due to lack of activity. Feel free to reopen if you are still working on this application (see also the project application workflow).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #8
gbisht commentedComment #9
gbisht commentedWorked on issues mentioned by kafmil. I added new feature to control display of open graph in comments for each content type from comment settings in content type edit page. Also added drupal caching to cache open graph meta tags in formation for each comment.
Comment #10
gbisht commentedComment #11
gbisht commentedComment #12
gbisht commentedComment #13
joshi.rohit100Looks fine to me except the commenting of open_graph_comments_display_comment() function
Comment #14
joshi.rohit100Comment #15
gbisht commentedNow commenting is fixed for open_graph_comments_display_comment() function.
Comment #16
znaeff commentedHi.
It seems hook_form_BASE_FORM_ID_alter() is used instead of hook_form_FORM_ID_alter().
See https://api.drupal.org/comment/25048#comment-25048
If so please change comment to
Implements hook_form_BASE_FORM_ID_alter()Comment #17
gbisht commentedThanks znaeff for reviewing the code.
I did changes you asked in open_graph_comments_form_node_type_form_alter function's comment.
Comment #18
gbisht commentedComment #19
gbisht commentedComment #20
gbisht commentedComment #21
klausiIt appears you are working in the "7.x" branch in git. You should really be working in a 7.x-1.x branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the 7.x branch:
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:
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #22
gbisht commentedComment #23
gbisht commentedComment #24
gbisht commentedThanks klausi for the review. Below are issues fixed.
open_graph_comments_comment_update() hook is implemented to remove cache so that if url is updated in comment then new cache can be generate for the comment.
Comment #25
gbisht commentedComment #26
klausiI'm confused, there is a 7.x branch and a 7.x-1.x branch, but there should only be a 7.x-1.x branch. Could you make sure that all your recent changes are on 7.x-1.x and then remove 7.x?
Comment #27
gbisht commentedSorry for the confusion, now I have removed 7.x branch and recent changes are in 7.x-1.x branch.
Comment #28
gwprod commentedI am somewhat concerned about line 28 in open_graph_comments.module
@$html->loadHTML($request_data->data);Is this a potential security hazard?
Comment #29
gbisht commented@gwprod thanks for your concern but at line 35 I am using check_plain() function to overcome any security issue.
Comment #30
joshi.rohit100Here are the few points from my review :-
a) For each node type, open graph comments setting is stored in variables table. So I think, variables related to open graph comments should be flushed out when this module is not in use.
b) In hook_comment_update, $comment_node_type is initialised. I think , there is no need to initialize this variable.
c) Again in hook_theme, no need to create variable $themes as you can simply return array. Creating un-necessary varibale causes performance problem as they take memory.
d) In hook_comment_view_alter, you are getting comment data for LANGUAGE_NONE. It will always returns the data for only one or default language, not for other languages.
e) (My Opinion) In hook_comment_view_alter, you have used four different variables $url, $title, $desc, $img.
Instead of using separate variables for them , you can use array.
thanks
Comment #31
gbisht commented@joshi.rohit100 thanks for the detailed review.
I looked into the issues mentioned by you and tried to fixed them in best possible way.
a) .install file is added and hook_uninstall() is implemented to remove variables set by the module.
b) $comment_node_type variable initialization is removed.
c) Now array is returned.
d) Now I'm getting data according to comment language and also making sure whether field translation is enable in comment body field or not.
e) $og_data array is used for four different variables.
Comment #32
joshi.rohit100All points are looking good except (e).
In (e) what I was trying to say is that , remove $title, $desc, $img, $url and use array something like this :-
$meta_array = array()then on change these
to
and for rest of the variables.
then change
to
Its my opinion as I think it will make code more cleaner.
Than again on template file, you should check if variable is set, then only output them.
Comment #33
gwprod commented@joshi.rohit100
I believe those issues are purely stylistic, not required by Drupal coding standards or best practices, and offer no increase in elegance or utility. I am reverting this to 'Needs Review'
Per https://www.drupal.org/node/532400
Important note for reviewers: A 'needs work' status change should be reserved for 'major' code quality issues. Minor changes, recommendations for full API compatability, and txt file perfection are not major code quality issues. Holding up reviews on these changes can come off as unnecessary and nitpicky, especially early in the review process. This can also cause frustratingly long waits for uninitiated applicants.
Comment #34
gwprod commentedHowever:
If he did want to increase the elegance of this block,
He could change it to.
And then change the tpl file to use the actual Open Graph properties.
Comment #35
joshi.rohit100@gwprod
Your example in #34 and what I mentioned in 32, doing same thing - making code more readable. It is not a good idea to throw un-necessasy variables as it makes code noisy that someone don't want to read. As in future, if someone looks at the module and feel uncomfortable with number of lines and unnessary variables.
Comment #36
joshi.rohit100Comment #37
gwprod commented@joshi.rohit100 I will reiterate that I believe a fairly minor issue of readability from your personal perspective is neither a blocking issue nor a major code quality issue.
Per https://www.drupal.org/node/532400
Important note for reviewers: A 'needs work' status change should be reserved for 'major' code quality issues. Minor changes, recommendations for full API compatability, and txt file perfection are not major code quality issues. Holding up reviews on these changes can come off as unnecessary and nitpicky, especially early in the review process. This can also cause frustratingly long waits for uninitiated applicants.
Comment #38
joshi.rohit100@gwprod
Ok fine, its not a major or blocking issue, but what about this ?
How will you judge the code quality as Same thing can be done using single loop or multiple loops. Then both codes are good or same ?
Comment #39
gwprod commented@joshi.rohit100
I personally would prefer to see code that is as elegant and efficient as possible. Some times that is not practical, some times it is not necessary. I would say that a major code quality issue is when things are not done 'The Drupal Way' by and large. When formatting is incorrect. When there are security vulnerabilities.
"Needs work" is when your teacher hands you back a paper and says 'F - Revise and resubmit"
Comment #40
gbisht commented@joshi.rohit100 and @gwprod thanks for discussing so extensively on this topic. In your discussion I found many points which I have improved.
1) As mentioned by @joshi.rohit100, now I using $meta_array variable to store meta data in array. And also checked for meta variables in template file as well because without control statement it was rendering empty divs.
2) Found that to check whether field is translatable or not we can use #field_translatable element in $build array on line 59.
3) Also removed $lid to create cache variable name for comment link's meta information as I don't think there is any useful need for it.
Please review the code again to make sure changes done by me are correct and working as required.
Comment #41
mpdonadioThe change is #32 is not a reason to go back to Needs Work. You even mentioned in #30 that is was an opinion.
Stylistic issues are never blockers, unless there is blatant disregard for Drupal coding standards. Miss some indentation here or there? Mention it, but don't push back. Totally unformatted code or wild spaghetti code? Push back.
Reviews are not meant to hold up applications to get perfect modules. They are primarily sanity checks to get good decent modules on DO, and also to ensure that a release doesn't have third party code, licensing problems, or security issues.
Comment #42
klausimanual review:
But otherwise looks RTBC to me.
Assigning to mpdonadio as he might have time to take a final look at this.
Comment #43
mpdonadioAutomated Review
Review of the 7.x-1.x branch:
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.
False positive about CSS.
Manual Review
(*) Your handling of the external URLs are not safe. On lines 80 and 86, replace the check_plain() with check_url(). This will ensure
that dangerous protocols (which can be overridden per site) get stripped. Poke through https://api.drupal.org/api/drupal/includes%21common.inc/function/calls/c...
to see how this gets used in core.
You need to implement a hook_node_type_delete() to delete your variable for that content type.
Not a fan of the target=_blank in the .tpl.php files. This should be the user's choice.
It would be a little better to use the theme functions for the image and link, rather than using variables in the template. These will also take care of the
sanitization problems mentioned above.
Good use of inline comments.
open_graph_comments_display_comment() is a bad name for what the function actually does. Maybe open_graph_comments_get_og_tags()?
Eventually, you may want to consider your own cache bin.
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.
This is good to go once the (*) lines are fixed.
Please don't remove the security tag, we keep that for statistics and to show examples of security problems.
Comment #44
gbisht commented@klausi and @mpdonadio thanks for the reviewing the project.
@klausi
Now using $reg_exurl variable value directly in preg_match() and filter_var() function is replaced with valid_url().
@mpdonadio
check_plain() replace with check_url() for link url and image url. open_graph_comments_display_comment() changed to open_graph_comments_get_og_tags() as its more appropriate.
And thanks for other recommendations will surely be implementing them in future releases.
Comment #45
mpdonadioI read `git diff eeef33c..HEAD` and this this RTBC. Normal procedure for admins is to not go straight from Needs Work to Fixed. I will check on this in a few days to see if there are any objections.
Comment #46
klausiCool, I agree that all necessary issues are now addressed, so ...
Thanks for your contribution, gulab.bisht!
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.
Comment #47
gbisht commentedThanks all the reviews for taking out some time to review this project. I really appreciate all the recommendations and suggestions given here. And now I definitely be more involved in the community.