Commit e7db24c3 authored by Davide Aprea's avatar Davide Aprea
Browse files

fixed api and atom10 format

parent 336ad12f
......@@ -18,6 +18,14 @@ class BrowserVerification
*/
public function handle($request, Closure $next)
{
if(($request->input("out", "") === "api" || $request->input("out", "") === "atom10") && app('App\Models\Key')->getStatus()) {
header('Content-type: application/xml; charset=utf-8');
} else {
header('Content-type: text/html; charset=utf-8');
}
header('X-Accel-Buffering: no');
if (($request->filled("loadMore") && Cache::has($request->input("loadMore"))) || app('App\Models\Key')->getStatus()) {
return $next($request);
}
......@@ -55,9 +63,6 @@ class BrowserVerification
}
}
header('Content-type: text/html; charset=utf-8');
header('X-Accel-Buffering: no');
$key = md5($request->ip() . microtime(true));
echo(view('layouts.resultpage.verificationHeader')->with('key', $key)->render());
......
......@@ -206,14 +206,13 @@ class MetaGer
->with('browser', (new Agent())->browser())
->with('fokus', $this->fokus);
break;
/* WIP
case 'api':
return response()->view('resultpages.metager3resultsatom10', ['results' => $viewResults, 'eingabe' => $this->eingabe, 'metager' => $this, 'resultcount' => sizeof($viewResults), 'key' => $this->apiKey, 'apiAuthorized' => $this->apiAuthorized])->header('Content-Type', 'application/xml');
return view('resultpages.metager3resultsatom10',['eingabe' => $this->eingabe, 'resultcount' => sizeof($viewResults), 'key' => $this->apiKey, 'metager' => $this]);
break;
case 'atom10':
return response()->view('resultpages.metager3resultsatom10', ['results' => $viewResults, 'eingabe' => $this->eingabe, 'metager' => $this, 'resultcount' => sizeof($viewResults), 'key' => $this->apiKey, 'apiAuthorized' => true])
->header('Content-Type', 'application/xml');
break;*/
return view('resultpages.metager3resultsatom10',['eingabe' => $this->eingabe, 'resultcount' => sizeof($viewResults), 'key' => $this->apiKey, 'metager' => $this]);
break;
case 'result-count':
# Wir geben die Ergebniszahl und die benötigte Zeit zurück:
return sizeof($viewResults) . ";" . round((microtime(true) - $this->starttime), 2);
......@@ -1204,7 +1203,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" /*WIP && $this->out !== "atom10" && $this->out !== "api"*/) {
if ($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style" && $this->out !== "result-count" && $this->out !== "atom10" && $this->out !== "api") {
$this->out = "html";
}
# Wir schalten den Cache aus, wenn die Ergebniszahl überprüft werden soll
......
......@@ -3,7 +3,7 @@
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
xmlns:mg="http://metager.de/opensearch/"
xmlns:ad="http://a9.com/-/opensearch/extensions/advertisement/1.0/">
<title>{!! htmlspecialchars($eingabe, ENT_XML1, 'UTF-8'); !!} - MetaGer</title>
<title>{{ htmlspecialchars($eingabe, ENT_XML1, 'UTF-8') }} - MetaGer</title>
<link href="{{ url()->full() }}"/>
<updated>{{ date('c') }}</updated>
<opensearch:totalResults>{{ $resultcount }}</opensearch:totalResults>
......@@ -11,7 +11,7 @@
<link rel="next" href="{{ htmlspecialchars($metager->nextSearchLink() ,ENT_QUOTES) }}" type="application/atom+xml"/>
<id>urn:uuid:1d634a8c-2764-424f-b082-6c96494b7240</id>
@include('layouts.atom10ad', ['ad' => $metager->popAd()])
@if($apiAuthorized)
@if(app('App\Models\Key')->getStatus())
@foreach($metager->getResults() as $index => $result)
@if(($index+1) % 5 === 0)
@include('layouts.atom10ad', ['ad' => $metager->popAd()])
......
Supports Markdown
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