Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-07-16 19:53:24 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
4c0783fdc7ecd64d78426b3cd06134f6e3375704
4c0783fd
1 parent
787ad20c
Added search
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
82 additions
and
9 deletions
app/Http/Controllers/PageController.php
app/Http/routes.php
app/Repos/PageRepo.php
resources/assets/sass/_forms.scss
resources/assets/sass/_text.scss
resources/assets/sass/styles.scss
resources/views/base.blade.php
resources/views/pages/search-results.blade.php
app/Http/Controllers/PageController.php
View file @
4c0783f
...
...
@@ -132,6 +132,15 @@ class PageController extends Controller
return
redirect
(
$page
->
getUrl
());
}
public
function
searchAll
(
Request
$request
)
{
$searchTerm
=
$request
->
get
(
'term'
);
if
(
empty
(
$searchTerm
))
return
redirect
()
->
back
();
$pages
=
$this
->
pageRepo
->
getBySearch
(
$searchTerm
);
return
view
(
'pages/search-results'
,
[
'pages'
=>
$pages
,
'searchTerm'
=>
$searchTerm
]);
}
/**
* Remove the specified resource from storage.
*
...
...
app/Http/routes.php
View file @
4c0783f
...
...
@@ -36,6 +36,7 @@ Route::get('/images/all/{page}', 'ImageController@getAll');
Route
::
get
(
'/images/{any}'
,
'ImageController@getImage'
)
->
where
(
'any'
,
'.*'
);
Route
::
get
(
'/link/{id}'
,
'PageController@redirectFromLink'
);
Route
::
get
(
'/pages/search/all'
,
'PageController@searchAll'
);
Route
::
get
(
'/'
,
function
()
{
return
view
(
'base'
);
...
...
app/Repos/PageRepo.php
View file @
4c0783f
...
...
@@ -49,4 +49,14 @@ class PageRepo
$page
->
delete
();
}
public
function
getBySearch
(
$term
)
{
$terms
=
explode
(
' '
,
trim
(
$term
));
$query
=
$this
->
page
;
foreach
(
$terms
as
$term
)
{
$query
=
$query
->
where
(
'text'
,
'like'
,
'%'
.
$term
.
'%'
);
}
return
$query
->
get
();
}
}
\ No newline at end of file
...
...
resources/assets/sass/_forms.scss
View file @
4c0783f
.input-base
{
background-color
:
#FFF
;
border-radius
:
2px
;
border
:
1px
solid
#BBB
;
border-top
:
1px
solid
#AAA
;
border-radius
:
3px
;
border
:
1px
solid
#CCC
;
display
:
inline-block
;
font-size
:
$fs-s
;
font-family
:
$text
;
...
...
resources/assets/sass/_text.scss
View file @
4c0783f
...
...
@@ -165,6 +165,14 @@ p.secondary, p .secondary, span.secondary, .text-secondary {
}
/*
* Lists
*/
ul
{
list-style
:
disc
;
margin-left
:
$-m
;
}
/*
* Generic text styling classes
*/
.underlined
{
...
...
resources/assets/sass/styles.scss
View file @
4c0783f
...
...
@@ -29,9 +29,10 @@ header hr {
header
.menu
{
margin-bottom
:
0
;
list-style
:
none
;
margin-left
:
0
;
li
{
display
:
inline-block
;
margin-
lef
t
:
$-m
;
margin-
righ
t
:
$-m
;
}
}
...
...
resources/views/base.blade.php
View file @
4c0783f
...
...
@@ -16,6 +16,11 @@
},
800
);
// Adjust to change animations speed (ms)
return
this
;
};
$
.
expr
[
":"
].
contains
=
$
.
expr
.
createPseudo
(
function
(
arg
)
{
return
function
(
elem
)
{
return
$
(
elem
).
text
().
toUpperCase
().
indexOf
(
arg
.
toUpperCase
())
>=
0
;
};
});
</script>
@yield('head')
</head>
...
...
@@ -23,11 +28,21 @@
<header>
<div
class=
"container"
>
<div
class=
"padded-vertical clearfix"
>
<div
class=
"logo float left"
>
Oxbow
</div>
<ul
class=
"menu float right"
>
<li><a
href=
"/books"
><i
class=
"fa fa-book"
></i>
Books
</a></li>
</ul>
<div
class=
"padded-vertical row clearfix"
>
<div
class=
"col-md-3"
>
<div
class=
"logo float left"
>
Oxbow
</div>
</div>
<div
class=
"col-md-9"
>
<ul
class=
"menu float"
>
<li><a
href=
"/books"
><i
class=
"fa fa-book"
></i>
Books
</a></li>
</ul>
<div
class=
"search-box float right"
>
<form
action=
"/pages/search/all"
id=
"search-form"
method=
"GET"
>
{!! csrf_field() !!}
<input
type=
"text"
placeholder=
"Search all pages..."
name=
"term"
id=
"search-input"
>
</form>
</div>
</div>
</div>
</div>
</header>
...
...
resources/views/pages/search-results.blade.php
0 → 100644
View file @
4c0783f
@extends('base')
@section('content')
<div
class=
"row"
>
<div
class=
"col-md-3 page-menu"
>
</div>
<div
class=
"col-md-9 page-content"
>
<h1>
Search Results
<span
class=
"subheader"
>
For '{{$searchTerm}}'
</span></h1>
<div
class=
"page-list"
>
@if(count($pages) > 0)
@foreach($pages as $page)
<a
href=
"{{$page->getUrl() . '#' . $searchTerm}}"
>
{{$page->name}}
</a>
@endforeach
@else
<p
class=
"text-muted"
>
No pages matched this search
</p>
@endif
</div>
</div>
</div>
@stop
\ No newline at end of file
Please
register
or
sign in
to post a comment