A simple module which changes the submitted by link to the node author. With this module installed the link will not point to the user account of the author, instead it will point to an associated Google+ profile. This associates the content with the user and will generally result in the user's profile picture being displayed in Google's search results leading to higher click-through rates.
This is different from other modules like Submitted By because it addresses one specific use case and requires much less configuration to get set up, i.e., one need not set up tokens or any of the additional fields the user account would require. It also does not create a new field to be added to content types, instead it works with and overrides Drupal's default "submitted by" feature.
How it Works
This module adds a field to the Drupal 7 user entity to store a Google+ profile ID. Using that field, if it is filled, this module alters the Submitted by line of a node's full content display to link to the Google+ profile of the appropriate author. Finally, by setting the "rel='author'" attribute Google search bots will recognize and display an author's profile picture in its search results.
Installation
1. Add the module to /sites/all/modules (or /sites/all/modules/contrib).
2. Go to admin/modules and enable the Google Authorship module.
3. For each user for whom you would like Google to display author information, add their 21 digit Google+ Profile ID from their profile URL. You may also have users do this themselves.
4. Ensure that the "Display Author and Date" setting is checked for all the content types that you would like to have Google Authorship apply its changes.
5. To verify that Google can see authorship information on your nodes, you can paste the URL of a node which this module should have overridden into Google's Structured Data Tool.
Important Notes
This module may not work with themes that override the submitted link too. If it does not seem to be working, please first check that your theme does not override it on its own.
TODOs
Add t() wrapper to field description
Change README.md to .txt
Change @params to @param
https://drupal.org/sandbox/gabesullice/2038225
git.drupal.org:sandbox/gabesullice/2038225.git
Code Reviews:
https://drupal.org/node/2035383#comment-7641801
https://drupal.org/node/2005244#comment-7641849
https://drupal.org/node/2037361#comment-7641961
Comments
Comment #0.0
gabesulliceSpelling
Comment #1
sreynen commentedHI gabesullice,
Code sniffer shows a lot of non-critical coding standards errors:
http://ventral.org/pareview/httpgitdrupalorgsandboxgabesullice2038225git...
Manual review:
* TODOs should be done before release, especially t().
* Your git branch should be 7.x-1.x. -alpha is a release, which should be a release, not a branch.
* "Implements google_authorship_preprocess_username()" should say "Implements template_preprocess_username()"
* "Implements google_authorship_get_google_id()" should say what the function does. A function does not implement itself.
* "if (strlen($google_id) != 21) {" You should be validating content on input, not output. If someone adds an invalid ID and it doesn't do anything, they won't know why. If you use hook_form_alter() to validate on input, you can tell them why, and even reject invalid values.
* Why is google_authorship_preprocess_username() limited to node views? Why not change username links anywhere they're displayed?
* In google_authorship_enable(), "echo 'True';" looks like a debug statement that might confuse users. If you replace that with feedback intended for users, make sure it gets wrapped in t().
Everything else looks good to me.
Comment #2
sreynen commentedForgot to set status. Looks like some of that was done while I was posting, but I think there's still some left to do.
Comment #3
gabesulliceWow, you were fast. Thank you. Yeah, I did get them done right after posting.
Thank you for clarifying. I thought that 1.0 would make it a release not the post hyphen text. Thanks again, will fix.
Fixed.
Done.
Will do shortly.
In most use cases, I imagine you would want Google to index the URL of the node content with only a Google+ Profile ID. Doing this everywhere could result in having the rel=author attribute tag in multiple places on the same page, e.g., on multiple comments or a view of teasers. This might break the feature or incorrectly attribute the node content to the wrong Google+ profile.
Good catch. Removed.
Thanks for your help.
Comment #4
gabesulliceImplemented.
Comment #5
gabesulliceComment #6
PA robot commentedWe 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 #7
pandaski commentedSome coding style issues with 1.x branch http://ventral.org/pareview/httpgitdrupalorgsandboxgabesullice2038225git...
Manual review:
Line 61, 92,95 google_authorshop.module
und for the language can be improved by LANGUAGE_NONE or a small snippet to detect the language setting.
Comment #8
gabesulliceGot rid of all the errors and warnings except the ones addressed below and the end of line ones. I've tried everything to fix those. I've set them up in PhpStorm, I've set git config --global config.crlf true, I've set text eol=lf in my .gitattributes. I don't know what else to do except ignore them.
These fields are all validated on user input to be all numeric strings. Wouldn't that just be unnecessary overhead? Maybe I'm not understanding what you mean or how this works.
Thank you for the review! I sincerely appreciate it!
Comment #9
pandaski commented@gabesullice regarding the language, my suggestion is to use LANGUAGE_NONE instead of und
Sorry if I bring the confusion :)
REF:
https://api.drupal.org/api/drupal/includes%21bootstrap.inc/constant/LANG...
Such as line 71:
From
To
Comment #10
gabesullice@joseph.zhao
Made those changes. Thank you for the code.
Comment #11
gabesulliceFound the dos2unix command and all the line endings are taken care of. The latest commit of 7.x-1.x has no errors
except a warning to remove the master branch, which I'll do now.(<- done)Comment #12
sreynen commentedI'd suggest getting rid of the README.md file, as it seems likely that will become out of sync with the README.txt file and people wouldn't know which is relevant. But that's not a blocker issue, and I don't see anything major, so marking this RTBC.
Comment #13
gabesulliceThanks, sreynen, I think I'll keep it on my local master for Github. I'll get rid of it on the 7.x-1.x branch and all future Drupal releases.
Comment #14
gregglesHere are some thoughts that are not blockers to approval.
I appreciate that the module does validation on the field which would prevent something like XSS, but it's standard in Drupal to filter on output and the construction of the url has no filtering to prevent problems. Have you tried disabling the validation and seeing what happens if invalid or malicious data is entered for the url? Using the safe_value is a good call in general, but I'm not sure it takes into account the filtering necessary to use the field as a url.
When you get the bundle and nid and do a lot of tests on them, I wonder whether that wouldn't be done better as a menu_get_object? Basically you run the risk that nodes are being displayed somewhere other than node/NID and then this module will stop working. Maybe this module could take action in hook_node_view to populate some data into the $variables for the preprocess function?
@gabesullice - when you've got the review bonus let me know (and if you do any experiments on the above points I'd be interested to hear that too).
Comment #14.0
gregglesFixed TODOs.
Comment #14.1
gabesulliceAdded code review
Comment #14.2
gabesulliceAdded another code review and made the code review an h3
Comment #15
gregglesI talked through each of the issues I mentioned in #14 in irc with @gabesullice and he said that the filters are escaped (great) and that he tried the hook_node_view idea and couldn't get it to actually work. Makes sense.
Thanks for your contribution, gabesullice!
I updated your account to let you 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 get 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 #16
gabesullice@sreynen @greggles @joseph.zhao: Thanks for all your help!
Comment #17
pandaski commented@gabesullice Great job mate!
Comment #18.0
(not verified) commentedAdded a 3rd code review