diff --git a/app/Book.php b/app/Book.php index abd23d64e..8a4be213f 100644 --- a/app/Book.php +++ b/app/Book.php @@ -2,9 +2,7 @@ namespace Oxbow; -use Illuminate\Database\Eloquent\Model; - -class Book extends Model +class Book extends Entity { protected $fillable = ['name', 'description']; @@ -29,16 +27,6 @@ class Book extends Model return $this->hasMany('Oxbow\Chapter'); } - public function createdBy() - { - return $this->belongsTo('Oxbow\User', 'created_by'); - } - - public function updatedBy() - { - return $this->belongsTo('Oxbow\User', 'updated_by'); - } - public function children() { $pages = $this->pages()->where('chapter_id', '=', 0)->get(); diff --git a/app/Chapter.php b/app/Chapter.php index b7623798a..4e011cec9 100644 --- a/app/Chapter.php +++ b/app/Chapter.php @@ -1,8 +1,7 @@ hasMany('Oxbow\Page')->orderBy('priority', 'ASC'); } - public function createdBy() - { - return $this->belongsTo('Oxbow\User', 'created_by'); - } - - public function updatedBy() - { - return $this->belongsTo('Oxbow\User', 'updated_by'); - } - public function getUrl() { return '/books/' . $this->book->slug . '/chapter/' . $this->slug; diff --git a/app/Entity.php b/app/Entity.php new file mode 100644 index 000000000..2d81ccd48 --- /dev/null +++ b/app/Entity.php @@ -0,0 +1,37 @@ +belongsTo('Oxbow\User', 'created_by'); + } + + /** + * Relation for the user that updated this entity. + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function updatedBy() + { + return $this->belongsTo('Oxbow\User', 'updated_by'); + } + + /** + * Compares this entity to another given entity. + * Matches by comparing class and id. + * @param $entity + * @return bool + */ + public function matches($entity) + { + return [get_class($this), $this->id] === [get_class($entity), $entity->id]; + } +} diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 6791c0f2a..97c401028 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -77,7 +77,7 @@ class BookController extends Controller public function show($slug) { $book = $this->bookRepo->getBySlug($slug); - return view('books/show', ['book' => $book]); + return view('books/show', ['book' => $book, 'current' => $book]); } /** @@ -89,7 +89,7 @@ class BookController extends Controller public function edit($slug) { $book = $this->bookRepo->getBySlug($slug); - return view('books/edit', ['book' => $book]); + return view('books/edit', ['book' => $book, 'current' => $book]); } /** @@ -121,7 +121,7 @@ class BookController extends Controller public function showDelete($bookSlug) { $book = $this->bookRepo->getBySlug($bookSlug); - return view('books/delete', ['book' => $book]); + return view('books/delete', ['book' => $book, 'current' => $book]); } /** diff --git a/app/Http/Controllers/ChapterController.php b/app/Http/Controllers/ChapterController.php index d5ccae024..eec5971a9 100644 --- a/app/Http/Controllers/ChapterController.php +++ b/app/Http/Controllers/ChapterController.php @@ -37,7 +37,7 @@ class ChapterController extends Controller public function create($bookSlug) { $book = $this->bookRepo->getBySlug($bookSlug); - return view('chapters/create', ['book' => $book]); + return view('chapters/create', ['book' => $book, 'current' => $book]); } /** @@ -74,7 +74,7 @@ class ChapterController extends Controller { $book = $this->bookRepo->getBySlug($bookSlug); $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id); - return view('chapters/show', ['book' => $book, 'chapter' => $chapter]); + return view('chapters/show', ['book' => $book, 'chapter' => $chapter, 'current' => $chapter]); } /** @@ -88,7 +88,7 @@ class ChapterController extends Controller { $book = $this->bookRepo->getBySlug($bookSlug); $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id); - return view('chapters/edit', ['book' => $book, 'chapter' => $chapter]); + return view('chapters/edit', ['book' => $book, 'chapter' => $chapter, 'current' => $chapter]); } /** @@ -120,7 +120,7 @@ class ChapterController extends Controller { $book = $this->bookRepo->getBySlug($bookSlug); $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id); - return view('chapters/delete', ['book' => $book, 'chapter' => $chapter]); + return view('chapters/delete', ['book' => $book, 'chapter' => $chapter, 'current' => $chapter]); } /** diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index b64290eaa..a41db39ef 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -90,7 +90,7 @@ class PageController extends Controller { $book = $this->bookRepo->getBySlug($bookSlug); $page = $this->pageRepo->getBySlug($pageSlug, $book->id); - return view('pages/show', ['page' => $page, 'book' => $book]); + return view('pages/show', ['page' => $page, 'book' => $book, 'current' => $page]); } /** @@ -104,7 +104,7 @@ class PageController extends Controller { $book = $this->bookRepo->getBySlug($bookSlug); $page = $this->pageRepo->getBySlug($pageSlug, $book->id); - return view('pages/edit', ['page' => $page, 'book' => $book]); + return view('pages/edit', ['page' => $page, 'book' => $book, 'current' => $page]); } /** @@ -157,7 +157,7 @@ class PageController extends Controller public function sortPages($bookSlug) { $book = $this->bookRepo->getBySlug($bookSlug); - return view('pages/sort', ['book' => $book]); + return view('pages/sort', ['book' => $book, 'current' => $book]); } /** @@ -200,7 +200,7 @@ class PageController extends Controller { $book = $this->bookRepo->getBySlug($bookSlug); $page = $this->pageRepo->getBySlug($pageSlug, $book->id); - return view('pages/delete', ['book' => $book, 'page' => $page]); + return view('pages/delete', ['book' => $book, 'page' => $page, 'current' => $page]); } /** @@ -229,7 +229,7 @@ class PageController extends Controller { $book = $this->bookRepo->getBySlug($bookSlug); $page = $this->pageRepo->getBySlug($pageSlug, $book->id); - return view('pages/revisions', ['page' => $page, 'book' => $book]); + return view('pages/revisions', ['page' => $page, 'book' => $book, 'current' => $page]); } /** diff --git a/app/Image.php b/app/Image.php index 07db68785..f80f33fff 100644 --- a/app/Image.php +++ b/app/Image.php @@ -2,9 +2,8 @@ namespace Oxbow; -use Illuminate\Database\Eloquent\Model; -class Image extends Model +class Image extends Entity { protected $fillable = ['name']; @@ -14,13 +13,4 @@ class Image extends Model return storage_path() . $this->url; } - public function createdBy() - { - return $this->belongsTo('Oxbow\User', 'created_by'); - } - - public function updatedBy() - { - return $this->belongsTo('Oxbow\User', 'updated_by'); - } } diff --git a/app/Page.php b/app/Page.php index 8ae744a8a..0fda5dec3 100644 --- a/app/Page.php +++ b/app/Page.php @@ -4,7 +4,7 @@ namespace Oxbow; use Illuminate\Database\Eloquent\Model; -class Page extends Model +class Page extends Entity { protected $fillable = ['name', 'html', 'priority']; @@ -32,15 +32,6 @@ class Page extends Model return $this->chapter()->count() > 0; } - public function createdBy() - { - return $this->belongsTo('Oxbow\User', 'created_by'); - } - - public function updatedBy() - { - return $this->belongsTo('Oxbow\User', 'updated_by'); - } public function revisions() { diff --git a/resources/assets/sass/_forms.scss b/resources/assets/sass/_forms.scss index f6b4a3d8a..2e0c5cf0e 100644 --- a/resources/assets/sass/_forms.scss +++ b/resources/assets/sass/_forms.scss @@ -78,11 +78,17 @@ input[type="text"], input[type="number"], input[type="email"], input[type="searc .title-input.page-title { font-size: 0.8em; + .input { + border: 1px solid #BBB; + margin-bottom: -1px; + } + input[type="text"] { + max-width: 840px; + margin: 0 auto; + border: none; + } } -.title-input.page-title input[type="text"]{ - //border: 2px dotted #BBB; - margin-bottom: 0; -} + .description-input textarea { diff --git a/resources/assets/sass/_text.scss b/resources/assets/sass/_text.scss index a542da8a1..b6e50cc40 100644 --- a/resources/assets/sass/_text.scss +++ b/resources/assets/sass/_text.scss @@ -133,14 +133,15 @@ blockquote { .code-base { background-color: #F8F8F8; font-family: monospace; - font-size: 0.88em; + font-size: 0.80em; border: 1px solid #DDD; border-radius: 3px; } code { @extend .code-base; - display: block; + display: inline; + padding: 1px 3px; white-space:pre; line-height: 1.2em; margin-bottom: 1.2em; diff --git a/resources/assets/sass/styles.scss b/resources/assets/sass/styles.scss index fc5e2630e..3ead26cb1 100644 --- a/resources/assets/sass/styles.scss +++ b/resources/assets/sass/styles.scss @@ -270,10 +270,15 @@ h1, h2, h3, h4, h5, h6 { .book-tree .sidebar-page-list { list-style: none; margin: 0; + margin-top: $-xl; border-left: 5px solid #7BD06E; li a { display: block; - border-bottom: 1px solid #3A3939; + border-bottom: none; + &:hover { + background-color: rgba(255, 255, 255, 0.2); + text-decoration: none; + } } li, a { display: block; @@ -290,19 +295,32 @@ h1, h2, h3, h4, h5, h6 { } .book { color: #7BD06E !important; + &.selected { + background-color: rgba(123, 208, 110, 0.29); + } } .chapter { color: #D2A64B !important; + &.selected { + background-color: rgba(239, 169, 42, 0.27); + } } .list-item-chapter { border-left: 5px solid #D2A64B; margin: 10px 10px; display: block; } + .list-item-page { + border-bottom: none; + } .page { color: #4599DC !important; border-left: 5px solid #4599DC; margin: 10px 10px; + border-bottom: none; + &.selected { + background-color: rgba(118, 164, 202, 0.41); + } } } diff --git a/resources/views/base.blade.php b/resources/views/base.blade.php index 8e102e3d3..a76635a3c 100644 --- a/resources/views/base.blade.php +++ b/resources/views/base.blade.php @@ -52,7 +52,7 @@
  • Users
  • Logout
  • - @if(isset($book) && !isset($books)) + @if(isset($book) && isset($current) && !isset($books))
    @include('pages/sidebar-tree-list', ['book' => $book])
    diff --git a/resources/views/pages/form.blade.php b/resources/views/pages/form.blade.php index 83e6bbc0e..176475129 100644 --- a/resources/views/pages/form.blade.php +++ b/resources/views/pages/form.blade.php @@ -6,7 +6,7 @@ {{ csrf_field() }}
    - @include('form/text', ['name' => 'name', 'placeholder' => 'Enter Page Title']) + @include('form/text', ['name' => 'name', 'placeholder' => 'Page Title'])
    @@ -38,7 +38,7 @@ menubar: false, height: 700, plugins: "image table textcolor paste link imagetools fullscreen", - toolbar: "undo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image link | fontsizeselect fullscreen", + toolbar: "undo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image link | fullscreen", content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}", file_browser_callback: function(field_name, url, type, win) { ImageManager.show(function(image) { diff --git a/resources/views/pages/sidebar-tree-list.blade.php b/resources/views/pages/sidebar-tree-list.blade.php index 45a726e1d..505d916d5 100644 --- a/resources/views/pages/sidebar-tree-list.blade.php +++ b/resources/views/pages/sidebar-tree-list.blade.php @@ -1,9 +1,9 @@