Showing
13 changed files
with
94 additions
and
33 deletions
app/Http/Controllers/HomeController.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace Oxbow\Http\Controllers; | ||
| 4 | + | ||
| 5 | +use Illuminate\Http\Request; | ||
| 6 | + | ||
| 7 | +use Oxbow\Http\Requests; | ||
| 8 | +use Oxbow\Http\Controllers\Controller; | ||
| 9 | +use Oxbow\Repos\BookRepo; | ||
| 10 | +use Oxbow\Services\ActivityService; | ||
| 11 | +use Oxbow\Services\Facades\Activity; | ||
| 12 | + | ||
| 13 | +class HomeController extends Controller | ||
| 14 | +{ | ||
| 15 | + | ||
| 16 | + protected $activityService; | ||
| 17 | + protected $bookRepo; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * HomeController constructor. | ||
| 21 | + * @param ActivityService $activityService | ||
| 22 | + * @param BookRepo $bookRepo | ||
| 23 | + */ | ||
| 24 | + public function __construct(ActivityService $activityService, BookRepo $bookRepo) | ||
| 25 | + { | ||
| 26 | + $this->activityService = $activityService; | ||
| 27 | + $this->bookRepo = $bookRepo; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * Display the homepage. | ||
| 33 | + * | ||
| 34 | + * @return Response | ||
| 35 | + */ | ||
| 36 | + public function index() | ||
| 37 | + { | ||
| 38 | + $books = $this->bookRepo->getAll(); | ||
| 39 | + $activity = $this->activityService->latest(); | ||
| 40 | + return view('home', ['books' => $books, 'activity' => $activity]); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | +} |
| ... | @@ -79,12 +79,9 @@ Route::group(['middleware' => 'auth'], function() { | ... | @@ -79,12 +79,9 @@ Route::group(['middleware' => 'auth'], function() { |
| 79 | // Search | 79 | // Search |
| 80 | Route::get('/pages/search/all', 'PageController@searchAll'); | 80 | Route::get('/pages/search/all', 'PageController@searchAll'); |
| 81 | 81 | ||
| 82 | - Route::get('/', function () { | 82 | + // Other Pages |
| 83 | - return view('home'); | 83 | + Route::get('/', 'HomeController@index'); |
| 84 | - }); | 84 | + Route::get('/home', 'HomeController@index'); |
| 85 | - Route::get('/home', function () { | ||
| 86 | - return view('home'); | ||
| 87 | - }); | ||
| 88 | 85 | ||
| 89 | 86 | ||
| 90 | }); | 87 | }); | ... | ... |
| ... | @@ -19,7 +19,6 @@ class ActivityService | ... | @@ -19,7 +19,6 @@ class ActivityService |
| 19 | $this->user = Auth::user(); | 19 | $this->user = Auth::user(); |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | - | ||
| 23 | /** | 22 | /** |
| 24 | * Add activity data to database. | 23 | * Add activity data to database. |
| 25 | * @para Entity $entity | 24 | * @para Entity $entity |
| ... | @@ -54,4 +53,15 @@ class ActivityService | ... | @@ -54,4 +53,15 @@ class ActivityService |
| 54 | $this->activity->save(); | 53 | $this->activity->save(); |
| 55 | } | 54 | } |
| 56 | 55 | ||
| 56 | + /** | ||
| 57 | + * Gets the latest activity. | ||
| 58 | + * @param int $count | ||
| 59 | + * @param int $page | ||
| 60 | + */ | ||
| 61 | + public function latest($count = 20, $page = 0) | ||
| 62 | + { | ||
| 63 | + return $this->activity->orderBy('created_at', 'desc') | ||
| 64 | + ->skip($count*$page)->take($count)->get(); | ||
| 65 | + } | ||
| 66 | + | ||
| 57 | } | 67 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
| 18 | "tinymce-dist": "~4.2.1", | 18 | "tinymce-dist": "~4.2.1", |
| 19 | "bootstrap": "~3.3.5", | 19 | "bootstrap": "~3.3.5", |
| 20 | "jquery-sortable": "~0.9.13", | 20 | "jquery-sortable": "~0.9.13", |
| 21 | - "material-design-iconic-font": "~2.1.1" | 21 | + "material-design-iconic-font": "~2.1.1", |
| 22 | + "vue": "~0.12.10" | ||
| 22 | } | 23 | } |
| 23 | } | 24 | } | ... | ... |
| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | "laravel-elixir-livereload": "0.0.3" | 5 | "laravel-elixir-livereload": "0.0.3" |
| 6 | }, | 6 | }, |
| 7 | "dependencies": { | 7 | "dependencies": { |
| 8 | - "laravel-elixir": "^2.0.0", | 8 | + "bootstrap-sass": "^3.0.0", |
| 9 | - "bootstrap-sass": "^3.0.0" | 9 | + "laravel-elixir": "^2.0.0" |
| 10 | } | 10 | } |
| 11 | } | 11 | } | ... | ... |
| ... | @@ -46,12 +46,13 @@ header { | ... | @@ -46,12 +46,13 @@ header { |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | .logo-container { | 48 | .logo-container { |
| 49 | - padding: $-xl $-s $-l $-s; | 49 | + padding: $-l $-s; |
| 50 | color: #CCC; | 50 | color: #CCC; |
| 51 | .logo { | 51 | .logo { |
| 52 | + display: block; | ||
| 52 | font-size: 2em; | 53 | font-size: 2em; |
| 53 | font-weight: bold; | 54 | font-weight: bold; |
| 54 | - margin-bottom: $-m; | 55 | + padding: $-m 0; |
| 55 | } | 56 | } |
| 56 | i { | 57 | i { |
| 57 | padding-right: $-s; | 58 | padding-right: $-s; |
| ... | @@ -63,11 +64,12 @@ header { | ... | @@ -63,11 +64,12 @@ header { |
| 63 | input { | 64 | input { |
| 64 | width: 100%; | 65 | width: 100%; |
| 65 | border-radius: 0; | 66 | border-radius: 0; |
| 66 | - padding: $-s $-m; | 67 | + padding: $-m; |
| 67 | background-color: rgba(0, 0, 0, 0.1); | 68 | background-color: rgba(0, 0, 0, 0.1); |
| 68 | border: none; | 69 | border: none; |
| 69 | border-top: 1px solid #333; | 70 | border-top: 1px solid #333; |
| 70 | border-bottom: 1px solid #333; | 71 | border-bottom: 1px solid #333; |
| 72 | + color: #EEE; | ||
| 71 | } | 73 | } |
| 72 | } | 74 | } |
| 73 | 75 | ... | ... |
| ... | @@ -22,5 +22,6 @@ return [ | ... | @@ -22,5 +22,6 @@ return [ |
| 22 | 'book_create' => 'created book', | 22 | 'book_create' => 'created book', |
| 23 | 'book_update' => 'updated book', | 23 | 'book_update' => 'updated book', |
| 24 | 'book_delete' => 'deleted book', | 24 | 'book_delete' => 'deleted book', |
| 25 | + 'book_sort' => 'sorted book', | ||
| 25 | 26 | ||
| 26 | ]; | 27 | ]; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -12,7 +12,7 @@ | ... | @@ -12,7 +12,7 @@ |
| 12 | <script src="/bower/bootstrap/dist/js/bootstrap.js"></script> | 12 | <script src="/bower/bootstrap/dist/js/bootstrap.js"></script> |
| 13 | <script src="/bower/jquery-sortable/source/js/jquery-sortable.js"></script> | 13 | <script src="/bower/jquery-sortable/source/js/jquery-sortable.js"></script> |
| 14 | <script src="/bower/dropzone/dist/min/dropzone.min.js"></script> | 14 | <script src="/bower/dropzone/dist/min/dropzone.min.js"></script> |
| 15 | - <script src="http://cdnjs.cloudflare.com/ajax/libs/vue/0.12.10/vue.min.js"></script> | 15 | + <script src="/bower/vue/dist/vue.min.js"></script> |
| 16 | <script> | 16 | <script> |
| 17 | $.fn.smoothScrollTo = function() { | 17 | $.fn.smoothScrollTo = function() { |
| 18 | if(this.length === 0) return; | 18 | if(this.length === 0) return; |
| ... | @@ -36,9 +36,8 @@ | ... | @@ -36,9 +36,8 @@ |
| 36 | <header> | 36 | <header> |
| 37 | <div class="padded row clearfix"> | 37 | <div class="padded row clearfix"> |
| 38 | <div class="col-md-12 logo-container"> | 38 | <div class="col-md-12 logo-container"> |
| 39 | - {{--<div ><img class="logo float left" src="/bookstack.svg" alt="BookStack"></div>--}} | 39 | + <a href="/" class="logo">BookStack</a> |
| 40 | - <div class="logo">BookStack</div> | 40 | + <div><i class="zmdi zmdi-account"></i> {{ Auth::user()->name }}</div> |
| 41 | - <div><i class="zmdi zmdi-account"></i> {{ \Illuminate\Support\Facades\Auth::user()->name }}</div> | ||
| 42 | </div> | 41 | </div> |
| 43 | </div> | 42 | </div> |
| 44 | </header> | 43 | </header> | ... | ... |
| ... | @@ -65,7 +65,7 @@ | ... | @@ -65,7 +65,7 @@ |
| 65 | <div class="col-md-3 col-md-offset-1"> | 65 | <div class="col-md-3 col-md-offset-1"> |
| 66 | <div class="margin-top large"><br></div> | 66 | <div class="margin-top large"><br></div> |
| 67 | <h3>Recent Activity</h3> | 67 | <h3>Recent Activity</h3> |
| 68 | - @include('partials/activity-list', ['entity' => $book]) | 68 | + @include('partials/activity-list', ['activity' => $book->recentActivity()]) |
| 69 | </div> | 69 | </div> |
| 70 | </div> | 70 | </div> |
| 71 | 71 | ... | ... |
| 1 | @extends('base') | 1 | @extends('base') |
| 2 | 2 | ||
| 3 | @section('content') | 3 | @section('content') |
| 4 | - <div id="container"></div> | ||
| 5 | -@stop | ||
| 6 | 4 | ||
| 5 | + <div class="row"> | ||
| 6 | + <div class="col-md-6 col-md-offset-1"> | ||
| 7 | + <div class="page-content"> | ||
| 8 | + <h2>Books</h2> | ||
| 9 | + @foreach($books as $book) | ||
| 10 | + <div class="book"> | ||
| 11 | + <h3><a href="{{$book->getUrl()}}">{{$book->name}}</a></h3> | ||
| 12 | + <p class="text-muted">{{$book->description}}</p> | ||
| 13 | + </div> | ||
| 14 | + <hr> | ||
| 15 | + @endforeach | ||
| 16 | + </div> | ||
| 17 | + </div> | ||
| 18 | + <div class="col-md-3 col-md-offset-1"> | ||
| 19 | + <div class="margin-top large"> </div> | ||
| 20 | + <h3>Recent Activity</h3> | ||
| 21 | + @include('partials/activity-list', ['activity' => $activity]) | ||
| 22 | + </div> | ||
| 23 | + </div> | ||
| 7 | 24 | ||
| 8 | -@section('bottom') | ||
| 9 | - @include('pages/image-manager') | ||
| 10 | - <div id="image-manager-container"></div> | ||
| 11 | - <script src="/js/image-manager.js"></script> | ||
| 12 | - <script> | ||
| 13 | - window.ImageManager.show(); | ||
| 14 | - </script> | ||
| 15 | @stop | 25 | @stop |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -2,8 +2,6 @@ | ... | @@ -2,8 +2,6 @@ |
| 2 | 2 | ||
| 3 | @section('head') | 3 | @section('head') |
| 4 | <script src="/bower/tinymce-dist/tinymce.jquery.min.js"></script> | 4 | <script src="/bower/tinymce-dist/tinymce.jquery.min.js"></script> |
| 5 | - <script src="/bower/dropzone/dist/min/dropzone.min.js"></script> | ||
| 6 | - <script src="/js/image-manager.js"></script> | ||
| 7 | @stop | 5 | @stop |
| 8 | 6 | ||
| 9 | @section('content') | 7 | @section('content') |
| ... | @@ -17,4 +15,5 @@ | ... | @@ -17,4 +15,5 @@ |
| 17 | 15 | ||
| 18 | @section('bottom') | 16 | @section('bottom') |
| 19 | @include('pages/image-manager') | 17 | @include('pages/image-manager') |
| 18 | + <script src="/js/image-manager.js"></script> | ||
| 20 | @stop | 19 | @stop |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -15,6 +15,5 @@ | ... | @@ -15,6 +15,5 @@ |
| 15 | 15 | ||
| 16 | @section('bottom') | 16 | @section('bottom') |
| 17 | @include('pages/image-manager') | 17 | @include('pages/image-manager') |
| 18 | - <div id="image-manager-container"></div> | ||
| 19 | <script src="/js/image-manager.js"></script> | 18 | <script src="/js/image-manager.js"></script> |
| 20 | @stop | 19 | @stop |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | 1 | ||
| 2 | {{--Requires an entity to be passed with the name $entity--}} | 2 | {{--Requires an entity to be passed with the name $entity--}} |
| 3 | 3 | ||
| 4 | -@if(count($entity->recentActivity()) > 0) | 4 | +@if(count($activity) > 0) |
| 5 | <div class="activity-list"> | 5 | <div class="activity-list"> |
| 6 | - @foreach($entity->recentActivity() as $activity) | 6 | + @foreach($activity as $activityItem) |
| 7 | <div class="activity-list-item"> | 7 | <div class="activity-list-item"> |
| 8 | - @include('partials/activity-item') | 8 | + @include('partials/activity-item', ['activity' => $activityItem]) |
| 9 | </div> | 9 | </div> |
| 10 | @endforeach | 10 | @endforeach |
| 11 | </div> | 11 | </div> | ... | ... |
-
Please register or sign in to post a comment