Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#3834 closed enhancement (fixed)

Patches MythWeb Weather module to use new MythWeather-revamp sources

Reported by: Joe Ripley <vitaminjoe@…> Owned by: Rob Smith
Priority: major Milestone: 0.21
Component: mythweb Version: head
Severity: low Keywords: MythWeather, MythWeather-revamp
Cc: Ticket locked: no

Description

This patch can be applied to the current SVN trunk of mythweb (release 14200). It patches the module to use the new MythWeather? plugin as a data source. The patch itself is just a quick hack, and only applies to the default template, not the lite. The functions of the MythWeather? plugin that I implemented are:

Current Conditions
3 Day Forecast
6 Day Forecast
18 Hour Forecast
Animated Maps

I don't use the Static Maps or the Severe Weather Alerts, so I haven't written them yet. The Animated Maps appear in MythWeb as animated JPEG images. I accomplished this by using JavaScript? to control the pictures. It allows you to speed up/slow down the animation. I based the JavaScript? code from the code used on the Environment Canada website. Seems to work well.

The weather module stores its cached weather data in the 'cache_dir' directory, so this must exist and be writable by the HTTP daemon for the module to work.

I can post a screen shot of the module in action if anyone wants to see it.

Attachments (7)

weather.patch (21.5 KB) - added by Joe Ripley <vitaminjoe@…> 17 years ago.
Patch for MythWeb weather module. Apply to the modules/weather directory.
weather.2.patch (46.3 KB) - added by Joe Ripley <vitaminjoe@…> 17 years ago.
New patch to add MythWeather?-revamp sources to MythWeb. Includes settings component.
mythweb-mythweather-revamp.jpg (129.4 KB) - added by Joe Ripley <vitaminjoe@…> 17 years ago.
Screenshot of plugin in action
3834_diff.patch (44.2 KB) - added by Joe Ripley <vitaminjoe@…> 16 years ago.
Revised patch to allow MythWeb Weather component to use the new MythWeather? sources. Addresses issues raised by xris and also includes support for displaying static maps.
3834_diff.2.patch (44.2 KB) - added by Joe Ripley <vitaminjoe@…> 16 years ago.
Re-posting the patch to correct a couple small typos. I should really check these things out a bit more thoroughly before posting.
3834_diff.3.patch (44.2 KB) - added by Joe Ripley <vitaminjoe@…> 16 years ago.
Fixes two bugs from the previous patch: (3834_diff.2.patch). Adds <LABEL> tag for search confirmation dialog. Starts draworder at 0 instead of 1.
3834_diff.4.patch (45.4 KB) - added by Joe Ripley <vitaminjoe@…> 16 years ago.
Revised patch to fix Weather settings screen

Download all attachments as: .zip

Change History (24)

Changed 17 years ago by Joe Ripley <vitaminjoe@…>

Attachment: weather.patch added

Patch for MythWeb weather module. Apply to the modules/weather directory.

Changed 17 years ago by Joe Ripley <vitaminjoe@…>

Attachment: weather.2.patch added

New patch to add MythWeather?-revamp sources to MythWeb. Includes settings component.

comment:1 Changed 17 years ago by Joe Ripley <vitaminjoe@…>

Added revised patch to allow the MythWeb Weather module to use the new MythWeather?-revamp as a data source.

This revision allows you to (partially) configure MythWeather? via MythWeb. The settings component allows addition/deletion of screens, changing locations, changing units, re-ordering screens, etc.

Patch was produced with 'svn diff' against the latest SVN revision.

This is meant to replace the previous patch listed on this ticket.

-- Joe Ripley vitaminjoe@…

comment:2 Changed 17 years ago by Joe Ripley <vitaminjoe@…>

Woops.

The new patch I uploaded has some changes made to the mythweb/modules/_shared/lang/English.lang file that shouldn't be there. These lines crept in when I applied patch #2301 to my mythweb tree.

Sorry about that.

-- Joe Ripley vitaminjoe@…

Changed 17 years ago by Joe Ripley <vitaminjoe@…>

Screenshot of plugin in action

comment:3 Changed 16 years ago by xris

There are a handful of small broken things in the patch (mostly just rewriting the svn auto-generated headers at the top of the files).

Anyway, aside from little stuff like the fact that you have "code" in the tmpl directory (tmpl/default/set_screen.php) -- template files shouldn't call other template files other than tiny snippets, use the main module controller for that -- the settings screen doesn't actually seem to work -- no inactive screens are listed to be added to the group.

Other nitpicky things:

  • Use <label> tags (active screens)
  • use ' instead of " when there isn't any interpretation going on (I actually use them differently to tell if I should expect interpreted characters).
  • don't leave ?> at the end of files -- it leads to problematic whitespace at the end of the file that makes tracking down "output started at..." type errors.
  • Don't use \t in strings when the rest of the code is using spaces, it leads to ugly html source.

Also, what files are no longer needed as part of this?

comment:4 in reply to:  3 Changed 16 years ago by Joe Ripley <vitaminjoe@…>

Replying to xris:

There are a handful of small broken things in the patch (mostly just rewriting the svn auto-generated headers at the top of the files).

Indeed. I apologize for that, I wrote most of this patch before I understood the nuances of SVN and the protocols followed for coding stuff in Myth. I can clean that up. :)

Anyway, aside from little stuff like the fact that you have "code" in the tmpl directory (tmpl/default/set_screen.php) -- template files shouldn't call other template files other than tiny snippets, use the main module controller for that -- the settings screen doesn't actually seem to work -- no inactive screens are listed to be added to the group.

Yeah, I totally agree with you. It was just a quick and lazy way to get things to work. :) I'll definitely move the code out to the main module controller. As for the settings screen not working, that's weird (no inactive screens listed?). The inactive screens list is built by checking the database for configured sources and then only listing the screen types that you have sources for.

If you have nothing in your weathersourcesettings table, that's probably why you have no inactive screens. I'll modify the code to check for this and spit out an appropriate error, or something.

Other nitpicky things:

  • Use <label> tags (active screens)
  • use ' instead of " when there isn't any interpretation going on (I actually use them differently to tell if I should expect interpreted characters).
  • don't leave ?> at the end of files -- it leads to problematic whitespace at the end of the file that makes tracking down "output started at..." type errors.
  • Don't use \t in strings when the rest of the code is using spaces, it leads to ugly html source.

All good ideas. I will modify the patch to conform to these standards.

Also, what files are no longer needed as part of this?

From just a cursory glance, these files are not required: mythplugins/mythweb/modules/weather/accid.dat mythplugins/mythweb/modules/weather/weathertypes.dat mythplugins/mythweb/modules/weather/set_prefs.php mythplugins/mythweb/modules/weather/Forecast.php mythplugins/mythweb/modules/weather/WeatherSite.php mythplugins/mythweb/modules/weather/set_prefs.php

Thanks for all the feedback Chris. I'll get working on the updates to the patch and hopefully post a revised version shortly.

-- Joe Ripley vitaminjoe@…

comment:5 Changed 16 years ago by Joe Ripley <vitaminjoe@…>

Please ignore my stupidity in quoting the file paths. The correct paths are:

mythplugins/mythweb/modules/weather/accid.dat mythplugins/mythweb/modules/weather/weathertypes.dat mythplugins/mythweb/modules/weather/set_prefs.php mythplugins/mythweb/modules/weather/includes/objects/Forecast.php mythplugins/mythweb/modules/weather/includes/objects/WeatherSite.php mythplugins/mythweb/modules/weather/tmpl/default/set_prefs.php

-- Joe Ripley vitaminjoe@…

Changed 16 years ago by Joe Ripley <vitaminjoe@…>

Attachment: 3834_diff.patch added

Revised patch to allow MythWeb Weather component to use the new MythWeather? sources. Addresses issues raised by xris and also includes support for displaying static maps.

comment:6 Changed 16 years ago by Joe Ripley <vitaminjoe@…>

Posted new patch to address issues raised by xris. Hopefully this one will be a bit more palatable. :)

This patch also includes support for displaying Static Maps in MythWeb. On the settings page, it will now display a warning if it cannot locate any weather sources in the database.

Comments are welcome.

Thanks!

-- Joe Ripley vitaminjoe@…

comment:7 Changed 16 years ago by Joe Ripley <vitaminjoe@…>

True to form, I forgot one minor detail.

Line 21 in mythplugins/mythweb/modules/weather/set_screen.php should reference 'weathersourcesettings' instead of 'weatherscreens'. Here's a diff:

--- /usr/src/myth/mythplugins/mythweb/modules/weather/set_screen.php    2007-09-25 17:08:46.428782000 -0600
+++ ./set_screen.php    2007-09-25 17:26:04.243923748 -0600
@@ -16,9 +16,8 @@
     require_once 'includes/objects/WeatherScreen.php';

 // Load all of the known mythtv frontend hosts
-    $Settings_Hosts = array('' => t('MythWeb Session'));
     $sh = $db->query('SELECT DISTINCT hostname
-                      FROM weatherscreens
+                      FROM weathersourcesettings
                       ORDER BY hostname');
     while (list($host) = $sh->fetch_row()) {
         if (empty($host))

Sorry about that... I can re-attach the patch with this diff applied if required.

-- Joe Ripley vitaminjoe@…

comment:8 Changed 16 years ago by Joe Ripley <vitaminjoe@…>

More noise from me.. I'm sorry.

Here's the REAL diff:

--- /usr/src/myth/mythplugins/mythweb/modules/weather/set_screen.php    2007-09-25 17:08:46.428782000 -0600
+++ ./set_screen.php    2007-09-25 17:40:37.021660517 -0600
@@ -16,9 +16,9 @@
     require_once 'includes/objects/WeatherScreen.php';

 // Load all of the known mythtv frontend hosts
-    $Settings_Hosts = array('' => t('MythWeb Session'));
+    $Settings_Hosts = array();
     $sh = $db->query('SELECT DISTINCT hostname
-                      FROM weatherscreens
+                      FROM weathersourcesettings
                       ORDER BY hostname');
     while (list($host) = $sh->fetch_row()) {
         if (empty($host))

I accidentally removed an entire line when I meant to just modify it... grrr.

-- Joe Ripley vitaminjoe@…

Changed 16 years ago by Joe Ripley <vitaminjoe@…>

Attachment: 3834_diff.2.patch added

Re-posting the patch to correct a couple small typos. I should really check these things out a bit more thoroughly before posting.

Changed 16 years ago by Joe Ripley <vitaminjoe@…>

Attachment: 3834_diff.3.patch added

Fixes two bugs from the previous patch: (3834_diff.2.patch). Adds <LABEL> tag for search confirmation dialog. Starts draworder at 0 instead of 1.

comment:9 Changed 16 years ago by Joe Ripley <vitaminjoe@…>

Attached new patch (3834_diff.3.patch).

Fixes several minor bugs from the original 3834_diff.patch:

  • Initialize $Settings_Host[] array to only include hosts that have sources defined in the 'weathersourcesettings' table.
  • Fixed typo in Edit Screen search results list (stray slash)
  • Adds <LABEL> tags for search confirmation dialog
  • Starts draworder at 0 instead of 1. This bug prevented the MythWeather? plugin from properly displaying screens if all screens were defined in MythWeb.

-- Joe Ripley vitaminjoe@…

Changed 16 years ago by Joe Ripley <vitaminjoe@…>

Attachment: 3834_diff.4.patch added

Revised patch to fix Weather settings screen

comment:10 Changed 16 years ago by Joe Ripley <vitaminjoe@…>

New version of MythWeb Weather patch (3834_diff.4.patch)

This version fixes a problem in the settings screen. The settings screen tried to generate lists of 'Inactive' and 'Active' screens prior to determining the configured hostnames.

The module still requires the user to have a configured list of sources for MythWeather?. This can be easily accomplished by opening MythWeather? in mythfrontend at least once so it can scan for grabber script files.

This version also provides a bit more information on the 'Active Screens' list. It lets the user know what grabber and location is configured for each screen.

Enjoy!

-- Joe Ripley vitaminjoe@…

comment:11 Changed 16 years ago by Joe Ripley <vitaminjoe@…>

I've tested this for about a month... and it seems solid (with r15058). I noticed that it doesn't have a milestone set, so just thought I'd bring it up and see if this patch will make it in the 0.21 release. If more work is needed on it, no problem, let me know and I'll do my best. :)

As far as I know it will apply cleanly to current SVN, since the MythWeb Weather module hasn't changed in quite some time.

-- Joe Ripley vitaminjoe@…

comment:12 Changed 16 years ago by Rob Smith

Milestone: unknown0.21
Owner: changed from xris to Rob Smith
Priority: minormajor
Status: newaccepted
Version: unknownhead

comment:13 Changed 16 years ago by fred.aker@…

Is it just me or is MythWeather? broken with the recent SNVs?
This patch has been working perfectly for weeks but recently the Current Conditions works but nothing for the 3-day, 6-day, static map and animated map.

comment:14 Changed 16 years ago by anonymous

I should mention... I am refering to mythweb only. No problems with MythWeather? in Mythtv.

comment:15 in reply to:  13 Changed 16 years ago by Joe Ripley <vitaminjoe@…>

Replying to fred.aker@yahoo.ca:

Is it just me or is MythWeather? broken with the recent SNVs?
This patch has been working perfectly for weeks but recently the Current Conditions works but nothing for the 3-day, 6-day, static map and animated map.

The patch should apply cleanly to even the latest SVN release. I've been using it for quite some time with no issues (my MythWeb is at [15797]). If you want help working out the kinks, start a thread at mythtv-users@….

-- Joe Ripley vitaminjoe@…

comment:16 Changed 16 years ago by Rob Smith

Resolution: fixed
Status: acceptedclosed

(In [15881]) Fixes #3834, this adds Joe Ripleys mythweather changes. Thanks Joe. Modified a bit, so if you already have the patch applied, you might need to revert it before you can update cleanly.

comment:17 in reply to:  description Changed 16 years ago by dbackeberg@…

Yes please, I'd love to see a screenshot :) The changeable animation rate sounds great. Thanks so much for your work on this.

Replying to Joe Ripley <vitaminjoe@gmail.com>:

This patch can be applied to the current SVN trunk of mythweb (release 14200). It patches the module to use the new MythWeather? plugin as a data source. The patch itself is just a quick hack, and only applies to the default template, not the lite. The functions of the MythWeather? plugin that I implemented are:

Current Conditions
3 Day Forecast
6 Day Forecast
18 Hour Forecast
Animated Maps

I don't use the Static Maps or the Severe Weather Alerts, so I haven't written them yet. The Animated Maps appear in MythWeb as animated JPEG images. I accomplished this by using JavaScript? to control the pictures. It allows you to speed up/slow down the animation. I based the JavaScript? code from the code used on the Environment Canada website. Seems to work well.

The weather module stores its cached weather data in the 'cache_dir' directory, so this must exist and be writable by the HTTP daemon for the module to work.

I can post a screen shot of the module in action if anyone wants to see it.

Note: See TracTickets for help on using tickets.