Commit d4e3c5e6 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '333-openweathermap-org' into 'development'

Die Wettersuche ist jetzt unter den Quicktips eingebaut

Closes #333

See merge request !536
parents 6e899b12 fd9ba88a
......@@ -85,8 +85,44 @@ class MetaGerSearch extends Controller
fclose($file);
}
# Wikipedia Quicktip
$quicktips = [];
# Das Wetter
try {
if (App::isLocale('en')) {
$url = "http://api.openweathermap.org/data/2.5/weather?type=like&units=metric&lang=en&q=" . urlencode($q) . "&APPID=" . getenv("openweathermap");
} else {
$url = "http://api.openweathermap.org/data/2.5/weather?type=like&units=metric&lang=de&q=" . urlencode($q) . "&APPID=" . getenv("openweathermap");
}
$result = json_decode($this->get($url), true);
$weather = [];
$weather["title"] = "Wetter in " . $result["name"];
$weather["URL"] = "http://openweathermap.org/city/" . $result["id"];
$descr = '<b class="detail-short">' . $result["main"]["temp"] . " °C, " . $result["weather"][0]["description"] . "</b>";
$details = '<table class="table table-condensed"><tr><td>Temperatur</td><td>' . $result["main"]["temp_min"] . " bis " . $result["main"]["temp_max"] . " °C</td></tr>";
$details .= "<tr><td>Druck</td><td>" . $result["main"]["pressure"] . " hPa</td></tr>";
$details .= "<tr><td>Luftfeuchtigkeit</td><td>" . $result["main"]["humidity"] . " %</td></tr>";
$details .= "<tr><td>Wind</td><td>" . $result["wind"]["speed"] . " m/s, " . $result["wind"]["deg"] . "°</td></tr>";
$details .= "<tr><td>Bewölkung</td><td>" . $result["clouds"]["all"] . " %</td></tr>";
if (isset($result->rain)) {
$details .= " | Regen letzte drei Stunden: " . $result["rain"]["3h"] . " h";
}
$details .= "</table>";
$weather["descr"] = $descr;
$weather["details"] = $details;
$weather["gefVon"] = "von <a href = \"https://openweathermap.org\" target=\"_blank\" rel=\"noopener\">Openweathermap</a>";
$requestData = [];
$requestData["url"] = "http://openweathermap.org/img/w/";
$weather["image"] = action('Pictureproxy@get', $requestData) . $result["weather"][0]["icon"] . ".png";
$weather["image-alt"] = $result["weather"][0]["main"];
$mquicktips[] = $weather;
} catch (\ErrorException $e) {
}
# Wikipedia Quicktip
if (App::isLocale('en')) {
$url = "https://en.wikipedia.org/w/api.php?action=opensearch&search=" . urlencode($q) . "&limit=1&namespace=0&format=json";
} else {
......
......@@ -6672,6 +6672,22 @@ button.close {
display: none !important;
}
}
.qtheader {
font-size: 16px;
margin: 0px;
font-weight: bold;
}
.info-details-available {
cursor: pointer;
}
.detail-short {
font-weight: bold;
font-size: 18px;
line-height: 60px;
}
.qt-icon {
height: 60px;
}
#spruch .author {
font-size: 14px;
color: #888;
......
This diff is collapsed.
//@import "./result-page.less";
@import "./quicktips.less";
#spruch .author {
......
.qtheader {
font-size: 16px;
margin: 0px;
font-weight: bold;
}
.info-details-available {
cursor: pointer;
}
.detail-short {
font-weight: bold;
font-size: 18px;
line-height: 60px;
}
.qt-icon {
height: 60px;
}
\ No newline at end of file
......@@ -9,8 +9,29 @@
@endif
@foreach( $mqs as $mq)
<div class="quicktip">
<b class="qtheader"><a href="{{ $mq['URL'] }}" target="_blank" rel="noopener">{{ $mq['title'] }}</a></b><br>
<h2 class="qtheader"><a href="{{ $mq['URL'] }}" target="_blank" rel="noopener">{{ $mq['title'] }}</a></h2>
<details>
<summary>
<div class="media">
@if( isset($mq['image']) && isset($mq['image-alt'] ))
<div class="media-left">
<img class="qt-icon" src="{!! $mq['image'] !!}" alt="{!! $mq['image-alt'] !!}">
</div>
@endif
<div class="media-body">
<div>{!! $mq['descr'] !!}</div>
</div>
@if( isset($mq['details']) )
<div class="media-right">
<span class="glyphicon glyphicon-info-sign info-details-available" aria-hidden="true"></span>
</div>
@endif
</div>
</summary>
@if( isset($mq['details']) )
{!! $mq['details'] !!}
@endif
</details>
@if( isset($mq['gefVon']) )
<div class="pull-right">{!! $mq['gefVon'] !!}</div>
@endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment