Add high/low temps and 3-day forecast
This commit is contained in:
parent
ae2ae1ffbf
commit
48e925e242
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"Overview": "Overview",
|
"Overview": "Overview",
|
||||||
"News": "News",
|
"News": "News",
|
||||||
"Headlines": "Headlines"
|
"Headlines": "Headlines",
|
||||||
|
"Weather": "Weather"
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,7 @@
|
|||||||
"High: {temp}{units}": "High: {temp}{units}",
|
"High: {temp}{units}": "High: {temp}{units}",
|
||||||
"Low: {temp}{units}": "Low: {temp}{units}",
|
"Low: {temp}{units}": "Low: {temp}{units}",
|
||||||
"Temperature: {temp}{units}": "Temperature: {temp}{units}",
|
"Temperature: {temp}{units}": "Temperature: {temp}{units}",
|
||||||
"{temp}{units}": "{temp}{units}"
|
"{temp}{units}": "{temp}{units}",
|
||||||
|
"{tempLow} to {tempHigh}{units}": "{tempLow} to {tempHigh}{units}",
|
||||||
|
"Low: {tempLow}{units} High: {tempHigh}{units}": "Low: {tempLow}{units} | High: {tempHigh}{units}"
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,35 @@ class Weather_DarkSky extends Weather {
|
|||||||
$currently->windBearing = $resp->currently->windBearing;
|
$currently->windBearing = $resp->currently->windBearing;
|
||||||
|
|
||||||
$this->setCurrently($currently);
|
$this->setCurrently($currently);
|
||||||
|
|
||||||
|
foreach ($resp->daily->data as $day) {
|
||||||
|
$daily = new Conditions();
|
||||||
|
|
||||||
|
$daily->lat = $this->lat;
|
||||||
|
$daily->lng = $this->lng;
|
||||||
|
$daily->time = $day->time;
|
||||||
|
|
||||||
|
$daily->summary = $day->summary;
|
||||||
|
$daily->setDayorNight();
|
||||||
|
|
||||||
|
$daily->tempHigh = $day->temperatureMax;
|
||||||
|
$daily->tempLow = $day->temperatureMin;
|
||||||
|
|
||||||
|
$daily->precipProbability = $day->precipProbability;
|
||||||
|
|
||||||
|
$daily->ozone = $day->ozone;
|
||||||
|
$daily->dewpoint = $day->dewPoint;
|
||||||
|
$daily->cloudCover = $day->cloudCover;
|
||||||
|
$daily->humidity = $day->humidity;
|
||||||
|
$daily->visibility = $day->visibility;
|
||||||
|
$daily->uvindex = $day->uvIndex;
|
||||||
|
|
||||||
|
$daily->windSpeed = $day->windSpeed;
|
||||||
|
$daily->windGust = $day->windGust;
|
||||||
|
$daily->windBearing = $day->windBearing;
|
||||||
|
|
||||||
|
$this->conditions[] = $daily;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,14 @@ define("PAGES", [
|
|||||||
"static/js/news.js"
|
"static/js/news.js"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"weather" => [
|
||||||
|
"title" => "Weather",
|
||||||
|
"navbar" => true,
|
||||||
|
"icon" => "fas fa-cloud",
|
||||||
|
"styles" => [
|
||||||
|
"static/weather-icons/css/weather-icons.min.css"
|
||||||
|
],
|
||||||
|
],
|
||||||
"404" => [
|
"404" => [
|
||||||
"title" => "404 error"
|
"title" => "404 error"
|
||||||
]
|
]
|
||||||
|
@ -33,10 +33,13 @@ foreach ($newsitems as $item) {
|
|||||||
|
|
||||||
<div class="card mb-4">
|
<div class="card mb-4">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="d-flex">
|
<div class="d-flex flex-wrap justify-content-around">
|
||||||
|
<div class="mr-4 mb-2 text-center">
|
||||||
<?php
|
<?php
|
||||||
$currently = $weather->getCurrently();
|
$currently = $weather->getCurrently();
|
||||||
|
$forecast = $weather->getForecast();
|
||||||
?>
|
?>
|
||||||
|
<div class="d-flex flex-wrap">
|
||||||
<div class="mr-4 display-4">
|
<div class="mr-4 display-4">
|
||||||
<i class="wi wi-fw <?php echo $currently->getIcon(); ?>"></i>
|
<i class="wi wi-fw <?php echo $currently->getIcon(); ?>"></i>
|
||||||
</div>
|
</div>
|
||||||
@ -45,6 +48,60 @@ foreach ($newsitems as $item) {
|
|||||||
<h4><?php $Strings->build("{temp}{units}", ["temp" => round(Weather::convertDegCToUnits($currently->temperature, $tempunits), 1), "units" => " $degreesymbol$tempunits"]); ?></h4>
|
<h4><?php $Strings->build("{temp}{units}", ["temp" => round(Weather::convertDegCToUnits($currently->temperature, $tempunits), 1), "units" => " $degreesymbol$tempunits"]); ?></h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<p class="font-weight-bold"><?php
|
||||||
|
$Strings->build("Low: {tempLow}{units} High: {tempHigh}{units}", [
|
||||||
|
"tempLow" => round(Weather::convertDegCToUnits($forecast[0]->tempLow, $tempunits), 1),
|
||||||
|
"tempHigh" => round(Weather::convertDegCToUnits($forecast[0]->tempHigh, $tempunits), 1),
|
||||||
|
"units" => " $degreesymbol$tempunits"
|
||||||
|
]);
|
||||||
|
?></p>
|
||||||
|
<p>
|
||||||
|
<?php
|
||||||
|
echo $forecast[0]->summary;
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<?php
|
||||||
|
$i = 0;
|
||||||
|
foreach ($forecast as $day) {
|
||||||
|
if ($i == 0) {
|
||||||
|
// skip the first one since it's today
|
||||||
|
$i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($i >= 4) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
?>
|
||||||
|
<div class="col-12 col-sm-4 text-center">
|
||||||
|
<div class="h1">
|
||||||
|
<i class="wi wi-fw <?php echo $day->getIcon(); ?>"></i>
|
||||||
|
</div>
|
||||||
|
<div class="h5">
|
||||||
|
<?php echo date("l", $day->time); ?>
|
||||||
|
</div>
|
||||||
|
<p class="font-weight-bold">
|
||||||
|
<?php
|
||||||
|
$Strings->build("{tempLow} to {tempHigh}{units}", [
|
||||||
|
"tempLow" => round(Weather::convertDegCToUnits($day->tempLow, $tempunits), 1),
|
||||||
|
"tempHigh" => round(Weather::convertDegCToUnits($day->tempHigh, $tempunits), 1),
|
||||||
|
"units" => " $degreesymbol$tempunits"
|
||||||
|
]);
|
||||||
|
?>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<?php echo $day->summary; ?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer d-flex justify-content-between">
|
<div class="card-footer d-flex justify-content-between">
|
||||||
<div>
|
<div>
|
||||||
|
8
pages/weather.php
Normal file
8
pages/weather.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user