Added sidebar highlighting and fixed code elements. Fixes #18

This commit is contained in:
Dan Brown 2015-08-16 14:51:45 +01:00
parent ca2a3ba0e8
commit 521b3b8eb1
14 changed files with 93 additions and 73 deletions

View 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();

View 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;

37
app/Entity.php Normal file
View File

@ -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];
}
}

View 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]);
}
/**

View 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]);
}
/**

View 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]);
}
/**

View 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');
}
}

View 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()
{

View 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 {

View 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;

View 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);
}
}
}

View 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>

View 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) {

View 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
@ -14,10 +14,10 @@
@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