html diff in revision view

This commit is contained in:
Younès EL BIACHE
2016-07-07 19:42:21 +02:00
parent 10418323ef
commit 9537e2ae95
6 changed files with 589 additions and 297 deletions

View File

@ -12,6 +12,7 @@ use BookStack\Repos\ChapterRepo;
use BookStack\Repos\PageRepo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Views;
use Icap\HtmlDiff\HtmlDiff;
class PageController extends Controller
{
@ -332,9 +333,19 @@ class PageController extends Controller
$book = $this->bookRepo->getBySlug($bookSlug);
$page = $this->pageRepo->getBySlug($pageSlug, $book->id);
$revision = $this->pageRepo->getRevisionById($revisionId);
$next = $revision->getNext() ?: $page;
$htmlDiff = new HtmlDiff($revision->html, $next->html, true);
$diff = $htmlDiff->outputDiff()->toString();
$page->fill($revision->toArray());
$this->setPageTitle('Page Revision For ' . $page->getShortName());
return view('pages/revision', ['page' => $page, 'book' => $book]);
return view('pages/revision', [
'page' => $page,
'book' => $book,
'diff' => $diff,
]);
}
/**