From 4b761d4b3ffff35ad971384697844bf7ab71ce9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phil=20H=C3=B6fer?= <phil@suma-ev.de> Date: Mon, 13 Mar 2017 08:25:33 +0100 Subject: [PATCH] Integration von OpenSearch/RSS 2.0 --- app/MetaGer.php | 9 +++++++- .../views/metager3resultsrss20.blade.php | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 resources/views/metager3resultsrss20.blade.php diff --git a/app/MetaGer.php b/app/MetaGer.php index 6afd48b7e..a92b5f534 100644 --- a/app/MetaGer.php +++ b/app/MetaGer.php @@ -140,6 +140,13 @@ class MetaGer ->with('suspendheader', "yes") ->with('browser', (new Agent())->browser()); break; + case 'rss20': + return view('metager3resultsrss20') + ->with('results', $viewResults) + ->with('eingabe', $this->eingabe) + ->with('metager', $this) + ->with('resultcount', sizeof($viewResults)); + break; case 'result-count': # Wir geben die Ergebniszahl und die benötigte Zeit zurück: return sizeof($viewResults) . ";" . round((microtime(true) - $this->starttime), 2); @@ -974,7 +981,7 @@ class MetaGer } $this->out = $request->input('out', "html"); # Standard output format html - if ($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style" && $this->out !== "result-count") { + if ($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style" && $this->out !== "result-count" && $this->out !== "rss20") { $this->out = "html"; } # Wir schalten den Cache aus, wenn die Ergebniszahl überprüft werden soll diff --git a/resources/views/metager3resultsrss20.blade.php b/resources/views/metager3resultsrss20.blade.php new file mode 100644 index 000000000..7b96fa956 --- /dev/null +++ b/resources/views/metager3resultsrss20.blade.php @@ -0,0 +1,21 @@ +<?xmlversion = "1.0"encoding = "UTF-8"?> + <rss version="2.0" + xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" + xmlns:atom="http://www.w3.org/2005/Atom"> + <channel> + <title>{{ $eingabe }} - MetaGer</title> + <description></description> + <opensearch:totalResults>{{ $resultcount }}</opensearch:totalResults> + <opensearch:Query role="request" searchTerms="{{ htmlspecialchars($eingabe, ENT_QUOTES) }}"/> + + @foreach($metager->getResults() as $result) + <item> + <title>{{ $result->titel }}</title> + <link>{{ $result->link }}</link> + <description> + {{ $result->descr }} + </description> + </item> + @endforeach + </channel> + </rss> -- GitLab