Commit 6358c9d9 authored by Dominik Hebeler's avatar Dominik Hebeler

Merge branch 'master' into '57-die-settingsseite-ubersetzen'

Updates from Master



See merge request !73
parents 48a7ad7d 7837ffa6
......@@ -15,6 +15,7 @@ class MetaGerSearch extends Controller
{
public function search(Request $request, MetaGer $metager)
{
#die($request->header('User-Agent'));
$time = microtime();
# Mit gelieferte Formulardaten parsen und abspeichern:
$metager->parseFormData($request);
......@@ -43,10 +44,13 @@ class MetaGerSearch extends Controller
# Zunächst den Spruch
$spruecheFile = storage_path() . "/app/public/sprueche.txt";
if( file_exists($spruecheFile) )
if( file_exists($spruecheFile) && $_GET['sprueche'])
{
$sprueche = file($spruecheFile);
$spruch = $sprueche[array_rand($sprueche)];
}else
{
$spruch = "";
}
# Die manuellen Quicktips:
......
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
#use App\MetaGer\Forwarder;
#use App\MetaGer\Results;
#use App\MetaGer\Search;
use App;
use App\MetaGer;
use Response;
class Pictureproxy extends Controller
{
function get(Request $request) {
if( $request->has('url') )
{
$file = file_get_contents($request->input('url'));
$responseCode = explode(" ", $http_response_header[0])[1];
$contentType = "";
foreach($http_response_header as $header)
{
if( strpos($header, "Content-Type:") === 0)
{
$tmp = explode(": ", $header);
$contentType = $tmp[1];
}
}
$response = Response::make($file, $responseCode);
$response->header('Content-Type', $contentType);
return $response;
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Response;
class StartpageController extends Controller
{
......@@ -64,4 +65,35 @@ class StartpageController extends Controller
\App::setLocale($locale);
return loadPage($subpage);
}
public function loadPlugin(Request $request, $locale = "de")
{
$requests = $request->all();
$params = [];
foreach($requests as $key => $value)
{
if( strpos($key, "param_") === 0 )
{
$key = substr($key, strpos($key, "param_") + 6 );
}
$params[$key] = $value;
}
if(!isset($params['focus']))
$params['focus'] = 'web';
if(!isset($params['encoding']))
$params['encoding'] = 'utf8';
if(!isset($params['lang']))
$params['lang'] = 'all';
$params["eingabe"] = "";
$link = action('MetaGerSearch@search', $params);
$response = Response::make(
view('plugin')->with('link', $link), "200");
$response->header('Content-Type', "application/xml");
return $response;
return $link;
}
}
\ No newline at end of file
......@@ -97,7 +97,9 @@
Route::get('meta/meta.ger3', 'MetaGerSearch@search');
Route::get('meta/picture', 'Pictureproxy@get');
Route::get('qt', 'MetaGerSearch@quicktips');
Route::get('tips', 'MetaGerSearch@tips');
Route::get('opensearch.xml', 'StartpageController@loadPlugin');
});
This diff is collapsed.
......@@ -105,18 +105,23 @@ class Result
foreach(explode(" ", trim($tmpEingabe)) as $el)
{
$el = preg_quote($el, "/");
if(preg_match("/\b$el\b/si", $tmpTitle))
if(strlen($tmpTitle) > 0)
{
$tmpRank += .7 * .6 * $maxRank;
}elseif (strpos($tmpTitle, $el) !== false) {
$tmpRank += .3 * .6 * $maxRank;
if(preg_match("/\b$el\b/si", $tmpTitle))
{
$tmpRank += .7 * .6 * $maxRank;
}elseif (strpos($tmpTitle, $el) !== false) {
$tmpRank += .3 * .6 * $maxRank;
}
}
if(preg_match("/\b$el\b/si", $tmpDescription))
if( strlen($tmpDescription) > 0 )
{
$tmpRank += .7 * .4 * $maxRank;
}elseif (strpos($tmpDescription, $el) !== false) {
$tmpRank += .3 * .4 * $maxRank;
if(preg_match("/\b$el\b/si", $tmpDescription))
{
$tmpRank += .7 * .4 * $maxRank;
}elseif (strpos($tmpDescription, $el) !== false) {
$tmpRank += .3 * .4 * $maxRank;
}
}
}
$tmpRank /= sizeof(explode(" ", trim($tmpEingabe))) * 10;
......
......@@ -19,6 +19,7 @@ abstract class Searchengine
public $ads = [];
public $write_time = 0;
public $connection_time = 0;
public $loaded = false;
function __construct(\SimpleXMLElement $engine, MetaGer $metager)
{
......@@ -231,6 +232,7 @@ abstract class Searchengine
// end of headers
if(sizeof($headers) > 1){
$bodySize = 0;
stream_set_blocking($this->fp, 1);
if( isset($headers["Transfer-Encoding"]) && $headers["Transfer-Encoding"] === "chunked" )
{
$body = $this->readChunked();
......@@ -245,6 +247,10 @@ abstract class Searchengine
{
die("Konnte nicht herausfinden, wie ich die Serverantwort von: " . $this->name . " auslesen soll. Header war: " . print_r($headers));
}
$this->loaded = true;
}else
{
return;
}
Redis::del($this->host . "." . $this->socketNumber);
......@@ -253,7 +259,6 @@ abstract class Searchengine
{
$body = $this->gunzip($body);
}
#print_r($headers);
#print($body);
#print("\r\n". $bodySize);
......@@ -265,6 +270,12 @@ abstract class Searchengine
#exit;
}
public function shutdown()
{
fclose($this->fp);
Redis::del($this->host . "." . $this->socketNumber);
}
private function readBody($length)
{
$theData = '';
......
......@@ -43,6 +43,7 @@ class Ecoshopper extends Searchengine
$anzeigeLink = $link;
}
$descr = $result->xpath('//doc/str[@name="artikelBeschreibung"]')[0]->__toString();
$image = $result->xpath('//doc/str[@name="artikelImageurl"]')[0]->__toString();
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
......@@ -51,7 +52,9 @@ class Ecoshopper extends Searchengine
$anzeigeLink,
$descr,
$this->gefVon,
$this->counter
$this->counter,
false,
$image
);
}
}
......
......@@ -35,6 +35,7 @@ class Mg_produkt2 extends Searchengine
parse_str($anzeigeLink['query'], $query);
$anzeigeLink = $query['diurl'];
$descr = $result->xpath('/doc/arr[@name="artikelBeschreibung"]')[0]->{"str"}->__toString();
$image = $result->xpath('/doc/arr[@name="artikelImageurl"]')[0]->{"str"}->__toString();
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
......@@ -43,7 +44,9 @@ class Mg_produkt2 extends Searchengine
$anzeigeLink,
$descr,
$this->gefVon,
$this->counter
$this->counter,
false,
$image
);
}
}
......
......@@ -20,6 +20,8 @@ class Zeitde extends Searchengine
return;
foreach( $results->{"matches"} as $result )
{
if( !isset($result->{"title"}) || !isset($result->{"href"}) || !isset($result->{"snippet"}))
continue;
$title = $result->{"title"};
$link = $result->{"href"};
$anzeigeLink = $link;
......
......@@ -114,6 +114,12 @@ return [
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
'redisLogs' => [
'host' => env('REDIS_LOGS_HOST', 'localhost'),
'password' => env('REDIS_LOGS_PASSWORD', null),
'port' => env('REDIS_MAIN_PORT', 6379),
'database' => 1,
],
],
......
......@@ -361,6 +361,14 @@ a:hover
margin-right:2px
}
.result .image {
padding:0;
}
.result .image > img{
max-width: 100%;
}
.popover-content{
/*padding-left: 0;
padding-right:0;*/
......
* {
}
.content-wrapper {
padding-top: 50px;
}
div#fokiChanger {
margin-bottom: 0;
}
#fokiChanger a {
color: grey;
}
li.list-group-item.selected {
background-color: #f5f5f5;
}
select#fokiChanger {
width: 100%;
height: 30px;
text-align: center;
background-color: inherit;
border: 0;
}
header#research {
width: 100%;
margin-left: -50%;
}
p.link {
white-space: nowrap;
}
header nav {
width: 100%;
padding: 0 10px;
margin-left: 0;
}
/* Research Bar */
#researchBar{
width:100%;
margin-left: -50%;
padding-left:0;
padding-right:0;
}
/* Result Boxen */
.result{
padding:0;
}
.result > .resultInformation{
margin-left:0;
padding-left:0;
}
.result .link a{
white-space:nowrap;
overflow:hidden;
}
.result.ad .link > a {
width: 50%;
max-width: 15ch;
overflow: hidden;
display: inline-flex;
text-overflow: ellipsis;
}
.result .hoster{
white-space:nowrap;
}
.row{
margin: 10px 0;
}
.row .col-md-8 {
padding: 0 10px;
}
.container-fluid {
padding: 5px 0;
}
.panel .panel-heading {
padding-top: 5px;
padding-bottom: 5px;
}
.content-wrapper{
width: 100%;
}
.result .link-link{
max-width:90%;
}
.alert ul {
padding-left:0px;
}
.resultContainer {
padding: 0!important;
}
\ No newline at end of file
......@@ -11,9 +11,19 @@
# nicht einmal wir selbst noch Zugriff auf die Daten haben:
if( !isset($_SERVER['HTTP_X_FORWARDED_FOR'] ))
{
$_SERVER['REMOTE_ADDR'] = substr($_SERVER['REMOTE_ADDR'], 0, strrpos($_SERVER['REMOTE_ADDR'], ".")) . ".0";
$_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 23);
$_SERVER['REMOTE_ADDR'] = preg_replace("/(\d+)\.(\d+)\.\d+.\d+/s", "$1.$2.0.0", $_SERVER['REMOTE_ADDR']);
}else
{
$_SERVER['HTTP_X_FORWARDED_FOR'] = preg_replace("/(\d+)\.(\d+)\.\d+.\d+/s", "$1.$2.0.0", $_SERVER['HTTP_X_FORWARDED_FOR']);
}
$agentPieces = explode(" ", $_SERVER['HTTP_USER_AGENT']);
for($i = 0; $i < count($agentPieces); $i++)
{
$agentPieces[$i] = preg_replace("/(\d+\.\d+)/s", "0.0", $agentPieces[$i]);
$agentPieces[$i] = preg_replace("/([^\/]*)\/\w+/s", "$1/0.0", $agentPieces[$i]);
}
$_SERVER['HTTP_USER_AGENT'] = implode(" ", $agentPieces);
/*
|--------------------------------------------------------------------------
......
......@@ -50,7 +50,7 @@ function checkPlugin(){
$("#plugin-modal .modal-header h4").html("MetaGer zum Firefox hinzufügen");
var content = "" +
"<ol>" +
"<li>Klicken Sie <a href=\"javascript:window.external.AddSearchProvider('https://metager.de/plugins/opensearchplugin.xml')\">hier</a> um MetaGer als Suchmaschine hinzuzufügen.</li>" +
"<li>Klicken Sie <a href=\"javascript:window.external.AddSearchProvider($('link[rel=search]').attr('href'))\">hier</a> um MetaGer als Suchmaschine hinzuzufügen.</li>" +
"<li>Setzen Sie einen Haken bei \"Diese als aktuelle Suchmaschine setzen\"</li>" +
"<li>Klicken Sie auf \"Hinzufügen\"</li>" +
"</ol>";
......@@ -59,7 +59,7 @@ function checkPlugin(){
$("#plugin-modal .modal-header h4").html("MetaGer zum Chrome hinzufügen");
var content = "" +
"<ol>" +
"<li>Klicken Sie <a href=\"javascript:window.external.AddSearchProvider('https://metager.de/plugins/opensearchplugin.xml')\" onclick=\"$('#more').removeClass('hidden');\">hier</a>, um MetaGer als Suchmaschine hinzuzufügen" +
"<li>Klicken Sie <a href=\"javascript:window.external.AddSearchProvider($('link[rel=search]').attr('href'))\" onclick=\"$('#more').removeClass('hidden');\">hier</a>, um MetaGer als Suchmaschine hinzuzufügen" +
"<ul id=\"more\" class=\"hidden list-unstyled\">" +
"<li>Klicken Sie im Popup auf OK</li>" +
"<li><small>(Sollte der OK-Knopf deaktiviert sein, ist MetaGer bereits in Ihren Suchmaschinen. Klicken Sie dann auf Abbrechen und fahren mit Schritt 2 fort.)</small></li>" +
......@@ -85,7 +85,7 @@ function checkPlugin(){
$("#plugin-modal .modal-header h4").html("MetaGer zum Internet Explorer hinzufügen");
var content = "" +
"<ol>" +
"<li>Klicken Sie <a href=\"javascript:window.external.addSearchProvider('https://metager.de/plugins/opensearchplugin.xml');\">hier</a>, um MetaGer als Suchmaschine hinzuzufügen" +
"<li>Klicken Sie <a href=\"javascript:window.external.addSearchProvider($('link[rel=search]').attr('href'));\">hier</a>, um MetaGer als Suchmaschine hinzuzufügen" +
"<li>Klicken Sie in Ihrem Browser oben rechts auf Extras (<span class=\"glyphicon glyphicon-cog\"></span>)</li>" +
"<li>Wählen Sie den Menüpunkt \"Add-Ons verwalten\"</li>" +
"<li>Klicken Sie im Bereich Add-On-Typen auf \"Suchanbieter\" und danach im rechten Bereich auf \"MetaGer\"</li>" +
......
......@@ -32,6 +32,10 @@ $(document).ready(function(){
$("#unten").click(function(){
alert("Auf der folgenden Startseite sind Ihre Einstellungen nun einmalig gespeichert. Nach Ihrer ersten Suche sind diese wieder verloren. Wenn Sie diese speichern möchten, können Sie sich allerdings ein Lesezeichnen einrichten.");
});
$("#plugin").click(function(){
$("form").attr('action', '/#plugin-modal');
alert("Ihr Browserplugin mit den persönlichen Sucheinstellungen wurde generiert. Folgen Sie bitte der Anleitung auf der folgenden Seite um es zu installieren. Beachten Sie: Zuvor sollten Sie ein eventuell bereits installiertes MetaGer-Plugin entfernen.");
});
});
function tickOptions(){
......
<div class="content-wrapper">
<header id="research">
<nav>
<ul class="list-inline">
<li class="hidden-xs hidden-sm pull-left">
<div class="logo"><a href="/"><h1>MetaGer</h1></a>
</div>
</li>
<li class="visible-xs visible-sm pull-left">
<div class="logo"><a href="/"><h1>MG</h1></a>
</div>
</li>
<li class="pull-right">
<form method="get" accept-charset="UTF-8" class="form" id="submitForm">
<div class="input-group">
<input autocomplete="off" class="form-control" form="submitForm" id="eingabeTop" name="eingabe" placeholder="Suchbegriffe erweitern/verändern, oder völlig neue Suche:" tabindex="1" type="text" value="{{ $eingabe }}" />
<div class="input-group-addon">
<button type='submit' form="submitForm" id='search'><span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
@foreach( $metager->request->all() as $key => $value)
@if($key !== "eingabe" && $key !== "page")
<input type='hidden' name='{{ $key }}' value='{{ $value }}' form='submitForm' />
@endif
@endforeach
</form>
</li>
</ul>
</nav>
</header>
<ul class="nav nav-tabs" id="foki" role="tablist">
@if( $metager->getFokus() === "web" )
<li id="webTabSelector" role="presentation" data-loaded="1" class="active">
<a aria-controls="web" data-href="#web" href="#web">
<span class='glyphicon glyphicon-globe'></span>
<span class="hidden-xs">Web</span>
</a>
</li>
@else
<li data-loaded="0" id="webTabSelector" role="presentation">
<a aria-controls="web" data-href="{{ $metager->generateSearchLink('web') }}" href="{{ $metager->generateSearchLink('web') }}">
<span class='glyphicon glyphicon-globe'></span>
<span class="hidden-xs">Web</span>
</a>
</li>
@endif
@if( $metager->getFokus() === "bilder" )
<li id="bilderTabSelector" role="presentation" data-loaded="1" class="active">
<a aria-controls="bilder" data-href="#bilder" href="#bilder">
<span class='glyphicon glyphicon-picture'></span>
<span class="hidden-xs">Bilder</span>
</a>
</li>
@else
<li data-loaded="0" id="bilderTabSelector" role="presentation">
<a aria-controls="bilder" data-href="{{ $metager->generateSearchLink('bilder') }}" href="{{ $metager->generateSearchLink('bilder') }}">
<span class='glyphicon glyphicon-picture'></span>
<span class="hidden-xs">Bilder</span>
</a>
</li>
@endif
@if( $metager->getFokus() === "nachrichten" )
<li id="nachrichtenTabSelector" role="presentation" data-loaded="1" class="active">
<a aria-controls="nachrichten" data-href="#nachrichten" href="#nachrichten">
<span class='glyphicon glyphicon-bullhorn'></span>
<span class="hidden-xs">Nachrichten</span>
</a>
</li>
@else
<li data-loaded="0" id="nachrichtenTabSelector" role="presentation" >
<a aria-controls="nachrichten" data-href="{{ $metager->generateSearchLink('nachrichten') }}" href="{{ $metager->generateSearchLink('nachrichten') }}">
<span class='glyphicon glyphicon-bullhorn'></span>
<span class="hidden-xs">Nachrichten</span>
</a>
</li>
@endif
@if( $metager->getFokus() === "wissenschaft" )
<li id="wissenschaftTabSelector" role="presentation" data-loaded="1" class="active">
<a aria-controls="wissenschaft" data-href="#wissenschaft" href="#wissenschaft">
<span class='glyphicon glyphicon-file'></span>
<span class="hidden-xs">Wissenschaft</span>
</a>
</li>
@else
<li data-loaded="0" id="wissenschaftTabSelector" role="presentation">
<a aria-controls="wissenschaft" data-href="{{ $metager->generateSearchLink('wissenschaft') }}" href="{{ $metager->generateSearchLink('wissenschaft') }}">
<span class='glyphicon glyphicon-file'></span>
<span class="hidden-xs">Wissenschaft</span>
</a>
</li>
@endif
@if( $metager->getFokus() === "produktsuche" )
<li id="produktsucheTabSelector" role="presentation" data-loaded="1" class="active">
<a aria-controls="produktsuche" data-href="#produktsuche" href="#produktsuche">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">Produktsuche</span>
</a>
</li>
@else
<li data-loaded="0" id="produktsucheTabSelector" role="presentation" >
<a aria-controls="produktsuche" data-href="{{ $metager->generateSearchLink('produktsuche') }}" href="{{ $metager->generateSearchLink('produktsuche') }}">
<span class='glyphicon glyphicon-shopping-cart'></span>
<span class="hidden-xs">Produktsuche</span>
</a>
</li>
@endif
@if( $metager->getFokus() === "angepasst" )
<li id="angepasstTabSelector" role="presentation" data-loaded="1" class="active">
<a aria-controls="angepasst" data-href="#angepasst" href="#angepasst">
<span class='glyphicon glyphicon-cog'></span>
<span class="hidden-xs">angepasst</span>
</a>
</li>
@endif
</ul>
<div class="tab-content container-fluid">
@if( sizeof($errors) > 0 )
<div class="alert alert-danger">
<ul>
@foreach($errors as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
@if( sizeof($warnings) > 0)
<div class="alert alert-warning">
<ul>
@foreach($warnings as $warning)
<li>{{ $warning }}</li>
@endforeach
</ul>
</div>
@endif
@if( $metager->getFokus() === "web" )
<div role="tabpanel" class="tab-pane active" id="web">
<div class="row">
@yield('results')
</div>
</div>
@else
<div role="tabpanel" class="tab-pane" id="web">
<div class="loader">
<img src="/img/ajax-loader.gif" alt="" />
</div>
</div>
@endif
@if( $metager->getFokus() === "bilder" )
<div role="tabpanel" class="tab-pane active" id="bilder">
<div class="row">
@yield('results')
</div>
</div>
@else
<div role="tabpanel" class="tab-pane" id="bilder">
<div class="loader">
<img src="/img/ajax-loader.gif" alt="" />
</div>
</div>
@endif
@if( $metager->getFokus() === "nachrichten" )
<div role="tabpanel" class="tab-pane active" id="nachrichten">
<div class="row">
@yield('results')
</div>
</div>
@else
<div role="tabpanel" class="tab-pane" id="nachrichten">
<div class="loader">
<img src="/img/ajax-loader.gif" alt="" />
</div>
</div>