[dev] Update to Jonah Weather

Joe Wilson joe.wilson at mindcandy.org
Thu May 1 17:02:15 PDT 2003


The patch below does the following:

- Clean up the Weather display a bit (makes it a lot like the
InterceptWeather.com display).
- Enables radar display (although no radar sites are yet available - I am
working on getting a list)
- Adds Satellite capability (also no data, but working on it)

Sorry the diff is so long.  The weather formatting changes were pretty extensive
(in that it affected nearly every lin in that section).

Regards,

Joe

Index: jonah/lib/Jonah.php
===================================================================
RCS file: /usr/local/cvs/horde/jonah/lib/Jonah.php,v
retrieving revision 1.48
diff -r1.48 Jonah.php
97d96
<         $radar = $weather->getRadar($location);
98a98,99
> 	$html .= '<tr><td class="text">';
>         $radar = $weather->getRadar($location);
100c101
<             $html .= ' (' . Horde::link($radar, _("Radar"), 'header', '',
"window.open('" .
---
>             $html .= '<b>(' . Horde::link($radar, _("Radar"), '', '',
"window.open('" .
102,103c103,111
<                                         "status=no, resizable=yes,
location=no, scrollbars=yes, width=660, height=500'); " .
<                                         'return false;') . _("Radar") .
'</a>)';
---
>                                         "status=no, resizable=yes,
location=no, scrollbars=yes, width=800, height=600'); " .
>                                         'return false;') . _("Radar") .
'</a></b>)';
>         }
>         $satellite = $weather->getSatellite($location);
>         if ($satellite) {
>             $html .= '(<b>' . Horde::link($satellite, _("Satellite"), '', '',
"window.open('" .
>                                         $satellite . "', '_blank',
'toolbar=no, menubar=no, " .
>                                         "status=no, resizable=yes,
location=no, scrollbars=yes, width=800, height=600'); " .
>                                         'return false;') . _("Satellite") .
'</a></b>)';
105c113
<         $html = '<tr><td class="text">';
---
>         $html .= '</td></tr><tr><td class="text" align="center">';
247c255
<             $html .= '<b>' . $weather->conditions['city'];
---
>             $html .= '<b><font size="+1">' . $weather->conditions['city'];
251c259
<             $html .= $sep . $weather->conditions['country'] . '</b>';
---
>             $html .= $sep . $weather->conditions['country'] . '</font></b>';
253c261
<             $html .= $sep . $weather->conditions['state'] . '</b>';
---
>             $html .= $sep . $weather->conditions['state'] . '</font></b>';
256c264
<             $html = sprintf(_("%s at %s"), $html, strftime("%X",
strtotime($weather->conditions['date'])));
---
>             $html = sprintf(_("%s as of %s"), $html, strftime("%X",
strtotime($weather->conditions['date'])));
258c266
<         $html .= ' <br />';
---
>         $html .= '</TD></TR>';
260c268,270
<             $html .= sprintf(_("The temperature is <b>%s</b>, "),
---
> 	    $html .= '<TR><TD align="center" class="text"><style> <!-- TD.underline
{border-bottom-style: solid;border-bottom-width: 1px;border-bottom-color:
#DDDDDD;}--></style>';
> 	    $html .= '<TABLE border="0" cellpadding="5" cellspacing="0"><TR><TD
rowspan="2" valign="center"><center>';
>             $html .= sprintf(_("<font size=\"+1\"><b>%s</b></font>"),
266c276
<             $html .= sprintf(_("humidity is at %s"),
$weather->conditions['humidity'] . '% ');
---
>             $html .= sprintf(_("<TD CLASS=\"underline\"
align=\"left\"><b>Humidity</b> %s</TD>"), $weather->conditions['humidity'] . '%
');
269c279
<             $html .= _("and there is no wind measured. ");
---
>             $html .= _("<TD CLASS=\"underline\" align=\"left\"><b>Wind</b>
Calm </TD>");
272c282
<                 $html .= sprintf(_("and the wind is %s at %s. "),
---
>                 $html .= sprintf(_("<TD CLASS=\"underline\"
align=\"left\"><b>Wind</b> %s at %s </TD>"),
278c288
<                 $html .= sprintf(_("and the wind is %s. "),
$weather->conditions['windDir']);
---
>                 $html .= sprintf(_("<TD CLASS=\"underline\"
align=\"left\"><b>Wind</b> %s</TD>"), $weather->conditions['windDir']);
282c292
<             $html .= sprintf(_("It feels like %s. "),
---
>             $html .= sprintf(_("<TD CLASS=\"underline\" align=\"left\"><b>Real
Feel</b> %s</TD>"),
288c298
<             $html .= sprintf(_("Barometer shows %s. "),
---
>             $html .= sprintf(_("</TR><TR><TD align=\"left\"><b>Barometer</b>
%s</TD>"),
295c305
<             $visibility = sprintf(_("Visibility is %s"),
---
>             $visibility = sprintf(_("<b>Visibility</b> %s"),
302c312
<         $html .= $visibility;
---
>         $html .= "<TD align=\"left\">$visibility</TD>";
305c315
<                 $uv = sprintf(_("minimal %s"), $weather->conditions['uv']);
---
>                 $uv = sprintf(_("Minimal (%s)"), $weather->conditions['uv']);
307c317
<                 $uv = sprintf(_("low %s"), $weather->conditions['uv']);
---
>                 $uv = sprintf(_("Low (%s)"), $weather->conditions['uv']);
309c319
<                 $uv = sprintf(_("moderate %s"), $weather->conditions['uv']);
---
>                 $uv = sprintf(_("Moderate (%s)"), $weather->conditions['uv']);
311c321
<                 $uv = sprintf(_("high %s. Use sunscreen"),
$weather->conditions['uv']);
---
>                 $uv = sprintf(_("High (%s)"), $weather->conditions['uv']);
313c323
<                 $uv = sprintf(_("very high %s. Stay indoors"),
$weather->conditions['uv']);
---
>                 $uv = sprintf(_("Very High (%s)"),
$weather->conditions['uv']);
315c325
<             $html .= sprintf(empty($visibility) ? _("The UV index is a %s. ")
: _(" and the UV index is a %s. "), $uv);
---
>             $html .= sprintf(empty($visibility) ? _("<TD><b>UV index</b> %s
</TD>") : _("<TD align=\"left\"><b>UV Index</b> %s </TD>"), $uv);
317c327
<             $html .= '. ';
---
>             $html .= ' ';
318a329
> 	$html .= '</TR></TABLE></TD></TR><TR><TD class="text">';
Index: jonah/lib/Weather.php
===================================================================
RCS file: /usr/local/cvs/horde/jonah/lib/Weather.php,v
retrieving revision 1.9
diff -r1.9 Weather.php
92a93,106
>      * Returns a link to the stations satellite image.
>      *
>      * @access public
>      * @param string $station  The weather station id.
>      * @return string          The url for the station's satellite image.
>      */
>     function getSatellite($station)
>     {
>         if ($this->exists($station)) {
>             return $this->_stations[$station]['satellite'];
>         }
>     }
>
>     /**
Index: jonah/lib/Weather/sql.php
===================================================================
RCS file: /usr/local/cvs/horde/jonah/lib/Weather/sql.php,v
retrieving revision 1.6
diff -r1.6 sql.php
173a174,187
>      * Returns a link to the stations satellite image.
>      *
>      * @access public
>      * @param string $station  The weather station id.
>      * @return string          The url for the station's satellite image.
>      */
>     function getSatellite($station)
>     {
>         if ($this->exists($station)) {
>             return $this->_station['satellite'];
>         }
>         return '';
>     }
>     /**
182c196,198
<         /* We currently have no radar information in the sql backend. */
---
>         if ($this->exists($station)) {
>             return $this->_station['radar'];
>         }
Index: jonah/scripts/db/jonah_weather.sql
===================================================================
RCS file: /usr/local/cvs/horde/jonah/scripts/db/jonah_weather.sql,v
retrieving revision 1.2
diff -r1.2 jonah_weather.sql
13a14
>     satellite VARCHAR(255) NOT NULL DEFAULT 'graphics/noradar.jpg',


More information about the dev mailing list