Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
1f49b486
Commit
1f49b486
authored
Mar 06, 2020
by
Dominik Hebeler
Browse files
Quicktips now loading through iframe
parent
dd1b01c1
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/MetaGerSearch.php
View file @
1f49b486
...
...
@@ -67,12 +67,6 @@ class MetaGerSearch extends Controller
return
response
(
$responseContent
);
}
# Die Quicktips als Job erstellen
$quicktips
=
$metager
->
createQuicktips
();
if
(
!
empty
(
$timings
))
{
$timings
[
"createQuicktips"
]
=
microtime
(
true
)
-
$time
;
}
# Suche für alle zu verwendenden Suchmaschinen als Job erstellen,
# auf Ergebnisse warten und die Ergebnisse laden
$metager
->
createSearchEngines
(
$request
,
$timings
);
...
...
@@ -89,12 +83,6 @@ class MetaGerSearch extends Controller
$timings
[
"retrieveResults"
]
=
microtime
(
true
)
-
$time
;
}
# Versuchen die Ergebnisse der Quicktips zu laden
$quicktipResults
=
$quicktips
->
loadResults
();
if
(
!
empty
(
$timings
))
{
$timings
[
"loadResults"
]
=
microtime
(
true
)
-
$time
;
}
# Alle Ergebnisse vor der Zusammenführung ranken:
$metager
->
rankAll
();
if
(
!
empty
(
$timings
))
{
...
...
@@ -121,7 +109,7 @@ class MetaGerSearch extends Controller
}
# Die Ausgabe erstellen:
$resultpage
=
$metager
->
createView
(
$quicktipResults
);
$resultpage
=
$metager
->
createView
();
if
(
$spamEntry
!==
null
)
{
Cache
::
put
(
'spam.'
.
$metager
->
getFokus
()
.
"."
.
md5
(
$spamEntry
),
$resultpage
->
render
(),
604800
);
}
...
...
@@ -278,4 +266,10 @@ class MetaGerSearch extends Controller
->
with
(
'title'
,
trans
(
'tips.title'
))
->
with
(
'tips'
,
$tips
);
}
public
function
quicktips
(
$search
)
{
$quicktips
=
new
\
App\Models\Quicktips\Quicktips
(
$search
);
return
view
(
'quicktips'
)
->
with
(
'quicktips'
,
$quicktips
->
getResults
());
}
}
app/MetaGer.php
View file @
1f49b486
...
...
@@ -131,7 +131,7 @@ class MetaGer
}
# Erstellt aus den gesammelten Ergebnissen den View
public
function
createView
(
$quicktipResults
=
[]
)
public
function
createView
()
{
# Hiermit werden die evtl. ausgewählten SuMas extrahiert, damit die Input-Boxen richtig gesetzt werden können
$focusPages
=
[];
...
...
@@ -171,7 +171,7 @@ class MetaGer
->
with
(
'apiAuthorized'
,
$this
->
apiAuthorized
)
->
with
(
'metager'
,
$this
)
->
with
(
'browser'
,
(
new
Agent
())
->
browser
())
->
with
(
'quicktips'
,
$quicktipResults
)
->
with
(
'quicktips'
,
action
(
'MetaGerSearch@quicktips'
,
[
"search"
=>
$this
->
eingabe
])
)
->
with
(
'focus'
,
$this
->
fokus
)
->
with
(
'resultcount'
,
count
(
$this
->
results
));
}
...
...
@@ -244,7 +244,7 @@ class MetaGer
->
with
(
'apiAuthorized'
,
$this
->
apiAuthorized
)
->
with
(
'metager'
,
$this
)
->
with
(
'browser'
,
(
new
Agent
())
->
browser
())
->
with
(
'quicktips'
,
$quicktipResults
)
->
with
(
'quicktips'
,
action
(
'MetaGerSearch@quicktips'
,
[
"search"
=>
$this
->
eingabe
])
)
->
with
(
'resultcount'
,
count
(
$this
->
results
))
->
with
(
'focus'
,
$this
->
fokus
);
break
;
...
...
@@ -464,13 +464,6 @@ class MetaGer
}
}
public
function
createQuicktips
()
{
# Die quicktips werden als job erstellt und zur Abarbeitung freigegeben
$quicktips
=
new
\
App\Models\Quicktips\Quicktips
(
$this
->
q
,
LaravelLocalization
::
getCurrentLocale
(),
$this
->
getTime
());
return
$quicktips
;
}
/*
* Die Erstellung der Suchmaschinen bis die Ergebnisse da sind mit Unterfunktionen
*/
...
...
app/Models/Quicktips/Quicktips.php
View file @
1f49b486
...
...
@@ -3,51 +3,42 @@
namespace
App\Models\Quicktips
;
use
Cache
;
use
Illuminate\Foundation\Bus\DispatchesJobs
;
use
Illuminate\Support\Facades\Redis
;
use
LaravelLocalization
;
use
Log
;
class
Quicktips
{
use
DispatchesJobs
;
private
$quicktipUrl
=
"/1.1/quicktips.xml"
;
private
$results
=
[];
const
QUICKTIP_NAME
=
"quicktips"
;
const
CACHE_DURATION
=
60
;
private
$hash
;
public
function
__construct
(
$search
,
$locale
,
$max_time
)
public
function
__construct
(
$search
/*
, $locale, $max_time
*/
)
{
$locale
=
LaravelLocalization
::
getCurrentLocale
();
if
(
env
(
"APP_ENV"
)
===
"production"
)
{
$this
->
quicktipUrl
=
"https://quicktips.metager.de"
.
$this
->
quicktipUrl
;
}
else
{
$this
->
quicktipUrl
=
"https://dev.quicktips.metager.de"
.
$this
->
quicktipUrl
;
}
$this
->
startSearch
(
$search
,
$locale
,
$max_time
);
$this
->
startSearch
(
$search
,
$locale
);
}
public
function
startSearch
(
$search
,
$locale
,
$max_time
)
public
function
startSearch
(
$search
,
$locale
)
{
$url
=
$this
->
quicktipUrl
.
"?search="
.
$this
->
normalize_search
(
$search
)
.
"&locale="
.
$locale
;
$this
->
hash
=
md5
(
$url
);
if
(
!
Cache
::
has
(
$this
->
hash
))
{
// Queue this search
$mission
=
[
"resulthash"
=>
$this
->
hash
,
"url"
=>
$url
,
"username"
=>
null
,
"password"
=>
null
,
"headers"
=>
[],
"cacheDuration"
=>
self
::
CACHE_DURATION
,
];
$mission
=
json_encode
(
$mission
);
Redis
::
rpush
(
\
App\MetaGer
::
FETCHQUEUE_KEY
,
$mission
);
$results
=
file_get_contents
(
$url
);
Cache
::
put
(
$this
->
hash
,
$results
,
Quicktips
::
CACHE_DURATION
);
}
else
{
$results
=
Cache
::
get
(
$this
->
hash
);
}
$this
->
results
=
$this
->
loadResults
(
$results
);
}
/**
...
...
@@ -56,9 +47,8 @@ class Quicktips
* 2. Parse the results
* Returns an empty array if no results are found
*/
public
function
loadResults
()
public
function
loadResults
(
$resultsRaw
)
{
$resultsRaw
=
$this
->
retrieveResults
(
$this
->
hash
);
if
(
$resultsRaw
)
{
$results
=
$this
->
parseResults
(
$resultsRaw
);
return
$results
;
...
...
@@ -175,4 +165,9 @@ class Quicktips
{
return
urlencode
(
$search
);
}
public
function
getResults
()
{
return
$this
->
results
;
}
}
resources/less/metager/pages/resultpage.less
View file @
1f49b486
@import "./resultpage/result-page.less";
@import "./resultpage/result.less";
@import "./resultpage/product.less";
@import "./resultpage/quicktips.less";
@import "./resultpage/result-saver.less";
@import "./resultpage/keyboard-nav.less";
\ No newline at end of file
resources/less/metager/pages/resultpage/quicktips.less
View file @
1f49b486
/* Quicktips */
@import "../../variables.less";
@import "../../general/cards.less";
@import "../../general/general.less";
@quicktip-font-large: @result-font-large;
@quicktip-font-medium: @result-font-medium;
@quicktip-font-small: @result-font-small;
#quicktips {
display: flex;
flex-direction: column;
margin: 0 8px;
background-color: inherit;
.quicktip {
.card-light;
position: relative;
...
...
@@ -15,7 +19,6 @@
}
margin: 10px 0px;
padding: 10px 10px 10px 10px;
width: 100%;
border: 1px solid #ccc;
background-color: white;
details:not([open=""]) {
...
...
@@ -24,6 +27,29 @@
}
}
.quicktip-summary {
display: block;
.btn {
display: inline-block;
margin-bottom: 0;
font-weight: 400;
text-align: center;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
background-image: none;
border: 1px solid transparent;
white-space: nowrap;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
border-radius: 4px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
text-decoration: none;
}
.quicktip-headline {
width: 100%;
display: flex;
...
...
resources/less/metager/pages/resultpage/result-page.less
View file @
1f49b486
/* Variables */
// Background color
@resultpage-background-color: @background-color;
// Margin to the left of the results
@results-margin-left: 16px;
// Min and max widths of the 2 resultpage columns
@results-width-min: 500px;
@results-width-max: 800px;
@additions-width-min: 500px;
@additions-width-max: 500px;
// Breakpoints for the 2 resultpage columns
@resultpage-breakpoint-max: (@results-width-max + @additions-width-max + @padding-small-default * 2 + @padding-small-default * 4 + 6);
@resultpage-breakpoint-min: (@results-width-min + @additions-width-min + @padding-small-default * 4);
@product-shop-color: green;
// The point upon which a .screen-large logo is displayed
@logo-size-breakpoint: (@results-width-min + @padding-small-default * 2);
// The point upon which the sidebar opener switches place
@sidebar-opener-breakpoint: (@results-width-max + @padding-small-default * 2 + 60px);
// Quicktip background color
@quicktip-background-color: @color-white;
// Color of the Spruch author
@spruch-author-color: @color-strong-grey;
/* Styles */
#header-logo {
...
...
@@ -400,6 +379,13 @@ a {
#search-settings {
display: none;
}
#quicktips {
height: 100%;
iframe{
height: 100%;
width: 100%;
}
}
}
footer {
grid-area: footer;
...
...
resources/less/metager/pages/resultpage/result.less
View file @
1f49b486
@result-font-large: 18px;
@result-font-medium: 16px;
@result-font-url: 14px;
@result-font-small: 12px;
@result-description-color: @color-black;
@result-image-border-color: @color-almost-white;
.result {
// Remove the margin from the first result because it already has margin from the grid ruleset
...
...
resources/less/metager/variables.less
View file @
1f49b486
// MetaGer Brand Color
@metager-orange: #FF8000;
@metager-orange: #FF8000;
// Shades of Gray
@color-white: white;
@color-almost-white: mix(@color-white, @color-black, 90%);
...
...
@@ -27,4 +27,33 @@ sans-serif;
// Screen sizes
@screen-mobile: 760px;
@screen-small: 1000px;
@screen-medium: 1200px;
\ No newline at end of file
@screen-medium: 1200px;
@result-font-large: 18px;
@result-font-medium: 16px;
@result-font-url: 14px;
@result-font-small: 12px;
@result-description-color: @color-black;
@result-image-border-color: @color-almost-white;
// Background color
@resultpage-background-color: @background-color;
// Margin to the left of the results
@results-margin-left: 16px;
// Min and max widths of the 2 resultpage columns
@results-width-min: 500px;
@results-width-max: 800px;
@additions-width-min: 500px;
@additions-width-max: 500px;
// Breakpoints for the 2 resultpage columns
@resultpage-breakpoint-max: (@results-width-max + @additions-width-max + @padding-small-default * 2 + @padding-small-default * 4 + 6);
@resultpage-breakpoint-min: (@results-width-min + @additions-width-min + @padding-small-default * 4);
@product-shop-color: green;
// The point upon which a .screen-large logo is displayed
@logo-size-breakpoint: (@results-width-min + @padding-small-default * 2);
// The point upon which the sidebar opener switches place
@sidebar-opener-breakpoint: (@results-width-max + @padding-small-default * 2 + 60px);
// Quicktip background color
@quicktip-background-color: @color-white;
// Color of the Spruch author
@spruch-author-color: @color-strong-grey;
\ No newline at end of file
resources/views/layouts/researchandtabs.blade.php
View file @
1f49b486
...
...
@@ -36,7 +36,7 @@
@include('layouts.keyboardNavBox')
@if( $metager->showQuicktips() )
<div
id=
"quicktips"
>
@include('quicktips', ['quicktips', $quicktips])
<iframe
src=
"{{ $quicktips }}"
frameborder=
"0"
></iframe>
</div>
@endif
</div>
...
...
resources/views/quicktips.blade.php
View file @
1f49b486
<!DOCTYPE html>
<html
lang=
"{{ LaravelLocalization::getCurrentLocale() }}"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Document
</title>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"{{ mix('css/quicktips.css') }}"
/>
<link
href=
"/fonts/liberationsans/stylesheet.css"
rel=
"stylesheet"
>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"{{ mix('css/fontawesome.css') }}"
/>
<link
type=
"text/css"
rel=
"stylesheet"
href=
"{{ mix('css/fontawesome-solid.css') }}"
/>
</head>
<body
id=
"quicktips"
>
@foreach($quicktips as $quicktip)
<div
class=
"quicktip"
type=
"{{ $quicktip->type }}"
>
@include('parts.quicktip', ['quicktip' => $quicktip])
</div>
@
endforeach
\ No newline at end of file
@endforeach
</body>
</html>
routes/web.php
View file @
1f49b486
...
...
@@ -196,7 +196,7 @@ Route::group(
Route
::
get
(
'pluginClose'
,
'LogController@pluginClose'
);
Route
::
get
(
'pluginInstall'
,
'LogController@pluginInstall'
);
Route
::
get
(
'qt'
,
'MetaGerSearch@quicktips'
);
Route
::
get
(
'qt
/{eingabe}
'
,
'MetaGerSearch@quicktips'
);
Route
::
get
(
'tips'
,
'MetaGerSearch@tips'
);
Route
::
get
(
'/plugins/opensearch.xml'
,
'StartpageController@loadPlugin'
);
Route
::
get
(
'owi'
,
function
()
{
...
...
webpack.mix.js
View file @
1f49b486
...
...
@@ -22,6 +22,9 @@ mix
.
less
(
"
resources/less/metager/metager.less
"
,
"
public/css/themes/metager.css
"
,
{
strictMath
:
true
})
.
less
(
"
resources/less/metager/pages/resultpage/quicktips.less
"
,
"
public/css/quicktips.css
"
,
{
strictMath
:
true
})
.
less
(
"
resources/less/font-awesome/fontawesome.less
"
,
"
public/css/fontawesome.css
"
,
{
strictMath
:
true
})
...
...
@@ -34,8 +37,8 @@ mix
.
less
(
"
resources/less/metager/pages/key.less
"
,
"
public/css/key.css
"
,
{
strictMath
:
true
}
strictMath
:
true
}
)
.
less
(
"
resources/less/utility.less
"
,
"
public/css/utility.css
"
,
{
strictMath
:
true
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment