diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 41d8bed26..c17a082a5 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -107,13 +107,14 @@ class BookController extends Controller 'name' => 'required|string|max:255', 'description' => 'string|max:1000' ]); + $book->fill($request->all()); $slug = Str::slug($book->name); while($this->bookRepo->countBySlug($slug) > 0 && $book->slug != $slug) { $slug += '1'; } $book->slug = $slug; $book->save(); - return redirect('/books'); + return redirect($book->getUrl()); } /** diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index b22c73949..da56fb26b 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -85,7 +85,8 @@ class PageController extends Controller */ public function show($bookSlug, $pageSlug) { - $page = $this->pageRepo->getBySlug($pageSlug); + $book = $this->bookRepo->getBySlug($bookSlug); + $page = $this->pageRepo->getBySlug($pageSlug, $book->id); return view('pages/show', ['page' => $page]); } @@ -98,7 +99,8 @@ class PageController extends Controller */ public function edit($bookSlug, $pageSlug) { - $page = $this->pageRepo->getBySlug($pageSlug); + $book = $this->bookRepo->getBySlug($bookSlug); + $page = $this->pageRepo->getBySlug($pageSlug, $book->id); return view('pages/edit', ['page' => $page]); } @@ -112,8 +114,8 @@ class PageController extends Controller */ public function update(Request $request, $bookSlug, $pageSlug) { - $page = $this->pageRepo->getBySlug($pageSlug); $book = $this->bookRepo->getBySlug($bookSlug); + $page = $this->pageRepo->getBySlug($pageSlug, $book->id); $page->fill($request->all()); $slug = Str::slug($page->name); while($this->pageRepo->countBySlug($slug, $book->id) > 0 && $slug != $pageSlug) { diff --git a/app/Repos/PageRepo.php b/app/Repos/PageRepo.php index 209e2816b..62fbe9d8f 100644 --- a/app/Repos/PageRepo.php +++ b/app/Repos/PageRepo.php @@ -27,9 +27,9 @@ class PageRepo return $this->page->all(); } - public function getBySlug($slug) + public function getBySlug($slug, $bookId) { - return $this->page->where('slug', '=', $slug)->first(); + return $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first(); } public function newFromInput($input) diff --git a/bower.json b/bower.json index c1831df7d..feed69959 100644 --- a/bower.json +++ b/bower.json @@ -15,6 +15,8 @@ ], "dependencies": { "dropzone": "~4.0.1", - "tinymce-dist": "~4.2.1" + "tinymce-dist": "~4.2.1", + "bootstrap": "~3.3.5", + "jquery-sortable": "~0.9.13" } } diff --git a/gulpfile.js b/gulpfile.js index 728827654..1da6e0497 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,4 +1,5 @@ var elixir = require('laravel-elixir'); +require('laravel-elixir-livereload'); /* |-------------------------------------------------------------------------- @@ -12,5 +13,5 @@ var elixir = require('laravel-elixir'); */ elixir(function(mix) { - mix.sass('styles.scss'); + mix.sass('styles.scss').livereload(); }); diff --git a/package.json b/package.json index b1b4a6e61..ecbb47b05 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { "private": true, "devDependencies": { - "gulp": "^3.8.8" + "gulp": "^3.8.8", + "laravel-elixir-livereload": "0.0.3" }, "dependencies": { "laravel-elixir": "^2.0.0", diff --git a/resources/assets/sass/_buttons.scss b/resources/assets/sass/_buttons.scss index 4ef81ede9..b28f29ea6 100644 --- a/resources/assets/sass/_buttons.scss +++ b/resources/assets/sass/_buttons.scss @@ -32,7 +32,7 @@ $button-border-radius: 3px; @include generate-button-colors(#EEE, $primary); } -.button, button[type="button"], input[type="button"], input[type="submit"] { +.button, input[type="button"], input[type="submit"] { @extend .button-base; &.pos { @include generate-button-colors(#EEE, $positive); diff --git a/resources/assets/sass/_forms.scss b/resources/assets/sass/_forms.scss index ae8a900f8..37e03c3cf 100644 --- a/resources/assets/sass/_forms.scss +++ b/resources/assets/sass/_forms.scss @@ -45,3 +45,40 @@ input[type="text"], input[type="number"], input[type="email"], input[type="searc .form-group { margin-bottom: $-s; } + +.inline-input-style { + border: 2px dotted #BBB; + display: block; + width: 100%; + padding: $-xs $-s; +} + +.title-input label, .description-input label{ + margin-top: $-m; + color: #666; +} + +.title-input input[type="text"] { + @extend h1; + @extend .inline-input-style; + margin-top: 0; + color: #444; +} + +.title-input.page-title { + padding: $-s; +} +.title-input.page-title input[type="text"]{ + //border: 2px dotted #BBB; + margin-bottom: 0; +} +.edit-area { + padding: 0 $-s $-s $-s; +} + +.description-input textarea { + @extend .inline-input-style; + font-size: $fs-m; + color: #666; + width: 100%; +} \ No newline at end of file diff --git a/resources/assets/sass/_html.scss b/resources/assets/sass/_html.scss index 73de7ff97..3b019d583 100644 --- a/resources/assets/sass/_html.scss +++ b/resources/assets/sass/_html.scss @@ -2,7 +2,7 @@ box-sizing: border-box; } html { - background-color: #FFF; + background-color: #f8f8f8; } body { font-family: $text; diff --git a/resources/assets/sass/_text.scss b/resources/assets/sass/_text.scss index 4cd440a11..9e24d4cd5 100644 --- a/resources/assets/sass/_text.scss +++ b/resources/assets/sass/_text.scss @@ -1,6 +1,6 @@ /* -* Header Styles -*/ + * Header Styles + */ h1 { font-size: 3.625em; @@ -23,11 +23,12 @@ h3 { h4 { font-size: 1em; line-height: 1.375em; - margin-top: 1.375em; - margin-bottom: 1.375em; + margin-top: 0.78571429em; + margin-bottom: 0.43137255em; } h1, h2, h3, h4 { + font-weight: 500; .subheader { display: block; font-size: 0.5em; @@ -37,8 +38,8 @@ h1, h2, h3, h4 { } /* -* Link styling -*/ + * Link styling + */ a { color: $primary; cursor: pointer; @@ -48,11 +49,14 @@ a { text-decoration: underline; color: darken($primary, 20%); } + i { + padding-right: $-s; + } } /* -* Other HTML Text Elements -*/ + * Other HTML Text Elements + */ p, ul, ol, pre, table, blockquote { margin-top: 0.3em; margin-bottom: 1.375em; @@ -136,8 +140,8 @@ span.code { padding: 1px $-xs; } /* -* Text colors -*/ + * Text colors + */ p.pos, p .pos, span.pos, .text-pos { color: $positive; } @@ -159,8 +163,8 @@ p.secondary, p .secondary, span.secondary, .text-secondary { } /* -* Generic text styling classes -*/ + * Generic text styling classes + */ .underlined { text-decoration: underline; } @@ -176,3 +180,13 @@ p.secondary, p .secondary, span.secondary, .text-secondary { .text-right { text-align: right; } + +/** + * Grouping + */ +.header-group { + margin: $-m 0; + h1, h2, h3, h4, h5, h6 { + margin: 0; + } +} \ No newline at end of file diff --git a/resources/assets/sass/_tinymce.scss b/resources/assets/sass/_tinymce.scss new file mode 100644 index 000000000..7c1cf771d --- /dev/null +++ b/resources/assets/sass/_tinymce.scss @@ -0,0 +1,18 @@ + +//.mce-container { +// .mce-menubar, .mce-toolbar-grp { +// position: fixed; +// width: 100%; +// } +// .mce-container-body { +// position: relative; +// overflow: hidden; +// display: block; +// } +//} + +.mce-tinymce.mce-container.fullscreen { + position: fixed; + top: 0; + height: 100%; +} \ No newline at end of file diff --git a/resources/assets/sass/styles.scss b/resources/assets/sass/styles.scss index 9f4eda5a9..6df66b832 100644 --- a/resources/assets/sass/styles.scss +++ b/resources/assets/sass/styles.scss @@ -7,6 +7,20 @@ @import "blocks"; @import "buttons"; @import "forms"; +@import "tinymce"; + +header { + background-color: #f8f8f8; + position: fixed; + display: block; + width: 100%; + z-index: -1; + top: 0; +} + +body { + margin-top: 64px; +} header hr { margin-top: 0; @@ -27,6 +41,81 @@ header .menu { font-size: 1.4em; } +.affix { + position: fixed; +} + +.page-style { + background-color: #FFF; + padding: $-s $-xxl $-xxl $-xxl; + border-radius: 4px; + box-shadow: 0 0 9px 0 rgba(0, 0, 0, 0.15); + margin-bottom: $-xxl; + max-width: 100%; +} + +.page-style.editor { + padding: 0 !important; +} + +.page-content { + @extend .page-style; + min-height: 70vh; + &.right { + float: right; + } + &.left { + float: left; + } +} + +.page-list { + a { + display: block; + padding: $-s 0; + border-bottom: 2px dotted #CCC; + &:first-child { + border-top: 2px dotted #CCC; + } + } +} + +.page-menu { + opacity: 0.6; + transition: opacity ease-in-out 120ms; + &:hover { + opacity: 1; + } +} + +.page-nav-list { + $nav-indent: $-s; + li { + //border-left: 1px solid rgba(0, 0, 0, 0.1); + padding-left: $-xs; + } + .nav-H2 { + margin-left: $nav-indent; + font-size: 0.95em; + } + .nav-H3 { + margin-left: $nav-indent*2; + font-size: 0.90em + } + .nav-H4 { + margin-left: $nav-indent*3; + font-size: 0.85em + } + .nav-H5 { + margin-left: $nav-indent*4; + font-size: 0.80em + } + .nav-H6 { + margin-left: $nav-indent*5; + font-size: 0.75em + } +} + .overlay { background-color: rgba(0, 0, 0, 0.2); position: fixed; diff --git a/resources/views/base.blade.php b/resources/views/base.blade.php index ba386d6c3..a8e17ce7e 100644 --- a/resources/views/base.blade.php +++ b/resources/views/base.blade.php @@ -7,18 +7,28 @@ + + @yield('head') -
-
- - +
+
+
+ + +
-
diff --git a/resources/views/books/create.blade.php b/resources/views/books/create.blade.php index 4d23e32bb..c3bb3fd6a 100644 --- a/resources/views/books/create.blade.php +++ b/resources/views/books/create.blade.php @@ -1,10 +1,19 @@ @extends('base') @section('content') -

New Book

-
- {{ csrf_field() }} - @include('books/form') -
+
+ + + +
+
+ @include('books/form') +
+
+ +
+ @stop \ No newline at end of file diff --git a/resources/views/books/edit.blade.php b/resources/views/books/edit.blade.php index 7478320e1..4cf54a6f7 100644 --- a/resources/views/books/edit.blade.php +++ b/resources/views/books/edit.blade.php @@ -1,11 +1,26 @@ @extends('base') @section('content') -

Edit Book

-
- {{ csrf_field() }} - - @include('books/form', ['model' => $book]) -
+ +
+ + + +
+
+ + @include('books/form', ['model' => $book]) +
+
+ +
+ + + + @stop \ No newline at end of file diff --git a/resources/views/books/form.blade.php b/resources/views/books/form.blade.php index 0d22d4e4d..163c37e96 100644 --- a/resources/views/books/form.blade.php +++ b/resources/views/books/form.blade.php @@ -1,8 +1,10 @@ -
- + +{{ csrf_field() }} +
+ @include('form/text', ['name' => 'name'])
-
+
@include('form/textarea', ['name' => 'description'])
diff --git a/resources/views/books/index.blade.php b/resources/views/books/index.blade.php index aaf51335b..e7643a768 100644 --- a/resources/views/books/index.blade.php +++ b/resources/views/books/index.blade.php @@ -2,24 +2,31 @@ @section('content') +
-
+ + + +
+ +
+ @foreach($books as $book) +
+
+

{{$book->name}}

+

{{$book->description}}

+
+
+ @endforeach +
+ +
-
- @foreach($books as $book) -
-

{{$book->name}}

-

{{$book->description}}

-
- Edit - @include('form/delete-button', ['url' => '/books/' . $book->id . '/destroy', 'text' => 'Delete']) -
-
- @endforeach -
+ @stop \ No newline at end of file diff --git a/resources/views/books/show.blade.php b/resources/views/books/show.blade.php index 809f6d2a4..4bc2f10f0 100644 --- a/resources/views/books/show.blade.php +++ b/resources/views/books/show.blade.php @@ -2,16 +2,42 @@ @section('content') -

{{$book->name}}

-

{{$book->description}}

- + New Page -

Pages:

- @if(count($book->pages) > 0) - @foreach($book->pages as $page) - {{$page->name}}
- @endforeach - @else -

This book has no pages

- @endif +
+ + + +
+

{{$book->name}}

+

{{$book->description}}

+ +
+

Pages

+ + New Page +
+
+ @if(count($book->pages) > 0) + @foreach($book->pages as $page) + {{$page->name}} + @endforeach + @else +

This book has no pages

+ @endif +
+ +

+ +

+ + +
+ + +
+ @stop \ No newline at end of file diff --git a/resources/views/form/delete-button.blade.php b/resources/views/form/delete-button.blade.php index 103eafad4..a5b1f2809 100644 --- a/resources/views/form/delete-button.blade.php +++ b/resources/views/form/delete-button.blade.php @@ -1,4 +1,4 @@ -
+ {{ csrf_field() }} diff --git a/resources/views/form/textarea.blade.php b/resources/views/form/textarea.blade.php index 5e230fede..c3b784d93 100644 --- a/resources/views/form/textarea.blade.php +++ b/resources/views/form/textarea.blade.php @@ -1,4 +1,4 @@ - @if($errors->has($name))
{{ $errors->first($name) }}
diff --git a/resources/views/pages/create.blade.php b/resources/views/pages/create.blade.php index df8e8a4c9..a5a45f015 100644 --- a/resources/views/pages/create.blade.php +++ b/resources/views/pages/create.blade.php @@ -1,9 +1,9 @@ @extends('base') @section('head') - - - + + + @stop @section('content') diff --git a/resources/views/pages/edit.blade.php b/resources/views/pages/edit.blade.php index 85502c2aa..16ded0b3d 100644 --- a/resources/views/pages/edit.blade.php +++ b/resources/views/pages/edit.blade.php @@ -7,57 +7,12 @@ @stop @section('content') - - - @include('pages/form', ['model' => $page]) -
- - - @stop \ No newline at end of file diff --git a/resources/views/pages/form.blade.php b/resources/views/pages/form.blade.php index 8ed8dd434..980c36f04 100644 --- a/resources/views/pages/form.blade.php +++ b/resources/views/pages/form.blade.php @@ -1,13 +1,80 @@ -{{ csrf_field() }} -
-
- @include('form/text', ['name' => 'name', 'placeholder' => 'Enter Page Title']) -
-
- -
-
-
- @include('form/textarea', ['name' => 'html']) + + +
+ + {{ csrf_field() }} +
+ @include('form/text', ['name' => 'name', 'placeholder' => 'Enter Page Title']) +
+
+ @include('form/textarea', ['name' => 'html']) +
+ +
+ + + + + + \ No newline at end of file diff --git a/resources/views/pages/show.blade.php b/resources/views/pages/show.blade.php index fb27d1e8e..ac586d18e 100644 --- a/resources/views/pages/show.blade.php +++ b/resources/views/pages/show.blade.php @@ -2,11 +2,54 @@ @section('content') - Edit Page +
+ -

{{$page->name}}

- -
- {!! $page->html !!} +
+

{{$page->name}}

+ {!! $page->html !!} +
+ + @stop