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

Merge branch '1062-add-dummy-engine-to-docker-installation' into 'development'

Resolve "add dummy-engine to docker installation"

Closes #1062

See merge request !1765
parents 80838242 94f09fd4
......@@ -671,7 +671,7 @@ class MetaGer
# Special case if search engines are disabled
# Since bing is normally only active if a filter is set but it should be active, too if yahoo is disabled
if ($this->getFokus() === "web" && empty($this->enabledSearchengines["yahoo"]) && \Cookie::get("web_engine_bing") !== "off") {
if ($this->getFokus() === "web" && empty($this->enabledSearchengines["yahoo"]) && \Cookie::get("web_engine_bing") !== "off" && isset($this->sumaFile->sumas->{"bing"})) {
$this->enabledSearchengines["bing"] = $this->sumaFile->sumas->{"bing"};
}
......@@ -758,6 +758,10 @@ class MetaGer
foreach ($this->engines as $engine) {
$keys[] = $engine->hash;
}
# Noch searchengines enabled
if (empty($keys)) {
return;
}
$cacheValues = Cache::many($keys);
foreach ($this->engines as $engine) {
if ($cacheValues[$engine->hash] !== null) {
......
<?php
namespace app\Models\parserSkripte;
use App\Models\Searchengine;
use Log;
use LaravelLocalization;
class Dummy extends Searchengine
{
public $results = [];
public function __construct($name, \stdClass $engine, \App\MetaGer $metager)
{
parent::__construct($name, $engine, $metager);
}
public function loadResults($result)
{
try {
$content = json_decode($result);
if (!$content) {
return;
}
foreach ($content as $result) {
$title = $result->title;
$link = $result->link;
$anzeigeLink = $link;
$descr = $result->descr;
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
$title,
$link,
$anzeigeLink,
$descr,
$this->engine->{"display-name"},$this->engine->homepage,
$this->counter
);
}
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
public function getNext(\App\MetaGer $metager, $result)
{
try {
$results = json_decode($result);
$newEngine = unserialize(serialize($this->engine));
$perPage = 0;
if(isset($newEngine->{"get-parameter"}->count)){
$perPage = $newEngine->{"get-parameter"}->count;
} else {
$perPage = 10;
}
$offset = 0;
if(empty($newEngine->{"get-parameter"}->skip)){
$offset = $perPage;
} else {
$offset = $newEngine->{"get-parameter"}->skip + $perPage;
}
if (PHP_INT_MAX - $perPage < ($offset + $perPage)) {
return;
} else {
$newEngine->{"get-parameter"}->skip = strval($offset);
}
$next = new Dummy($this->name, $newEngine, $metager);
$this->next = $next;
} catch (\Exception $e) {
Log::error("A problem occurred parsing results from $this->name:");
Log::error($e->getMessage());
return;
}
}
}
\ No newline at end of file
{
"sumas": {
"dummy": {
"host": "dummy-nginx",
"path": "\/",
"port": 80,
"query-parameter": "q",
"input-encoding": "utf8",
"output-encoding": "utf8",
"parser-class": "Dummy",
"get-parameter": {},
"request-header": {},
"display-name": "dummy",
"engine-boost": 1,
"cache-duration": -1,
"disabled": false,
"filter-opt-in": false,
"homepage": "https:\/\/gitlab.metager.de\/open-source\/dummy-engine"
}
},
"foki": {
"web": {
"display-name": "index.foki.web",
"sumas": [
"dummy"
],
"main": [
"dummy"
]
}
},
"filter": {
"query-filter": {},
"parameter-filter": {
"count": {
"name": "metaGer.filter.count",
"desc": "",
"get-parameter": "count",
"values": {
"10": "10",
"20": "20",
"30": "30",
"40": "40",
"50": "50",
"100": "100"
},
"sumas": {
"dummy": {
"get-parameter": "count",
"values": {
"10": "10",
"20": "20",
"30": "30",
"40": "40",
"50": "50",
"100": "100"
}
}
}
},
"min": {
"name": "metaGer.filter.min",
"desc": "",
"get-parameter": "min",
"values": {
"nofilter" : "0",
"2": "2",
"4": "4",
"6": "6",
"8": "8",
"10": "10"
},
"sumas": {
"dummy": {
"get-parameter": "min",
"values": {
"nofilter" : "0",
"2": "2000",
"4": "4000",
"6": "6000",
"8": "8000",
"10": "10000"
}
}
}
},
"max": {
"name": "metaGer.filter.max",
"desc": "",
"get-parameter": "max",
"values": {
"nofilter" : "0",
"2": "2",
"4": "4",
"6": "6",
"8": "8",
"10": "10"
},
"sumas": {
"dummy": {
"get-parameter": "max",
"values": {
"nofilter" : "0",
"2": "2000",
"4": "4000",
"6": "6000",
"8": "8000",
"10": "10000"
}
}
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<sumas>
<suma name="mnogosearch" host="mg3.suma-ev.de" skript="/cgi-bin/search.cgi" formData="q=&lt;&lt;QUERY&gt;&gt;&amp;cs=utf-8&amp;ps=20" package="mnogosearch" type="web" port="80" userSelectable="1" displayName="Wikis" outputEncoding="Latin1"/>
<suma name="BASE" host="baseapi.ub.uni-bielefeld.de" skript="/cgi-bin/BaseHttpSearchInterface.fcgi" formData="func=PerformSearch&amp;query=&lt;&lt;QUERY&gt;&gt;" package="BASE" port="80" formDataEn="func=PerformSearch&amp;query=&lt;&lt;QUERY&gt;&gt;" displayName="BASE" userSelectable="1" type="wissenschaft" homepage="http://www.base-search.net/"/>
<suma name="blogsearch" host="blogsuche.suma-ev.de" skript="/blogsearch/xmlout.php" formData="search=&lt;&lt;QUERY&gt;&gt;&amp;length=400&amp;rows=50&amp;category=&lt;&lt;CATEGORY&gt;&gt;" package="blogsearch" port="80" inputEncoding="utf8" displayName="Blogsuche" userSelectable="1" type="andere" engineBoost="0.2" homepage="http://blogsuche.suma-ev.de/blogsearch/index.php"/>
</sumas>
......@@ -76,3 +76,14 @@ services:
volumes:
- .:/html
command: "php artisan dusk"
dummy-phpfpm:
restart: on-failure
image: registry.metager.de/open-source/dummy-engine/master
working_dir: /html
dummy-nginx:
depends_on:
- "dummy-phpfpm"
restart: on-failure
image: registry.metager.de/open-source/dummy-engine/master
working_dir: /html
command: sh -c "sed -i 's/fastcgi_pass localhost:9000;/fastcgi_pass dummy-phpfpm:9000;/g' /etc/nginx/conf.d/default.conf && nginx"
\ No newline at end of file
......@@ -7,6 +7,14 @@ if [ ! -f "/data/.env" ]; then
cp /data/.env.example /data/.env
fi
if [ ! -f "/data/config/sumas.json" ]; then
cp /data/config/sumas.json.example /data/config/sumas.json
fi
if [ ! -f "/data/config/sumasEn.json" ]; then
cp /data/config/sumas.json.example /data/config/sumasEn.json
fi
if [ -f "/data/database/useragents.sqlite" ]; then
rm /data/database/useragents.sqlite
fi
......
......@@ -133,5 +133,10 @@ return [
"filter.rabate" => "Min. Rabatt",
"filter.count" => "Anzahl",
"filter.skip" => "Überspringen",
"filter.min" => "Minimum Sleep (in s)",
"filter.max" => "Maximum Sleep (in s)",
"settings" => "Einstellungen",
];
......@@ -133,5 +133,10 @@ return [
"filter.rabate" => "Min. Rabate",
"filter.count" => "Count",
"filter.skip" => "Skip",
"filter.min" => "Minimum sleep (in s)",
"filter.max" => "Maximum sleep (in s)",
"settings" => "Settings",
];
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