Skip to content
GitLab
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
5bdcd5b7
Commit
5bdcd5b7
authored
Jun 03, 2016
by
Dominik Hebeler
Browse files
Quicktips in die neue Version eingeführt
parent
c0ece913
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/MetaGerSearch.php
View file @
5bdcd5b7
...
...
@@ -13,7 +13,6 @@ use App\MetaGer;
class
MetaGerSearch
extends
Controller
{
public
function
search
(
Request
$request
,
MetaGer
$metager
)
{
$time
=
microtime
();
...
...
@@ -40,7 +39,111 @@ class MetaGerSearch extends Controller
public
function
quicktips
(
Request
$request
)
{
$q
=
$request
->
input
(
'q'
,
''
);
# Zunächst den Spruch
$spruecheFile
=
storage_path
()
.
"/app/public/sprueche.txt"
;
if
(
file_exists
(
$spruecheFile
)
)
{
$sprueche
=
file
(
$spruecheFile
);
$spruch
=
$sprueche
[
array_rand
(
$sprueche
)];
}
# Die manuellen Quicktips:
$file
=
storage_path
()
.
"/app/public/qtdata.csv"
;
$mquicktips
=
[];
if
(
file_exists
(
$file
)
&&
$q
!==
''
)
{
$file
=
fopen
(
$file
,
'r'
);
while
((
$line
=
fgetcsv
(
$file
))
!==
FALSE
)
{
$words
=
array_slice
(
$line
,
3
);
$isIn
=
FALSE
;
foreach
(
$words
as
$word
){
$word
=
strtolower
(
$word
);
if
(
strpos
(
$q
,
$word
)
!==
FALSE
){
$isIn
=
TRUE
;
break
;
}
}
if
(
$isIn
===
TRUE
){
$quicktip
=
array
(
'QT_Type'
=>
"MQT"
);
$quicktip
[
"URL"
]
=
$line
[
0
];
$quicktip
[
"title"
]
=
$line
[
1
];
$quicktip
[
"descr"
]
=
$line
[
2
];
$mquicktips
[]
=
$quicktip
;
}
}
fclose
(
$file
);
}
# Wikipedia Quicktip
$quicktips
=
[];
$url
=
"http://de.wikipedia.org/w/api.php?action=query&titles="
.
urlencode
(
implode
(
"_"
,
array_diff
(
explode
(
" "
,
$q
),
array
(
"wikipedia"
))))
.
"&prop=info|extracts|categories&inprop=url|displaytitle&exintro&exsentences=3&format=json"
;
$decodedResponse
=
json_decode
(
$this
->
get
(
$url
),
true
);
foreach
(
$decodedResponse
[
"query"
][
"pages"
]
as
$result
)
{
if
(
isset
(
$result
[
'displaytitle'
])
&&
isset
(
$result
[
'fullurl'
])
&&
isset
(
$result
[
'extract'
])
)
{
$quicktip
=
[];
$quicktip
[
"title"
]
=
$result
[
'displaytitle'
];
$quicktip
[
"URL"
]
=
$result
[
'fullurl'
];
$quicktip
[
"descr"
]
=
strip_tags
(
$result
[
'extract'
]);
$quicktips
[]
=
$quicktip
;
}
}
$mquicktips
=
array_merge
(
$mquicktips
,
$quicktips
);
# Uns Natürlich das wussten Sie schon:
$file
=
storage_path
()
.
"/app/public/tips.txt"
;
if
(
file_exists
(
$file
)
)
{
$tips
=
file
(
$file
);
$tip
=
$tips
[
array_rand
(
$tips
)];
$mquicktips
[]
=
[
'title'
=>
'Wussten Sie schon?'
,
'descr'
=>
$tip
,
'URL'
=>
'/tips'
];
}
# Uns die Werbelinks:
$file
=
storage_path
()
.
"/app/public/ads.txt"
;
if
(
file_exists
(
$file
)
)
{
$ads
=
json_decode
(
file_get_contents
(
$file
),
true
);
$ad
=
$ads
[
array_rand
(
$ads
)];
$mquicktips
[]
=
[
'title'
=>
$ad
[
'title'
],
'descr'
=>
$ad
[
'descr'
],
'URL'
=>
$ad
[
'URL'
]];
}
return
view
(
'quicktip'
)
->
with
(
'spruch'
,
$spruch
)
->
with
(
'mqs'
,
$mquicktips
);
}
public
function
tips
()
{
$file
=
storage_path
()
.
"/app/public/tips.txt"
;
$tips
=
[];
if
(
file_exists
(
$file
)
)
{
$tips
=
file
(
$file
);
}
return
view
(
'tips'
)
->
with
(
'title'
,
'MetaGer - Tipps & Tricks'
)
->
with
(
'tips'
,
$tips
);
}
function
get
(
$url
)
{
$process
=
curl_init
(
$url
);
curl_setopt
(
$process
,
CURLOPT_USERAGENT
,
$_SERVER
[
'HTTP_USER_AGENT'
]);
curl_setopt
(
$process
,
CURLOPT_TIMEOUT
,
30
);
curl_setopt
(
$process
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$process
,
CURLOPT_FOLLOWLOCATION
,
1
);
$return
=
curl_exec
(
$process
);
curl_close
(
$process
);
return
$return
;
}
}
\ No newline at end of file
app/Http/routes.php
View file @
5bdcd5b7
...
...
@@ -88,4 +88,5 @@
Route
::
get
(
'meta/meta.ger3'
,
'MetaGerSearch@search'
);
Route
::
get
(
'qt'
,
'MetaGerSearch@quicktips'
);
Route
::
get
(
'tips'
,
'MetaGerSearch@tips'
);
});
resources/views/metager3.blade.php
View file @
5bdcd5b7
...
...
@@ -19,6 +19,7 @@
</
nav
>
</
div
>
<
div
class
=
"col-md-4"
id
=
"quicktips"
>
<
iframe
class
=
"col-mod-4 hidden-xs hidden-sm"
src
=
"/qt?q={{
$metager->getQ
() }}"
></
iframe
>
</
div
>
@
endsection
...
...
resources/views/metager3results.blade.php
deleted
100644 → 0
View file @
c0ece913
<div
class=
"col-md-8"
>
{{-- 3-Mal Werbung --}}
@for($i = 0; $i
<
=
2;
$
i
++)
@
include
('
layouts.ad
',
['
ad
'
=
>
$metager->popAd()])
@endfor
@foreach($metager->getResults()->items() as $result)
@if($result->number % 7 === 0)
@include('layouts.ad', ['ad' => $metager->popAd()])
@endif
@include('layouts.result', ['result' => $result])
@endforeach
</div>
<div
class=
"col-md-4"
id=
"quicktips"
>
</div>
\ No newline at end of file
resources/views/quicktip.blade.php
0 → 100644
View file @
5bdcd5b7
<html>
<head>
<title>
MetaGer Quicktips
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/css/bootstrap.css"
/>
<style>
.quicktip
{
margin-bottom
:
15px
;
padding
:
10px
;
line-height
:
1.2
!important
;
font-family
:
Georgia
,
"Times New Roman"
,
Palatino
,
Times
,
serif
;
color
:
#000
;
border-left
:
3px
solid
#FB0
;
font-size
:
14px
;
}
.wikiqtextract
{
font-family
:
Georgia
,
"Times New Roman"
,
Palatino
,
Times
,
serif
;
}
.wikiqtextract
p
{
margin-bottom
:
0
;
}
.quicktip
a
{
color
:
#00F
;
}
.qtheader
{
font-family
:
verdana
,
arial
,
helvetica
,
sans-serif
;
}
.mutelink
{
color
:
black
!important
;
}
#spruch
{
margin-bottom
:
20px
;
padding
:
5px
;
line-height
:
1.2
!important
;
color
:
#070
;
border-left
:
3px
solid
#070
;
font-size
:
16px
;
font-family
:
Georgia
,
"Times New Roman"
,
Palatino
,
Times
,
serif
;
}
.author
{
float
:
right
!important
;
}
</style>
</head>
<body>
<blockquote
id=
"spruch"
>
{!! $spruch !!}
</blockquote>
@foreach( $mqs as $mq)
<div
class=
"quicktip"
>
<b
class=
"qtheader"
>
<a
href=
"{{ $mq['URL'] }}"
target=
"_blank"
>
{{ $mq['title'] }}
</a>
</b>
<br
/>
<div>
{!! $mq['descr'] !!}
</div>
</div>
@endforeach
</body>
</html>
\ No newline at end of file
resources/views/tips.blade.php
0 → 100644
View file @
5bdcd5b7
@
extends
(
'layouts.staticPages'
)
@
section
(
'title'
,
$title
)
@
section
(
'content'
)
<
h1
>
MetaGer
Tipps
,
unsortiert
-
dies
&
das
-
wussten
Sie
schon
?</
h1
>
<
ol
>
@
foreach
(
$tips
as
$tip
)
<
li
>
{
!!
$tip
!!
}
</
li
>
@
endforeach
</
ol
>
@
endsection
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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