Commit 90eae865 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '1113-fix-assoziator' into 'development'

Resolve "Fix Assoziator"

Closes #1113

See merge request !1840
parents 2739b59f 07514f73
......@@ -14,13 +14,25 @@ class Assoziator extends Controller
return redirect(LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/asso'));
}
$url = "https://metager.de/meta/meta.ger3?eingabe=" . urlencode($eingabe) . "&out=atom10&key=test";
$params = [
"eingabe" => $eingabe,
"out" => "atom10",
"key" => env("ASSO_KEY", "test"),
];
$url = route("resultpage", $params);
# Special Case for local development as the port forwarding does not work within docker
if(env("APP_ENV", "") === "local" && stripos($url, "http://localhost:8080") === 0){
$url = str_replace("http://localhost:8080", "http://nginx", $url);
}
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_USERAGENT => $_SERVER["AGENT"],
CURLOPT_USERAGENT => $_SERVER["HTTP_USER_AGENT"],
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_MAXCONNECTS => 500,
......@@ -34,6 +46,11 @@ class Assoziator extends Controller
));
$response = curl_exec($ch);
if(curl_errno($ch)){
abort(500, curl_error($ch));
}
$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
......@@ -115,8 +132,9 @@ class Assoziator extends Controller
->with('navbarFocus', 'dienste')
->with('words', $words)
->with('keywords', $eingabe)
->with('wordCount', $wordCount);
->with('wordCount', $wordCount)
->with('css', [mix('css/asso/style.css')])
->with('darkcss', [mix('css/asso/dark.css')]);;
die(var_dump($words));
}
}
......@@ -17,7 +17,7 @@ class BrowserVerification
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
public function handle($request, Closure $next, $route = "resultpage")
{
$bvEnabled = config("metager.metager.browserverification_enabled");
......@@ -42,6 +42,7 @@ class BrowserVerification
}
header('X-Accel-Buffering: no');
//use parameter for middleware to skip this when using associator
if (($request->filled("loadMore") && Cache::has($request->input("loadMore"))) || app('App\Models\Key')->getStatus()) {
return $next($request);
}
......@@ -83,7 +84,7 @@ class BrowserVerification
$params = $request->all();
$params["mgv"] = $key;
$url = route("resultpage", $params);
$url = route($route, $params);
echo(view('layouts.resultpage.unverifiedResultPage')
->with('url', $url)
......
......@@ -46,6 +46,8 @@ class HumanVerification
* If someone that uses a bot finds this out we
* might have to change it at some point.
*/
//use parameter for middleware to skip this when using associator
if (!env('BOT_PROTECTION', false) || app('App\Models\Key')->getStatus()) {
$update = false;
return $next($request);
......
.reasso {
color: #fd8307;
}
tr:nth-child(odd){
background-color: #333030;
}
\ No newline at end of file
table {
width: 100%;
}
table > tbody > tr {
text-align: center;
}
tr:nth-child(odd){
background-color: #dbd8d8;
}
form div.input-group-addon button {
padding: 9px;
}
.reasso {
color: #06C;
font-size: 1.3rem;
cursor: pointer;
}
.reasso:hover {
color: red;
}
td.association {
display: flex;
align-items: center;
margin-left: 8px;
padding: 8px;
}
.asso-search-link {
margin-right: 10px;
}
\ No newline at end of file
@extends('layouts.subPages')
@section('title', $title )
@section('title', $title)
@section('content')
<style>
form div.input-group-addon button {
padding: 9px;
}
<h1 class="page-title">{{ trans('asso.head.1') }}</h1>
<div class="card-heavy">
<p>{{ trans('asso.1.1') }} <a
href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/datenschutz') }}"
target="_blank">{{ trans('asso.1.2') }}</a>{{ trans('asso.1.3') }}.</p>
.reasso {
color: rgb(0, 102, 204);
}
.reasso:hover {
color: red;
}
td.association {
display: flex;
}
.asso-search-link {
margin-right: 10px;
}
</style>
<h1 class="page-title">{{ trans('asso.head.1') }}</h1>
<div class="card-heavy">
<p>{{ trans('asso.1.1') }} <a href="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), '/datenschutz') }}" target="_blank">{{ trans('asso.1.2') }}</a>{{ trans('asso.1.3') }}.</p>
<form method="post" class="form-inline">
<input type="text" class="form-control search-input-mini" placeholder="{{ trans('asso.search.placeholder') }}" @if(isset($keywords)) value="{{$keywords}}" @endif name="q" required autofocus/><button type="submit" class="search-btn-mini"><i class="fa fa-search" aria-hidden="true"></i></button>
</form>
</div>
@if(isset($words))
<div class="card-heavy">
<div class="table-responsive">
<table class="table">
<caption>Assoziationen für "{{ $keywords }}"</caption>
<thead>
<tr>
<th>#</th>
<th>Assoziation</th>
<th>Relevanz</th>
</tr>
</thead>
<tbody>
@php $i = 1; @endphp
@foreach($words as $key => $value)
<tr>
<td>{{ $i }}</td>
<td class="association">
<a class="asso-search-link" href="{{ action('MetaGerSearch@search', ['eingabe' => $key]) }}" title="{{ trans('asso.searchasso.title') }}"><i class="fa fa-search" aria-hidden="true"></i></a>
<form method="POST">
<button name="q" value="{{ $key }}" class="reasso" type="submit" title="{{ trans('asso.reasso.title') }}">{{ $key }}</button>
</form>
</td>
<td>{{ round(($value / $wordCount) * 100, 2) }}%</td>
@php $i++; @endphp
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endif
<form method="get" class="form-inline"
action="{{ LaravelLocalization::getLocalizedURL(LaravelLocalization::getCurrentLocale(), route('assoresults')) }}">
<input type="text" class="form-control search-input-mini" placeholder="{{ trans('asso.search.placeholder') }}"
@if (isset($keywords)) value="{{ $keywords }}" @endif name="q" required autofocus /><button type="submit" class="search-btn-mini"><i
class="fa fa-search" aria-hidden="true"></i></button>
</form>
</div>
@if (isset($words))
<div class="card-heavy">
<div class="table-responsive">
<table class="table">
<caption>Assoziationen für "{{ $keywords }}"</caption>
<thead>
<tr>
<th>#</th>
<th>Assoziation</th>
<th>Relevanz</th>
</tr>
</thead>
<tbody>
@php $i = 1; @endphp
@foreach ($words as $key => $value)
<tr>
<td>{{ $i }}</td>
<td class="association">
<a class="asso-search-link"
href="{{ action('MetaGerSearch@search', ['eingabe' => $key]) }}"
title="{{ trans('asso.searchasso.title') }}"><i class="fa fa-search"
aria-hidden="true"></i></a>
<a name="q" value="{{ $key }}" class="reasso"
href="{{ route('assoresults', ['q' => $key]) }}"
title="{{ trans('asso.reasso.title') }}">{{ $key }}</a>
</td>
<td>{{ round(($value / $wordCount) * 100, 2) }}%</td>
@php $i++; @endphp
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endif
@endsection
......@@ -38,9 +38,11 @@ Route::group(
Route::get('asso', function () {
return view('assoziator.asso')
->with('title', trans('titles.asso'))
->with('navbarFocus', 'dienste');
->with('navbarFocus', 'dienste')
->with('css', [mix('css/asso/style.css')])
->with('darkcss', [mix('css/asso/dark.css')]);
});
Route::post('asso', 'Assoziator@asso');
Route::get('asso/meta.ger3', 'Assoziator@asso')->middleware('browserverification:assoresults', 'humanverification')->name("assoresults");
Route::get('impressum', function () {
return view('impressum')
......
......@@ -55,6 +55,12 @@ mix
.less("resources/less/metager/pages/count/style.less", "public/css/count/style.css", {
strictMath: true
})
.less("resources/less/metager/pages/asso/style-dark.less", "public/css/asso/dark.css", {
strictMath: true
})
.less("resources/less/metager/pages/asso/style.less", "public/css/asso/style.css", {
strictMath: true
})
.less("resources/less/metager/pages/spende/danke.less", "public/css/spende/danke.css", {
strictMath: true
})
......
Markdown is supported
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