Drupal 7 Module
Open Weather is a module I created to parse out the weather response from openweathermap.org. The main reason I created this was because Google had killed it's weather API, thus rendering the Google Weather module useless. This module is a nice way for users to get weather in their site now.
This module has a few nice features. First, it can handle unlimited cities for weather output. Each city will have it's own block which can be customized to show whatever weather details you see fit. You can even theme this yourself by overriding the theme that comes with the module. Second, all data is incorporated into views. This gives the developer or user the ability to show forecast data in their site, or simply display the data anyway they want. Third (currently in progress), is the ability for users of a website to have their own weather in their profile.
git clone http://git.drupal.org/sandbox/kherda/1777890.git open_weather
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | open_weather.patch | 3.22 KB | dj1999 |
| #7 | open wheather.txt | 15.96 KB | weebpal |
| #5 | open_weather.module.patch | 6.91 KB | dj1999 |
| #3 | codesniffer_openweather.txt | 38.49 KB | jvdurme |
Comments
Comment #1
jvdurme commentedHi Kherda,
the demo looks very slick. Nice!
However, your git command you posted is wrong. It asks for a password.
Please write the correct command:
git clone http://git.drupal.org/sandbox/kherda/1777890.git open_weatherI ran CodeSniffer on your files and there are still some coding issues.
They are below.Please find the report as attachment in my next comment below. I couldn't attach something here while re-editing.
You can check with CodeSniffer yourself: http://drupal.org/project/drupalcs
It is better if these code styling issues are fixed first.
The guidelines for code writing can be found here: http://drupal.org/coding-standards
cheers,
Joost
Comment #2
ankitchauhan commented@jvdurme
Please don't paste errors as comment. Attach them in a document if they are more than 20.
thanks
Comment #3
jvdurme commentedAh, ok. Sorry about that.
Kherda, find the CodeSniffer report attached to this comment.
Comment #4
kherda commentedThank you for the heads up on the Code Sniffer! I had never used that before... Everything should be up to Drupal Standards now (latest code committed).
Kevin
Comment #5
dj1999 commentedHi,
this is a very nice module, thanks!
Some challange was to start poperly working.
I do not know that just for me or not, but can't generate weather data on times what in admin form have:
2 am 5 am 8 am 11 am 2 pm 5 pm 8 pm 11 pm
I get these times :
3 am 6 am 9 am 12 pm 3 pm 6 pm 9 pm 12 am
After modify times with timezone differeces works fine.
Here a patch, maybe help somebody too.
Regards,
Joe
Comment #6
kherda commentedThanks for the patch! I had implemented it locally and tested... everything worked nicely, however I figure that since all of the data is already stored in a table using views to extract we really didn't need to confusion of an interval selection, so I removed it. This will be easier for the site admin implementing in the future. This way no one will have any timezone issues.
Comment #7
weebpal commentedHi Kevin,
Thanks for your really interesting project, I hope that will be approve early, so please update your project follow Drupal Coding Standard. And I also please to give some small note after take a look your code:
- should we add a litle validate here to skip some special cases
- Could we we use fetchField here
- Maybe "return" is useless in these situations
Hope that your project will be approved early.
Regards,
WeebPal
Comment #8
DmitriyMakeev commentedЗlease specify the requirements for the module like CURL library for PHP. I had to install it to see the module ;)
And some bugs:
1. You need to remove a master, and set the correct default branch: Setting a default branch, Moving from a master to a major version branch.
2. Please fix coding style issues detected by automated tools:
http://ventral.org/pareview/httpgitdrupalorgsandboxkherda1777890git
3. open_weather.module
Line 89: use t() for the watchdog message.
open_weather.admin.inc
Line 23: use t() for "City", "Coords"...
Line 35: use t() for 'Fahrenheit'
4. Try to not use queries like db_query("DELETE FROM {variable} WHERE name LIKE 'open_weather_%'");. Use
5. In open_weather_uninstall() function use variable_del() for each variable in case if someone accidentally call its variable starting with 'open_weather_'.
Comment #9
DmitriyMakeev commentedComment #10
kherda commentedDmitriyMakeev (and others),
Thanks for the feedback. Aside from updating the code, I also implemented some additional logic to handle unlimited cities (each with their own settings). The weather for each city can be extracted using views (custom filter operator helps you select the city you entered), or you can implement the block created for each city, which will show the current weather (which can be altered in the theme layer).
I created a few custom handlers in views, one in particular will display the correct weather image (now included with the module).
I am using one main variable now for ease of use (JSON object as the contents).
Everything is a lot cleaner and more user friendly.
I will be sure to note the need for cURL as it is required for the API.
Kevin
Comment #11
klausiSet this to "needs review" once you are ready.
We are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)
Comment #12
mariusm commentedHello,
I receive this errors
Notice: Undefined variable: blocks in open_weather_block_info() (line 536 of D:\wamp\www\testdr\sites\all\modules\openweather\open_weather.module).
Warning: Invalid argument supplied for foreach() in _block_rehash() (line 389 of D:\wamp\www\testdr\modules\block\block.module).
Thanks,
Marius
Comment #13
kherda commentedThanks Marius,
I am working on that. After the initial implementation of the module it is seeking weather that has not been returned yet. It's on my radar :) I am looking to make an update this afternoon, when I do I will post again with the updates.
Kevin
Comment #14
kherda commentedHey Everyone,
I have made some major updates to this module. The only dependency now is on the views module and out of the box each cities weather will come with it's own customizable block. To take this further, you can theme out this block if you need by copying the file in the theme dir to your themes dir. Everything is working nicely... if there any any issues, please let me know.
Kevin
Update. I just added in the ability for users to view their own weather (weather data stored in the user data object). Need to refresh this based on interval on user profile page load, but it's indeed working.
Comment #15
dj1999 commentedHere is a patch for localization.
Comment #16
kherda commentedPatch added, thanks for this!
I will be adding in metric vs imperial options sometime this week for other weather conversions (such as wind speed).
Comment #17
dj1999 commentedYes, it missed for me too. Wind data are international knot and I need them meters per second. If could set it in admin form is better than modify open-weather-block.tpl.php.
Comment #18
kherda commentedI agree. I currently have the weather format selection as an option in the admin section. I will change that to metric or imperial and the rest of the formatting will inherit the change. I will try to push this update out today. Be on the lookout.
Kevin
Comment #19
dj1999 commentedSome secure and more localization.
Because t() say:
"You should never use t() to translate variables, such as calling
t($text);
, unless the text that the variable holds has been passed through t() elsewhere (e.g., $text is one of several translated literal strings in an array)."
I do not know this is the best way, but so could translate weather text and description. If it's other way I hope drupal experts will tell us.
Sorry that code and not patch but I hacked much more the module :)
Comment #20
kherda commentedThanks for your notes. I put them in place. I also updated the format to render as imperial vs metric, which will not only alter the temperature, but also the wind speed. I made some minor adjustments to the user weather option as well.
Comment #21
r2integrated commentedWow, what a great module! Views integration is hugely useful. Overall, I think this is quite worthy to be accepted into the community. There are a few issues I've noted below:
Automated Review:
There is still a master branch, make sure to set the correct default branch: http://drupal.org/node/1659588 . Then remove the master branch, see also step 6 and 7 in http://drupal.org/node/1127732
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.
Source: http://ventral.org/pareview - PAReview.sh online service
Manual Review:
Bottom Line
Aside from a few issues, this is a very well-done module and should make it to full project status.
Comment #22
klausiClosing due to lack of activity. Feel free to reopen if you are still working on this application.
If you reopen this please keep in mind that we are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)
Comment #23
polSorry to dig up old thread, but here is a working module for OpenLayers and OpenWeatherMap: http://drupal.org/project/olowm
Comment #23.0
polUpdated git url and specific module information that has changed or been updated as I have been developing.