]> BookStack Code Mirror - bookstack/commitdiff
Added sidebar highlighting and fixed code elements. Fixes #18
authorDan Brown <redacted>
Sun, 16 Aug 2015 13:51:45 +0000 (14:51 +0100)
committerDan Brown <redacted>
Sun, 16 Aug 2015 13:51:45 +0000 (14:51 +0100)
14 files changed:
app/Book.php
app/Chapter.php
app/Entity.php [new file with mode: 0644]
app/Http/Controllers/BookController.php
app/Http/Controllers/ChapterController.php
app/Http/Controllers/PageController.php
app/Image.php
app/Page.php
resources/assets/sass/_forms.scss
resources/assets/sass/_text.scss
resources/assets/sass/styles.scss
resources/views/base.blade.php
resources/views/pages/form.blade.php
resources/views/pages/sidebar-tree-list.blade.php

index abd23d64e1aa02707261cb3e0421ba3ba6cdd3ed..8a4be213f5c73681a1a8a522880cff689283ebd3 100644 (file)
@@ -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();
index b7623798a5c67d9883238e941254601875bcc67e..4e011cec9f3603c7147fe52d1efa79553cd366c1 100644 (file)
@@ -1,8 +1,7 @@
 <?php namespace Oxbow;
 
-use Illuminate\Database\Eloquent\Model;
 
-class Chapter extends Model
+class Chapter extends Entity
 {
 
     protected $fillable = ['name', 'description', 'priority', 'book_id'];
@@ -17,16 +16,6 @@ class Chapter extends Model
         return $this->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 (file)
index 0000000..2d81ccd
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+namespace Oxbow;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Entity extends Model
+{
+    /**
+     * Relation for the user that created this entity.
+     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
+     */
+    public function createdBy()
+    {
+        return $this->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];
+    }
+}
index 6791c0f2a8f611ebeb136c3c485ff46dfe385f63..97c401028ec68aa2761d843d6f76798e9fa30562 100644 (file)
@@ -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]);
     }
 
     /**
index d5ccae024250b6e4c77d4c92390f0d70d25094e0..eec5971a9d4842278548bb5203d08420af28f7eb 100644 (file)
@@ -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]);
     }
 
     /**
index b64290eaa24ecd35d84fda4872ac2118d6a5e1be..a41db39ef708fb11f6526ad80ab79789e9dda028 100644 (file)
@@ -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]);
     }
 
     /**
index 07db687854943815d9fc61714c5e35e088e0a477..f80f33fffffd00902f21e3993b20f98c2034dd3d 100644 (file)
@@ -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');
-    }
 }
index 8ae744a8aed7af56594f021ca1a3f4ead4e3236a..0fda5dec362f396db199fc851cfec1ba4218f729 100644 (file)
@@ -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()
     {
index f6b4a3d8af670dc45351af43e68647a6d080b6bd..2e0c5cf0e244b1cc683aa004e55ef98b108e2414 100644 (file)
@@ -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 {
index a542da8a1b740a48f3f0a60364ffae978ade849f..b6e50cc404f61ab3571c543407b5bd2c2392e2a0 100644 (file)
@@ -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;
index fc5e2630e42f4cfade7b77966798e0b0daf0004e..3ead26cb125a9fa070856020edfbc0b1326079eb 100644 (file)
@@ -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);
+    }
   }
 }
 
index 8e102e3d34095a2a07dbd8add7701ca1e5848942..a76635a3cfce5b96f57dfc0885c950ceb8b72183 100644 (file)
@@ -52,7 +52,7 @@
             <li><a href="/users"><i class="zmdi zmdi-accounts"></i>Users</a></li>
             <li><a href="/logout"><i class="zmdi zmdi-run zmdi-hc-flip-horizontal"></i>Logout</a></li>
         </ul>
-        @if(isset($book) && !isset($books))
+        @if(isset($book) && isset($current) && !isset($books))
             <div class="book-tree">
                 @include('pages/sidebar-tree-list', ['book' => $book])
             </div>
index 83e6bbc0eb041b3d381680f11a752dc35371cf6d..176475129e3743f88e7ce0f41620ffe89244040a 100644 (file)
@@ -6,7 +6,7 @@
     {{ csrf_field() }}
     <div class="title-input page-title clearfix">
         <div class="input">
-            @include('form/text', ['name' => 'name', 'placeholder' => 'Enter Page Title'])
+            @include('form/text', ['name' => 'name', 'placeholder' => 'Page Title'])
         </div>
     </div>
     <div class="edit-area">
@@ -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) {
index 45a726e1de8646679980ca554a345cb537c54c50..505d916d5e89edcee1beced5066ba3e7abdde41a 100644 (file)
@@ -1,9 +1,9 @@
 
 <ul class="sidebar-page-list menu">
-    <li class="book-header"><a href="{{$book->getUrl()}}" class="book"><i class="zmdi zmdi-book"></i>{{$book->name}}</a></li>
+    <li class="book-header"><a href="{{$book->getUrl()}}" class="book {{ $current->matches($book)? 'selected' : '' }}"><i class="zmdi zmdi-book"></i>{{$book->name}}</a></li>
     @foreach($book->children() as $bookChild)
         <li class="list-item-{{is_a($bookChild, 'Oxbow\Chapter') ? 'chapter' : 'page' }}">
-            <a href="{{$bookChild->getUrl()}}" class="{{is_a($bookChild, 'Oxbow\Chapter') ? 'chapter' : 'page' }}">
+            <a href="{{$bookChild->getUrl()}}" class="{{is_a($bookChild, 'Oxbow\Chapter') ? 'chapter' : 'page' }} {{ $current->matches($bookChild)? 'selected' : '' }}">
                 @if(is_a($bookChild, 'Oxbow\Chapter'))
                     <i class="zmdi zmdi-collection-bookmark chapter-toggle"></i>
                 @else
 
             @if(is_a($bookChild, 'Oxbow\Chapter') && count($bookChild->pages) > 0)
                 <ul class="menu">
-                    @foreach($bookChild->pages as $page)
+                    @foreach($bookChild->pages as $childPage)
                         <li class="list-item-page">
-                            <a href="{{$page->getUrl()}}" class="page">
-                                <i class="zmdi zmdi-file-text"></i> {{ $page->name }}
+                            <a href="{{$childPage->getUrl()}}" class="page {{ $current->matches($childPage)? 'selected' : '' }}">
+                                <i class="zmdi zmdi-file-text"></i> {{ $childPage->name }}
                             </a>
                         </li>
                     @endforeach