Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-08-16 14:51:45 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
521b3b8eb113ec86c718c2f8040ab6f3c8394fbf
521b3b8e
1 parent
ca2a3ba0
Added sidebar highlighting and fixed code elements. Fixes #18
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
93 additions
and
73 deletions
app/Book.php
app/Chapter.php
app/Entity.php
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
app/Book.php
View file @
521b3b8
...
...
@@ -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
();
...
...
app/Chapter.php
View file @
521b3b8
<?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
;
...
...
app/Entity.php
0 → 100644
View file @
521b3b8
<?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
];
}
}
app/Http/Controllers/BookController.php
View file @
521b3b8
...
...
@@ -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
]);
}
/**
...
...
app/Http/Controllers/ChapterController.php
View file @
521b3b8
...
...
@@ -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
]);
}
/**
...
...
app/Http/Controllers/PageController.php
View file @
521b3b8
...
...
@@ -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
]);
}
/**
...
...
app/Image.php
View file @
521b3b8
...
...
@@ -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'
);
}
}
...
...
app/Page.php
View file @
521b3b8
...
...
@@ -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
()
{
...
...
resources/assets/sass/_forms.scss
View file @
521b3b8
...
...
@@ -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
{
...
...
resources/assets/sass/_text.scss
View file @
521b3b8
...
...
@@ -133,14 +133,15 @@ blockquote {
.code-base
{
background-color
:
#F8F8F8
;
font-family
:
monospace
;
font-size
:
0
.8
8
em
;
font-size
:
0
.8
0
em
;
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
;
...
...
resources/assets/sass/styles.scss
View file @
521b3b8
...
...
@@ -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
);
}
}
}
...
...
resources/views/base.blade.php
View file @
521b3b8
...
...
@@ -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>
...
...
resources/views/pages/form.blade.php
View file @
521b3b8
...
...
@@ -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 | f
ontsizeselect f
ullscreen"
,
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
)
{
...
...
resources/views/pages/sidebar-tree-list.blade.php
View file @
521b3b8
<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 $
p
age)
@foreach($bookChild->pages as $
childP
age)
<li
class=
"list-item-page"
>
<a
href=
"{{$
page->getUrl()}}"
class=
"page
"
>
<i
class=
"zmdi zmdi-file-text"
></i>
{{ $
p
age->name }}
<a
href=
"{{$
childPage->getUrl()}}"
class=
"page {{ $current->matches($childPage)? 'selected' : '' }}
"
>
<i
class=
"zmdi zmdi-file-text"
></i>
{{ $
childP
age->name }}
</a>
</li>
@endforeach
...
...
Please
register
or
sign in
to post a comment