Skip to content

Commit 910faab

Browse files
committed
Merge branch 'master' into release
2 parents f184d76 + e519236 commit 910faab

144 files changed

Lines changed: 6381 additions & 759 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Entity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ public static function fullTextSearch($fieldsToSearch, $terms, $wheres = [])
115115
{
116116
$termString = '';
117117
foreach ($terms as $term) {
118-
$termString .= $term . '* ';
118+
$termString .= htmlentities($term) . '* ';
119119
}
120120
$fields = implode(',', $fieldsToSearch);
121121
$termStringEscaped = \DB::connection()->getPdo()->quote($termString);
122122
$search = static::addSelect(\DB::raw('*, MATCH(name) AGAINST('.$termStringEscaped.' IN BOOLEAN MODE) AS title_relevance'));
123-
$search = $search->whereRaw('MATCH(' . $fields . ') AGAINST(? IN BOOLEAN MODE)', [$termString]);
123+
$search = $search->whereRaw('MATCH(' . $fields . ') AGAINST(? IN BOOLEAN MODE)', [$termStringEscaped]);
124124

125125
// Add additional where terms
126126
foreach ($wheres as $whereTerm) {

app/Http/Controllers/PageController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ public function store(Request $request, $bookSlug)
6161
{
6262
$this->checkPermission('page-create');
6363
$this->validate($request, [
64-
'name' => 'required|string|max:255',
65-
'html' => 'required|string',
66-
'parent' => 'integer|exists:pages,id'
64+
'name' => 'required|string|max:255'
6765
]);
6866

6967
$input = $request->all();
@@ -121,6 +119,9 @@ public function edit($bookSlug, $pageSlug)
121119
public function update(Request $request, $bookSlug, $pageSlug)
122120
{
123121
$this->checkPermission('page-update');
122+
$this->validate($request, [
123+
'name' => 'required|string|max:255'
124+
]);
124125
$book = $this->bookRepo->getBySlug($bookSlug);
125126
$page = $this->pageRepo->getBySlug($pageSlug, $book->id);
126127
$this->pageRepo->updatePage($page, $book->id, $request->all());

app/Repos/BookRepo.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public function getPopular($count = 10, $page = 0)
9595
*/
9696
public function getBySlug($slug)
9797
{
98-
return $this->book->where('slug', '=', $slug)->first();
98+
$book = $this->book->where('slug', '=', $slug)->first();
99+
if ($book === null) abort(404);
100+
return $book;
99101
}
100102

101103
/**
@@ -220,9 +222,9 @@ public function getChildren(Book $book)
220222
*/
221223
public function getBySearch($term)
222224
{
223-
$terms = explode(' ', preg_quote(trim($term)));
225+
$terms = explode(' ', $term);
224226
$books = $this->book->fullTextSearch(['name', 'description'], $terms);
225-
$words = join('|', $terms);
227+
$words = join('|', explode(' ', preg_quote(trim($term), '/')));
226228
foreach ($books as $book) {
227229
//highlight
228230
$result = preg_replace('#' . $words . '#iu', "<span class=\"highlight\">\$0</span>", $book->getExcerpt(100));

app/Repos/ChapterRepo.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public function getAll()
5656
*/
5757
public function getBySlug($slug, $bookId)
5858
{
59-
return $this->chapter->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
59+
$chapter = $this->chapter->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
60+
if ($chapter === null) abort(404);
61+
return $chapter;
6062
}
6163

6264
/**
@@ -127,9 +129,9 @@ public function findSuitableSlug($name, $bookId, $currentId = false)
127129
*/
128130
public function getBySearch($term, $whereTerms = [])
129131
{
130-
$terms = explode(' ', preg_quote(trim($term)));
132+
$terms = explode(' ', $term);
131133
$chapters = $this->chapter->fullTextSearch(['name', 'description'], $terms, $whereTerms);
132-
$words = join('|', $terms);
134+
$words = join('|', explode(' ', preg_quote(trim($term), '/')));
133135
foreach ($chapters as $chapter) {
134136
//highlight
135137
$result = preg_replace('#' . $words . '#iu', "<span class=\"highlight\">\$0</span>", $chapter->getExcerpt(100));

app/Repos/PageRepo.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public function getAll()
6464
*/
6565
public function getBySlug($slug, $bookId)
6666
{
67-
return $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
67+
$page = $this->page->where('slug', '=', $slug)->where('book_id', '=', $bookId)->first();
68+
if ($page === null) abort(404);
69+
return $page;
6870
}
6971

7072
/**
@@ -120,6 +122,7 @@ public function saveNew(array $input, Book $book, $chapterId = null)
120122
*/
121123
protected function formatHtml($htmlText)
122124
{
125+
if($htmlText == '') return $htmlText;
123126
libxml_use_internal_errors(true);
124127
$doc = new \DOMDocument();
125128
$doc->loadHTML($htmlText);
@@ -174,11 +177,11 @@ protected function formatHtml($htmlText)
174177
*/
175178
public function getBySearch($term, $whereTerms = [])
176179
{
177-
$terms = explode(' ', preg_quote(trim($term)));
180+
$terms = explode(' ', $term);
178181
$pages = $this->page->fullTextSearch(['name', 'text'], $terms, $whereTerms);
179182

180183
// Add highlights to page text.
181-
$words = join('|', $terms);
184+
$words = join('|', explode(' ', preg_quote(trim($term), '/')));
182185
//lookahead/behind assertions ensures cut between words
183186
$s = '\s\x00-/:-@\[-`{-~'; //character set for start/end of words
184187

gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ elixir.extend('queryVersion', function(inputFiles) {
2121
elixir(function(mix) {
2222
mix.sass('styles.scss')
2323
.sass('print-styles.scss')
24-
.browserify(['jquery-extensions.js', 'global.js'], 'public/js/common.js')
24+
.browserify('global.js', 'public/js/common.js')
2525
.queryVersion(['css/styles.css', 'css/print-styles.css', 'js/common.js']);
2626
});

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
{
22
"private": true,
33
"devDependencies": {
4-
"gulp": "^3.9.0",
5-
"insert-css": "^0.2.0"
4+
"gulp": "^3.9.0"
65
},
76
"dependencies": {
7+
"angular": "^1.5.0-rc.0",
8+
"angular-animate": "^1.5.0-rc.0",
9+
"angular-resource": "^1.5.0-rc.0",
10+
"angular-sanitize": "^1.5.0-rc.0",
811
"babel-runtime": "^5.8.29",
912
"bootstrap-sass": "^3.0.0",
1013
"dropzone": "^4.0.1",
1114
"laravel-elixir": "^3.4.0",
12-
"vue": "^1.0.4",
13-
"vue-hot-reload-api": "^1.2.1",
14-
"vue-resource": "^0.1.16",
15-
"vueify": "^5.0.1",
16-
"vueify-insert-css": "^1.0.0",
1715
"zeroclipboard": "^2.2.0"
1816
}
1917
}
22.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)