]> BookStack Code Mirror - bookstack/commitdiff
Added included content into page's text view
authorDan Brown <redacted>
Sat, 22 Jul 2017 13:21:56 +0000 (14:21 +0100)
committerDan Brown <redacted>
Sat, 22 Jul 2017 13:21:56 +0000 (14:21 +0100)
Allows rendered content to be shown in listings and used in searches.
Also prevented angular tags in content being parsed in listings.

Fixes #442

app/Repos/EntityRepo.php
resources/views/books/show.blade.php
resources/views/chapters/show.blade.php

index 7bc5fc4fc159f2a2984e8b2fe62eda5593416b44..7865de772fbfe7c30b33cff3ac16fdeb6813f0cc 100644 (file)
@@ -571,7 +571,7 @@ class EntityRepo
 
         $draftPage->slug = $this->findSuitableSlug('page', $draftPage->name, false, $draftPage->book->id);
         $draftPage->html = $this->formatHtml($input['html']);
-        $draftPage->text = strip_tags($draftPage->html);
+        $draftPage->text = $this->pageToPlainText($draftPage->html);
         $draftPage->draft = false;
         $draftPage->revision_count = 1;
 
@@ -713,6 +713,17 @@ class EntityRepo
         return $content;
     }
 
+    /**
+     * Get the plain text version of a page's content.
+     * @param Page $page
+     * @return string
+     */
+    public function pageToPlainText(Page $page)
+    {
+        $html = $this->renderPage($page);
+        return strip_tags($html);
+    }
+
     /**
      * Get a new draft page instance.
      * @param Book $book
@@ -816,7 +827,7 @@ class EntityRepo
         $userId = user()->id;
         $page->fill($input);
         $page->html = $this->formatHtml($input['html']);
-        $page->text = strip_tags($page->html);
+        $page->text = $this->pageToPlainText($page);
         if (setting('app-editor') !== 'markdown') $page->markdown = '';
         $page->updated_by = $userId;
         $page->revision_count++;
@@ -933,7 +944,7 @@ class EntityRepo
         $revision = $page->revisions()->where('id', '=', $revisionId)->first();
         $page->fill($revision->toArray());
         $page->slug = $this->findSuitableSlug('page', $page->name, $page->id, $book->id);
-        $page->text = strip_tags($page->html);
+        $page->text = $this->pageToPlainText($page->html);
         $page->updated_by = user()->id;
         $page->save();
         $this->searchService->indexEntity($page);
@@ -953,7 +964,7 @@ class EntityRepo
         if ($page->draft) {
             $page->fill($data);
             if (isset($data['html'])) {
-                $page->text = strip_tags($data['html']);
+                $page->text = $this->pageToPlainText($data['html']);
             }
             $page->save();
             return $page;
index ddbe7a0a4ab0488fbe819a9204ccd7824a4f1e84..353018dbc76e0a8f9b2a5628dc56a1361404a67e 100644 (file)
@@ -50,7 +50,7 @@
     </div>
 
 
-    <div class="container" id="entity-dashboard" entity-id="{{ $book->id }}" entity-type="book">
+    <div ng-non-bindable class="container" id="entity-dashboard" entity-id="{{ $book->id }}" entity-type="book">
         <div class="row">
             <div class="col-md-7">
 
                 @endif
 
                 <div class="search-box">
-                    <form v-on:submit="searchBook">
+                    <form v-on:submit.prevent="searchBook">
                         <input v-model="searchTerm" v-on:change="checkSearchForm()" type="text" name="term" placeholder="{{ trans('entities.books_search_this') }}">
                         <button type="submit"><i class="zmdi zmdi-search"></i></button>
                         <button v-if="searching" v-cloak class="text-neg" v-on:click="clearSearch()" type="button"><i class="zmdi zmdi-close"></i></button>
index d4126cbccee764fb95fd0d27dcb84d93a2df79c0..85aa252d190a6ac0a785514e780701483eafb00b 100644 (file)
@@ -47,7 +47,7 @@
     </div>
 
 
-    <div class="container" id="entity-dashboard" entity-id="{{ $chapter->id }}" entity-type="chapter">
+    <div class="container" id="entity-dashboard" ng-non-bindable entity-id="{{ $chapter->id }}" entity-type="chapter">
         <div class="row">
             <div class="col-md-7">
                 <h1>{{ $chapter->name }}</h1>
                 @endif
 
                 <div class="search-box">
-                    <form v-on:submit="searchBook">
+                    <form v-on:submit.prevent="searchBook">
                         <input v-model="searchTerm" v-on:change="checkSearchForm()" type="text" name="term" placeholder="{{ trans('entities.chapters_search_this') }}">
                         <button type="submit"><i class="zmdi zmdi-search"></i></button>
                         <button v-if="searching" v-cloak class="text-neg" v-on:click="clearSearch()" type="button"><i class="zmdi zmdi-close"></i></button>