Showing
8 changed files
with
82 additions
and
9 deletions
| ... | @@ -132,6 +132,15 @@ class PageController extends Controller | ... | @@ -132,6 +132,15 @@ class PageController extends Controller |
| 132 | return redirect($page->getUrl()); | 132 | return redirect($page->getUrl()); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | + public function searchAll(Request $request) | ||
| 136 | + { | ||
| 137 | + $searchTerm = $request->get('term'); | ||
| 138 | + if(empty($searchTerm)) return redirect()->back(); | ||
| 139 | + | ||
| 140 | + $pages = $this->pageRepo->getBySearch($searchTerm); | ||
| 141 | + return view('pages/search-results', ['pages' => $pages, 'searchTerm' => $searchTerm]); | ||
| 142 | + } | ||
| 143 | + | ||
| 135 | /** | 144 | /** |
| 136 | * Remove the specified resource from storage. | 145 | * Remove the specified resource from storage. |
| 137 | * | 146 | * | ... | ... |
| ... | @@ -36,6 +36,7 @@ Route::get('/images/all/{page}', 'ImageController@getAll'); | ... | @@ -36,6 +36,7 @@ Route::get('/images/all/{page}', 'ImageController@getAll'); |
| 36 | Route::get('/images/{any}', 'ImageController@getImage')->where('any', '.*'); | 36 | Route::get('/images/{any}', 'ImageController@getImage')->where('any', '.*'); |
| 37 | 37 | ||
| 38 | Route::get('/link/{id}', 'PageController@redirectFromLink'); | 38 | Route::get('/link/{id}', 'PageController@redirectFromLink'); |
| 39 | +Route::get('/pages/search/all', 'PageController@searchAll'); | ||
| 39 | 40 | ||
| 40 | Route::get('/', function () { | 41 | Route::get('/', function () { |
| 41 | return view('base'); | 42 | return view('base'); | ... | ... |
| ... | @@ -49,4 +49,14 @@ class PageRepo | ... | @@ -49,4 +49,14 @@ class PageRepo |
| 49 | $page->delete(); | 49 | $page->delete(); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | + public function getBySearch($term) | ||
| 53 | + { | ||
| 54 | + $terms = explode(' ', trim($term)); | ||
| 55 | + $query = $this->page; | ||
| 56 | + foreach($terms as $term) { | ||
| 57 | + $query = $query->where('text', 'like', '%'.$term.'%'); | ||
| 58 | + } | ||
| 59 | + return $query->get(); | ||
| 60 | + } | ||
| 61 | + | ||
| 52 | } | 62 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | 1 | ||
| 2 | .input-base { | 2 | .input-base { |
| 3 | background-color: #FFF; | 3 | background-color: #FFF; |
| 4 | - border-radius: 2px; | 4 | + border-radius: 3px; |
| 5 | - border: 1px solid #BBB; | 5 | + border: 1px solid #CCC; |
| 6 | - border-top: 1px solid #AAA; | ||
| 7 | display: inline-block; | 6 | display: inline-block; |
| 8 | font-size: $fs-s; | 7 | font-size: $fs-s; |
| 9 | font-family: $text; | 8 | font-family: $text; | ... | ... |
| ... | @@ -165,6 +165,14 @@ p.secondary, p .secondary, span.secondary, .text-secondary { | ... | @@ -165,6 +165,14 @@ p.secondary, p .secondary, span.secondary, .text-secondary { |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | /* | 167 | /* |
| 168 | + * Lists | ||
| 169 | + */ | ||
| 170 | +ul { | ||
| 171 | + list-style: disc; | ||
| 172 | + margin-left: $-m; | ||
| 173 | +} | ||
| 174 | + | ||
| 175 | +/* | ||
| 168 | * Generic text styling classes | 176 | * Generic text styling classes |
| 169 | */ | 177 | */ |
| 170 | .underlined { | 178 | .underlined { | ... | ... |
| ... | @@ -29,9 +29,10 @@ header hr { | ... | @@ -29,9 +29,10 @@ header hr { |
| 29 | header .menu { | 29 | header .menu { |
| 30 | margin-bottom: 0; | 30 | margin-bottom: 0; |
| 31 | list-style: none; | 31 | list-style: none; |
| 32 | + margin-left: 0; | ||
| 32 | li { | 33 | li { |
| 33 | display: inline-block; | 34 | display: inline-block; |
| 34 | - margin-left: $-m; | 35 | + margin-right: $-m; |
| 35 | } | 36 | } |
| 36 | } | 37 | } |
| 37 | 38 | ... | ... |
| ... | @@ -16,6 +16,11 @@ | ... | @@ -16,6 +16,11 @@ |
| 16 | }, 800); // Adjust to change animations speed (ms) | 16 | }, 800); // Adjust to change animations speed (ms) |
| 17 | return this; | 17 | return this; |
| 18 | }; | 18 | }; |
| 19 | + $.expr[":"].contains = $.expr.createPseudo(function(arg) { | ||
| 20 | + return function( elem ) { | ||
| 21 | + return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; | ||
| 22 | + }; | ||
| 23 | + }); | ||
| 19 | </script> | 24 | </script> |
| 20 | @yield('head') | 25 | @yield('head') |
| 21 | </head> | 26 | </head> |
| ... | @@ -23,11 +28,21 @@ | ... | @@ -23,11 +28,21 @@ |
| 23 | 28 | ||
| 24 | <header> | 29 | <header> |
| 25 | <div class="container"> | 30 | <div class="container"> |
| 26 | - <div class="padded-vertical clearfix"> | 31 | + <div class="padded-vertical row clearfix"> |
| 27 | - <div class="logo float left">Oxbow</div> | 32 | + <div class="col-md-3"> |
| 28 | - <ul class="menu float right"> | 33 | + <div class="logo float left">Oxbow</div> |
| 29 | - <li><a href="/books"><i class="fa fa-book"></i>Books</a></li> | 34 | + </div> |
| 30 | - </ul> | 35 | + <div class="col-md-9"> |
| 36 | + <ul class="menu float"> | ||
| 37 | + <li><a href="/books"><i class="fa fa-book"></i>Books</a></li> | ||
| 38 | + </ul> | ||
| 39 | + <div class="search-box float right"> | ||
| 40 | + <form action="/pages/search/all" id="search-form" method="GET"> | ||
| 41 | + {!! csrf_field() !!} | ||
| 42 | + <input type="text" placeholder="Search all pages..." name="term" id="search-input"> | ||
| 43 | + </form> | ||
| 44 | + </div> | ||
| 45 | + </div> | ||
| 31 | </div> | 46 | </div> |
| 32 | </div> | 47 | </div> |
| 33 | </header> | 48 | </header> | ... | ... |
| 1 | +@extends('base') | ||
| 2 | + | ||
| 3 | +@section('content') | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + <div class="row"> | ||
| 7 | + | ||
| 8 | + <div class="col-md-3 page-menu"> | ||
| 9 | + | ||
| 10 | + </div> | ||
| 11 | + | ||
| 12 | + <div class="col-md-9 page-content"> | ||
| 13 | + <h1>Search Results <span class="subheader">For '{{$searchTerm}}'</span></h1> | ||
| 14 | + <div class="page-list"> | ||
| 15 | + @if(count($pages) > 0) | ||
| 16 | + @foreach($pages as $page) | ||
| 17 | + <a href="{{$page->getUrl() . '#' . $searchTerm}}">{{$page->name}}</a> | ||
| 18 | + @endforeach | ||
| 19 | + @else | ||
| 20 | + <p class="text-muted">No pages matched this search</p> | ||
| 21 | + @endif | ||
| 22 | + </div> | ||
| 23 | + </div> | ||
| 24 | + | ||
| 25 | + </div> | ||
| 26 | + | ||
| 27 | + | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +@stop | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment