Dan Brown

Expanded chapters interface and improved book/page deletion

...@@ -78,8 +78,7 @@ class BookController extends Controller ...@@ -78,8 +78,7 @@ class BookController extends Controller
78 public function show($slug) 78 public function show($slug)
79 { 79 {
80 $book = $this->bookRepo->getBySlug($slug); 80 $book = $this->bookRepo->getBySlug($slug);
81 - $pageTree = $this->pageRepo->getTreeByBookId($book->id); 81 + return view('books/show', ['book' => $book]);
82 - return view('books/show', ['book' => $book, 'pageTree' => $pageTree]);
83 } 82 }
84 83
85 /** 84 /**
...@@ -119,14 +118,25 @@ class BookController extends Controller ...@@ -119,14 +118,25 @@ class BookController extends Controller
119 } 118 }
120 119
121 /** 120 /**
121 + * Shows the page to confirm deletion
122 + * @param $bookSlug
123 + * @return \Illuminate\View\View
124 + */
125 + public function showDelete($bookSlug)
126 + {
127 + $book = $this->bookRepo->getBySlug($bookSlug);
128 + return view('books/delete', ['book' => $book]);
129 + }
130 +
131 + /**
122 * Remove the specified book from storage. 132 * Remove the specified book from storage.
123 * 133 *
124 - * @param int $id 134 + * @param $bookSlug
125 * @return Response 135 * @return Response
126 */ 136 */
127 - public function destroy($id) 137 + public function destroy($bookSlug)
128 { 138 {
129 - $this->bookRepo->destroyById($id); 139 + $this->bookRepo->destroyBySlug($bookSlug);
130 return redirect('/books'); 140 return redirect('/books');
131 } 141 }
132 } 142 }
......
...@@ -25,20 +25,10 @@ class ChapterController extends Controller ...@@ -25,20 +25,10 @@ class ChapterController extends Controller
25 $this->bookRepo = $bookRepo; 25 $this->bookRepo = $bookRepo;
26 $this->chapterRepo = $chapterRepo; 26 $this->chapterRepo = $chapterRepo;
27 } 27 }
28 - 28 +
29 29
30 /** 30 /**
31 - * Display a listing of the resource. 31 + * Show the form for creating a new chapter.
32 - *
33 - * @return Response
34 - */
35 - public function index()
36 - {
37 - //
38 - }
39 -
40 - /**
41 - * Show the form for creating a new resource.
42 * 32 *
43 * @param $bookSlug 33 * @param $bookSlug
44 * @return Response 34 * @return Response
...@@ -50,7 +40,7 @@ class ChapterController extends Controller ...@@ -50,7 +40,7 @@ class ChapterController extends Controller
50 } 40 }
51 41
52 /** 42 /**
53 - * Store a newly created resource in storage. 43 + * Store a newly created chapter in storage.
54 * 44 *
55 * @param $bookSlug 45 * @param $bookSlug
56 * @param Request $request 46 * @param Request $request
...@@ -65,52 +55,88 @@ class ChapterController extends Controller ...@@ -65,52 +55,88 @@ class ChapterController extends Controller
65 $book = $this->bookRepo->getBySlug($bookSlug); 55 $book = $this->bookRepo->getBySlug($bookSlug);
66 $chapter = $this->chapterRepo->newFromInput($request->all()); 56 $chapter = $this->chapterRepo->newFromInput($request->all());
67 $chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id); 57 $chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id);
58 + $chapter->priority = $this->bookRepo->getNewPriority($book);
68 $book->chapters()->save($chapter); 59 $book->chapters()->save($chapter);
69 return redirect($book->getUrl()); 60 return redirect($book->getUrl());
70 } 61 }
71 62
72 /** 63 /**
73 - * Display the specified resource. 64 + * Display the specified chapter.
74 * 65 *
75 - * @param int $id 66 + * @param $bookSlug
67 + * @param $chapterSlug
76 * @return Response 68 * @return Response
77 */ 69 */
78 - public function show($id) 70 + public function show($bookSlug, $chapterSlug)
79 { 71 {
80 - // 72 + $book = $this->bookRepo->getBySlug($bookSlug);
73 + $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
74 + return view('chapters/show', ['book' => $book, 'chapter' => $chapter]);
81 } 75 }
82 76
83 /** 77 /**
84 - * Show the form for editing the specified resource. 78 + * Show the form for editing the specified chapter.
85 * 79 *
86 - * @param int $id 80 + * @param $bookSlug
81 + * @param $chapterSlug
87 * @return Response 82 * @return Response
88 */ 83 */
89 - public function edit($id) 84 + public function edit($bookSlug, $chapterSlug)
90 { 85 {
91 - // 86 + $book = $this->bookRepo->getBySlug($bookSlug);
87 + $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
88 + return view('chapters/edit', ['book' => $book, 'chapter' => $chapter]);
92 } 89 }
93 90
94 /** 91 /**
95 - * Update the specified resource in storage. 92 + * Update the specified chapter in storage.
96 * 93 *
97 - * @param Request $request 94 + * @param Request $request
98 - * @param int $id 95 + * @param $bookSlug
96 + * @param $chapterSlug
99 * @return Response 97 * @return Response
100 */ 98 */
101 - public function update(Request $request, $id) 99 + public function update(Request $request, $bookSlug, $chapterSlug)
100 + {
101 + $book = $this->bookRepo->getBySlug($bookSlug);
102 + $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
103 + $chapter->fill($request->all());
104 + $chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id, $chapter->id);
105 + $chapter->save();
106 + return redirect($chapter->getUrl());
107 + }
108 +
109 + /**
110 + * Shows the page to confirm deletion of this chapter.
111 + * @param $bookSlug
112 + * @param $chapterSlug
113 + * @return \Illuminate\View\View
114 + */
115 + public function showDelete($bookSlug, $chapterSlug)
102 { 116 {
103 - // 117 + $book = $this->bookRepo->getBySlug($bookSlug);
118 + $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
119 + return view('chapters/delete', ['book' => $book, 'chapter' => $chapter]);
104 } 120 }
105 121
106 /** 122 /**
107 - * Remove the specified resource from storage. 123 + * Remove the specified chapter from storage.
108 * 124 *
109 - * @param int $id 125 + * @param $bookSlug
126 + * @param $chapterSlug
110 * @return Response 127 * @return Response
111 */ 128 */
112 - public function destroy($id) 129 + public function destroy($bookSlug, $chapterSlug)
113 { 130 {
114 - // 131 + $book = $this->bookRepo->getBySlug($bookSlug);
132 + $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
133 + if(count($chapter->pages) > 0) {
134 + foreach($chapter->pages as $page) {
135 + $page->chapter_id = 0;
136 + $page->save();
137 + }
138 + }
139 + $chapter->delete();
140 + return redirect($book->getUrl());
115 } 141 }
116 } 142 }
......
...@@ -63,7 +63,6 @@ class PageController extends Controller ...@@ -63,7 +63,6 @@ class PageController extends Controller
63 $this->validate($request, [ 63 $this->validate($request, [
64 'name' => 'required|string|max:255', 64 'name' => 'required|string|max:255',
65 'html' => 'required|string', 65 'html' => 'required|string',
66 - 'priority' => 'integer',
67 'parent' => 'integer|exists:pages,id' 66 'parent' => 'integer|exists:pages,id'
68 ]); 67 ]);
69 $book = $this->bookRepo->getBySlug($bookSlug); 68 $book = $this->bookRepo->getBySlug($bookSlug);
...@@ -72,7 +71,8 @@ class PageController extends Controller ...@@ -72,7 +71,8 @@ class PageController extends Controller
72 while($this->pageRepo->countBySlug($slug, $book->id) > 0) { 71 while($this->pageRepo->countBySlug($slug, $book->id) > 0) {
73 $slug .= '1'; 72 $slug .= '1';
74 } 73 }
75 - $page->slug =$slug; 74 + $page->slug = $slug;
75 + $page->priority = $this->bookRepo->getNewPriority($book);
76 76
77 if($request->has('parent')) { 77 if($request->has('parent')) {
78 $page->page_id = $request->get('parent'); 78 $page->page_id = $request->get('parent');
...@@ -96,9 +96,8 @@ class PageController extends Controller ...@@ -96,9 +96,8 @@ class PageController extends Controller
96 $book = $this->bookRepo->getBySlug($bookSlug); 96 $book = $this->bookRepo->getBySlug($bookSlug);
97 $page = $this->pageRepo->getBySlug($pageSlug, $book->id); 97 $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
98 $breadCrumbs = $this->pageRepo->getBreadCrumbs($page); 98 $breadCrumbs = $this->pageRepo->getBreadCrumbs($page);
99 - $sidebarBookTree = $this->bookRepo->getTree($book, $page->id);
100 //dd($sidebarBookTree); 99 //dd($sidebarBookTree);
101 - return view('pages/show', ['page' => $page, 'breadCrumbs' => $breadCrumbs, 'book' => $book, 'sidebarBookTree' => $sidebarBookTree]); 100 + return view('pages/show', ['page' => $page, 'breadCrumbs' => $breadCrumbs, 'book' => $book]);
102 } 101 }
103 102
104 /** 103 /**
...@@ -187,14 +186,26 @@ class PageController extends Controller ...@@ -187,14 +186,26 @@ class PageController extends Controller
187 return redirect($book->getUrl()); 186 return redirect($book->getUrl());
188 } 187 }
189 188
189 + public function showDelete($bookSlug, $pageSlug)
190 + {
191 + $book = $this->bookRepo->getBySlug($bookSlug);
192 + $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
193 + return view('pages/delete', ['book' => $book, 'page' => $page]);
194 + }
195 +
190 /** 196 /**
191 * Remove the specified resource from storage. 197 * Remove the specified resource from storage.
192 * 198 *
193 - * @param int $id 199 + * @param $bookSlug
200 + * @param $pageSlug
194 * @return Response 201 * @return Response
202 + * @internal param int $id
195 */ 203 */
196 - public function destroy($id) 204 + public function destroy($bookSlug, $pageSlug)
197 { 205 {
198 - // 206 + $book = $this->bookRepo->getBySlug($bookSlug);
207 + $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
208 + $page->delete();
209 + return redirect($book->getUrl());
199 } 210 }
200 } 211 }
......
...@@ -19,8 +19,9 @@ Route::group(['prefix' => 'books'], function() { ...@@ -19,8 +19,9 @@ Route::group(['prefix' => 'books'], function() {
19 Route::post('/', 'BookController@store'); 19 Route::post('/', 'BookController@store');
20 Route::get('/{slug}/edit', 'BookController@edit'); 20 Route::get('/{slug}/edit', 'BookController@edit');
21 Route::put('/{slug}', 'BookController@update'); 21 Route::put('/{slug}', 'BookController@update');
22 - Route::delete('/{id}/destroy', 'BookController@destroy'); 22 + Route::delete('/{id}', 'BookController@destroy');
23 Route::get('/{slug}', 'BookController@show'); 23 Route::get('/{slug}', 'BookController@show');
24 + Route::get('/{slug}/delete', 'BookController@showDelete');
24 25
25 Route::get('/{bookSlug}/page/create', 'PageController@create'); 26 Route::get('/{bookSlug}/page/create', 'PageController@create');
26 Route::post('/{bookSlug}/page', 'PageController@store'); 27 Route::post('/{bookSlug}/page', 'PageController@store');
...@@ -29,10 +30,17 @@ Route::group(['prefix' => 'books'], function() { ...@@ -29,10 +30,17 @@ Route::group(['prefix' => 'books'], function() {
29 Route::get('/{bookSlug}/page/{pageSlug}', 'PageController@show'); 30 Route::get('/{bookSlug}/page/{pageSlug}', 'PageController@show');
30 Route::get('/{bookSlug}/page/{pageSlug}/create', 'PageController@create'); 31 Route::get('/{bookSlug}/page/{pageSlug}/create', 'PageController@create');
31 Route::get('/{bookSlug}/page/{pageSlug}/edit', 'PageController@edit'); 32 Route::get('/{bookSlug}/page/{pageSlug}/edit', 'PageController@edit');
33 + Route::get('/{bookSlug}/page/{pageSlug}/delete', 'PageController@showDelete');
32 Route::put('/{bookSlug}/page/{pageSlug}', 'PageController@update'); 34 Route::put('/{bookSlug}/page/{pageSlug}', 'PageController@update');
35 + Route::delete('/{bookSlug}/page/{pageSlug}', 'PageController@destroy');
33 36
34 Route::get('/{bookSlug}/chapter/create', 'ChapterController@create'); 37 Route::get('/{bookSlug}/chapter/create', 'ChapterController@create');
35 Route::post('/{bookSlug}/chapter/create', 'ChapterController@store'); 38 Route::post('/{bookSlug}/chapter/create', 'ChapterController@store');
39 + Route::get('/{bookSlug}/chapter/{chapterSlug}', 'ChapterController@show');
40 + Route::put('/{bookSlug}/chapter/{chapterSlug}', 'ChapterController@update');
41 + Route::get('/{bookSlug}/chapter/{chapterSlug}/edit', 'ChapterController@edit');
42 + Route::get('/{bookSlug}/chapter/{chapterSlug}/delete', 'ChapterController@showDelete');
43 + Route::delete('/{bookSlug}/chapter/{chapterSlug}', 'ChapterController@destroy');
36 44
37 }); 45 });
38 46
......
...@@ -22,11 +22,6 @@ class Page extends Model ...@@ -22,11 +22,6 @@ class Page extends Model
22 return $this->belongsTo('Oxbow\Book'); 22 return $this->belongsTo('Oxbow\Book');
23 } 23 }
24 24
25 - public function children()
26 - {
27 - return $this->hasMany('Oxbow\Page')->orderBy('priority', 'ASC');
28 - }
29 -
30 public function parent() 25 public function parent()
31 { 26 {
32 return $this->belongsTo('Oxbow\Page', 'page_id'); 27 return $this->belongsTo('Oxbow\Page', 'page_id');
......
...@@ -44,21 +44,19 @@ class BookRepo ...@@ -44,21 +44,19 @@ class BookRepo
44 return $this->book->where('slug', '=', $slug)->count(); 44 return $this->book->where('slug', '=', $slug)->count();
45 } 45 }
46 46
47 - public function destroyById($id) 47 + public function destroyBySlug($bookSlug)
48 { 48 {
49 - $book = $this->getById($id); 49 + $book = $this->getBySlug($bookSlug);
50 - foreach($book->pages as $page) { 50 + foreach($book->children() as $child) {
51 - $this->pageRepo->destroyById($page->id); 51 + $child->delete();
52 } 52 }
53 $book->delete(); 53 $book->delete();
54 } 54 }
55 55
56 - public function getTree($book, $currentPageId = false) 56 + public function getNewPriority($book)
57 { 57 {
58 - $tree = $book->toArray(); 58 + $lastElem = $book->children()->pop();
59 - $tree['pages'] = $this->pageRepo->getTreeByBookId($book->id, $currentPageId); 59 + return $lastElem ? $lastElem->priority + 1 : 0;
60 - $tree['hasChildren'] = count($tree['pages']) > 0;
61 - return $tree;
62 } 60 }
63 61
64 } 62 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -53,10 +53,10 @@ class ChapterRepo ...@@ -53,10 +53,10 @@ class ChapterRepo
53 return $query->count() > 0; 53 return $query->count() > 0;
54 } 54 }
55 55
56 - public function findSuitableSlug($name, $bookId) 56 + public function findSuitableSlug($name, $bookId, $currentId = false)
57 { 57 {
58 $slug = Str::slug($name); 58 $slug = Str::slug($name);
59 - while($this->doesSlugExist($slug, $bookId)) { 59 + while($this->doesSlugExist($slug, $bookId, $currentId)) {
60 $slug .= '-' . substr(md5(rand(1, 500)), 0, 3); 60 $slug .= '-' . substr(md5(rand(1, 500)), 0, 3);
61 } 61 }
62 return $slug; 62 return $slug;
......
...@@ -71,44 +71,6 @@ class PageRepo ...@@ -71,44 +71,6 @@ class PageRepo
71 } 71 }
72 72
73 /** 73 /**
74 - * Creates a tree of child pages, Nested by their
75 - * set parent pages.
76 - * @param $bookId
77 - * @param bool $currentPageId
78 - * @return array
79 - */
80 - public function getTreeByBookId($bookId, $currentPageId = false)
81 - {
82 - $topLevelPages = $this->getTopLevelPages($bookId);
83 - $pageTree = [];
84 -
85 - foreach($topLevelPages as $key => $topPage) {
86 - $pageTree[$key] = $this->toArrayTree($topPage, $currentPageId);
87 - }
88 -
89 - return $pageTree;
90 - }
91 -
92 - /**
93 - * Creates a page tree array with the supplied page
94 - * as the parent of the tree.
95 - * @param $page
96 - * @param bool $currentPageId
97 - * @return mixed
98 - */
99 - private function toArrayTree($page, $currentPageId = false)
100 - {
101 - $cPage = $page->toSimpleArray();
102 - $cPage['current'] = ($currentPageId !== false && $cPage['id'] === $currentPageId);
103 - $cPage['pages'] = [];
104 - foreach($page->children as $key => $childPage) {
105 - $cPage['pages'][$key] = $this->toArrayTree($childPage, $currentPageId);
106 - }
107 - $cPage['hasChildren'] = count($cPage['pages']) > 0;
108 - return $cPage;
109 - }
110 -
111 - /**
112 * Gets the pages at the top of the page hierarchy. 74 * Gets the pages at the top of the page hierarchy.
113 * @param $bookId 75 * @param $bookId
114 */ 76 */
......
...@@ -21,10 +21,21 @@ ...@@ -21,10 +21,21 @@
21 box-shadow: 0 0 4px 2px rgba(0, 0, 0, 0.08); 21 box-shadow: 0 0 4px 2px rgba(0, 0, 0, 0.08);
22 } 22 }
23 23
24 +
25 +
24 .edit-area { 26 .edit-area {
25 height: 100%; 27 height: 100%;
26 } 28 }
27 29
28 .page-style.editor { 30 .page-style.editor {
29 height: 100%; 31 height: 100%;
32 +}
33 +
34 +.mce-tinymce {
35 + .mce-panel {
36 + background-color: #FFF;
37 + }
38 + .mce-btn {
39 + background-color: #FFF;
40 + }
30 } 41 }
...\ No newline at end of file ...\ No newline at end of file
......
1 +@extends('base')
2 +
3 +@section('content')
4 +
5 + <div class="page-content">
6 + <h1>Delete Book</h1>
7 + <p>This will delete the book with the name '{{$book->name}}', All pages and chapters will be removed.</p>
8 + <p class="text-neg">Are you sure you want to delete this book?</p>
9 +
10 + <form action="{{$book->getUrl()}}" method="POST">
11 + {!! csrf_field() !!}
12 + <input type="hidden" name="_method" value="DELETE">
13 + <button type="submit" class="button neg">Confirm</button>
14 + <a href="{{$book->getUrl()}}" class="button">Cancel</a>
15 + </form>
16 + </div>
17 +
18 +@stop
19 +
20 +@section('bottom')
21 + @include('pages/image-manager')
22 +@stop
...\ No newline at end of file ...\ No newline at end of file
...@@ -8,12 +8,6 @@ ...@@ -8,12 +8,6 @@
8 <input type="hidden" name="_method" value="PUT"> 8 <input type="hidden" name="_method" value="PUT">
9 @include('books/form', ['model' => $book]) 9 @include('books/form', ['model' => $book])
10 </form> 10 </form>
11 - <hr class="margin-top large">
12 - <div class="margin-top large shaded padded">
13 - <h2 class="margin-top">Delete this book</h2>
14 - <p>This will delete this book and all it's pages.</p>
15 - @include('form/delete-button', ['url' => '/books/' . $book->id . '/destroy', 'text' => 'Delete'])
16 - </div>
17 </div> 11 </div>
18 12
19 @stop 13 @stop
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
5 <div class="row faded-small"> 5 <div class="row faded-small">
6 <div class="col-md-6"></div> 6 <div class="col-md-6"></div>
7 <div class="col-md-6"> 7 <div class="col-md-6">
8 - <div class="action-buttons"> 8 + <div class="action-buttons faded">
9 - <a href="{{$book->getEditUrl()}}"><i class="fa fa-pencil"></i>Edit Book</a> 9 + <a href="{{$book->getEditUrl()}}"><i class="fa fa-pencil"></i>Edit</a>
10 - <a href="{{ $book->getUrl() }}/sort"><i class="fa fa-sort"></i>Sort Pages</a> 10 + <a href="{{ $book->getUrl() }}/sort"><i class="fa fa-sort"></i>Sort</a>
11 + <a href="{{ $book->getUrl() }}/delete"><i class="fa fa-trash"></i>Delete</a>
11 </div> 12 </div>
12 </div> 13 </div>
13 </div> 14 </div>
...@@ -24,16 +25,21 @@ ...@@ -24,16 +25,21 @@
24 </div> 25 </div>
25 </div> 26 </div>
26 27
27 - <div class="page-list"> 28 + <div>
28 @foreach($book->children() as $childElement) 29 @foreach($book->children() as $childElement)
29 - <div class="page-list-item"> 30 + <div >
30 - @if(is_a($childElement, 'Oxbow\Chapter')) 31 + <h3>
31 - <i class="fa fa-archive"></i> 32 + <a href="{{ $childElement->getUrl() }}">
32 - @else 33 + @if(is_a($childElement, 'Oxbow\Chapter'))
33 - <i class="fa fa-file"></i> 34 + <i class="fa fa-archive"></i>
34 - @endif 35 + @else
35 - {{$childElement->name}} 36 + <i class="fa fa-file"></i>
37 + @endif
38 + {{ $childElement->name }}
39 + </a>
40 + </h3>
36 </div> 41 </div>
42 + <hr>
37 @endforeach 43 @endforeach
38 </div> 44 </div>
39 45
......
1 +@extends('base')
2 +
3 +@section('content')
4 +
5 + <div class="page-content">
6 + <h1>Delete Chapter</h1>
7 + <p>This will delete the chapter with the name '{{$chapter->name}}', All pages will be removed
8 + and added directly to the book.</p>
9 + <p class="text-neg">Are you sure you want to delete this chapter?</p>
10 +
11 + <form action="{{$chapter->getUrl()}}" method="POST">
12 + {!! csrf_field() !!}
13 + <input type="hidden" name="_method" value="DELETE">
14 + <button type="submit" class="button neg">Confirm</button>
15 + <a href="{{$chapter->getUrl()}}" class="button">Cancel</a>
16 + </form>
17 + </div>
18 +
19 +@stop
20 +
21 +@section('bottom')
22 + @include('pages/image-manager')
23 +@stop
...\ No newline at end of file ...\ No newline at end of file
1 +@extends('base')
2 +
3 +@section('content')
4 +
5 + <div class="page-content">
6 + <h1>Edit Chapter</h1>
7 + <form action="{{$chapter->getUrl()}}" method="POST">
8 + <input type="hidden" name="_method" value="PUT">
9 + @include('chapters/form', ['model' => $chapter])
10 + </form>
11 + </div>
12 +
13 +@stop
...\ No newline at end of file ...\ No newline at end of file
1 +@extends('base')
2 +
3 +@section('content')
4 +
5 + <div class="row faded-small">
6 + <div class="col-md-6"></div>
7 + <div class="col-md-6 faded">
8 + <div class="action-buttons">
9 + <a href="{{$chapter->getUrl() . '/edit'}}" ><i class="fa fa-pencil"></i>Edit</a>
10 + <a href="{{$chapter->getUrl() . '/delete'}}"><i class="fa fa-trash"></i>Delete</a>
11 + </div>
12 + </div>
13 + </div>
14 +
15 +
16 + <div class="page-content">
17 + <h1>{{ $chapter->name }}</h1>
18 + <p class="text-muted">{{ $chapter->description }}</p>
19 + @if(count($chapter->pages) > 0)
20 + <h4 class="text-muted">Pages</h4>
21 + <div class="page-list">
22 + @foreach($chapter->pages as $page)
23 + <div >
24 + <h3>
25 + <a href="{{ $page->getUrl() }}">
26 + <i class="fa fa-file"></i>
27 + {{ $page->name }}
28 + </a>
29 + </h3>
30 + </div>
31 + <hr>
32 + @endforeach
33 + </div>
34 + @endif
35 + </div>
36 +
37 +
38 +@stop
1 +@extends('base')
2 +
3 +@section('content')
4 +
5 + <div class="page-content">
6 + <h1>Delete Page</h1>
7 + <p>Are you sure you want to delete this page?</p>
8 +
9 + <form action="{{$page->getUrl()}}" method="POST">
10 + {!! csrf_field() !!}
11 + <input type="hidden" name="_method" value="DELETE">
12 + <button type="submit" class="button neg">Confirm</button>
13 + <a href="{{$page->getUrl()}}" class="button">Cancel</a>
14 + </form>
15 + </div>
16 +
17 +@stop
18 +
19 +@section('bottom')
20 + @include('pages/image-manager')
21 +@stop
...\ No newline at end of file ...\ No newline at end of file
...@@ -31,9 +31,10 @@ ...@@ -31,9 +31,10 @@
31 body_class: 'page-content', 31 body_class: 'page-content',
32 relative_urls: false, 32 relative_urls: false,
33 statusbar: false, 33 statusbar: false,
34 - height: 600, 34 + menubar: false,
35 - plugins: "image table textcolor paste link imagetools", 35 + height: 700,
36 - toolbar: "undo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image link | fontsizeselect full", 36 + plugins: "image table textcolor paste link imagetools fullscreen",
37 + toolbar: "undo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table image link | fontsizeselect fullscreen",
37 content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}", 38 content_style: "body {padding-left: 15px !important; padding-right: 15px !important; margin:0!important; margin-left:auto!important;margin-right:auto!important;}",
38 file_browser_callback: function(field_name, url, type, win) { 39 file_browser_callback: function(field_name, url, type, win) {
39 ImageManager.show('#image-manager', function(image) { 40 ImageManager.show('#image-manager', function(image) {
...@@ -46,20 +47,20 @@ ...@@ -46,20 +47,20 @@
46 win.document.getElementById(field_name).fireEvent("onchange"); 47 win.document.getElementById(field_name).fireEvent("onchange");
47 } 48 }
48 }); 49 });
49 - },
50 - setup: function(editor) {
51 - editor.addButton('full', {
52 - title: 'Expand Editor',
53 - icon: 'fullscreen',
54 - onclick: function() {
55 - var container = $(editor.getContainer()).toggleClass('fullscreen');
56 - var isFull = container.hasClass('fullscreen');
57 - var iframe = container.find('iframe').first();
58 - var height = isFull ? $(window).height()-110 : 600;
59 - iframe.css('height', height + 'px');
60 - }
61 - });
62 } 50 }
51 +// setup: function(editor) {
52 +// editor.addButton('full', {
53 +// title: 'Expand Editor',
54 +// icon: 'fullscreen',
55 +// onclick: function() {
56 +// var container = $(editor.getContainer()).toggleClass('fullscreen');
57 +// var isFull = container.hasClass('fullscreen');
58 +// var iframe = container.find('iframe').first();
59 +// var height = isFull ? $(window).height()-110 : 600;
60 +// iframe.css('height', height + 'px');
61 +// }
62 +// });
63 +// }
63 }); 64 });
64 65
65 66
......
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
2 2
3 @section('sidebar') 3 @section('sidebar')
4 <div class="book-tree"> 4 <div class="book-tree">
5 - <h4><a href="/books/{{$sidebarBookTree['slug']}}"><i class="fa fa-book"></i>{{$sidebarBookTree['name']}}</a></h4> 5 + <h4><a href="{{$book->getUrl()}}"><i class="fa fa-book"></i>{{$book->name}}</a></h4>
6 - @if($sidebarBookTree['hasChildren']) 6 + @include('pages/sidebar-tree-list', ['book' => $book])
7 - @include('pages/sidebar-tree-list', ['pageTree' => $sidebarBookTree['pages']])
8 - @endif
9 </div> 7 </div>
10 @stop 8 @stop
11 9
...@@ -25,8 +23,8 @@ ...@@ -25,8 +23,8 @@
25 </div> 23 </div>
26 <div class="col-md-6 faded"> 24 <div class="col-md-6 faded">
27 <div class="action-buttons"> 25 <div class="action-buttons">
28 - <a href="{{$page->getUrl() . '/edit'}}" ><i class="fa fa-pencil"></i>Edit this page</a> 26 + <a href="{{$page->getUrl() . '/edit'}}" ><i class="fa fa-pencil"></i>Edit</a>
29 - <a href="{{$page->getUrl() . '/create'}}"><i class="fa fa-file-o"></i>Create Sub-page</a> 27 + <a href="{{$page->getUrl() . '/delete'}}"><i class="fa fa-trash"></i>Delete</a>
30 </div> 28 </div>
31 </div> 29 </div>
32 </div> 30 </div>
......
1 {{--Requires an array of pages to be passed as $pageTree--}} 1 {{--Requires an array of pages to be passed as $pageTree--}}
2 2
3 <ul class="sidebar-page-list"> 3 <ul class="sidebar-page-list">
4 - @foreach($pageTree as $subPage) 4 + @foreach($book->children() as $bookChild)
5 - <li @if($subPage['hasChildren'])class="has-children"@endif> 5 + <li>
6 - <a href="{{$subPage['url']}}" @if($subPage['current'])class="bold"@endif>{{$subPage['name']}}</a> 6 + {{ $bookChild->name }}
7 - @if($subPage['hasChildren']) 7 + @if(is_a($bookChild, 'Oxbow\Chapter') && count($bookChild->pages) > 0)
8 - @include('pages/sidebar-tree-list', ['pageTree' => $subPage['pages']]) 8 + <ul>
9 + @foreach($pages as $page)
10 + <li>{{ $page->name }}</li>
11 + @endforeach
12 + </ul>
9 @endif 13 @endif
10 </li> 14 </li>
11 @endforeach 15 @endforeach
......