Weather plug-in

19th Jan 2006 Danny
I've got a plugin started for adding weather information to the b2evolution sidebar. It might be of interest to sites that are focused on a single location. I maintain the website for a local newspaper and this is one of the features that b2evo needs before I can migrate the site from PostNuke to b2evolution. If you think this might be something to offer on AM, then let me know what it needs to have. Right now it displays current temp, icon, today's high, today's low and a link to the Weather.com 10-day forecast for the location. But Weather.com's xml feed provides all kinds of information, so the sky's the limit. Params in the skin can set all sorts of things, including the location ID and measurement units (standard or metric). You can take a look at it here.

geekI couldn't resist trying this out

PS. Is this the right place to propose stuff like this, or should I just send an email?
Todo:
  1. Finish the backoffice part so that a site that only wants one set of weather settings can just store them in the database. If other blogs on the site want different settings, they can be done in the skin. Maybe the backoffice page can take their settings via a form, and generate the code they need to paste into the skin.
  2. Edit: Done. This can all be done in the backoffice now.
  3. Set up some kind of caching.EDIT: Done. My plugin now caches to the database.
Edit: I've got things working fairly well now. I haven't progressed much as far as the front end presentation, but everything under the hood works fine. Now it's just a matter of making the data presentation more interesting and flexible. Get the file here: weatherplugin.zip.
 
 
 
 

Comments

Anonymous
19th Jan 2006
Danny ... yes, yes and more yes! (been on my to-do list)

Note to self ... redo the sideGeek toolbar (cause the skin folder has been renamed) EDIT: Done (and killed the PZ2 ALT-button to keep blabba happy) ;)

Danny - COOL! (I've been wanting a customized php weather thing for some time ... got several scripts, but just no time to do anything with it).

ULTIMATELY ... for [OUR] site, I want to customize the graphics and do something like HERE ... click the graphic and you can see they've built a bunch of branches to display custom graphics ... depending on weather. Cool! (My problem, besides lack of TIME ... is that I can only draw stick figures like a 5-year old ... Alex is rapidly gaining on me!! ACK!)

for the [PLUGIN] ... maybe we can think about using Some of these icons

and wrap them up into some nice looking graphic to include for the sidebar like this or summat like it.

(You can see I've given this some thought?)

-stk
 
Anonymous
19th Jan 2006
Danny,

I didn't see your link (was so excited by a weather plugin that i just started typing) Ack!

What you have done looks really good. For us (In Celcius Canada with Farenheit Readers) ... would be good to have something stored to the cookie so vistors could select F/C the way THEY want ... rather than the way WE want. (Dunno if cookie is best, but would be persistent). Something that allowed visitors to select what they want and then always get what they selected ... sounds like chocolate chip to me.

Looks like you have most of the coding part down, but I have a bunch of links saved ... for when I was to get started on it ... do you want those (maybe one will incorporate some idea that you hadn't thought of or a neat feature?) Lemme know.

I still like the idea of a graphic behind it to give it some "style" ... for a couple reasons ..

1) can be made "blandish" to fit into a lot of sites.

2) *might* even be made to be customizable in the CSS (or user-made background image?) if done right (just a thought, haven't explored)

3) might lead to some $$ if some business site wanted to customize the graphic for their needs.

4) Could also be a way to advertise AM! ? (if have made by am or summat and a imageMap) ... dunno, might be "tacky" ... still (as Yabba says, "links are links")

Note to self: Still thinking about a "enhanced by AM!" logo for next or on top of a b2evo logo (like a shortcut arrow).

I also like the idea of displaying MORE information on hover (using a CSS pop-up technique ... like the geek dude) AND then linking (like you did) the extended forecast page as an external link to the whole image.

(MIGHT need to find other feeds for better International coverage?? Dunno ... Does the place your using have intl airport code capability?)

Email is good ... never collaborated before using a blog (would think forum better, but we can try this, see how it works ... NOTE TO YABBA ... "super blog" ... nudge, nudge).

ARe you up to speed on Yabbas new AM backoffice plug-ins updater and management tools? (He's really a ace programmer and I think that AM! is really gonna rock because of it!)

ALSO ... Try our new search!

search for "code plugin" ... see the highlights?

now try "http" ...
[mind the double statement ... we're working on that] then but then try it on your own site lol ... get returns?

b2evo has always returned false positives (they find stuff INSIDE html tags) yuck. Never noticed till we highlighted. AND we FIXED IT without hacking the code!! Do we rock or what?

-stk
 
Anonymous
20th Jan 2006
Great, I'm glad I won't be the only one interested in this. And that gives me some direction, too. The graphic that all hook together on that news site are very nice. I've never seen anything quite like that. I've seen the page with all the different icon sets. It souldn't be too hard to swap in icon sets. Weather.com just has their icons numbered (1.png, 2.png, etc) and the xml returns an icon number. So, any icon sets that match that numbering scheme can be dropped in and should work fine. I like the other one, too. Is that a Wordpress plugin or just a standalone script? I'll download it and take a look. I like the idea of caching in the database. Then the user doesn't have to mess with chmodding a cache dir.

We could set a cookie for the unit of measure people want. Unless someone wants oatmeal cookies. I can't abide that. If you've got more links, send them my way. I'll look into the css hover tricks, that's a good idea. I think weather.com has pretty good international support. If there's something better, then I'll switch, but I haven't looked into it much. The only other service like this I ran across was something from the US government. That probably wouldn't have good international support. It's hard to get the people in Washington to even admit that there are other countries. But weather.com has their own codes for cities. I'll have to build something into the backoffice that lets the user search by name, then saves the valid city id for them.

I read the post about the updating system. Sounds very handy. The General might try to talk you into donating that code to the central plugin and skin repositories.

Search highlighting looks great. Format is customizable in css, very nice. I guess the user just drops the code at the bottom of their main css file when they install? It would be nice if there were an easy way to put css code in a plugin and have it available to all b2evo skins (for the people who don't want to customize it and don't want to have to edit every skin). I guess you could use a skin tag and put it in the , but that still requires editing the _main.php file.

Anyway, you've given me some good direction on the weather plugin. I'll work on that some more.
 
Anonymous
20th Jan 2006
Danny,

Oh ... for the mother of all customized weather script, you should check out This Blog. He's taken the Channel 6 thing and greatly expanded on it, making it his site header and overlapping images. It is a piece of art. (Some people have too much talent. And to think he stopped blogging ... blah!) Make sure to check out "the panorama info" tab in the lower right of the header AND use FireFox ... can PAN the panorama". ;)

(Note to self: allow in comments for this site ... at least for members at the min, pref the world, who knows what good link we'll get ... tho I hear yabba saying ... or what spammy link).

Another thought ... with icons, might be to have a plugin setting that chooses several backgrounds (colors and/or styles) and maybe 2 or 3 icon sets. Or ... at the minimum ... 2 background/icon combinations. (i.e., one that works on sites with dark backgrounds and one that works with sites having white or light-colored backgrounds).

The gif can be renamed to match whatever scheme is required, no problem there.

I haven't really looked into the various services that offer weather, but since I looked into to it "a tad", I've come to realize that most major international airports collect and make their data available. So finding a feed *might* not be that difficult. (I believe that the location you're using throws out a pop-up ad when you click for an extended forecast). It would be prefereable to find a place that didn't do that, but I don't know how difficult that would be. Something to look into ... if not for that, then as a secondary place to get a weather feed IF the first site | or feed is interrupted or down.

Some of the following links you might find useful: (I've listed them all here ... just to have them all in one place):

EXAMPLE Sites:
Dunstan's Site
Channel 6 News Lawrence, KS
Mike Davidson Improving the Weather

WEATHER ICONS:
Weather Icons Update
Weather Icons Sets

MISC SCRIPT LEADS:
53x11.com Web Dev PHP Weather.com XML Parser, 1.4
cruelacid productions php realtime weather
Mattsscripts.co.uk - the ultimate free script archive
Ravis 2004 PHP Weather Script
Woody's PHP Scripts
Collin Grady » PHP Weather
Displaying weather on your Web site with PHP
Jeremiah's PHP Weather Hack
PHP Weather - SourceForge Download < -- I didn't get it to work, but look below ... works (or did for me)
PHP Weather
Hmmm ... look here ->National Weather Service ... Internet Weather Source (Ad-free AND International data ;) )
PHP Weather ... INFO ... might find this helpful ..

There you go. Those were all the leads I linked. I haven't gone through them in a while, but some are more promising than others. Have a look. Hopefully you'll get some ideas or script snippets or something useful.

Cheers! -stk


 
Anonymous
20th Jan 2006
Hi Danny,
Lol, now that I know where your dev blog is I can spam yah :p

Nice work with the plugin (lol, knew you'd make Scott happy with that one), the geeky geezer's cool isn't he ;) It looks like you two have pretty much covered all of options.

EDIT: Done (and killed the PZ2 ALT-button to keep blabba happy) ;)

Lol, cheers ;)

"super blog" - lol, sheesh *salutes* yes SIR :|
That'll take quite a tad of work and I was waiting until you had a bunch of fluffy shit to do so I'd get peace and quiet to code :|

The General might try to talk you into donating that code to the central plugin and skin repositories.

Lol, funnily enough, I've actually put some thought into a "global list" plugin (basically grabs and caches lists from registered developers) which I'm sure he'd find far more useful ;)

Scott, we can add whatever html tags we want to comments (without hacking _formatting.php cos we is cool ;) ), give me a list of the ones you want and I'll sort it out (I'll add <a> now) ;)

I was also thinking of making some of the renderers work with comments (bbcode, code, smilies etc), the code plugin would be a tad of a bitch to amend ( it has to grab content before b2evo and our form fields have random names ), but it should all be achievable.

Have fun
¥
 
Anonymous
20th Jan 2006
Ok, I read through all of those links, and here's what I found about choosing a service. There are three options, as far as I can tell.
  1. Weather.com - It's pretty simple to put together a request url and then parse the xml response. But they do have annoying ads. I opened IE, turned off the pop-up blocker and browsed around their site. I was annoyed, but at least I know where to find a date should I ever need one. I don't really want to support a site that uses pop-up ads. They're just using the information from the government, so with them, I'm paying for it twice. Once in tax dollars and once in ads. The only way I would use them is if I removed all links to their site. And that violates their terms for the service, so why bother?

  2. NOAA's METAR conditions - Returns something like this, which you then have to parse. Kind of clunky. And it's only current conditions.

  3. NOAA's xml feeds - No ads, forecasts and all kinds of information. Uses SOAP, which I know nothing about. Looks more complicated in general.

Most of the scripts I've seen so far use either 1 or 2 above. I don't really like either of them. What's I've seen of 3 looks pretty difficult to use. I'm going to read the documentation for it and see if it scares me off.

We can't really deal with graphics until the service stuff is all set up, but I like your ideas. They're ambitious.
 
Anonymous
20th Jan 2006
From what I've read about SOAP so far, it looks way to complicated to use for this, it requires a code library like NuSOAP to be included, which means it's harder to make it as portable as a plugin needs to be. NOAA has another xml service that just returns a simple xml file of current conditions, but it's US only, and not even very many cites in the US. Weather.com is looking better all the time. I'm at a loss here. What do you two think?
 
Anonymous
21st Jan 2006
Test.php

;)

¥
 
Anonymous
21st Jan 2006
Looks nice. Can I take a look at the source code?
 
Anonymous
21st Jan 2006
Hi Danny,
Sorry, had a tad of a busy day so this is the first chance I've had to reply.

At the moment the code just page scrapes weather.msn.com to extract the whole table ( your weather is from http://weather.msn.com/local.aspx?wealocations=wc:USMO0001 ).

It really is just a simple fopen() + grab relevant segment of page. When I next get chance I'll try and improve it so that it just grabs the relevant data instead, which you can then manipulate as desired.

The current code can be found here (that reminds me, I really need to set you up an ftp account, if you email me your choice of user/pwd I'll get it done).

¥
 
Anonymous
27th Jan 2006
You still have the page that demo's the latest version?
 
Anonymous
27th Jan 2006
Yes, it's still running on my dev blog. But most of the changes I've made have been in the backoffice. You can grab the file and install it if you want to take a look. Link is up in the original post. It's one plugin file, plus a bunch of icons. Just drop the file and the weather folder into the plugins dir and install. Uncomment the section called "What the cache dragged in" to see a print_r of the weather data array. That will give you an idea about the kinds of data that can still be added.
 
Anonymous
27th Jan 2006
Sheesh, give a guy ftp access and he still makes yah do the work of uploading :|

I'm afraid the weather plugin doesn't work properly on this version (1.7 cvs, which is a tad behind 1.7 beta) because it doesn't trigger the install/uninstall events required. However, based on your dev blog it's looking good and I can't wait to see the admin area in action :D

If you want it to work with the update manager then you need to add this line to your vars section :-

/* internal */
var $am_plugin_details = array( 'name' =>'am_weather', 'version' => '.5' );

and then add this function anywhere before the end of the class :-

function am_update( & $params ){ $params = $this->am_plugin_details; }

Also, do you want to release this via AM or via your own site with a copy on AM ?

If you want to release it via AM do you mind if I rename it (and change help link inside to point to "release post" once written) to bring it in line with our other plugins? Full credit will obviously be given in "release post" and in the code.

Typically our plugins have something like this in them :-

* @package plugins
*
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author Yabba - {@link http://www.astonishme.co.uk/}
* @author Stk - {@link http://www.astonishme.co.uk/}
*
* @version $Id: _am_code.plugin.php,v 1.00 Exp $
*/
if( !defined('EVO_CONFIG_LOADED') ) die( 'Please, do not access this page directly.' );

/**
* Code Plugin
*
* @package plugins
*/

class am_code_plugin extends Plugin
{
var $name = 'AM Code';
var $code = 'am_code';
var $priority = 100;
var $version = 'CVS $Revision: 1.00 $';
var $author = 'Astonish Me';
var $help_url = 'http://www.astonishme.co.uk/';

the @author & @link would obviously be you and your blog, and the posting on AM would reflect that you are the coder (you can even write the fluff if you want ;) )

Anyway, just let me know, and we'll make it as you want it.

¥
 
Anonymous
27th Jan 2006
I would have installed it, but I'm having trouble logging in with my ftp client on my Mac (CyberDuck is the client). I can log in from the command line, but not the gui. It errors out when trying to list the dir. Also, I wasn't sure if you wanted me installing stuff. Next time I will. No Install and Uninstall events, eh? What, are you guys in the stone age? I hope they don't pull those events before release. They're so nice. I emailed some login info so you can try it out on my site. I'm open to changing the name and distributing it through AM. We can fix it up with all that code before release. I've already got some of the documentation written. You'll see it when you log in.
 
Anonymous
28th Jan 2006
Lol, hey we like the stone age :|

I shouldn't imagine they'll get rid of the install/uninstall events, as you say they're far to usefull.

The admin area looks great, I'm sure people are going to love this one ;)

¥
 
 

Recent Comments

     
     

    Archives