1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-04-27 15:57:04 +03:00

Merge branch 'diff' of git://github.com/younes0/BookStack into younes0-diff

This commit is contained in:
Dan Brown 2016-09-29 09:32:40 +01:00
commit fff5bbcee4
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
6 changed files with 219 additions and 54 deletions

View File

@ -12,6 +12,7 @@ use BookStack\Repos\ChapterRepo;
use BookStack\Repos\PageRepo; use BookStack\Repos\PageRepo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Views; use Views;
use GatherContent\Htmldiff\Htmldiff;
class PageController extends Controller class PageController extends Controller
{ {
@ -335,9 +336,18 @@ class PageController extends Controller
$book = $this->bookRepo->getBySlug($bookSlug); $book = $this->bookRepo->getBySlug($bookSlug);
$page = $this->pageRepo->getBySlug($pageSlug, $book->id); $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
$revision = $this->pageRepo->getRevisionById($revisionId); $revision = $this->pageRepo->getRevisionById($revisionId);
$next = $revision->getNext() ?: $page;
$diff = (new Htmldiff)->diff($revision->html, $next->html);
$page->fill($revision->toArray()); $page->fill($revision->toArray());
$this->setPageTitle('Page Revision For ' . $page->getShortName()); $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,
]);
} }
/** /**

View File

@ -32,4 +32,25 @@ class PageRevision extends Model
return $this->page->getUrl() . '/revisions/' . $this->id; return $this->page->getUrl() . '/revisions/' . $this->id;
} }
/**
* Get previous revision
* @return \BookStack\PageRevision
*/
public function getPrevious()
{
if ($id = PageRevision::where('id', '<', $this->id)->max('id')) {
return PageRevision::find($id);
}
}
/**
* Get next revision
* @return \BookStack\PageRevision
*/
public function getNext()
{
if ($id = PageRevision::where('id', '>', $this->id)->min('id')) {
return PageRevision::find($id);
}
}
} }

View File

@ -7,13 +7,15 @@
"require": { "require": {
"php": ">=5.6.4", "php": ">=5.6.4",
"laravel/framework": "^5.3.4", "laravel/framework": "^5.3.4",
"ext-tidy": "*",
"intervention/image": "^2.3", "intervention/image": "^2.3",
"laravel/socialite": "^2.0", "laravel/socialite": "^2.0",
"barryvdh/laravel-ide-helper": "^2.1", "barryvdh/laravel-ide-helper": "^2.1",
"barryvdh/laravel-debugbar": "^2.2.3", "barryvdh/laravel-debugbar": "^2.2.3",
"league/flysystem-aws-s3-v3": "^1.0", "league/flysystem-aws-s3-v3": "^1.0",
"barryvdh/laravel-dompdf": "^0.7", "barryvdh/laravel-dompdf": "^0.7",
"predis/predis": "^1.1" "predis/predis": "^1.1",
"gathercontent/htmldiff": "^0.2.1"
}, },
"require-dev": { "require-dev": {
"fzaninotto/faker": "~1.4", "fzaninotto/faker": "~1.4",

218
composer.lock generated
View File

@ -4,21 +4,21 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "c90a6e41767306ceb3b8cedb91468390", "hash": "3124d900cfe857392a94de479f3ff6d4",
"content-hash": "3b5d2d6b77fbe71101e7e8eaff0754fe", "content-hash": "a968767a73f77e66e865c276cf76eedf",
"packages": [ "packages": [
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.19.6", "version": "3.19.11",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "34060bf0db260031697b17dbb37fa1bbec92f1c4" "reference": "19bac3bdd7988cbf7f89d5ce8e2748d774e2cde8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/34060bf0db260031697b17dbb37fa1bbec92f1c4", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/19bac3bdd7988cbf7f89d5ce8e2748d774e2cde8",
"reference": "34060bf0db260031697b17dbb37fa1bbec92f1c4", "reference": "19bac3bdd7988cbf7f89d5ce8e2748d774e2cde8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -85,32 +85,32 @@
"s3", "s3",
"sdk" "sdk"
], ],
"time": "2016-09-08 20:27:15" "time": "2016-09-27 19:38:36"
}, },
{ {
"name": "barryvdh/laravel-debugbar", "name": "barryvdh/laravel-debugbar",
"version": "V2.2.3", "version": "v2.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/barryvdh/laravel-debugbar.git", "url": "https://github.com/barryvdh/laravel-debugbar.git",
"reference": "ecd1ce5c4a827e2f6a8fb41bcf67713beb1c1cbd" "reference": "0c87981df959c7c1943abe227baf607c92f204f9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/ecd1ce5c4a827e2f6a8fb41bcf67713beb1c1cbd", "url": "https://api.github.com/repos/barryvdh/laravel-debugbar/zipball/0c87981df959c7c1943abe227baf607c92f204f9",
"reference": "ecd1ce5c4a827e2f6a8fb41bcf67713beb1c1cbd", "reference": "0c87981df959c7c1943abe227baf607c92f204f9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"illuminate/support": "5.1.*|5.2.*|5.3.*", "illuminate/support": "5.1.*|5.2.*|5.3.*",
"maximebf/debugbar": "~1.11.0|~1.12.0", "maximebf/debugbar": "~1.13.0",
"php": ">=5.5.9", "php": ">=5.5.9",
"symfony/finder": "~2.7|~3.0" "symfony/finder": "~2.7|~3.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.2-dev" "dev-master": "2.3-dev"
} }
}, },
"autoload": { "autoload": {
@ -139,7 +139,7 @@
"profiler", "profiler",
"webprofiler" "webprofiler"
], ],
"time": "2016-07-29 15:00:36" "time": "2016-09-15 14:05:56"
}, },
{ {
"name": "barryvdh/laravel-dompdf", "name": "barryvdh/laravel-dompdf",
@ -358,6 +358,57 @@
], ],
"time": "2015-11-09 22:51:51" "time": "2015-11-09 22:51:51"
}, },
{
"name": "cogpowered/finediff",
"version": "0.3.1",
"source": {
"type": "git",
"url": "https://github.com/cogpowered/FineDiff.git",
"reference": "339ddc8c3afb656efed4f2f0a80e5c3d026f8ea8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/cogpowered/FineDiff/zipball/339ddc8c3afb656efed4f2f0a80e5c3d026f8ea8",
"reference": "339ddc8c3afb656efed4f2f0a80e5c3d026f8ea8",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"mockery/mockery": "*",
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"psr-0": {
"cogpowered\\FineDiff": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Rob Crowe",
"email": "rob@cogpowered.com"
},
{
"name": "Raymond Hill"
}
],
"description": "PHP implementation of a Fine granularity Diff engine",
"homepage": "https://github.com/cogpowered/FineDiff",
"keywords": [
"diff",
"finediff",
"opcode",
"string",
"text"
],
"time": "2014-05-19 10:25:02"
},
{ {
"name": "dnoegel/php-xdg-base-dir", "name": "dnoegel/php-xdg-base-dir",
"version": "0.1", "version": "0.1",
@ -519,6 +570,55 @@
"homepage": "https://github.com/dompdf/dompdf", "homepage": "https://github.com/dompdf/dompdf",
"time": "2016-05-11 00:36:29" "time": "2016-05-11 00:36:29"
}, },
{
"name": "gathercontent/htmldiff",
"version": "0.2.1",
"source": {
"type": "git",
"url": "https://github.com/gathercontent/htmldiff.git",
"reference": "24674a62315f64330134b4a4c5b01a7b59193c93"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/gathercontent/htmldiff/zipball/24674a62315f64330134b4a4c5b01a7b59193c93",
"reference": "24674a62315f64330134b4a4c5b01a7b59193c93",
"shasum": ""
},
"require": {
"cogpowered/finediff": "0.3.1",
"ext-tidy": "*"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"squizlabs/php_codesniffer": "1.*"
},
"type": "library",
"autoload": {
"psr-0": {
"GatherContent\\Htmldiff": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andrew Cairns",
"email": "andrew@gathercontent.com"
},
{
"name": "Mathew Chapman",
"email": "mat@gathercontent.com"
},
{
"name": "Peter Legierski",
"email": "peter@gathercontent.com"
}
],
"description": "Compare two HTML strings",
"time": "2015-04-15 15:39:46"
},
{ {
"name": "guzzlehttp/guzzle", "name": "guzzlehttp/guzzle",
"version": "6.2.1", "version": "6.2.1",
@ -899,16 +999,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v5.3.9", "version": "v5.3.11",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "f6fbb481672f8dc4bc6882d5d654bbfa3588c8ec" "reference": "ca48001b95a0543fb39fcd7219de960bbc03eaa5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/f6fbb481672f8dc4bc6882d5d654bbfa3588c8ec", "url": "https://api.github.com/repos/laravel/framework/zipball/ca48001b95a0543fb39fcd7219de960bbc03eaa5",
"reference": "f6fbb481672f8dc4bc6882d5d654bbfa3588c8ec", "reference": "ca48001b95a0543fb39fcd7219de960bbc03eaa5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -956,6 +1056,7 @@
"illuminate/http": "self.version", "illuminate/http": "self.version",
"illuminate/log": "self.version", "illuminate/log": "self.version",
"illuminate/mail": "self.version", "illuminate/mail": "self.version",
"illuminate/notifications": "self.version",
"illuminate/pagination": "self.version", "illuminate/pagination": "self.version",
"illuminate/pipeline": "self.version", "illuminate/pipeline": "self.version",
"illuminate/queue": "self.version", "illuminate/queue": "self.version",
@ -1022,7 +1123,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2016-09-12 14:08:29" "time": "2016-09-28 02:15:37"
}, },
{ {
"name": "laravel/socialite", "name": "laravel/socialite",
@ -1273,16 +1374,16 @@
}, },
{ {
"name": "maximebf/debugbar", "name": "maximebf/debugbar",
"version": "v1.12.0", "version": "v1.13.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/maximebf/php-debugbar.git", "url": "https://github.com/maximebf/php-debugbar.git",
"reference": "e634fbd32cd6bc3fa0e8c972b52d4bf49bab3988" "reference": "5f49a5ed6cfde81d31d89378806670d77462526e"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/e634fbd32cd6bc3fa0e8c972b52d4bf49bab3988", "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/5f49a5ed6cfde81d31d89378806670d77462526e",
"reference": "e634fbd32cd6bc3fa0e8c972b52d4bf49bab3988", "reference": "5f49a5ed6cfde81d31d89378806670d77462526e",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1301,7 +1402,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.12-dev" "dev-master": "1.13-dev"
} }
}, },
"autoload": { "autoload": {
@ -1330,7 +1431,7 @@
"debug", "debug",
"debugbar" "debugbar"
], ],
"time": "2016-05-15 13:11:34" "time": "2016-09-15 14:01:59"
}, },
{ {
"name": "monolog/monolog", "name": "monolog/monolog",
@ -1558,16 +1659,16 @@
}, },
{ {
"name": "nikic/php-parser", "name": "nikic/php-parser",
"version": "v2.1.0", "version": "v2.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nikic/PHP-Parser.git", "url": "https://github.com/nikic/PHP-Parser.git",
"reference": "47b254ea51f1d6d5dc04b9b299e88346bf2369e3" "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/47b254ea51f1d6d5dc04b9b299e88346bf2369e3", "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4dd659edadffdc2143e4753df655d866dbfeedf0",
"reference": "47b254ea51f1d6d5dc04b9b299e88346bf2369e3", "reference": "4dd659edadffdc2143e4753df655d866dbfeedf0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1605,7 +1706,7 @@
"parser", "parser",
"php" "php"
], ],
"time": "2016-04-19 13:41:41" "time": "2016-09-16 12:04:44"
}, },
{ {
"name": "paragonie/random_compat", "name": "paragonie/random_compat",
@ -1825,22 +1926,30 @@
}, },
{ {
"name": "psr/log", "name": "psr/log",
"version": "1.0.0", "version": "1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/php-fig/log.git", "url": "https://github.com/php-fig/log.git",
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" "reference": "5277094ed527a1c4477177d102fe4c53551953e0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", "url": "https://api.github.com/repos/php-fig/log/zipball/5277094ed527a1c4477177d102fe4c53551953e0",
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", "reference": "5277094ed527a1c4477177d102fe4c53551953e0",
"shasum": "" "shasum": ""
}, },
"require": {
"php": ">=5.3.0"
},
"type": "library", "type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": { "autoload": {
"psr-0": { "psr-4": {
"Psr\\Log\\": "" "Psr\\Log\\": "Psr/Log/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -1854,12 +1963,13 @@
} }
], ],
"description": "Common interface for logging libraries", "description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [ "keywords": [
"log", "log",
"psr", "psr",
"psr-3" "psr-3"
], ],
"time": "2012-12-21 11:40:51" "time": "2016-09-19 16:02:08"
}, },
{ {
"name": "psy/psysh", "name": "psy/psysh",
@ -3167,16 +3277,16 @@
}, },
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",
"version": "1.5.2", "version": "1.5.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/myclabs/DeepCopy.git", "url": "https://github.com/myclabs/DeepCopy.git",
"reference": "da8529775f14f4fdae33f916eb0cf65f6afbddbc" "reference": "ea74994a3dc7f8d2f65a06009348f2d63c81e61f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/da8529775f14f4fdae33f916eb0cf65f6afbddbc", "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/ea74994a3dc7f8d2f65a06009348f2d63c81e61f",
"reference": "da8529775f14f4fdae33f916eb0cf65f6afbddbc", "reference": "ea74994a3dc7f8d2f65a06009348f2d63c81e61f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3205,7 +3315,7 @@
"object", "object",
"object graph" "object graph"
], ],
"time": "2016-09-06 16:07:05" "time": "2016-09-16 13:37:59"
}, },
{ {
"name": "phpdocumentor/reflection-common", "name": "phpdocumentor/reflection-common",
@ -3661,24 +3771,24 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "5.5.4", "version": "5.5.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "3e6e88e56c912133de6e99b87728cca7ed70c5f5" "reference": "a57126dc681b08289fef6ac96a48e30656f84350"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3e6e88e56c912133de6e99b87728cca7ed70c5f5", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a57126dc681b08289fef6ac96a48e30656f84350",
"reference": "3e6e88e56c912133de6e99b87728cca7ed70c5f5", "reference": "a57126dc681b08289fef6ac96a48e30656f84350",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-dom": "*", "ext-dom": "*",
"ext-json": "*", "ext-json": "*",
"ext-pcre": "*", "ext-libxml": "*",
"ext-reflection": "*", "ext-mbstring": "*",
"ext-spl": "*", "ext-xml": "*",
"myclabs/deep-copy": "~1.3", "myclabs/deep-copy": "~1.3",
"php": "^5.6 || ^7.0", "php": "^5.6 || ^7.0",
"phpspec/prophecy": "^1.3.1", "phpspec/prophecy": "^1.3.1",
@ -3700,7 +3810,12 @@
"conflict": { "conflict": {
"phpdocumentor/reflection-docblock": "3.0.2" "phpdocumentor/reflection-docblock": "3.0.2"
}, },
"require-dev": {
"ext-pdo": "*"
},
"suggest": { "suggest": {
"ext-tidy": "*",
"ext-xdebug": "*",
"phpunit/php-invoker": "~1.1" "phpunit/php-invoker": "~1.1"
}, },
"bin": [ "bin": [
@ -3735,7 +3850,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2016-08-26 07:11:44" "time": "2016-09-21 14:40:13"
}, },
{ {
"name": "phpunit/phpunit-mock-objects", "name": "phpunit/phpunit-mock-objects",
@ -4524,7 +4639,8 @@
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": ">=5.6.4" "php": ">=5.6.4",
"ext-tidy": "*"
}, },
"platform-dev": [] "platform-dev": []
} }

12
resources/assets/sass/_pages.scss Normal file → Executable file
View File

@ -71,6 +71,18 @@
max-width: 100%; max-width: 100%;
height: auto !important; height: auto !important;
} }
// diffs
ins,
del {
text-decoration: none;
}
ins {
background: #dbffdb;
}
del {
background: #FFECEC;
}
} }
// Page content pointers // Page content pointers

View File

@ -24,5 +24,9 @@
<div style="clear:left;"></div> <div style="clear:left;"></div>
@if (isset($diff) && $diff)
{!! $diff !!}
@else
{!! $page->html !!} {!! $page->html !!}
@endif
</div> </div>