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

fixed imagesearch layout

parent 98436c52
...@@ -93,19 +93,19 @@ class MetaGer ...@@ -93,19 +93,19 @@ class MetaGer
$tmp = file_get_contents(config_path() . "/blacklistUrl.txt"); $tmp = file_get_contents(config_path() . "/blacklistUrl.txt");
$this->urlsBlacklisted = explode("\n", $tmp); $this->urlsBlacklisted = explode("\n", $tmp);
} }
# Versuchen Blacklists einzulesen # Versuchen Blacklists einzulesen
if (file_exists(config_path() . "/adBlacklistDomains.txt")) { if (file_exists(config_path() . "/adBlacklistDomains.txt")) {
$tmp = file_get_contents(config_path() . "/adBlacklistDomains.txt"); $tmp = file_get_contents(config_path() . "/adBlacklistDomains.txt");
$this->adDomainsBlacklisted = explode("\n", $tmp); $this->adDomainsBlacklisted = explode("\n", $tmp);
} }
if(file_exists(config_path() . "/adBlacklistUrl.txt")){ if (file_exists(config_path() . "/adBlacklistUrl.txt")) {
$tmp = file_get_contents(config_path() . "/adBlacklistUrl.txt"); $tmp = file_get_contents(config_path() . "/adBlacklistUrl.txt");
$this->adUrlsBlacklisted = explode("\n", $tmp); $this->adUrlsBlacklisted = explode("\n", $tmp);
} }
if(file_exists(config_path() . "/blacklistDescriptionUrl.txt")){ if (file_exists(config_path() . "/blacklistDescriptionUrl.txt")) {
$tmp = file_get_contents(config_path() . "/blacklistDescriptionUrl.txt"); $tmp = file_get_contents(config_path() . "/blacklistDescriptionUrl.txt");
$this->blacklistDescriptionUrl = explode("\n", $tmp); $this->blacklistDescriptionUrl = explode("\n", $tmp);
} }
...@@ -172,6 +172,7 @@ class MetaGer ...@@ -172,6 +172,7 @@ class MetaGer
->with('errors', $this->errors) ->with('errors', $this->errors)
->with('apiAuthorized', $this->apiAuthorized) ->with('apiAuthorized', $this->apiAuthorized)
->with('metager', $this) ->with('metager', $this)
->with('imagesearch', true)
->with('browser', (new Agent())->browser()); ->with('browser', (new Agent())->browser());
default: default:
return view('resultpages.resultpage_images') return view('resultpages.resultpage_images')
...@@ -185,6 +186,7 @@ class MetaGer ...@@ -185,6 +186,7 @@ class MetaGer
->with('browser', (new Agent())->browser()) ->with('browser', (new Agent())->browser())
->with('quicktips', $quicktipResults) ->with('quicktips', $quicktipResults)
->with('focus', $this->fokus) ->with('focus', $this->fokus)
->with('imagesearch', true)
->with('resultcount', count($this->results)); ->with('resultcount', count($this->results));
} }
} else { } else {
...@@ -292,7 +294,7 @@ class MetaGer ...@@ -292,7 +294,7 @@ class MetaGer
if (!empty($timings)) { if (!empty($timings)) {
$timings["prepareResults"]["validated results"] = microtime(true) - $timings["starttime"]; $timings["prepareResults"]["validated results"] = microtime(true) - $timings["starttime"];
} }
$this->duplicationCheck(); $this->duplicationCheck();
if (!empty($timings)) { if (!empty($timings)) {
$timings["prepareResults"]["duplications checked"] = microtime(true) - $timings["starttime"]; $timings["prepareResults"]["duplications checked"] = microtime(true) - $timings["starttime"];
...@@ -301,8 +303,8 @@ class MetaGer ...@@ -301,8 +303,8 @@ class MetaGer
$newResults = []; $newResults = [];
foreach ($this->ads as $ad) { foreach ($this->ads as $ad) {
if (($ad->strippedHost !== "" && (in_array($ad->strippedHost, $this->adDomainsBlacklisted) || if (($ad->strippedHost !== "" && (in_array($ad->strippedHost, $this->adDomainsBlacklisted) ||
in_array($ad->strippedLink, $this->adUrlsBlacklisted))) || ($ad->strippedHostAnzeige !== "" && (in_array($ad->strippedHostAnzeige, $this->adDomainsBlacklisted) || in_array($ad->strippedLink, $this->adUrlsBlacklisted))) || ($ad->strippedHostAnzeige !== "" && (in_array($ad->strippedHostAnzeige, $this->adDomainsBlacklisted) ||
in_array($ad->strippedLinkAnzeige, $this->adUrlsBlacklisted))) in_array($ad->strippedLinkAnzeige, $this->adUrlsBlacklisted)))
) { ) {
continue; continue;
} }
...@@ -387,15 +389,15 @@ class MetaGer ...@@ -387,15 +389,15 @@ class MetaGer
if (strpos($link, "http://") === 0) { if (strpos($link, "http://") === 0) {
$link = substr($link, 7); $link = substr($link, 7);
} }
if (strpos($link, "https://") === 0) { if (strpos($link, "https://") === 0) {
$link = substr($link, 8); $link = substr($link, 8);
} }
if (strpos($link, "www.") === 0) { if (strpos($link, "www.") === 0) {
$link = substr($link, 4); $link = substr($link, 4);
} }
$link = trim($link, "/"); $link = trim($link, "/");
if (isset($arr[$link])) { if (isset($arr[$link])) {
...@@ -403,7 +405,7 @@ class MetaGer ...@@ -403,7 +405,7 @@ class MetaGer
$arr[$link]->gefVonLink[] = $this->results[$i]->gefVonLink[0]; $arr[$link]->gefVonLink[] = $this->results[$i]->gefVonLink[0];
// The duplicate might already be an adgoal partnershop // The duplicate might already be an adgoal partnershop
if($this->results[$i]->partnershop){ if ($this->results[$i]->partnershop) {
# Den Link hinzufügen: # Den Link hinzufügen:
$arr[$link]->logo = $this->results[$i]->logo; $arr[$link]->logo = $this->results[$i]->logo;
$arr[$link]->image = $this->results[$i]->image; $arr[$link]->image = $this->results[$i]->image;
...@@ -414,7 +416,7 @@ class MetaGer ...@@ -414,7 +416,7 @@ class MetaGer
array_splice($this->results, $i, 1); array_splice($this->results, $i, 1);
$i--; $i--;
if ($arr[$link]->new === true || $this->results[$i]->new === true) { if ($arr[$link]->new === true || $this->results[$i]->new === true) {
$arr[$link]->changed = true; $arr[$link]->changed = true;
} }
} else { } else {
$arr[$link] = &$this->results[$i]; $arr[$link] = &$this->results[$i];
...@@ -427,16 +429,17 @@ class MetaGer ...@@ -427,16 +429,17 @@ class MetaGer
* @param Boolean $wait Wait for Results? * @param Boolean $wait Wait for Results?
* @return Boolean whether or not all Admitad Objects are finished * @return Boolean whether or not all Admitad Objects are finished
*/ */
public function parseAffiliates(&$affiliates){ public function parseAffiliates(&$affiliates)
{
$wait = false; $wait = false;
$finished = true; $finished = true;
if(!$this->javascript){ if (!$this->javascript) {
$wait = true; $wait = true;
} }
foreach ($affiliates as $affiliate) { foreach ($affiliates as $affiliate) {
$affiliate->fetchAffiliates($wait); $affiliate->fetchAffiliates($wait);
$affiliate->parseAffiliates($this->results); $affiliate->parseAffiliates($this->results);
if(!$affiliate->finished){ if (!$affiliate->finished) {
$finished = false; $finished = false;
} }
} }
...@@ -653,7 +656,7 @@ class MetaGer ...@@ -653,7 +656,7 @@ class MetaGer
{ {
if ($this->canCache()) { if ($this->canCache()) {
foreach ($this->engines as $engine) { foreach ($this->engines as $engine) {
if(Cache::has($engine->hash)){ if (Cache::has($engine->hash)) {
$engine->cached = true; $engine->cached = true;
$engine->retrieveResults($this, Cache::get($engine->hash)); $engine->retrieveResults($this, Cache::get($engine->hash));
} }
...@@ -794,31 +797,31 @@ class MetaGer ...@@ -794,31 +797,31 @@ class MetaGer
public function sumaIsDisabled($suma) public function sumaIsDisabled($suma)
{ {
return return
isset($suma['disabled']) isset($suma['disabled'])
&& $suma['disabled']->__toString() === "1"; && $suma['disabled']->__toString() === "1";
} }
public function sumaIsOverture($suma) public function sumaIsOverture($suma)
{ {
return return
$suma["name"]->__toString() === "overture" $suma["name"]->__toString() === "overture"
|| $suma["name"]->__toString() === "overtureAds"; || $suma["name"]->__toString() === "overtureAds";
} }
public function sumaIsNotAdsuche($suma) public function sumaIsNotAdsuche($suma)
{ {
return return
$suma["name"]->__toString() !== "qualigo" $suma["name"]->__toString() !== "qualigo"
&& $suma["name"]->__toString() !== "similar_product_ads" && $suma["name"]->__toString() !== "similar_product_ads"
&& $suma["name"]->__toString() !== "overtureAds"; && $suma["name"]->__toString() !== "overtureAds";
} }
public function requestIsCached($request) public function requestIsCached($request)
{ {
return return
$request->filled('next') $request->filled('next')
&& Cache::has($request->input('next')) && Cache::has($request->input('next'))
&& unserialize(Cache::get($request->input('next')))['page'] > 1; && unserialize(Cache::get($request->input('next')))['page'] > 1;
} }
public function getCachedEngines($request) public function getCachedEngines($request)
...@@ -866,7 +869,7 @@ class MetaGer ...@@ -866,7 +869,7 @@ class MetaGer
break; break;
} }
$answer = Redis::brpop($enginesToWaitFor, 2); $answer = Redis::brpop($enginesToWaitFor, 2);
if ($answer === null) { if ($answer === null) {
continue; continue;
} else { } else {
...@@ -1125,7 +1128,7 @@ class MetaGer ...@@ -1125,7 +1128,7 @@ class MetaGer
public function createQuicktips() public function createQuicktips()
{ {
# Die quicktips werden als job erstellt und zur Abarbeitung freigegeben # Die quicktips werden als job erstellt und zur Abarbeitung freigegeben
if (!$this->dummy) { if (!$this->dummy && $this->getFokus() !== "bilder") {
$quicktips = new \App\Models\Quicktips\Quicktips($this->q, LaravelLocalization::getCurrentLocale(), $this->getTime(), $this->sprueche); $quicktips = new \App\Models\Quicktips\Quicktips($this->q, LaravelLocalization::getCurrentLocale(), $this->getTime(), $this->sprueche);
return $quicktips; return $quicktips;
} else { } else {
...@@ -1278,7 +1281,7 @@ class MetaGer ...@@ -1278,7 +1281,7 @@ class MetaGer
} }
} }
foreach (Cookie::get() as $key => $value) { foreach (Cookie::get() as $key => $value) {
if ((stripos($key, $this->fokus.'_blpage') === 0) && (stripos($value, '*.') === false)) { if ((stripos($key, $this->fokus . '_blpage') === 0) && (stripos($value, '*.') === false)) {
$this->hostBlacklist[] = $value; $this->hostBlacklist[] = $value;
} }
} }
...@@ -1320,7 +1323,7 @@ class MetaGer ...@@ -1320,7 +1323,7 @@ class MetaGer
} }
} }
foreach (Cookie::get() as $key => $value) { foreach (Cookie::get() as $key => $value) {
if (stripos($key, $this->fokus.'_blpage') === 0 && stripos($value, '*.') === 0) { if (stripos($key, $this->fokus . '_blpage') === 0 && stripos($value, '*.') === 0) {
$this->domainBlacklist[] = str_replace("*.", "", $value); $this->domainBlacklist[] = str_replace("*.", "", $value);
} }
} }
...@@ -1371,7 +1374,7 @@ class MetaGer ...@@ -1371,7 +1374,7 @@ class MetaGer
$words = preg_split("/\s+/si", $tmp); $words = preg_split("/\s+/si", $tmp);
$newQ = $this->q; $newQ = $this->q;
foreach ($words as $word) { foreach ($words as $word) {
if(preg_match("/^-[a-zA-Z0-9]/", $word)){ if (preg_match("/^-[a-zA-Z0-9]/", $word)) {
$this->stopWords[] = substr($word, 1); $this->stopWords[] = substr($word, 1);
$newQ = str_ireplace($word, "", $newQ); $newQ = str_ireplace($word, "", $newQ);
} }
...@@ -1910,15 +1913,18 @@ class MetaGer ...@@ -1910,15 +1913,18 @@ class MetaGer
return $this->headerPrinted; return $this->headerPrinted;
} }
public function isDummy(){ public function isDummy()
{
return $this->dummy; return $this->dummy;
} }
public function jsEnabled() { public function jsEnabled()
{
return $this->javascript; return $this->javascript;
} }
public function setJsEnabled(bool $bool){ public function setJsEnabled(bool $bool)
{
$this->javascript = $bool; $this->javascript = $bool;
} }
/** /**
......
...@@ -80,28 +80,10 @@ class BingBilder extends Searchengine ...@@ -80,28 +80,10 @@ class BingBilder extends Searchengine
{ {
$url = $result->image; $url = $result->image;
// all images get cropped to a width of 400 px $newHeight = 150;
// We will calculate the height after cropping
// All Images in a row get 250px
// If the height after cropping is a multiple of that plus the gap between rows
// we will allow the image to span up to three rows
$newWidth = 400;
$newHeight = 250;
$heightMultiplier = 1; // Can be 1..3 in the end
$gapPixels = 8;
$width = $result->imageDimensions["width"];
$height = $result->imageDimensions["height"];
$heightAfterCrop = $height * (400 / $width);
$heightMultiplier = max(1, min(3, floor($heightAfterCrop / 250)));
$newHeight = $newHeight * $heightMultiplier + (($heightMultiplier - 1) * $gapPixels);
$requestDataBing = [ $requestDataBing = [
"w" => $newWidth,
"h" => $newHeight, "h" => $newHeight,
"c" => 7, // Smart Cropping
]; ];
$requestDataBing = http_build_query($requestDataBing, "", "&", PHP_QUERY_RFC3986); $requestDataBing = http_build_query($requestDataBing, "", "&", PHP_QUERY_RFC3986);
...@@ -110,9 +92,6 @@ class BingBilder extends Searchengine ...@@ -110,9 +92,6 @@ class BingBilder extends Searchengine
$requestData = []; $requestData = [];
$requestData["url"] = $url; $requestData["url"] = $url;
$link = action('Pictureproxy@get', $requestData); $link = action('Pictureproxy@get', $requestData);
return [ return $link;
"link" => $link,
"height-multiplier" => $heightMultiplier
];
} }
} }
...@@ -214,27 +214,59 @@ a { ...@@ -214,27 +214,59 @@ a {
/* Hier der Style für die Bilder */ /* Hier der Style für die Bilder */
.image-container { .imagesearch {
display: grid; #resultpage-container {
grid-template-columns: 1fr 1fr 1fr; grid-template-areas:
gap: 8px; "whitespace searchbar"
margin-bottom: 16px; "whitespace foki"
"whitespace options"
"results results"
"footer footer";
grid-template-columns: minmax(0, 150px) minmax(800px, 1770px);
@media(max-width: 800px) {
grid-template-columns: 0 1fr 0;
grid-template-areas:
"searchbar searchbar searchbar"
"foki foki foki"
"options options options"
"results results results"
"footer footer footer";
}
margin: 0;
gap: 0;
>.image { #additions-container {
&.height-2 { display: none;
grid-row: span 2;
} }
&.height-3 { #options {
grid-row: span 3; margin: 8px 0;
} }
>a { #results-container {
display: block; max-width: initial;
padding: 8px;
>div { .image-container {
>img { display: flex;
width: 100%; align-items: center;
gap: 16px;
flex-wrap: wrap;
>.image {
flex-grow: 1;
>a {
display: block;
>div {
>img {
width: 100%;
}
}
}
} }
} }
} }
......
@php <div class="image" data-width="{{$result->imageDimensions['width']}}" data-height="{{$result->imageDimensions['height']}}">
$imageData = \App\Models\parserSkripte\BingBilder::generateThumbnailUrl($result)
@endphp
<div class="image height-{{$imageData['height-multiplier']}}" data-width="{{$result->imageDimensions['width']}}" data-height="{{$result->imageDimensions['height']}}">
<a href="{{ $result->link }}" target="_blank"> <a href="{{ $result->link }}" target="_blank">
<div title="{{ $result->titel }}"> <div title="{{ $result->titel }}">
<img src="{{ $imageData['link'] }}" alt="{{ $result->titel }}" /> <img src="{{ \App\Models\parserSkripte\BingBilder::generateThumbnailUrl($result) }}" alt="{{ $result->titel }}" />
<!--<div>{{ $result->gefVon[0] }}</div>--> <!--<div>{{ $result->gefVon[0] }}</div>-->
</div> </div>
</a> </a>
......
@if(!$metager->isHeaderPrinted()) @if(!$metager->isHeaderPrinted())
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{!! trans('staticPages.meta.language') !!}"> <html lang="{!! trans('staticPages.meta.language') !!}">
<head>
<meta charset="utf-8">
<link href="/favicon.ico" rel="icon" type="image/x-icon" />
<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link rel="apple-touch-icon" href="/img/apple/touch-icon.png">
<link rel="apple-touch-icon" sizes="57x57" href="/img/apple/touch-icon-57.png">
<link rel="apple-touch-icon" sizes="72x72" href="/img/apple/touch-icon-72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/img/apple/touch-icon-76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/img/apple/touch-icon-114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/img/apple/touch-icon-120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/img/apple/touch-icon-144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/img/apple/touch-icon-152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple/touch-icon-180.png">
@if(empty(Cookie::get('key')))
<link rel="search" type="application/opensearchdescription+xml" title="{{ trans('staticPages.opensearch') }}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin')) }}">
@else
<link rel="search" type="application/opensearchdescription+xml" title="{{ trans('staticPages.opensearch') }}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin', ['key' => Cookie::get('key')])) }}">
@endif
<link href="/fonts/liberationsans/stylesheet.css" rel="stylesheet">
<head>
<meta charset="utf-8">
<link href="/favicon.ico" rel="icon" type="image/x-icon" />
<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link rel="apple-touch-icon" href="/img/apple/touch-icon.png">
<link rel="apple-touch-icon" sizes="57x57" href="/img/apple/touch-icon-57.png">
<link rel="apple-touch-icon" sizes="72x72" href="/img/apple/touch-icon-72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/img/apple/touch-icon-76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/img/apple/touch-icon-114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/img/apple/touch-icon-120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/img/apple/touch-icon-144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/img/apple/touch-icon-152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple/touch-icon-180.png">
@if(empty(Cookie::get('key')))
<link rel="search" type="application/opensearchdescription+xml" title="{{ trans('staticPages.opensearch') }}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin')) }}">
@else
<link rel="search" type="application/opensearchdescription+xml" title="{{ trans('staticPages.opensearch') }}" href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), action('StartpageController@loadPlugin', ['key' => Cookie::get('key')])) }}">
@endif
<link href="/fonts/liberationsans/stylesheet.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager.css') }}"/>
@if(Cookie::get('dark_mode') === "2")
<link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager-dark.css') }}"/>
@elseif(Cookie::get('dark_mode') === "1")
<link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager.css') }}"/>
@elseif(Request::input('out', '') !== "results-with-style" )
<link type="text/css" rel="stylesheet" media="(prefers-color-scheme:dark)" href="{{ mix('css/themes/metager-dark.css') }}"/>
@endif
@endif <link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager.css') }}" />
<title>{{ $eingabe }} - MetaGer</title> @if(Cookie::get('dark_mode') === "2")
<meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport" /> <link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager-dark.css') }}" />
<meta name="p" content="{{ getmypid() }}" /> @elseif(Cookie::get('dark_mode') === "1")
<meta name="q" content="{{ $eingabe }}" /> <link type="text/css" rel="stylesheet" href="{{ mix('css/themes/metager.css') }}" />
<meta name="l" content="{{ LaravelLocalization::getCurrentLocale() }}" /> @elseif(Request::input('out', '') !== "results-with-style" )
<meta name="mm" content="{{ $metager->getVerificationId() }}" /> <link type="text/css" rel="stylesheet" media="(prefers-color-scheme:dark)" href="{{ mix('css/themes/metager-dark.css') }}" />
<meta name="mn" content="{{ $metager->getVerificationCount() }}" /> @endif
<meta name="searchkey" content="{{ $metager->getSearchUid() }}" />
<meta name="referrer" content="origin"> @endif
<meta name="age-meta-label" content="age=18"/> <title>{{ $eingabe }} - MetaGer</title>
@include('parts.utility') <meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport" />
</head> <meta name="p" content="{{ getmypid() }}" />
<body id="resultpage-body"> <meta name="q" content="{{ $eingabe }}" />
@if(Request::getHttpHost() === "metager3.de") <meta name="l" content="{{ LaravelLocalization::getCurrentLocale() }}" />
<div class="alert alert-info metager3-unstable-warning-resultpage"> <meta name="mm" content="{{ $metager->getVerificationId() }}" />
{!! @trans('resultPage.metager3') !!} <meta name="mn" content="{{ $metager->getVerificationCount() }}" />
<meta name="searchkey" content="{{ $metager->getSearchUid() }}" />
<meta name="referrer" content="origin">
<meta name="age-meta-label" content="age=18" />
@include('parts.utility')
</head>
<body id="resultpage-body" @if(!empty($imagesearch) && $imagesearch)class="imagesearch" @endif>
@if(Request::getHttpHost() === "metager3.de")
<div class="alert alert-info metager3-unstable-warning-resultpage">
{!! @trans('resultPage.metager3') !!}
</div>
@endif
@if( !isset($suspendheader) )
@include('layouts.researchandtabs')
@else
<link rel="stylesheet" href="/css/noheader.css">
<div id="resultpage-container-noheader">
<div id="results-container">
<span name="top"></span>
@include('parts.errors')
@include('parts.warnings')
@yield('results')
<div id="backtotop"><a href="#top">@lang('results.backtotop')</a></div>