Description
Noty_messages implements Noty Library inside of the Drupal system, allowing the user to overtake some or all messages and display them similar to the growl messaging system. Normally it was meant for JQuery 1.7, but I wrote an addon to be able to use it with older jquery versions.
Similar Projects
There are no other modules for drupal that allow to use this specific library. A full project has been started by iler but he has graciously agreed to let me go through the review process in order to become a vetted user and has been added as the maintainer to this project instead.
However, there are similar modules that implement this kind of functionality:
Purr Messages
Besides implementing a different library, this module does not provide the per - message type flexibility that this module does. It also provides rules integration which is on the roadmap for this module. It also does not use the queue or or delay systems in jQuery. Furthermore, there is no capability to provide custom buttons or callbacks (which while undocumented at the moment is possible to do in this module). I really like this module and believe it be a strong solution, however this module implements a different solution to a similar problem.
Growl Notify
I did not do heavy research into this module's code, but it does rely heavily on notifications modules and messaging modules which is different than what this module is working to accomplish. Also there is no Drupal 7 Port.
jGrowl
This implements the jGrowl library which is also a different beast. There is also no Drupal 7 port at the moment.
Better Messages
I saved the best for last. This module also does not implement the noty library, but is a worthy competitor indeed. The same level of customization can be achieved and you can even alter the template files. However, this library uses php templating for theming the messages which makes it much more robust. In noty messages, all the theming is done with CSS and the variables are passed directly through the message. PHP's involvement ends after the scripts are on the page which makes the messages much more flexible and callable. There are much more differences here, and I truly do not consider this module to be in the same category. Also there's no stable Drupal 7 Port.
Review Bonus
Run 1
Run 2
Project Links
Sandbox
git repository viewer: http://drupalcode.org/sandbox/MrMaksimize/1449608.git
git clone url: http://git.drupal.org/sandbox/MrMaksimize/1449608.git
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | changes.patch | 27.41 KB | MrMaksimize |
| #33 | noty_messages_settings_form.patch | 1.25 KB | MrMaksimize |
| Screen shot 2012-03-31 at 10.23.59 PM.png | 160.91 KB | MrMaksimize |
Comments
Comment #1
chi commented[EDIT] Oops, It seems I cloned default branch.
Comment #2
chi commentedThere are some issues you can work:
http://ventral.org/pareview/httpgitdrupalorgsandboxmrmaksimize1449608git
I think it's a not good idea to check libraries for every message. Use hook_system_requirements() instead.
dependencies[] = ctoolsPlease clarify me by which way it used in your module.
Comment #3
MrMaksimize commentedOh interesting.... good catch! Will fix that up...
Also, noticed that ventral is freaking out about the promise.js which is really just a small jquery port and has already been merged into noty. I think i'll just dump it from the repo
As for ctools, you're absolutely right - it's not being used and that dep is going away. I think i just put it there because I was working with js and *thought* I would use it :)
One other thing - do you have any idea what this means? +12: [critical] Potential problem: drupal_set_message() only accepts filtered text, be sure all !placeholders for $variables in t() are fully sanitized using check_plain(), filter_xss() or similar.
this is the line it's talking about:
drupal_set_message(t('Please install noty library'), $type = 'warning');
Comment #4
MrMaksimize commentedYay!! Good call on hook_requirements. I always wondered how that was being done. pushed up a fix.
This is the only thing left in ventral
I'm not sure how to fix either one of those. The related lines are:
and
Comment #5
chi commentedAs stated in documentation hook_system_requirements() should be placed in module_name.install file.
Comment #6
chi commentedIt looks as $type variable is not used.
Comment #7
chi commentedAs ucfirst() is not multibyte-compatible Drupal has custom implementations of the function.
drupal_ucfirst()
Comment #8
patrickd commented@Chi, thanks for your help, but would you mind to edit your last comments instead of posting a new one for every issue you find? (Just for readability) ;-)
Comment #9
christianchristensen commentedThis looks like a really useful module - I would love to start using this in place of something like Better Messages as this certainly seems to provide more visual configuration options and a "more current" UI. Very neat!
Comment #10
iler commentedChanging status as these things seem to be fixed.
Comment #11
MrMaksimize commentedD'oh. Late night coding = i thought the docs said NOT to put it into the install file. /me slaps self with fish. Thanks @iler for fixing that up!
Comment #12
targoo commentedHi
1) noty_messages.admin.inc
You can use $form['#attached']['js'] instead of drupal_add_js() in your forms (like noty_messages_admin_settings) so others can easily manipulate it.
2) noty_messages.admin.inc
t() should not contain tags.
http://drupal.org/node/322731
3) noty_messages.admin.inc
Do you always need the variable $disabled in noty_messages_admin_settings ? If the js is not present you will not display some of these fields anyway ? And in 'noty_messages_generate_settings_form' it seems $disabled is always FALSE ?
I will leave it to needs review as I didn't spot anything critical so you can get other reviews. But we do really need more hands in the application queue and it is highly recommend to get a review bonus so we will come back to your application sooner.
Check : http://drupal.org/node/1011698
See also #1410826: [META] Review bonus
Thanks,
Comment #13
MrMaksimize commented@targoo
Thanks for the review! The last commit fixes all the issues you mentioned above. Good call on the disabled - that was left over from before I discovered states :) I was thinking at first of using it to control which menu items would be disabled, but it feels more like a UI hassle than help.
I also will get on reviewing some other people's stuff :)
Comment #14
chi commentedComment #15
MrMaksimize commentedHi Chi!
Thanks for the thoroughness. To answer your questions:
$config_keys[$value] = variable_get('noty_messages_' . $value, _noty_messages_get_default($message_types, constant(strtoupper('noty_' . $value))));that uses the constants. And there are numerous functions calling back to this one.$custom_css = noty_messages_get_custom_css(TRUE);custom_css is used as a css override as needed and gets put into drupal_add_css()empty()usage if just something I'm used to using to do what I believe are safe checks with booleans. I had bad experience with !$variable checks before. Unless it's a performance issue or a code standards issue that I'm not aware of, I'd like to keep the emptysWhew that was long :)
Comment #16
MrMaksimize commentedJust pushed up a fix for that hook help :)
Comment #17
MrMaksimize commentedForgot to set needs review
Comment #17.0
MrMaksimize commentedAdded a space
Comment #17.1
MrMaksimize commentedAdding one project for review bonus
Comment #18
chi commentedI mean noty_messages_admin_settings(). I cannot find $admin variable within the function. Here is the code.
There is another unused variable $themelayer inside noty_messages_messages_setup():
$custom_css = noty_messages_get_custom_css($themelayer = TRUE);Always check $is_noty in noty_messages_type() it seems that the variable will never change. $message_types in noty_messages_settings_reset() seems as unused.
There are no any reasons to use empty() if you are sure that a variable is set and it can be evaluated to TRUE or FALSE.
Here some other examples:
There is a lot of such similar micro issues in your code. It isn't a performance issue or a code standards issue it just makes your code clear and unambiguous.
Comment #19
pdrake commentedI would not recommend changing from strstr() to preg_match() for performance reasons, though switching to strpos() would be advisable (see the note on http://www.php.net/manual/en/function.strstr.php).
Comment #20
chi commentedI got about 0.03 ms. It's too little to take into account (especially in Drupal).
But actually it doesn't matter what are you using preg_match or strpos. I just pointed on code style.
Comment #21
MrMaksimize commented@Chi @pdrake,
Thanks again for taking the time to review and post here guys :) Much appreciated.
I found a nice set of performance tests for functions here, and made some decisions based off of this:
for the strpos/strstr/preg_match dilemma, the devel_check now looks like this:
The reason is strpos is acting weird within an OR statement like this (returning BOOL 0), preg_match would be too much of a performance hit, and strstr seems like a nice compromise
I've gotten rid of all the function($var=something) calls I could find, that's a great point, although if the goal is to improve readability leaving them may be better. But no use taking up a pointer if the variable isn't reused (yes I do write some objective c :))
I've also cleaned up the micro issues I could find in my code, and followed @Chi's suggestions.
However, I still have a major problem switching from empty(); I don't think it cleans up the code, I actually think it improves readability, and seems to be a small performance win for undefined variables. (but a minor 2ms loss for false / true, but I'd rather be safe than sorry).
Pushing up latest and running through ventral - http://ventral.org/pareview/httpgitdrupalorgsandboxmrmaksimize1449608git. Setting to needs review :)
Comment #22
chi commentedWhat about $is_noty variable in this function? It seems that the variable will never change.
Also did not found by which way $messages parameter is used.
Sometimes it is good practice to pre-initialize your arrays when applicable so you don't accidentally populate data to an existing array with the same name defined elsewhere in the code. I didn't find any information about it in Drupal code standards but core modules don't use this practice. See node_block_info() for example.
Take look at the noty_messages_status_messages() seems as $output was initialized twice. Also check $noty_out that seems to be unused.
There is discussion about deletion of variables prefixed with your module's name.
http://drupal.stackexchange.com/a/2476/432
Comment #23
MrMaksimize commented@Chi if didn't know better, I'd say you have an automated tool I don't know about :p
Removed is_noty variable and $messages from noty_messages_type();
Cleaned up noty_messages_status_messages from unneeded variables and functions
Cleaned up hook_uninstall
RE: Deleting variables - great point! And I didn't even think about that, but I'm already implementing that kind of functionality. By iterating only through the return of _noty_messages_get_config, I'm limiting the deletion only to my modules' variables.
As for initializing arrays, I think I'll keep them around, I do feel like it is good practice and it gives me more granular control :)
Latest fixes are up there and thanks for the review! (ventral is clean)
Comment #24
chi commentedYup, about variables you are right.
'noty_messages_' . $keyseems to be safe.Comment #25
luxpaparazzi commentedShouldn't you use http://git.drupal.org/sandbox/MrMaksimize/1449608.git as your GIT-URL?
Respect for your inline-documentation, I should probably hire your for documenting my own code ;)
I did not see any major problems, but I'll definetly correct the following:
I'll put an empty line between function calls
found before:
- before noty_messages_build_messages()
- noty_messages_generate_settings_form()
HTML should not be put into t() function:
I let the status "needs review" for other people having a look at it.
Comment #26
patrickd commentedbtw, it's kind of allowed to put a-tags this way into t() functions (just have a look at core hook_help implementations [I don't like that either])
Comment #26.0
patrickd commentedFormatting
Comment #27
MrMaksimize commented@luxpaparazzi and @patrickd, thanks for the review!
Just added the proper clone url - for some reason I thought it should point to the repo viewer. D'oh.
Also fixed spacing :)
This t() thing, seems to be weird. It was mentioned before in this comment, but then I looked up this handbook page and that's exactly what it tells people to do. I already changed one line like that, so I just made this the same. Thanks for the catch.
Also added Drupal.t to the test messages :)
And @luxpaparazzi I do love my inline docs :) Perhaps even overuse them. But if not for them, I wouldn't know what half my code does lol :)
Comment #28
MrMaksimize commentedIgnore this one. I posted another review comment in the wrong issue.
Comment #28.0
MrMaksimize commentedadding proper clone url
Comment #28.1
MrMaksimize commentedAdding review bonus 2
Comment #28.2
MrMaksimize commentedMissed a tag
Comment #28.3
MrMaksimize commentedone more review
Comment #29
MrMaksimize commentedSetting tag for PARreview: review bonus
Comment #30
chi commentedI suppose that submit handler will not be executed if form validation failed.
It seems you reinvent the wheel. There is a simple drupal function which can help you add default buttons and reset module settings.
system_settings_form
I am wondering is there a real need to have "global messages settings"? I think it doesn't bring any UX profits for such simple module as noty_messages.
The same question about custom css functionality. There is a lot of ways to add custom css. Why do you want to make your own method for this?
Removal of these features make your module more maintainable.
Of course it is my subjective opinion :-)
Comment #31
MrMaksimize commented@chi
Hmm good point!! I'll check out this system_settings_form tomorrow morning - I'm pretty much brain dead for the day :) Lol love that node though - "Let's face it. You're smart, but it's really good odds that someone else in the world has tried this before, and then written it into an API." That's Drupal in a nutshell :)
OH wait, couldn't resist looking at the form. It won't do the reset though - or is there something I missed?
I do agree with you - there are multiple ways to add custom css. But the noty library provides a custom theming system which is pretty nice, and while - yes, i can write in my own css in a random file provided by this theme, consider multi - theme sites, theme switching, or say you want to have pre-defined system messages in different sections of the site (theme switching is on my todo list). I just think it gives more flexibility that way.
Global settings - also a good point, they could be removed. But as we know, Drupal can sometimes be a headache to administer. So I do wanna give the option - set it and it'll work of all of 'em, or customize it.
I don't believe removing either one would make it more maintenable, but keeping them would make it more flexible. I also want to integrate this with rules at some point at which point i think these features would come in handy :)
I mean - to be honest, I think this discussion is meta ;) It's either your subjective opinion or mine, or someone else's on the queue. And we've had quite a few people check this module out, but no one has actually used it in a production site, and the number (compared to the larger community) is small. I think the real answers to these questions will come about when there are people actually using this module and posting in the issue queues.
Comment #32
chi commentedOops, in D7 the reset button has been removed, but it is not documented yet.
#518750: Rethink the system settings form
Comment #33
MrMaksimize commentedCool cool. So I switched to system_settings_form, I'm a bit iffy though if that's a win. I added a rough patch of the last commit so you guys can see what changed.
I kept it contained so i can always just revert.
Comment #34
patrickd commentedComment #35
patrickd commentedphp = 5.1drupal7 requires 5.2, therefore senseless here'access callback' => 'user_access',this is a default value, you don't have to set it'original_status_messages'you probably should also prefix that theme function with your full module name(not tested it) but are you sure this is necessary ?
array('type' => 'setting', 'cache' => FALSE)cache key only works for added files, neither for settings nor for inline jsbut this looks all pretty good to me, we'll get this done soon ;)
I've removed the "review bonus" tag, you can add it again after 3 more reviews, remember to pick old issues first
thanks
regards
Comment #36
MrMaksimize commentedWhoa awesome patrickd! Thanks for the review!! I'm so excited!!
Just giving this a quick look (will dive in deeper tonight / tomorrow), but a few questions about your notes:
6. use the full module name when prefixing variables - would this include globals too that I define at the top of the .module file?
12. is it really necessary to reinvent the configuration system ? ^^ but okay, if you want it that way, why not - would you mind elaborating on this a bit? Is this in relation's to Chi's comment here - http://drupal.org/node/1510938#comment-5835182?
Re: review bonus - sorry about that :) I just saw the note about picking older issues on the doc page after I did the reviews. Will pick older ones next time :)
Comment #37
MrMaksimize commentedHi Patrick!!
Went through the code and made (most) of the changes:
1. RE: Namespace - I've been working on noty_messages for a while, and close to the end Iler pinged me and said he saw my project after he already created the namespace. I asked him if it would be ok if I bring him in as collaborator so I could go through code review on this module, get vetted status and have my first project up on d.o. He agreed and said he was willing to deprecate / remove the namespace in favor of this one. (Drupal community love right there!) Also, this one is a bit different (noty vs noty_messages). Lol I know it's kind of dumb, but I've been wanting to get a project on d.o for a while and if possible that's the way I'd like to go.
2. Removed php version from info file
3. Fixed README
4. Adjusted global space comments from // to /* */
5. Went through all the comments and adjusted for capitalization and fullstops.
6. Changed global defined variables to noty_messages namespace
7. Wrapped the text in t() where missed
8. Wrote a better hook_help
9. Removed access_callback key from menu item
10. Prefixed original_status_messages to be noty_messages_original_status_messages
11. Yeah the module_load_include is needed, otherwise it won't find the function :(
12. Still not sure what you mean here :)
13. Removed cache from $options array for drupal_add_js
14. Ended up removing get_custom_css. Overriding css in the theme makes sense. I'm only doing some switching for when the user picks a custom theme, otherwise, they can just put overrides into a css file like normal
15. Added configure link
16. Changed all links to noty messages into the actual repository
17. Added element validation
Comment #37.0
MrMaksimize commentedone more
Comment #37.1
MrMaksimize commentedadding another review
Comment #37.2
MrMaksimize commentedUpdated issue summary.
Comment #38
MrMaksimize commentedI updated the issue with 3 more reviews, but I got a little confused. Not sure if I should change RTBC or leave it... Doesn't say anything in the process doc about this :)
So I'll just leave the RTBC and add the tag :)
Comment #39
klausimanual review:
But that are just minor issues, so ...
Thanks for your contribution, MrMaksimize! 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. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.
Thanks to the dedicated reviewer(s) as well.
Comment #40
MrMaksimize commentedAaaah!!! Thanks klausi and all the people that took time to review!! I'm very excited and am looking forward to being a good maintainer and contributor.
Re: manual review
1. noty_messages_admin_settings(): do not check for the library here again, this should be done only once in hook_requirements().
I'm not sure what a better way would be. If I don't check for the lib, the form will show up... And I don't want people to be misled thinking they can use the functionality when the library is not in place. Should i use something like drupal_check_module instead?
2. I am doing element validation for speed and delay using element_validate_integer_positive which would set a form_error. Or would that not even let it get to the submit function anyway?
3. I checked out theme_item_list, and I saw that it wraps it in
I do want to say I've really enjoyed the review process and will probably come back to participate in the review queues. I think the process is great and on the right track. Also I think you guys are doing an amazing job, keep it up. Thanks to all the reviewers once again!!
Comment #41.0
(not verified) commentedUpdated issue summary.