Dan Brown

Added sidebar highlighting and fixed code elements. Fixes #18

...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
2 2
3 namespace Oxbow; 3 namespace Oxbow;
4 4
5 -use Illuminate\Database\Eloquent\Model; 5 +class Book extends Entity
6 -
7 -class Book extends Model
8 { 6 {
9 7
10 protected $fillable = ['name', 'description']; 8 protected $fillable = ['name', 'description'];
...@@ -29,16 +27,6 @@ class Book extends Model ...@@ -29,16 +27,6 @@ class Book extends Model
29 return $this->hasMany('Oxbow\Chapter'); 27 return $this->hasMany('Oxbow\Chapter');
30 } 28 }
31 29
32 - public function createdBy()
33 - {
34 - return $this->belongsTo('Oxbow\User', 'created_by');
35 - }
36 -
37 - public function updatedBy()
38 - {
39 - return $this->belongsTo('Oxbow\User', 'updated_by');
40 - }
41 -
42 public function children() 30 public function children()
43 { 31 {
44 $pages = $this->pages()->where('chapter_id', '=', 0)->get(); 32 $pages = $this->pages()->where('chapter_id', '=', 0)->get();
......
1 <?php namespace Oxbow; 1 <?php namespace Oxbow;
2 2
3 -use Illuminate\Database\Eloquent\Model;
4 3
5 -class Chapter extends Model 4 +class Chapter extends Entity
6 { 5 {
7 6
8 protected $fillable = ['name', 'description', 'priority', 'book_id']; 7 protected $fillable = ['name', 'description', 'priority', 'book_id'];
...@@ -17,16 +16,6 @@ class Chapter extends Model ...@@ -17,16 +16,6 @@ class Chapter extends Model
17 return $this->hasMany('Oxbow\Page')->orderBy('priority', 'ASC'); 16 return $this->hasMany('Oxbow\Page')->orderBy('priority', 'ASC');
18 } 17 }
19 18
20 - public function createdBy()
21 - {
22 - return $this->belongsTo('Oxbow\User', 'created_by');
23 - }
24 -
25 - public function updatedBy()
26 - {
27 - return $this->belongsTo('Oxbow\User', 'updated_by');
28 - }
29 -
30 public function getUrl() 19 public function getUrl()
31 { 20 {
32 return '/books/' . $this->book->slug . '/chapter/' . $this->slug; 21 return '/books/' . $this->book->slug . '/chapter/' . $this->slug;
......
1 +<?php
2 +
3 +namespace Oxbow;
4 +
5 +use Illuminate\Database\Eloquent\Model;
6 +
7 +class Entity extends Model
8 +{
9 + /**
10 + * Relation for the user that created this entity.
11 + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
12 + */
13 + public function createdBy()
14 + {
15 + return $this->belongsTo('Oxbow\User', 'created_by');
16 + }
17 +
18 + /**
19 + * Relation for the user that updated this entity.
20 + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
21 + */
22 + public function updatedBy()
23 + {
24 + return $this->belongsTo('Oxbow\User', 'updated_by');
25 + }
26 +
27 + /**
28 + * Compares this entity to another given entity.
29 + * Matches by comparing class and id.
30 + * @param $entity
31 + * @return bool
32 + */
33 + public function matches($entity)
34 + {
35 + return [get_class($this), $this->id] === [get_class($entity), $entity->id];
36 + }
37 +}
...@@ -77,7 +77,7 @@ class BookController extends Controller ...@@ -77,7 +77,7 @@ class BookController extends Controller
77 public function show($slug) 77 public function show($slug)
78 { 78 {
79 $book = $this->bookRepo->getBySlug($slug); 79 $book = $this->bookRepo->getBySlug($slug);
80 - return view('books/show', ['book' => $book]); 80 + return view('books/show', ['book' => $book, 'current' => $book]);
81 } 81 }
82 82
83 /** 83 /**
...@@ -89,7 +89,7 @@ class BookController extends Controller ...@@ -89,7 +89,7 @@ class BookController extends Controller
89 public function edit($slug) 89 public function edit($slug)
90 { 90 {
91 $book = $this->bookRepo->getBySlug($slug); 91 $book = $this->bookRepo->getBySlug($slug);
92 - return view('books/edit', ['book' => $book]); 92 + return view('books/edit', ['book' => $book, 'current' => $book]);
93 } 93 }
94 94
95 /** 95 /**
...@@ -121,7 +121,7 @@ class BookController extends Controller ...@@ -121,7 +121,7 @@ class BookController extends Controller
121 public function showDelete($bookSlug) 121 public function showDelete($bookSlug)
122 { 122 {
123 $book = $this->bookRepo->getBySlug($bookSlug); 123 $book = $this->bookRepo->getBySlug($bookSlug);
124 - return view('books/delete', ['book' => $book]); 124 + return view('books/delete', ['book' => $book, 'current' => $book]);
125 } 125 }
126 126
127 /** 127 /**
......
...@@ -37,7 +37,7 @@ class ChapterController extends Controller ...@@ -37,7 +37,7 @@ class ChapterController extends Controller
37 public function create($bookSlug) 37 public function create($bookSlug)
38 { 38 {
39 $book = $this->bookRepo->getBySlug($bookSlug); 39 $book = $this->bookRepo->getBySlug($bookSlug);
40 - return view('chapters/create', ['book' => $book]); 40 + return view('chapters/create', ['book' => $book, 'current' => $book]);
41 } 41 }
42 42
43 /** 43 /**
...@@ -74,7 +74,7 @@ class ChapterController extends Controller ...@@ -74,7 +74,7 @@ class ChapterController extends Controller
74 { 74 {
75 $book = $this->bookRepo->getBySlug($bookSlug); 75 $book = $this->bookRepo->getBySlug($bookSlug);
76 $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id); 76 $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
77 - return view('chapters/show', ['book' => $book, 'chapter' => $chapter]); 77 + return view('chapters/show', ['book' => $book, 'chapter' => $chapter, 'current' => $chapter]);
78 } 78 }
79 79
80 /** 80 /**
...@@ -88,7 +88,7 @@ class ChapterController extends Controller ...@@ -88,7 +88,7 @@ class ChapterController extends Controller
88 { 88 {
89 $book = $this->bookRepo->getBySlug($bookSlug); 89 $book = $this->bookRepo->getBySlug($bookSlug);
90 $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id); 90 $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
91 - return view('chapters/edit', ['book' => $book, 'chapter' => $chapter]); 91 + return view('chapters/edit', ['book' => $book, 'chapter' => $chapter, 'current' => $chapter]);
92 } 92 }
93 93
94 /** 94 /**
...@@ -120,7 +120,7 @@ class ChapterController extends Controller ...@@ -120,7 +120,7 @@ class ChapterController extends Controller
120 { 120 {
121 $book = $this->bookRepo->getBySlug($bookSlug); 121 $book = $this->bookRepo->getBySlug($bookSlug);
122 $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id); 122 $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
123 - return view('chapters/delete', ['book' => $book, 'chapter' => $chapter]); 123 + return view('chapters/delete', ['book' => $book, 'chapter' => $chapter, 'current' => $chapter]);
124 } 124 }
125 125
126 /** 126 /**
......
...@@ -90,7 +90,7 @@ class PageController extends Controller ...@@ -90,7 +90,7 @@ class PageController extends Controller
90 { 90 {
91 $book = $this->bookRepo->getBySlug($bookSlug); 91 $book = $this->bookRepo->getBySlug($bookSlug);
92 $page = $this->pageRepo->getBySlug($pageSlug, $book->id); 92 $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
93 - return view('pages/show', ['page' => $page, 'book' => $book]); 93 + return view('pages/show', ['page' => $page, 'book' => $book, 'current' => $page]);
94 } 94 }
95 95
96 /** 96 /**
...@@ -104,7 +104,7 @@ class PageController extends Controller ...@@ -104,7 +104,7 @@ class PageController extends Controller
104 { 104 {
105 $book = $this->bookRepo->getBySlug($bookSlug); 105 $book = $this->bookRepo->getBySlug($bookSlug);
106 $page = $this->pageRepo->getBySlug($pageSlug, $book->id); 106 $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
107 - return view('pages/edit', ['page' => $page, 'book' => $book]); 107 + return view('pages/edit', ['page' => $page, 'book' => $book, 'current' => $page]);
108 } 108 }
109 109
110 /** 110 /**
...@@ -157,7 +157,7 @@ class PageController extends Controller ...@@ -157,7 +157,7 @@ class PageController extends Controller
157 public function sortPages($bookSlug) 157 public function sortPages($bookSlug)
158 { 158 {
159 $book = $this->bookRepo->getBySlug($bookSlug); 159 $book = $this->bookRepo->getBySlug($bookSlug);
160 - return view('pages/sort', ['book' => $book]); 160 + return view('pages/sort', ['book' => $book, 'current' => $book]);
161 } 161 }
162 162
163 /** 163 /**
...@@ -200,7 +200,7 @@ class PageController extends Controller ...@@ -200,7 +200,7 @@ class PageController extends Controller
200 { 200 {
201 $book = $this->bookRepo->getBySlug($bookSlug); 201 $book = $this->bookRepo->getBySlug($bookSlug);
202 $page = $this->pageRepo->getBySlug($pageSlug, $book->id); 202 $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
203 - return view('pages/delete', ['book' => $book, 'page' => $page]); 203 + return view('pages/delete', ['book' => $book, 'page' => $page, 'current' => $page]);
204 } 204 }
205 205
206 /** 206 /**
...@@ -229,7 +229,7 @@ class PageController extends Controller ...@@ -229,7 +229,7 @@ class PageController extends Controller
229 { 229 {
230 $book = $this->bookRepo->getBySlug($bookSlug); 230 $book = $this->bookRepo->getBySlug($bookSlug);
231 $page = $this->pageRepo->getBySlug($pageSlug, $book->id); 231 $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
232 - return view('pages/revisions', ['page' => $page, 'book' => $book]); 232 + return view('pages/revisions', ['page' => $page, 'book' => $book, 'current' => $page]);
233 } 233 }
234 234
235 /** 235 /**
......
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
2 2
3 namespace Oxbow; 3 namespace Oxbow;
4 4
5 -use Illuminate\Database\Eloquent\Model;
6 5
7 -class Image extends Model 6 +class Image extends Entity
8 { 7 {
9 8
10 protected $fillable = ['name']; 9 protected $fillable = ['name'];
...@@ -14,13 +13,4 @@ class Image extends Model ...@@ -14,13 +13,4 @@ class Image extends Model
14 return storage_path() . $this->url; 13 return storage_path() . $this->url;
15 } 14 }
16 15
17 - public function createdBy()
18 - {
19 - return $this->belongsTo('Oxbow\User', 'created_by');
20 - }
21 -
22 - public function updatedBy()
23 - {
24 - return $this->belongsTo('Oxbow\User', 'updated_by');
25 - }
26 } 16 }
......
...@@ -4,7 +4,7 @@ namespace Oxbow; ...@@ -4,7 +4,7 @@ namespace Oxbow;
4 4
5 use Illuminate\Database\Eloquent\Model; 5 use Illuminate\Database\Eloquent\Model;
6 6
7 -class Page extends Model 7 +class Page extends Entity
8 { 8 {
9 protected $fillable = ['name', 'html', 'priority']; 9 protected $fillable = ['name', 'html', 'priority'];
10 10
...@@ -32,15 +32,6 @@ class Page extends Model ...@@ -32,15 +32,6 @@ class Page extends Model
32 return $this->chapter()->count() > 0; 32 return $this->chapter()->count() > 0;
33 } 33 }
34 34
35 - public function createdBy()
36 - {
37 - return $this->belongsTo('Oxbow\User', 'created_by');
38 - }
39 -
40 - public function updatedBy()
41 - {
42 - return $this->belongsTo('Oxbow\User', 'updated_by');
43 - }
44 35
45 public function revisions() 36 public function revisions()
46 { 37 {
......
...@@ -78,11 +78,17 @@ input[type="text"], input[type="number"], input[type="email"], input[type="searc ...@@ -78,11 +78,17 @@ input[type="text"], input[type="number"], input[type="email"], input[type="searc
78 78
79 .title-input.page-title { 79 .title-input.page-title {
80 font-size: 0.8em; 80 font-size: 0.8em;
81 + .input {
82 + border: 1px solid #BBB;
83 + margin-bottom: -1px;
84 + }
85 + input[type="text"] {
86 + max-width: 840px;
87 + margin: 0 auto;
88 + border: none;
89 + }
81 } 90 }
82 -.title-input.page-title input[type="text"]{ 91 +
83 - //border: 2px dotted #BBB;
84 - margin-bottom: 0;
85 -}
86 92
87 93
88 .description-input textarea { 94 .description-input textarea {
......
...@@ -133,14 +133,15 @@ blockquote { ...@@ -133,14 +133,15 @@ blockquote {
133 .code-base { 133 .code-base {
134 background-color: #F8F8F8; 134 background-color: #F8F8F8;
135 font-family: monospace; 135 font-family: monospace;
136 - font-size: 0.88em; 136 + font-size: 0.80em;
137 border: 1px solid #DDD; 137 border: 1px solid #DDD;
138 border-radius: 3px; 138 border-radius: 3px;
139 } 139 }
140 140
141 code { 141 code {
142 @extend .code-base; 142 @extend .code-base;
143 - display: block; 143 + display: inline;
144 + padding: 1px 3px;
144 white-space:pre; 145 white-space:pre;
145 line-height: 1.2em; 146 line-height: 1.2em;
146 margin-bottom: 1.2em; 147 margin-bottom: 1.2em;
......
...@@ -270,10 +270,15 @@ h1, h2, h3, h4, h5, h6 { ...@@ -270,10 +270,15 @@ h1, h2, h3, h4, h5, h6 {
270 .book-tree .sidebar-page-list { 270 .book-tree .sidebar-page-list {
271 list-style: none; 271 list-style: none;
272 margin: 0; 272 margin: 0;
273 + margin-top: $-xl;
273 border-left: 5px solid #7BD06E; 274 border-left: 5px solid #7BD06E;
274 li a { 275 li a {
275 display: block; 276 display: block;
276 - border-bottom: 1px solid #3A3939; 277 + border-bottom: none;
278 + &:hover {
279 + background-color: rgba(255, 255, 255, 0.2);
280 + text-decoration: none;
281 + }
277 } 282 }
278 li, a { 283 li, a {
279 display: block; 284 display: block;
...@@ -290,19 +295,32 @@ h1, h2, h3, h4, h5, h6 { ...@@ -290,19 +295,32 @@ h1, h2, h3, h4, h5, h6 {
290 } 295 }
291 .book { 296 .book {
292 color: #7BD06E !important; 297 color: #7BD06E !important;
298 + &.selected {
299 + background-color: rgba(123, 208, 110, 0.29);
300 + }
293 } 301 }
294 .chapter { 302 .chapter {
295 color: #D2A64B !important; 303 color: #D2A64B !important;
304 + &.selected {
305 + background-color: rgba(239, 169, 42, 0.27);
306 + }
296 } 307 }
297 .list-item-chapter { 308 .list-item-chapter {
298 border-left: 5px solid #D2A64B; 309 border-left: 5px solid #D2A64B;
299 margin: 10px 10px; 310 margin: 10px 10px;
300 display: block; 311 display: block;
301 } 312 }
313 + .list-item-page {
314 + border-bottom: none;
315 + }
302 .page { 316 .page {
303 color: #4599DC !important; 317 color: #4599DC !important;
304 border-left: 5px solid #4599DC; 318 border-left: 5px solid #4599DC;
305 margin: 10px 10px; 319 margin: 10px 10px;
320 + border-bottom: none;
321 + &.selected {
322 + background-color: rgba(118, 164, 202, 0.41);
323 + }
306 } 324 }
307 } 325 }
308 326
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
52 <li><a href="/users"><i class="zmdi zmdi-accounts"></i>Users</a></li> 52 <li><a href="/users"><i class="zmdi zmdi-accounts"></i>Users</a></li>
53 <li><a href="/logout"><i class="zmdi zmdi-run zmdi-hc-flip-horizontal"></i>Logout</a></li> 53 <li><a href="/logout"><i class="zmdi zmdi-run zmdi-hc-flip-horizontal"></i>Logout</a></li>
54 </ul> 54 </ul>
55 - @if(isset($book) && !isset($books)) 55 + @if(isset($book) && isset($current) && !isset($books))
56 <div class="book-tree"> 56 <div class="book-tree">
57 @include('pages/sidebar-tree-list', ['book' => $book]) 57 @include('pages/sidebar-tree-list', ['book' => $book])
58 </div> 58 </div>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
6 {{ csrf_field() }} 6 {{ csrf_field() }}
7 <div class="title-input page-title clearfix"> 7 <div class="title-input page-title clearfix">
8 <div class="input"> 8 <div class="input">
9 - @include('form/text', ['name' => 'name', 'placeholder' => 'Enter Page Title']) 9 + @include('form/text', ['name' => 'name', 'placeholder' => 'Page Title'])
10 </div> 10 </div>
11 </div> 11 </div>
12 <div class="edit-area"> 12 <div class="edit-area">
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
38 menubar: false, 38 menubar: false,
39 height: 700, 39 height: 700,
40 plugins: "image table textcolor paste link imagetools fullscreen", 40 plugins: "image table textcolor paste link imagetools fullscreen",
41 - toolbar: "undo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image link | fontsizeselect fullscreen", 41 + toolbar: "undo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image link | fullscreen",
42 content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}", 42 content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}",
43 file_browser_callback: function(field_name, url, type, win) { 43 file_browser_callback: function(field_name, url, type, win) {
44 ImageManager.show(function(image) { 44 ImageManager.show(function(image) {
......
1 1
2 <ul class="sidebar-page-list menu"> 2 <ul class="sidebar-page-list menu">
3 - <li class="book-header"><a href="{{$book->getUrl()}}" class="book"><i class="zmdi zmdi-book"></i>{{$book->name}}</a></li> 3 + <li class="book-header"><a href="{{$book->getUrl()}}" class="book {{ $current->matches($book)? 'selected' : '' }}"><i class="zmdi zmdi-book"></i>{{$book->name}}</a></li>
4 @foreach($book->children() as $bookChild) 4 @foreach($book->children() as $bookChild)
5 <li class="list-item-{{is_a($bookChild, 'Oxbow\Chapter') ? 'chapter' : 'page' }}"> 5 <li class="list-item-{{is_a($bookChild, 'Oxbow\Chapter') ? 'chapter' : 'page' }}">
6 - <a href="{{$bookChild->getUrl()}}" class="{{is_a($bookChild, 'Oxbow\Chapter') ? 'chapter' : 'page' }}"> 6 + <a href="{{$bookChild->getUrl()}}" class="{{is_a($bookChild, 'Oxbow\Chapter') ? 'chapter' : 'page' }} {{ $current->matches($bookChild)? 'selected' : '' }}">
7 @if(is_a($bookChild, 'Oxbow\Chapter')) 7 @if(is_a($bookChild, 'Oxbow\Chapter'))
8 <i class="zmdi zmdi-collection-bookmark chapter-toggle"></i> 8 <i class="zmdi zmdi-collection-bookmark chapter-toggle"></i>
9 @else 9 @else
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
14 14
15 @if(is_a($bookChild, 'Oxbow\Chapter') && count($bookChild->pages) > 0) 15 @if(is_a($bookChild, 'Oxbow\Chapter') && count($bookChild->pages) > 0)
16 <ul class="menu"> 16 <ul class="menu">
17 - @foreach($bookChild->pages as $page) 17 + @foreach($bookChild->pages as $childPage)
18 <li class="list-item-page"> 18 <li class="list-item-page">
19 - <a href="{{$page->getUrl()}}" class="page"> 19 + <a href="{{$childPage->getUrl()}}" class="page {{ $current->matches($childPage)? 'selected' : '' }}">
20 - <i class="zmdi zmdi-file-text"></i> {{ $page->name }} 20 + <i class="zmdi zmdi-file-text"></i> {{ $childPage->name }}
21 </a> 21 </a>
22 </li> 22 </li>
23 @endforeach 23 @endforeach
......