Reviews of other projects
http://drupal.org/node/1400086#comment-5590504
http://drupal.org/node/1423362#comment-5624952
http://drupal.org/node/1416752#comment-5624916
http://drupal.org/node/1390218#comment-5624884
New: Below reviews: On Feb 29th, 2012
http://drupal.org/node/1426386#comment-5670738
http://drupal.org/node/1431424#comment-5670808
http://drupal.org/node/1399684#comment-5671004
http://drupal.org/node/1281690#comment-5671138
http://drupal.org/node/1447752#comment-5671246
Description:
The googlebook module (for Drupal 7) is a filter module and an API for the http://books.google.com, that allows a user to insert rich Google Book data into nodes via filters with data retrieved from the http://books.google.com domain.
The user of this filter module will be able to easily insert:
- book data from Google into pages using Drupal filters, There are options to include / exclude any data fields,
- a book cover image when it exists
- and for books with a full or partial preview, the Google book reader for the volume.
The starting framework of the code was based on the Book Post module to get ideas which gets data from Open Library instead of the Google Books API although little remains of that module other than the framework. The googlebook module API is different based on the data returned as well as the final aims of the module, although they do both return book data. The Google Book module can output a page image as well as the built in book reader from Google.
There are many search options with Google books and many options to display that data within the Google Book module.
Link to Google Books module project page
http://drupal.org/sandbox/darrellulm/1372154
Promoted to full module at: http://drupal.org/project/google_books
A direct link to Google Books git repository
Git page link: http://drupal.org/node/1372154/git-instructions/7.x-1.x/nonmaintainer
Git instructions:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/darrellulm/1372154.git googlebook
Link to running demo of module
http://superpowerplanet.com/content/drupal-google-book-filter-module
How to use the inline options
In line display options to override the global Google Book filter settings can be made by options after the search string. The format for the search strings and options are:
Use global display options:
[google_book: search string]
In line options always come after the search string and are separated by a vertical bar, i.e. a '|' character.
[google_book: search string | option 1 | option 2 | option 3 | ... ]
Options to include are just used normally, like 'worldcat' while options to exclude in the display are prefaced by the 'no_' prefix.
Example:
[google_book: The Hobbit | no_librarything | no_image | viewer | title | no_description]
These are the content options:
- worldcat / no_worldcat
- openlibrary / no_openlibrary
- librarything / no_librarything
- pagecurl / no_pagecurl
- titlelink / no_titlelink
- image / no_image
- reader / no_reader
Also each an every data field can be turned on or off overriding the Google Books filter global default.
The in_line field settings are below
- kind
- id
- etag
- selfLink
- volumeInfo
- title
- authors
- publisher
- publishedDate
- description
- industryIdentifiers
- type
- identifier
- pageCount
- dimensions
- height
- width
- thickness
- printType
- mainCategory
- categories
- averageRating
- ratingsCount
- contentVersion
- imageLinks
- smallThumbnail
- thumbnail
- small
- medium
- large
- extraLarge
- language
- previewLink
- infoLink
- canonicalVolumeLink
- saleInfo
- country
- saleability
- isEbook
- listPrice
- amount
- currencyCode
- buyLink
- accessInfo
- viewability
- embeddable
- publicDomain
- textToSpeechPermission
- epub
- acsTokenLink
- accessViewStatus
Contact Darrell Ulm if you need any information on this module at:
http://drupal.org/user/46284/
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | drupalcs-result.txt | 3.26 KB | klausi |
| #10 | drupalcs-result.txt | 1.56 KB | klausi |
| localhost 2011-12-27 15:59:19.jpg | 80.16 KB | darrell_ulm |
Comments
Comment #1
natemow commentedAutomated review:
It appears you are working in the "master" branch in git. You should really be working in a version specific 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 master 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. Go and review some other project applications, so we can get back to yours sooner.
Comment #1.0
natemow commentedTook out link that was not useful.
Comment #2
darrell_ulm commentedMade the changes to formatting and repositories as indicated in feedback. Thank you.
Comment #3
natemow commentedLooking better...still a few issues found.
Automated review:
It appears you are working in the "master" branch in git. You should really be working in a version specific 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 master 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. Go and review some other project applications, so we can get back to yours sooner.
Comment #4
darrell_ulm commentedOK, master is cleared out all but README, and I replaced the string functions with drupal_string
When testing at http://ventral.org/pareview/httpgitdrupalorgsandboxdarrellulm1372154git-...
Everything came up clear, i.e. no errors.
Local tests with the coder module also came up clear.
Thanks!
-Darrell
Comment #5
misc commentedI tested it and worked as described. Did a manual review of the code, and it looks correct. So for me it is thumbs up.
EDIT: Just to be clear, did not find any security issues, and could not find a similar module for drupal 7 that does the same thing. Code is well written and uses drupal functions, and is well documented.
Comment #6
darrell_ulm commentedMISc,
Thank you! Much appreciated!
Comment #7
darrell_ulm commentedMISc,
By the way, what is the next step?
Thanks in advance!
Comment #8
misc commentedNext step is, if no other reviewer here thinks otherwise, is to be granted git acces to grant full project release by one of the Git administrators.
Comment #9
darrell_ulm commentedMISc,
Sounds good. Thanks again!
Comment #10
klausiThe following git branches do not match the release branch pattern, you should remove/rename them. See http://drupal.org/node/1015226
Review of the 7.x-1.x-dev 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. Get a review bonus and we will come back to your application sooner.
manual review:
Comment #10.0
klausiUpdated instructions for 7.x-1.x-dev branch.
Comment #11
darrell_ulm commentedOK, all clear on my local test at:
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme .and remote test at http://ventral.org/.
I addressed these issues:
googlebookapi.install: remove the copyright notice, all code on drupal.org is GPL anyway + downloadable tarballs get an extra LICENSE.txt file. Also in the other files.googlebookapi_uninstall(): empty function, so remove it.googlebookapi_get_googlebook_data(): for documenting function parameters you should use the @param syntax, see http://drupal.org/node/1354#functions . Also on other functions."json_decode($bookkeys, TRUE);": you should use drupal_json_decode() instead. Also elsewehere.googlebookapi_get_googlebook_data(): $obj is a bad variable name, use something more descriptive, e.g. $cached_books, $cache etc.googlebookapi_get_googlebook_version_count(): useless docblock, please at least explain the function in one sentence. Also elsewhere."'#title' => 'Google Book Data Fields',": all user facing text should run through t() for translation. Please check all your strings.googlebook_filter_process(): you could use a foreach() loop here, then you don't need the counter. You can add new array elements simply with $book[] = ...googlebook_retrieve_bookdata(): what is you strategy to sanitize the third party provided data before printing it? You have to use the appropriate sanitization function (check_plain(), check_url() etc.) before embedding any user provided property (or google provided in this case) into your HTML output. See http://drupal.org/node/28984 and http://drupalscout.com/knowledge-base/drupal-text-filtering-cheat-sheet-...Also you should split up googlebook_retrieve_bookdata(): this function should only assemble the necessary data and pass it to a theme function that actually renders the output. So other modules/themes can easily override and customize it.Again, thanks to the reviewers in advance!
Cheers,
~Darrell Ulm
Comment #12
darrell_ulm commentedOK, I checked off everything in comment:
http://drupal.org/node/1387232#comment-5556090
I ran through and made the changes I was given on the list and all the automated tests come up clear.
Thanks in advance!
Cheers,
~Darrell Ulm
Comment #13
misc commentedSo I approve again, hope that other reviewers feel the same :-)
Comment #14
darrell_ulm commentedMISc, Thanks again. - Darrell Ulm
Comment #15
elc commentedblockers
It seems these values are used verbatim later on so they should be validated on input.
non-blockers
Comment #16
darrell_ulm commentedAnswer them as I get through each:
googlebookapi_json_extractAPI duplication? http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_j...
Not at all: The link you gave has code of:
googlebookapi_json_extract (my code) as you can see, works with the specific results of calling drupal_json_decode. It is part of the JSON processing to avoid 100 separate if then statements to pull out the required fields by name for each element of the returned JSON array and a way to collapse the hierarchical array into a flat array using recursion. It is possible it could look like a JSON string parser but is far more simple.
FIXED: OK, renamed googlebookapi_json_extract to more accurate and descriptive googlebookapi_demark_and_flatten
googlebook_filter_processIt seems the module should be looking for a marker, not just everything inside {{}}. Other modules may use this same "signal" elsewhere. Most other modules use square brackets - eg [node:5] in node link. {{googlebooks:drupal+7+development}}
This can be changed to [googlebooks:drupal+7+development]. Is this what you are indicating?
FIXED
too much growth hormonePlease remove the 7.x-1.x-dev branch from the d.o git repository if you are no longer using it. 7.x-N.x is the normal major version branch naming convention and you seem to have one of those too. Both branches seem to be identical. Just in case you hadn't seen it before -
Can remove.
FIXED
git commit messages and attributionPlease refer to Commit messages - providing history and credit about giving yourself some credit and properly formatting commit messages.
Yes/ I read this link, now adding my own issues and fixing them. Then indicating in the patch.
FIXED
googlebook_filter_settings
When user can enter anything they want, but you want them to enter an integer, validate for it instead of accepting and storing anything and then having to do output processing on it everywhere. It looks like all the textfield inputs need to be integers - use a full blown #validate function, or #element_validate on each of them.
FIXEDIt seems these values are used verbatim later on so they should be validated on input.
googlebook_retrieve_bookdata, googlebookapi_get_googlebook_data, googlebookapi_cached_requestNone of these functions takes into account the request failing for whatever reason. The last one even caches the faulty result.
FIXED
googlebookapi_cached_requestcache id can easily be longer than the 255 limit on the cid. Usually cid is set to module specific prefix, sub-area specific prefix, and then a hash of the user provided data so that the length of the cid is always known to be less than the limit.
Added sha256 hashing function to cache as indicated on drupal.org as the new standard.
And as you probably saw in the code, the GoogleBook module has an install function with it's own cache table for efficiency, rather than the bulk Drupal cache. So as one would expect, I did not add the
I assume you already saw that in the code and didn't really want me to add the prefix for a cache table already created specifically for GoogleBook.
Also I did miss documenting the return param on that schema function, so added the 1 line of doc.
FIXED
theme function - preprocess_methodName is generic and does not indicate at all that this is a google books theme function. Perhaps it would be better called 'googlebook'?
Changed to 'googlebook_theme_template'
FIXED
Comment #17
misc commentedHere I go again.
Seriously, @ELC, I think this is to picky. It is obvious that @darrellulm has an understanding of Drupal standards, and the module works, and is easily to setup. Improvements could always be done when you release your project as a full project, how many sandbox projects is a stable release on the first day they become full projects?
Comment #18
elc commented@misc This is not the correct forum for such arguments. If you have issues with my reviews you may ask for a second opinion or talk to me directly. This is not your application?
The project has a security issue which it seems I forgot to add the tag for. The unvalidated user input is entered directly into the HTML output. This is a canary for understanding the security implications of trusting user input and using the forms API. Security and understanding the Drupal API are some goals of this process.
The unhandled error states on http requests, and cache id key length are not as important but are serious enough that they will cause unexpected errors and warnings, and could be potentially difficult to diagnose at a later date as they will not be easily reproduced.
@darrellulm
I look forward to the other fixes.
Comment #19
misc commented@ELC, I am also doing review of this applicant, and raised my concern in the issue there I think we are to picky. Further discussion on the subject could be done here: http://groups.drupal.org/node/208403
Comment #20
darrell_ulm commentedI will rename googlebookapi_json_extract to something more descriptive. I can see where the naming similarity is not the best way to go given that the function is doing something specific to my module and is not really an extraction. So I will rename when I get a chance.
Will work on other issues soon.
-Cheers,
~Darrell
Comment #21
darrell_ulm commentedOK @ELC and @MISc, I made all the changes indicated. Coming up clean. Thanks for all of both of your suggestions, made it a better module.
I checked off each of the tasks at the comment above:
http://drupal.org/node/1387232#comment-5573508
Cheers,
@darrellulm
Comment #22
elc commentedMain security issue addressed; admin input is now validated as a number before being accepted and included in output html.
The second blocking issue listed in #15 is still at large. I'll open a bug on the project page as they will cause errors to displayed to the user, not outright break or be a security issue. Hmm.. one of them doesn't cause errors. It appears that access an non-existent index on a NULL value does not throw an E_NOTICE. The property still throws one though.
Caching; fixed. I agree that it doesn't need a module specific identifier. Perhaps you should make the search string lower case before hashing it so that differences in case don't mean keeping a cached copy for each.
Theme name; it's certainly module specific!
Also fixed the non-blockers.
other mild suggestions
[googlebook:The Hobbit] or [googlebook:9780618154012] or [googlebook:Rucker+Software]
and this will filter the input to replace with Google Book data
and images from http://books.google.com
So, the next step from here is for another git admin to come along and review it again and if they find it to be all good, they'll set it to "fixed" and grant the git vetted status. If they find any issues, it will be bouced back to needs work with appropriate instructions.
Comment #23
klausiThis automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Get a review bonus and we will come back to your application sooner.
There is a git tag that has the same name as the branch 7.x-1.x. Make sure to remove this tag to avoid confusion.
manual review:
Sorry to bump this back to needs work, but you need to know where to use check_plain() and where not.
Comment #23.0
klausiChanged information to indicate 7.x.1.x normal release branch for naming conventions.
Comment #24
darrell_ulm commentedOK, handled these and set to the 7.x-1.x repo.
Comment #25
darrell_ulm commentedHey, fixed most of them, now making a theme function(s) for the output.
Reply to:
Also I knew that the form #default already checked the input but I tossed them in anyway in case you (or whoever reviewed it) didn't know since I wanted a pass! ;)
Took those out and resubmitted.
How to handle the Javascript, I assume you are aware that drupal_add_js does not work with hook_filter() with caching? I don't believe this was ever fixed in Drupal 7. Please advise, are you sure you want me to use drupal_add_js() with hook_filter? Due the to processing order, the filter is rendered only once when the cache is cleared or reset, then of course the drupal_add_js() cannot render from the cached version!
Do you have a preference on how you add javascript, I assume you did not mean drupal_add_js, for non hook_filter modules, of course it works, but not with hook_filter (the point of the module.)
See:
http://mostrey.be/hookfilter-versus-drupaladdjs
http://drupal.org/update/modules/6/7#attached_js
Cheers,
~Darrell
Comment #26
darrell_ulm commentedSorry to bump this back to you, fixed most of the issues, but because you are asking me to use drupal_add_js() within hook_filter(), that just isn't going to work because of the processing order.
See my prior comment.
http://drupal.org/node/1387232#comment-5593036
So I had to fix what I could and sorry, had to pass it back until I get advisement on the drupal_add_js() request. Yes, works well everywhere, not inside hook_filter. I can just take the JavaScript out if Drupal cannot handle adding JavaScript from a filter.
Request to please advise on drupal_add_js() so I can continue.
Thanks again.
Comment #27
elc commentedre: that javascript
After looking at what it is and asking for some advice about it, here's MESHO on the subject ;)
There are two parts to the javascript for a book; a file which is pulled in from google -
define('GOOGLE_BOOK_EXTERN_JS', 'https://www.google.com/jsapi');, and a dynamic chunk of script based on the ISBN of the book.The file from google should be included on any page that needs it - teaser or full node display, or random entity. Due to that being stupendously hard to figure out, just always add it during hook_init() with drupal_add_js().
The dynamic piece of script is entirely based on the exact entry of text being replace, it should remain there as inline javascript. There is no way to add it to the top of the page without ruining caching and generally getting in the way.
Comment #28
darrell_ulm commented@ELC, thanks for verifying this. I have been looking for a better way to do this in Drupal, and everywhere else drupal_add_js() works pretty well. I was hoping not to add anything globally, as it would be nice to only put it on the needed pages, but that does seem to be pretty tricky.
Again, thanks for the feedback, will munch away at the code when time permits again.
Yep, just verified hook_init() works as stated; hook_init() is all pervasive.
Now working on the theme functions and better pre-processing. This process is good and will produce a better module. My hope is that people who post book information find it useful, so polish can only help.
Thanks again.
Comment #29
darrell_ulm commentedklausi & ELC,
OK, below I go through each point.
Removed.
manual review:
Crossed out each one completed.
"'#default_value' => isset($filter->settings['googlebook_link']['worldcat']) ? check_plain(...": The form API will run check_plain() on #default_value, so you should not use check_plain() here. Double escaping is bad.Yes.function doc blocks: The first line e.g. "Implements: googlebook_filter_info()" does not contain any information. You are just repeating the function name here. The first line should contain the short description, see http://drupal.org/node/1354#functionsMissed that one."array_walk($params, create_function('&$val', '$val = trim($val);'));": why can't you use $params = array_map('trim', $params); ?Good Point!googlebook.tpl.php: a template file should be HTML code that has PHP code snippets embedded, not the other way around. So you would not need all that print statements. On the other hand, if there is more theming logic than HTML code you should consider using a theme function instead.Cleaned template file up and added theme function for Biblio fields."htmlentities($info_link)": you should use check_url() here instead. Even better: use the l() function to generate link markup and read its documentation, it will sanitize things for you if you want.Updated.$html_coverimage: do not create the image markup yourself, use theme('image', ...) instead.Done.Do not embed javascript yourself in the HTML output, use drupal_add_js() instead. This is required so that Drupal is able to aggregate javascript, other modules could alter it, etc.Handled this as advised in above comments.Also added googlebook.css as starting place for styling displayed book data. Added the CSS file also through the hook_init() like the global JavaScript.
Klausi & ELC, thanks again for review, very instructive and very good to clean up the templates whenever possible.
-Darrell Ulm
Comment #29.0
darrell_ulm commentedChanged bracket notation.
Comment #30
darrell_ulm commentedReviews of other projects
http://drupal.org/node/1400086#comment-5590504
http://drupal.org/node/1423362#comment-5624952
http://drupal.org/node/1416752#comment-5624916
http://drupal.org/node/1390218#comment-5624884
Comment #31
jordojuice commentedCorrect me if I'm wrong: shouldn't
googlebookbegoogle_bookandgooglebookapibegoogle_book_api?Comment #32
jordojuice commentedI won't set it to needs review because I just glanced at the code, but I found this line in
googlebookapi.module277 drupal_set_message($message = t('Googlebooks: Could not retrieve data from google.com. @err', array('@err' => check_plain($url_data->error))), $type = 'error');Using the
@errwill already ensure that the string is passed throughcheck_plain(), and assigning the$messagevariable is kind of pointless.Comment #33
elc commentedLooks good, however you have processing and logic in the template file and template function. The theme functions are meant to only be printing out things that have been completely prepared already. Or looping through and array of completely prepared stuff, or conditionally including wrapper divs around prepared stuff.
In googlebook.tpl.php, the call to theme('image') and theme('googlebookbiblio') should have already been done in the preprocess funtion and their output should simply be "print $whatever;", or "if ($whatever) .. etc." Or if you setup render arrays in the preprocess function, if ($whatver) drupal_render($whatever).
http://drupal.org/node/223430
Please note that full render arrays for everything is new to Drupal 7 and so not many modules will have this implemented.
Still back on needs work because of the logic in themes.
Comment #34
darrell_ulm commentedOK, this makes sense and proved easy and sensible enough.
This is done and now I cleaned up the large function in googlebook.module to separate it into function in a more sensible way and put the data setup in the theme pre-process function.
I won't set it to needs review because I just glanced at the code, but I found this line in googlebookapi.module277 drupal_set_message($message = t('Googlebooks: Could not retrieve data from google.com. @err', array('@err' => check_plain($url_data->error))), $type = 'error');
Using the @err will already ensure that the string is passed through check_plain(), and assigning the $message variable is kind of pointless.
Fixed
Working on: from: http://drupal.org/node/1387232#comment-5630260
Correct me if I'm wrong: shouldn't googlebook be google_book and googlebookapi be google_book_api?
Comment #35
darrell_ulm commentedOK, made all changes as indicated in:
And, added 1 space in the CSS file to pass the code formatting style guide.
Comment #36
klausimanual review:
Otherwise this looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #37
darrell_ulm commentedAdded documentation as per:
http://drupal.org/comment/reply/1387232/5660790#comment-5660790
Documentation changes committed.
Comment #37.0
darrell_ulm commentedPAReview: review bonus
updates
Comment #38
darrell_ulm commentedNew: Below reviews: On Feb 29th, 2012
http://drupal.org/node/1426386#comment-5670738
http://drupal.org/node/1431424#comment-5670808
http://drupal.org/node/1399684#comment-5671004
http://drupal.org/node/1281690#comment-5671138
http://drupal.org/node/1447752#comment-5671246
Comment #39
patrickd commentedyour application was already RTBC, read about the workflow of applications.
Comment #40
darrell_ulm commented@patrickd
Right. I made the changes as in:
http://drupal.org/node/1387232#comment-5664900
and from the description assumed it needed to be reviewed again.
Thanks for the information.
Comment #41
elc commentedThanks for your contribution, Darrell! Welcome to the community of project contributors on drupal.org.
I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process (as you have). Please consider reviewing (more) other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
That last paragraph seems like it might need a different template for people who have actually participated in the review process ;)
Comment #42
darrell_ulm commentedGreat, thanks for the review.
It is a good process and worth going through.
Cheers,
Comment #42.0
darrell_ulm commentedNew: Below reviews: On Feb 29th, 2012
http://drupal.org/node/1426386#comment-5670738
http://drupal.org/node/1431424#comment-5670808
http://drupal.org/node/1399684#comment-5671004
http://drupal.org/node/1281690#comment-5671138
http://drupal.org/node/1447752#comment-5671246
Comment #43.0
(not verified) commentedInserted link to full module node at http://drupal.org/project/google_books