Dan Brown

Added recently created & updated page listings

Closes #46.
...@@ -278,4 +278,30 @@ class PageController extends Controller ...@@ -278,4 +278,30 @@ class PageController extends Controller
278 ]); 278 ]);
279 } 279 }
280 280
281 + /**
282 + * Show a listing of recently created pages
283 + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
284 + */
285 + public function showRecentlyCreated()
286 + {
287 + $pages = $this->pageRepo->getRecentlyCreatedPaginated(20);
288 + return view('pages/detailed-listing', [
289 + 'title' => 'Recently Created Pages',
290 + 'pages' => $pages
291 + ]);
292 + }
293 +
294 + /**
295 + * Show a listing of recently created pages
296 + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
297 + */
298 + public function showRecentlyUpdated()
299 + {
300 + $pages = $this->pageRepo->getRecentlyUpdatedPaginated(20);
301 + return view('pages/detailed-listing', [
302 + 'title' => 'Recently Updated Pages',
303 + 'pages' => $pages
304 + ]);
305 + }
306 +
281 } 307 }
......
...@@ -3,6 +3,11 @@ ...@@ -3,6 +3,11 @@
3 // Authenticated routes... 3 // Authenticated routes...
4 Route::group(['middleware' => 'auth'], function () { 4 Route::group(['middleware' => 'auth'], function () {
5 5
6 + Route::group(['prefix' => 'pages'], function() {
7 + Route::get('/recently-created', 'PageController@showRecentlyCreated');
8 + Route::get('/recently-updated', 'PageController@showRecentlyUpdated');
9 + });
10 +
6 Route::group(['prefix' => 'books'], function () { 11 Route::group(['prefix' => 'books'], function () {
7 12
8 // Books 13 // Books
......
...@@ -358,5 +358,22 @@ class PageRepo ...@@ -358,5 +358,22 @@ class PageRepo
358 $page->delete(); 358 $page->delete();
359 } 359 }
360 360
361 + /**
362 + * Get the latest pages added to the system.
363 + * @param $count
364 + */
365 + public function getRecentlyCreatedPaginated($count = 20)
366 + {
367 + return $this->page->orderBy('created_at', 'desc')->paginate($count);
368 + }
369 +
370 + /**
371 + * Get the latest pages added to the system.
372 + * @param $count
373 + */
374 + public function getRecentlyUpdatedPaginated($count = 20)
375 + {
376 + return $this->page->orderBy('updated_at', 'desc')->paginate($count);
377 + }
361 378
362 } 379 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -139,54 +139,6 @@ form.search-box { ...@@ -139,54 +139,6 @@ form.search-box {
139 height: 43px; 139 height: 43px;
140 } 140 }
141 141
142 -.dropdown-container {
143 - display: inline-block;
144 - vertical-align: top;
145 - position: relative;
146 -}
147 -
148 -.dropdown-container ul {
149 - display: none;
150 - position: absolute;
151 - z-index: 999;
152 - top: 0;
153 - list-style: none;
154 - right: 0;
155 - margin: $-m 0;
156 - background-color: #FFFFFF;
157 - box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.1);
158 - border-radius: 1px;
159 - border: 1px solid #EEE;
160 - min-width: 180px;
161 - padding: $-xs 0;
162 - color: #555;
163 - text-align: left !important;
164 - &.wide {
165 - min-width: 220px;
166 - }
167 - .text-muted {
168 - color: #999;
169 - }
170 - a {
171 - display: block;
172 - padding: $-xs $-m;
173 - color: #555;
174 - &:hover {
175 - text-decoration: none;
176 - background-color: #EEE;
177 - }
178 - i {
179 - margin-right: $-m;
180 - padding-right: 0;
181 - display: inline;
182 - width: 22px;
183 - }
184 - }
185 - li.border-bottom {
186 - border-bottom: 1px solid #DDD;
187 - }
188 -}
189 -
190 .breadcrumbs span.sep { 142 .breadcrumbs span.sep {
191 color: #aaa; 143 color: #aaa;
192 padding: 0 $-xs; 144 padding: 0 $-xs;
......
...@@ -285,18 +285,31 @@ ul.pagination { ...@@ -285,18 +285,31 @@ ul.pagination {
285 } 285 }
286 } 286 }
287 287
288 -.entity-list.compact { 288 +.entity-list {
289 - font-size: 0.6em; 289 + >div {
290 - > div {
291 padding: $-m 0; 290 padding: $-m 0;
292 } 291 }
293 - h3, a {
294 - line-height: 1.2;
295 - }
296 h3 { 292 h3 {
297 margin: 0; 293 margin: 0;
298 } 294 }
299 p { 295 p {
296 + margin: $-xs 0 0 0;
297 + }
298 + hr {
299 + margin: 0;
300 + }
301 + .text-small.text-muted {
302 + color: #AAA;
303 + font-size: 0.75em;
304 + margin-top: $-xs;
305 + }
306 +}
307 +.entity-list.compact {
308 + font-size: 0.6em;
309 + h3, a {
310 + line-height: 1.2;
311 + }
312 + p {
300 display: none; 313 display: none;
301 font-size: $fs-m * 0.8; 314 font-size: $fs-m * 0.8;
302 padding-top: $-xs; 315 padding-top: $-xs;
...@@ -305,4 +318,52 @@ ul.pagination { ...@@ -305,4 +318,52 @@ ul.pagination {
305 hr { 318 hr {
306 margin: 0; 319 margin: 0;
307 } 320 }
308 -}
...\ No newline at end of file ...\ No newline at end of file
321 +}
322 +
323 +.dropdown-container {
324 + display: inline-block;
325 + vertical-align: top;
326 + position: relative;
327 +}
328 +
329 +.dropdown-container ul {
330 + display: none;
331 + position: absolute;
332 + z-index: 999;
333 + top: 0;
334 + list-style: none;
335 + right: 0;
336 + margin: $-m 0;
337 + background-color: #FFFFFF;
338 + box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.1);
339 + border-radius: 1px;
340 + border: 1px solid #EEE;
341 + min-width: 180px;
342 + padding: $-xs 0;
343 + color: #555;
344 + text-align: left !important;
345 + &.wide {
346 + min-width: 220px;
347 + }
348 + .text-muted {
349 + color: #999;
350 + }
351 + a {
352 + display: block;
353 + padding: $-xs $-m;
354 + color: #555;
355 + &:hover {
356 + text-decoration: none;
357 + background-color: #EEE;
358 + }
359 + i {
360 + margin-right: $-m;
361 + padding-right: 0;
362 + display: inline;
363 + width: 22px;
364 + }
365 + }
366 + li.border-bottom {
367 + border-bottom: 1px solid #DDD;
368 + }
369 +}
......
...@@ -254,10 +254,15 @@ ol { ...@@ -254,10 +254,15 @@ ol {
254 .text-bigger { 254 .text-bigger {
255 font-size: 1.1em; 255 font-size: 1.1em;
256 } 256 }
257 +
257 .text-large { 258 .text-large {
258 font-size: 1.6666em; 259 font-size: 1.6666em;
259 } 260 }
260 261
262 +.no-color {
263 + color: inherit;
264 +}
265 +
261 /** 266 /**
262 * Grouping 267 * Grouping
263 */ 268 */
......
...@@ -28,14 +28,15 @@ ...@@ -28,14 +28,15 @@
28 @else 28 @else
29 <h3>Recent Books</h3> 29 <h3>Recent Books</h3>
30 @endif 30 @endif
31 - @include('partials/entity-list', ['entities' => $recents, 'size' => 'compact']) 31 + @include('partials/entity-list', ['entities' => $recents, 'style' => 'compact'])
32 </div> 32 </div>
33 33
34 <div class="col-sm-4"> 34 <div class="col-sm-4">
35 - <h3>Recently Created Pages</h3> 35 + <h3><a class="no-color" href="/pages/recently-created">Recently Created Pages</a></h3>
36 - @include('partials/entity-list', ['entities' => $recentlyCreatedPages, 'size' => 'compact']) 36 + @include('partials/entity-list', ['entities' => $recentlyCreatedPages, 'style' => 'compact'])
37 - <h3>Recently Updated Pages</h3> 37 +
38 - @include('partials/entity-list', ['entities' => $recentlyCreatedPages, 'size' => 'compact']) 38 + <h3><a class="no-color" href="/pages/recently-updated">Recently Updated Pages</a></h3>
39 + @include('partials/entity-list', ['entities' => $recentlyCreatedPages, 'style' => 'compact'])
39 </div> 40 </div>
40 41
41 <div class="col-sm-4" id="recent-activity"> 42 <div class="col-sm-4" id="recent-activity">
......
1 +@extends('base')
2 +
3 +@section('content')
4 +
5 + <div class="container">
6 + <div class="row">
7 +
8 + <div class="col-sm-7">
9 + <h1>{{ $title }}</h1>
10 + @include('partials/entity-list', ['entities' => $pages, 'style' => 'detailed'])
11 + {!! $pages->links() !!}
12 + </div>
13 +
14 + <div class="col-sm-4 col-sm-offset-1"></div>
15 +
16 + </div>
17 + </div>
18 +@stop
...\ No newline at end of file ...\ No newline at end of file
...@@ -3,18 +3,29 @@ ...@@ -3,18 +3,29 @@
3 <a href="{{ $page->getUrl() }}" class="text-page"><i class="zmdi zmdi-file-text"></i>{{ $page->name }}</a> 3 <a href="{{ $page->getUrl() }}" class="text-page"><i class="zmdi zmdi-file-text"></i>{{ $page->name }}</a>
4 </h3> 4 </h3>
5 5
6 - @if(isset($showMeta) && $showMeta)
7 - <div class="meta">
8 - <span class="text-book"><i class="zmdi zmdi-book"></i> {{ $page->book->name }}</span>
9 - @if($page->chapter)
10 - <span class="text-chapter"><i class="zmdi zmdi-collection-bookmark"></i> {{ $page->chapter->name }}</span>
11 - @endif
12 - </div>
13 - @endif
14 -
15 @if(isset($page->searchSnippet)) 6 @if(isset($page->searchSnippet))
16 <p class="text-muted">{!! $page->searchSnippet !!}</p> 7 <p class="text-muted">{!! $page->searchSnippet !!}</p>
17 @else 8 @else
18 <p class="text-muted">{{ $page->getExcerpt() }}</p> 9 <p class="text-muted">{{ $page->getExcerpt() }}</p>
19 @endif 10 @endif
11 +
12 + @if(isset($style) && $style === 'detailed')
13 + <div class="row meta text-muted text-small">
14 + <div class="col-md-4">
15 + Created {{$page->created_at->diffForHumans()}} @if($page->createdBy)by {{$page->createdBy->name}}@endif <br>
16 + Last updated {{ $page->updated_at->diffForHumans() }} @if($page->updatedBy)by {{$page->updatedBy->name}} @endif
17 + </div>
18 + <div class="col-md-8">
19 + <a class="text-book" href="{{ $page->book->getUrl() }}"><i class="zmdi zmdi-book"></i>{{ $page->book->getExcerpt(30) }}</a>
20 + <br>
21 + @if($page->chapter)
22 + <a class="text-chapter" href="{{ $page->chapter->getUrl() }}"><i class="zmdi zmdi-collection-bookmark"></i>{{ $page->chapter->getExcerpt(30) }}</a>
23 + @else
24 + <i class="zmdi zmdi-collection-bookmark"></i> Page is not in a chapter
25 + @endif
26 + </div>
27 + </div>
28 + @endif
29 +
30 +
20 </div> 31 </div>
...\ No newline at end of file ...\ No newline at end of file
......
1 1
2 -<div class="entity-list @if(isset($size)){{ $size }}@endif"> 2 +<div class="entity-list @if(isset($style)){{ $style }}@endif" ng-non-bindable>
3 @if(count($entities) > 0) 3 @if(count($entities) > 0)
4 @foreach($entities as $index => $entity) 4 @foreach($entities as $index => $entity)
5 @if($entity->isA('page')) 5 @if($entity->isA('page'))
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
13 <div class="page-list"> 13 <div class="page-list">
14 @if(count($pages) > 0) 14 @if(count($pages) > 0)
15 @foreach($pages as $page) 15 @foreach($pages as $page)
16 - @include('pages/list-item', ['page' => $page, 'showMeta' => true]) 16 + @include('pages/list-item', ['page' => $page, 'style' => 'detailed'])
17 <hr> 17 <hr>
18 @endforeach 18 @endforeach
19 @else 19 @else
......
...@@ -250,5 +250,23 @@ class EntityTest extends TestCase ...@@ -250,5 +250,23 @@ class EntityTest extends TestCase
250 ->click('Revisions')->seeStatusCode(200); 250 ->click('Revisions')->seeStatusCode(200);
251 } 251 }
252 252
253 + public function test_recently_created_pages_view()
254 + {
255 + $user = $this->getNewUser();
256 + $content = $this->createEntityChainBelongingToUser($user);
257 +
258 + $this->asAdmin()->visit('/pages/recently-created')
259 + ->seeInNthElement('.entity-list .page', 0, $content['page']->name);
260 + }
261 +
262 + public function test_recently_updated_pages_view()
263 + {
264 + $user = $this->getNewUser();
265 + $content = $this->createEntityChainBelongingToUser($user);
266 +
267 + $this->asAdmin()->visit('/pages/recently-updated')
268 + ->seeInNthElement('.entity-list .page', 0, $content['page']->name);
269 + }
270 +
253 271
254 } 272 }
......