Merge branch 'summary' of git://github.com/younes0/BookStack into younes0-summary
Showing
7 changed files
with
49 additions
and
9 deletions
| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | ||
| 4 | class PageRevision extends Model | 4 | class PageRevision extends Model |
| 5 | { | 5 | { |
| 6 | - protected $fillable = ['name', 'html', 'text', 'markdown']; | 6 | + protected $fillable = ['name', 'html', 'text', 'markdown', 'summary']; |
| 7 | 7 | ||
| 8 | /** | 8 | /** |
| 9 | * Get the user that created the page revision | 9 | * Get the user that created the page revision | ... | ... |
| ... | @@ -310,7 +310,7 @@ class PageRepo extends EntityRepo | ... | @@ -310,7 +310,7 @@ class PageRepo extends EntityRepo |
| 310 | { | 310 | { |
| 311 | // Save a revision before updating | 311 | // Save a revision before updating |
| 312 | if ($page->html !== $input['html'] || $page->name !== $input['name']) { | 312 | if ($page->html !== $input['html'] || $page->name !== $input['name']) { |
| 313 | - $this->saveRevision($page); | 313 | + $this->saveRevision($page, $input['summary']); |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | // Prevent slug being updated if no name change | 316 | // Prevent slug being updated if no name change |
| ... | @@ -362,7 +362,7 @@ class PageRepo extends EntityRepo | ... | @@ -362,7 +362,7 @@ class PageRepo extends EntityRepo |
| 362 | * @param Page $page | 362 | * @param Page $page |
| 363 | * @return $this | 363 | * @return $this |
| 364 | */ | 364 | */ |
| 365 | - public function saveRevision(Page $page) | 365 | + public function saveRevision(Page $page, $summary = null) |
| 366 | { | 366 | { |
| 367 | $revision = $this->pageRevision->fill($page->toArray()); | 367 | $revision = $this->pageRevision->fill($page->toArray()); |
| 368 | if (setting('app-editor') !== 'markdown') $revision->markdown = ''; | 368 | if (setting('app-editor') !== 'markdown') $revision->markdown = ''; |
| ... | @@ -372,6 +372,7 @@ class PageRepo extends EntityRepo | ... | @@ -372,6 +372,7 @@ class PageRepo extends EntityRepo |
| 372 | $revision->created_by = auth()->user()->id; | 372 | $revision->created_by = auth()->user()->id; |
| 373 | $revision->created_at = $page->updated_at; | 373 | $revision->created_at = $page->updated_at; |
| 374 | $revision->type = 'version'; | 374 | $revision->type = 'version'; |
| 375 | + $revision->summary = $summary; | ||
| 375 | $revision->save(); | 376 | $revision->save(); |
| 376 | // Clear old revisions | 377 | // Clear old revisions |
| 377 | if ($this->pageRevision->where('page_id', '=', $page->id)->count() > 50) { | 378 | if ($this->pageRevision->where('page_id', '=', $page->id)->count() > 50) { | ... | ... |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use Illuminate\Database\Schema\Blueprint; | ||
| 4 | +use Illuminate\Database\Migrations\Migration; | ||
| 5 | + | ||
| 6 | +class AddSummaryToPageRevisions extends Migration | ||
| 7 | +{ | ||
| 8 | + /** | ||
| 9 | + * Run the migrations. | ||
| 10 | + * | ||
| 11 | + * @return void | ||
| 12 | + */ | ||
| 13 | + public function up() | ||
| 14 | + { | ||
| 15 | + Schema::table('page_revisions', function ($table) { | ||
| 16 | + $table->string('summary')->nullable(); | ||
| 17 | + }); | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * Reverse the migrations. | ||
| 22 | + * | ||
| 23 | + * @return void | ||
| 24 | + */ | ||
| 25 | + public function down() | ||
| 26 | + { | ||
| 27 | + Schema::table('page_revisions', function ($table) { | ||
| 28 | + $table->dropColumn('summary'); | ||
| 29 | + }); | ||
| 30 | + } | ||
| 31 | +} |
| ... | @@ -27,8 +27,8 @@ | ... | @@ -27,8 +27,8 @@ |
| 27 | </div> | 27 | </div> |
| 28 | <div class="col-sm-4 faded"> | 28 | <div class="col-sm-4 faded"> |
| 29 | <div class="action-buttons" ng-cloak> | 29 | <div class="action-buttons" ng-cloak> |
| 30 | - | ||
| 31 | <button type="button" ng-if="isUpdateDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button> | 30 | <button type="button" ng-if="isUpdateDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button> |
| 31 | + <input name="summary" id="summary-input" type="text" placeholder="edit summary" /> | ||
| 32 | <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button> | 32 | <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button> |
| 33 | </div> | 33 | </div> |
| 34 | </div> | 34 | </div> | ... | ... |
| ... | @@ -17,17 +17,18 @@ | ... | @@ -17,17 +17,18 @@ |
| 17 | </div> | 17 | </div> |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | - <div class="container small" ng-non-bindable> | 20 | + <div class="container medium" ng-non-bindable> |
| 21 | <h1>Page Revisions <span class="subheader">For "{{ $page->name }}"</span></h1> | 21 | <h1>Page Revisions <span class="subheader">For "{{ $page->name }}"</span></h1> |
| 22 | 22 | ||
| 23 | @if(count($page->revisions) > 0) | 23 | @if(count($page->revisions) > 0) |
| 24 | 24 | ||
| 25 | <table class="table"> | 25 | <table class="table"> |
| 26 | <tr> | 26 | <tr> |
| 27 | - <th width="40%">Name</th> | 27 | + <th width="30%">Name</th> |
| 28 | - <th colspan="2" width="20%">Created By</th> | 28 | + <th colspan="2" width="10%">Created By</th> |
| 29 | - <th width="20%">Revision Date</th> | 29 | + <th width="15%">Revision Date</th> |
| 30 | - <th width="20%">Actions</th> | 30 | + <th width="20%">Summary</th> |
| 31 | + <th width="15%">Actions</th> | ||
| 31 | </tr> | 32 | </tr> |
| 32 | @foreach($page->revisions as $revision) | 33 | @foreach($page->revisions as $revision) |
| 33 | <tr> | 34 | <tr> |
| ... | @@ -39,6 +40,7 @@ | ... | @@ -39,6 +40,7 @@ |
| 39 | </td> | 40 | </td> |
| 40 | <td> @if($revision->createdBy) {{$revision->createdBy->name}} @else Deleted User @endif</td> | 41 | <td> @if($revision->createdBy) {{$revision->createdBy->name}} @else Deleted User @endif</td> |
| 41 | <td><small>{{$revision->created_at->format('jS F, Y H:i:s')}} <br> ({{$revision->created_at->diffForHumans()}})</small></td> | 42 | <td><small>{{$revision->created_at->format('jS F, Y H:i:s')}} <br> ({{$revision->created_at->diffForHumans()}})</small></td> |
| 43 | + <td>{{$revision->summary}}</td> | ||
| 42 | <td> | 44 | <td> |
| 43 | <a href="{{$revision->getUrl()}}" target="_blank">Preview</a> | 45 | <a href="{{$revision->getUrl()}}" target="_blank">Preview</a> |
| 44 | <span class="text-muted"> | </span> | 46 | <span class="text-muted"> | </span> | ... | ... |
-
Please register or sign in to post a comment