namespace Oxbow;
-use Illuminate\Database\Eloquent\Model;
-
-class Book extends Model
+class Book extends Entity
{
protected $fillable = ['name', 'description'];
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();
<?php namespace Oxbow;
-use Illuminate\Database\Eloquent\Model;
-class Chapter extends Model
+class Chapter extends Entity
{
protected $fillable = ['name', 'description', 'priority', 'book_id'];
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;
--- /dev/null
+<?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];
+ }
+}
public function show($slug)
{
$book = $this->bookRepo->getBySlug($slug);
- return view('books/show', ['book' => $book]);
+ return view('books/show', ['book' => $book, 'current' => $book]);
}
/**
public function edit($slug)
{
$book = $this->bookRepo->getBySlug($slug);
- return view('books/edit', ['book' => $book]);
+ return view('books/edit', ['book' => $book, 'current' => $book]);
}
/**
public function showDelete($bookSlug)
{
$book = $this->bookRepo->getBySlug($bookSlug);
- return view('books/delete', ['book' => $book]);
+ return view('books/delete', ['book' => $book, 'current' => $book]);
}
/**
public function create($bookSlug)
{
$book = $this->bookRepo->getBySlug($bookSlug);
- return view('chapters/create', ['book' => $book]);
+ return view('chapters/create', ['book' => $book, 'current' => $book]);
}
/**
{
$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]);
}
/**
{
$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]);
}
/**
{
$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]);
}
/**
{
$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]);
}
/**
{
$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]);
}
/**
public function sortPages($bookSlug)
{
$book = $this->bookRepo->getBySlug($bookSlug);
- return view('pages/sort', ['book' => $book]);
+ return view('pages/sort', ['book' => $book, 'current' => $book]);
}
/**
{
$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]);
}
/**
{
$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]);
}
/**
namespace Oxbow;
-use Illuminate\Database\Eloquent\Model;
-class Image extends Model
+class Image extends Entity
{
protected $fillable = ['name'];
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');
- }
}
use Illuminate\Database\Eloquent\Model;
-class Page extends Model
+class Page extends Entity
{
protected $fillable = ['name', 'html', 'priority'];
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()
{
.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 {
.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;
.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;
}
.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);
+ }
}
}
<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>
{{ 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">
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) {
<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