diff --git a/app/Http/Controllers/MetaGerSearch.php b/app/Http/Controllers/MetaGerSearch.php index 9d2de525c9cd57c6bbaaf92e4476ebadd8b67912..169c8a46e6b51c160036469d654423fe9c16fa24 100644 --- a/app/Http/Controllers/MetaGerSearch.php +++ b/app/Http/Controllers/MetaGerSearch.php @@ -67,12 +67,6 @@ class MetaGerSearch extends Controller return response($responseContent); } - # Die Quicktips als Job erstellen - $quicktips = $metager->createQuicktips(); - if (!empty($timings)) { - $timings["createQuicktips"] = microtime(true) - $time; - } - # Suche für alle zu verwendenden Suchmaschinen als Job erstellen, # auf Ergebnisse warten und die Ergebnisse laden $metager->createSearchEngines($request, $timings); @@ -89,12 +83,6 @@ class MetaGerSearch extends Controller $timings["retrieveResults"] = microtime(true) - $time; } - # Versuchen die Ergebnisse der Quicktips zu laden - $quicktipResults = $quicktips->loadResults(); - if (!empty($timings)) { - $timings["loadResults"] = microtime(true) - $time; - } - # Alle Ergebnisse vor der Zusammenführung ranken: $metager->rankAll(); if (!empty($timings)) { @@ -121,7 +109,7 @@ class MetaGerSearch extends Controller } # Die Ausgabe erstellen: - $resultpage = $metager->createView($quicktipResults); + $resultpage = $metager->createView(); if ($spamEntry !== null) { Cache::put('spam.' . $metager->getFokus() . "." . md5($spamEntry), $resultpage->render(), 604800); } @@ -278,4 +266,10 @@ class MetaGerSearch extends Controller ->with('title', trans('tips.title')) ->with('tips', $tips); } + + public function quicktips($search) + { + $quicktips = new \App\Models\Quicktips\Quicktips($search); + return view('quicktips')->with('quicktips', $quicktips->getResults()); + } } diff --git a/app/MetaGer.php b/app/MetaGer.php index 495ce417e5c820cd36a2978957d764bc623e369a..ccfcd3520884c2dff6fb34dc14f9f2bbd77ac5a3 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -131,7 +131,7 @@ class MetaGer } # Erstellt aus den gesammelten Ergebnissen den View - public function createView($quicktipResults = []) + public function createView() { # Hiermit werden die evtl. ausgewählten SuMas extrahiert, damit die Input-Boxen richtig gesetzt werden können $focusPages = []; @@ -171,7 +171,7 @@ class MetaGer ->with('apiAuthorized', $this->apiAuthorized) ->with('metager', $this) ->with('browser', (new Agent())->browser()) - ->with('quicktips', $quicktipResults) + ->with('quicktips', action('MetaGerSearch@quicktips', ["search" => $this->eingabe])) ->with('focus', $this->fokus) ->with('resultcount', count($this->results)); } @@ -244,7 +244,7 @@ class MetaGer ->with('apiAuthorized', $this->apiAuthorized) ->with('metager', $this) ->with('browser', (new Agent())->browser()) - ->with('quicktips', $quicktipResults) + ->with('quicktips', action('MetaGerSearch@quicktips', ["search" => $this->eingabe])) ->with('resultcount', count($this->results)) ->with('focus', $this->fokus); break; @@ -464,13 +464,6 @@ class MetaGer } } - public function createQuicktips() - { - # Die quicktips werden als job erstellt und zur Abarbeitung freigegeben - $quicktips = new \App\Models\Quicktips\Quicktips($this->q, LaravelLocalization::getCurrentLocale(), $this->getTime()); - return $quicktips; - } - /* * Die Erstellung der Suchmaschinen bis die Ergebnisse da sind mit Unterfunktionen */ diff --git a/app/Models/Quicktips/Quicktips.php b/app/Models/Quicktips/Quicktips.php index 06306dcde031b42f5b8b3f9cfd208d8e7a0f7680..1088e82cd777f49dd400e08e44f0dab80996ce8d 100644 --- a/app/Models/Quicktips/Quicktips.php +++ b/app/Models/Quicktips/Quicktips.php @@ -3,51 +3,42 @@ namespace App\Models\Quicktips; use Cache; -use Illuminate\Foundation\Bus\DispatchesJobs; -use Illuminate\Support\Facades\Redis; +use LaravelLocalization; use Log; class Quicktips { - use DispatchesJobs; private $quicktipUrl = "/1.1/quicktips.xml"; + private $results = []; const QUICKTIP_NAME = "quicktips"; const CACHE_DURATION = 60; private $hash; - public function __construct($search, $locale, $max_time) + public function __construct($search/*, $locale, $max_time*/) { + $locale = LaravelLocalization::getCurrentLocale(); if (env("APP_ENV") === "production") { $this->quicktipUrl = "https://quicktips.metager.de" . $this->quicktipUrl; } else { $this->quicktipUrl = "https://dev.quicktips.metager.de" . $this->quicktipUrl; } - $this->startSearch($search, $locale, $max_time); + $this->startSearch($search, $locale); } - public function startSearch($search, $locale, $max_time) + public function startSearch($search, $locale) { $url = $this->quicktipUrl . "?search=" . $this->normalize_search($search) . "&locale=" . $locale; $this->hash = md5($url); if (!Cache::has($this->hash)) { - - // Queue this search - $mission = [ - "resulthash" => $this->hash, - "url" => $url, - "username" => null, - "password" => null, - "headers" => [], - "cacheDuration" => self::CACHE_DURATION, - ]; - - $mission = json_encode($mission); - - Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); + $results = file_get_contents($url); + Cache::put($this->hash, $results, Quicktips::CACHE_DURATION); + } else { + $results = Cache::get($this->hash); } + $this->results = $this->loadResults($results); } /** @@ -56,9 +47,8 @@ class Quicktips * 2. Parse the results * Returns an empty array if no results are found */ - public function loadResults() + public function loadResults($resultsRaw) { - $resultsRaw = $this->retrieveResults($this->hash); if ($resultsRaw) { $results = $this->parseResults($resultsRaw); return $results; @@ -175,4 +165,9 @@ class Quicktips { return urlencode($search); } + + public function getResults() + { + return $this->results; + } } diff --git a/resources/less/metager/pages/resultpage.less b/resources/less/metager/pages/resultpage.less index 90d190d8194ef13de6a44adfa4e7298318eb3968..a2a703ea1965582827ae6a5a7ecdf2f0dc31a7ca 100644 --- a/resources/less/metager/pages/resultpage.less +++ b/resources/less/metager/pages/resultpage.less @@ -1,6 +1,5 @@ @import "./resultpage/result-page.less"; @import "./resultpage/result.less"; @import "./resultpage/product.less"; -@import "./resultpage/quicktips.less"; @import "./resultpage/result-saver.less"; @import "./resultpage/keyboard-nav.less"; \ No newline at end of file diff --git a/resources/less/metager/pages/resultpage/quicktips.less b/resources/less/metager/pages/resultpage/quicktips.less index ff37db3800cb78e9755bc19513f8deff44643409..f90932f48e01e39ada0dd949c8c13d25d5b5686a 100644 --- a/resources/less/metager/pages/resultpage/quicktips.less +++ b/resources/less/metager/pages/resultpage/quicktips.less @@ -1,11 +1,15 @@ /* Quicktips */ - +@import "../../variables.less"; +@import "../../general/cards.less"; +@import "../../general/general.less"; @quicktip-font-large: @result-font-large; @quicktip-font-medium: @result-font-medium; @quicktip-font-small: @result-font-small; #quicktips { display: flex; flex-direction: column; + margin: 0 8px; + background-color: inherit; .quicktip { .card-light; position: relative; @@ -15,7 +19,6 @@ } margin: 10px 0px; padding: 10px 10px 10px 10px; - width: 100%; border: 1px solid #ccc; background-color: white; details:not([open=""]) { @@ -24,6 +27,29 @@ } } .quicktip-summary { + display: block; + .btn { + display: inline-block; + margin-bottom: 0; + font-weight: 400; + text-align: center; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + background-image: none; + border: 1px solid transparent; + white-space: nowrap; + padding: 6px 12px; + font-size: 14px; + line-height: 1.42857143; + border-radius: 4px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + text-decoration: none; + } .quicktip-headline { width: 100%; display: flex; diff --git a/resources/less/metager/pages/resultpage/result-page.less b/resources/less/metager/pages/resultpage/result-page.less index 4a60c0fefdbb49728a9aaa68b07fb9a1580aafa7..2c3f9045edb9169c454a4189cae12fe0adce9eab 100644 --- a/resources/less/metager/pages/resultpage/result-page.less +++ b/resources/less/metager/pages/resultpage/result-page.less @@ -1,26 +1,5 @@ /* Variables */ -// Background color -@resultpage-background-color: @background-color; -// Margin to the left of the results -@results-margin-left: 16px; -// Min and max widths of the 2 resultpage columns -@results-width-min: 500px; -@results-width-max: 800px; -@additions-width-min: 500px; -@additions-width-max: 500px; -// Breakpoints for the 2 resultpage columns -@resultpage-breakpoint-max: (@results-width-max + @additions-width-max + @padding-small-default * 2 + @padding-small-default * 4 + 6); -@resultpage-breakpoint-min: (@results-width-min + @additions-width-min + @padding-small-default * 4); -@product-shop-color: green; -// The point upon which a .screen-large logo is displayed -@logo-size-breakpoint: (@results-width-min + @padding-small-default * 2); -// The point upon which the sidebar opener switches place -@sidebar-opener-breakpoint: (@results-width-max + @padding-small-default * 2 + 60px); -// Quicktip background color -@quicktip-background-color: @color-white; -// Color of the Spruch author -@spruch-author-color: @color-strong-grey; /* Styles */ #header-logo { @@ -400,6 +379,13 @@ a { #search-settings { display: none; } + #quicktips { + height: 100%; + iframe{ + height: 100%; + width: 100%; + } + } } footer { grid-area: footer; diff --git a/resources/less/metager/pages/resultpage/result.less b/resources/less/metager/pages/resultpage/result.less index 242f6f01320886a92118161cc72b19b1d428fa8f..eb42ae189ace4967a48dd030462389303458de84 100644 --- a/resources/less/metager/pages/resultpage/result.less +++ b/resources/less/metager/pages/resultpage/result.less @@ -1,9 +1,3 @@ -@result-font-large: 18px; -@result-font-medium: 16px; -@result-font-url: 14px; -@result-font-small: 12px; -@result-description-color: @color-black; -@result-image-border-color: @color-almost-white; .result { // Remove the margin from the first result because it already has margin from the grid ruleset diff --git a/resources/less/metager/variables.less b/resources/less/metager/variables.less index 11522db7220581b0c458ba9201ae4ed0a66dd955..2dc72d81cbf45c9c1b0acd986a092bdd592306d2 100644 --- a/resources/less/metager/variables.less +++ b/resources/less/metager/variables.less @@ -1,5 +1,5 @@ // MetaGer Brand Color -@metager-orange: #FF8000; +@metager-orange: #FF8000; // Shades of Gray @color-white: white; @color-almost-white: mix(@color-white, @color-black, 90%); @@ -27,4 +27,33 @@ sans-serif; // Screen sizes @screen-mobile: 760px; @screen-small: 1000px; -@screen-medium: 1200px; \ No newline at end of file +@screen-medium: 1200px; + +@result-font-large: 18px; +@result-font-medium: 16px; +@result-font-url: 14px; +@result-font-small: 12px; +@result-description-color: @color-black; +@result-image-border-color: @color-almost-white; + +// Background color +@resultpage-background-color: @background-color; +// Margin to the left of the results +@results-margin-left: 16px; +// Min and max widths of the 2 resultpage columns +@results-width-min: 500px; +@results-width-max: 800px; +@additions-width-min: 500px; +@additions-width-max: 500px; +// Breakpoints for the 2 resultpage columns +@resultpage-breakpoint-max: (@results-width-max + @additions-width-max + @padding-small-default * 2 + @padding-small-default * 4 + 6); +@resultpage-breakpoint-min: (@results-width-min + @additions-width-min + @padding-small-default * 4); +@product-shop-color: green; +// The point upon which a .screen-large logo is displayed +@logo-size-breakpoint: (@results-width-min + @padding-small-default * 2); +// The point upon which the sidebar opener switches place +@sidebar-opener-breakpoint: (@results-width-max + @padding-small-default * 2 + 60px); +// Quicktip background color +@quicktip-background-color: @color-white; +// Color of the Spruch author +@spruch-author-color: @color-strong-grey; \ No newline at end of file diff --git a/resources/views/layouts/researchandtabs.blade.php b/resources/views/layouts/researchandtabs.blade.php index 8ec665cc5eea2909a517208e0ef11b78c3e7694e..9e9596e0cc281bb673cf0a82750fbd6df5e41859 100644 --- a/resources/views/layouts/researchandtabs.blade.php +++ b/resources/views/layouts/researchandtabs.blade.php @@ -36,7 +36,7 @@ @include('layouts.keyboardNavBox') @if( $metager->showQuicktips() ) <div id="quicktips"> - @include('quicktips', ['quicktips', $quicktips]) + <iframe src="{{ $quicktips }}" frameborder="0"></iframe> </div> @endif </div> diff --git a/resources/views/quicktips.blade.php b/resources/views/quicktips.blade.php index f354bda8b7ff7dadefffc7704e3bf4325b39b28b..8a2d65ad38a94387643f33fc912f30b4715d31c1 100644 --- a/resources/views/quicktips.blade.php +++ b/resources/views/quicktips.blade.php @@ -1,5 +1,19 @@ +<!DOCTYPE html> +<html lang="{{ LaravelLocalization::getCurrentLocale() }}"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Document</title> + <link type="text/css" rel="stylesheet" href="{{ mix('css/quicktips.css') }}" /> + <link href="/fonts/liberationsans/stylesheet.css" rel="stylesheet"> + <link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome.css') }}" /> + <link type="text/css" rel="stylesheet" href="{{ mix('css/fontawesome-solid.css') }}" /> +</head> +<body id="quicktips"> @foreach($quicktips as $quicktip) <div class="quicktip" type="{{ $quicktip->type }}"> @include('parts.quicktip', ['quicktip' => $quicktip]) </div> -@endforeach \ No newline at end of file +@endforeach +</body> +</html> diff --git a/routes/web.php b/routes/web.php index 16b658253b881a5d38385eea7c4137c440d95e78..7f6093e491b6413cc4604a2ddaa2f24f81126fb5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -196,7 +196,7 @@ Route::group( Route::get('pluginClose', 'LogController@pluginClose'); Route::get('pluginInstall', 'LogController@pluginInstall'); - Route::get('qt', 'MetaGerSearch@quicktips'); + Route::get('qt/{eingabe}', 'MetaGerSearch@quicktips'); Route::get('tips', 'MetaGerSearch@tips'); Route::get('/plugins/opensearch.xml', 'StartpageController@loadPlugin'); Route::get('owi', function () { diff --git a/webpack.mix.js b/webpack.mix.js index 573059346677b6f5738dc299cbc260fa310a51df..882de714d88b6a8ccde46693c544762dd324ada1 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -22,6 +22,9 @@ mix .less("resources/less/metager/metager.less", "public/css/themes/metager.css", { strictMath: true }) + .less("resources/less/metager/pages/resultpage/quicktips.less", "public/css/quicktips.css", { + strictMath: true + }) .less("resources/less/font-awesome/fontawesome.less", "public/css/fontawesome.css", { strictMath: true }) @@ -34,8 +37,8 @@ mix .less( "resources/less/metager/pages/key.less", "public/css/key.css", { - strictMath: true - } + strictMath: true + } ) .less("resources/less/utility.less", "public/css/utility.css", { strictMath: true