move widget HTML into smarty3 template and update styling
This commit is contained in:
parent
02b29b2a6a
commit
f9c887e24d
|
@ -1,10 +1,7 @@
|
||||||
|
ul.curweather-details li {
|
||||||
#curtemp-settings-label, #curtemp-location-label, #curtemp-enable-label {
|
list-type: none;
|
||||||
float: left;
|
|
||||||
width: 200px;
|
|
||||||
margin-bottom: 25px;
|
|
||||||
}
|
}
|
||||||
#curtemp-network {
|
p.curweather-footer {
|
||||||
float: left;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,11 @@ function curweather_uninstall() {
|
||||||
// the caching time depending on the plans they got from openweathermap.org
|
// the caching time depending on the plans they got from openweathermap.org
|
||||||
// and the usage of the friendica temppath
|
// and the usage of the friendica temppath
|
||||||
|
|
||||||
class ExampleCache extends AbstractCache
|
class CWCache extends AbstractCache
|
||||||
{
|
{
|
||||||
private function urlToPath($url)
|
private function urlToPath($url)
|
||||||
{
|
{
|
||||||
|
// take friendicas tmp directory as base for the cache
|
||||||
$tmp = get_config('system','temppath');
|
$tmp = get_config('system','temppath');
|
||||||
$dir = $tmp . DIRECTORY_SEPARATOR . "OpenWeatherMapPHPAPI";
|
$dir = $tmp . DIRECTORY_SEPARATOR . "OpenWeatherMapPHPAPI";
|
||||||
if (!is_dir($dir)) {
|
if (!is_dir($dir)) {
|
||||||
|
@ -104,7 +105,7 @@ function curweather_network_mod_init(&$fk_app,&$b) {
|
||||||
// Get OpenWeatherMap object. Don't use caching (take a look into
|
// Get OpenWeatherMap object. Don't use caching (take a look into
|
||||||
// Example_Cache.php to see how it works).
|
// Example_Cache.php to see how it works).
|
||||||
//$owm = new OpenWeatherMap();
|
//$owm = new OpenWeatherMap();
|
||||||
$owm = new OpenWeatherMap(null, new ExampleCache(), $cachetime);
|
$owm = new OpenWeatherMap(null, new CWCache(), $cachetime);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$weather = $owm->getWeather($rpt, $units, $lang, $appid);
|
$weather = $owm->getWeather($rpt, $units, $lang, $appid);
|
||||||
|
@ -118,23 +119,29 @@ function curweather_network_mod_init(&$fk_app,&$b) {
|
||||||
$pressure = $weather->pressure;
|
$pressure = $weather->pressure;
|
||||||
$wind = $weather->wind->speed->getDescription().', '.$weather->wind->speed . " " . $weather->wind->direction;
|
$wind = $weather->wind->speed->getDescription().', '.$weather->wind->speed . " " . $weather->wind->direction;
|
||||||
$description = $weather->clouds->getDescription();
|
$description = $weather->clouds->getDescription();
|
||||||
|
$city = array(
|
||||||
|
'name'=>$weather->city->name,
|
||||||
|
'lon' =>$weather->city->lon,
|
||||||
|
'lat' =>$weather->city->lat
|
||||||
|
);
|
||||||
} catch(OWMException $e) {
|
} catch(OWMException $e) {
|
||||||
info ( 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').');
|
info ( 'OpenWeatherMap exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').');
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
info ('General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').');
|
info ('General exception: ' . $e->getMessage() . ' (Code ' . $e->getCode() . ').');
|
||||||
}
|
}
|
||||||
|
|
||||||
$curweather = '<div id="curweather-network" class="widget">
|
$t = get_markup_template("widget.tpl", "addon/curweather/" );
|
||||||
<div class="title tool">
|
$curweather = replace_macros ($t, array(
|
||||||
<h4>'.t("Current Weather").': '.$weather->city->name.'</h4></div>';
|
'$title' => t("Current Weather"),
|
||||||
|
'$city' => $city,
|
||||||
$curweather .= "$description; $temp<br />";
|
'$description' => $description,
|
||||||
$curweather .= t('Relative Humidity').": $rhumid<br />";
|
'$temp' => $temp,
|
||||||
$curweather .= t('Pressure').": $pressure<br />";
|
'$relhumidity' => array('caption'=>t('Relative Humidity'), 'val'=>$rhumid),
|
||||||
$curweather .= t('Wind').": $wind<br />";
|
'$pressure' => array('caption'=>t('Pressure'), 'val'=>$pressure),
|
||||||
$curweather .= '<span style="font-size:0.8em;">'. t('Data by').': <a href="http://openweathermap.org">OpenWeatherMap</a>. <a href="http://openweathermap.org/Maps?zoom=7&lat='.$weather->city->lat.'&lon='.$weather->city->lon.'&layers=B0FTTFF">'.t('Show on map').'</a></span>';
|
'$wind' => array('caption'=>t('Wind'), 'val'=> $wind),
|
||||||
|
'$databy' => t('Data by'),
|
||||||
$curweather .= '</div><div class="clear"></div>';
|
'$showonmap' => t('Show on map')
|
||||||
|
));
|
||||||
|
|
||||||
$fk_app->page['aside'] = $curweather.$fk_app->page['aside'];
|
$fk_app->page['aside'] = $curweather.$fk_app->page['aside'];
|
||||||
|
|
||||||
|
|
15
curweather/templates/widget.tpl
Normal file
15
curweather/templates/widget.tpl
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<div id="curweather-network" class="widget">
|
||||||
|
<div class="title tool">
|
||||||
|
<h4>{{$title}}: {{$city['name']}}</h4>
|
||||||
|
</div>
|
||||||
|
<p>{{$description}}, {{$temp}}
|
||||||
|
<ul class="curweather-details">
|
||||||
|
<li>{{$relhumidity['caption']}}: {{$relhumidity['val']}}</li>
|
||||||
|
<li>{{$pressure['caption']}}: {{$pressure['val']}}</li>
|
||||||
|
<li>{{$wind['caption']}}: {{$wind['val']}}</li>
|
||||||
|
</ul></p>
|
||||||
|
<p class="curweather-footer">
|
||||||
|
{{$databy}}: <a href="http://openweathermap.org">OpenWeatherMap</a>. <a href="http://openweathermap.org/Maps?zoom=7&lat={{$lat}}&lon={{$lon}}&layers=B0FTTFF">{{$showonmap}}</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="clear"></div>
|
Loading…
Reference in a new issue