mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Applied latest styleCI changes
This commit is contained in:
parent
cb0d674a71
commit
1a26b47782
@ -119,9 +119,10 @@ class BookContents
|
|||||||
// Sort our changes from our map to be chapters first
|
// Sort our changes from our map to be chapters first
|
||||||
// Since they need to be process to ensure book alignment for child page changes.
|
// Since they need to be process to ensure book alignment for child page changes.
|
||||||
$sortMapItems = $sortMap->all();
|
$sortMapItems = $sortMap->all();
|
||||||
usort($sortMapItems, function(BookSortMapItem $itemA, BookSortMapItem $itemB) {
|
usort($sortMapItems, function (BookSortMapItem $itemA, BookSortMapItem $itemB) {
|
||||||
$aScore = $itemA->type === 'page' ? 2 : 1;
|
$aScore = $itemA->type === 'page' ? 2 : 1;
|
||||||
$bScore = $itemB->type === 'page' ? 2 : 1;
|
$bScore = $itemB->type === 'page' ? 2 : 1;
|
||||||
|
|
||||||
return $aScore - $bScore;
|
return $aScore - $bScore;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -167,9 +168,9 @@ class BookContents
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentParentKey = 'book:' . $model->book_id;
|
$currentParentKey = 'book:' . $model->book_id;
|
||||||
if ($model instanceof Page && $model->chapter_id) {
|
if ($model instanceof Page && $model->chapter_id) {
|
||||||
$currentParentKey = 'chapter:' . $model->chapter_id;
|
$currentParentKey = 'chapter:' . $model->chapter_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentParent = $modelMap[$currentParentKey] ?? null;
|
$currentParent = $modelMap[$currentParentKey] ?? null;
|
||||||
@ -265,6 +266,7 @@ class BookContents
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load models from the database into the given sort map.
|
* Load models from the database into the given sort map.
|
||||||
|
*
|
||||||
* @return array<string, Entity>
|
* @return array<string, Entity>
|
||||||
*/
|
*/
|
||||||
protected function loadModelsFromSortMap(BookSortMap $sortMap): array
|
protected function loadModelsFromSortMap(BookSortMap $sortMap): array
|
||||||
@ -272,8 +274,8 @@ class BookContents
|
|||||||
$modelMap = [];
|
$modelMap = [];
|
||||||
$ids = [
|
$ids = [
|
||||||
'chapter' => [],
|
'chapter' => [],
|
||||||
'page' => [],
|
'page' => [],
|
||||||
'book' => [],
|
'book' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($sortMap->all() as $sortMapItem) {
|
foreach ($sortMap->all() as $sortMapItem) {
|
||||||
|
@ -41,5 +41,4 @@ class BookSortMap
|
|||||||
|
|
||||||
return $map;
|
return $map;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -4,7 +4,6 @@ namespace BookStack\Entities\Tools;
|
|||||||
|
|
||||||
class BookSortMapItem
|
class BookSortMapItem
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
@ -30,7 +29,6 @@ class BookSortMapItem
|
|||||||
*/
|
*/
|
||||||
public $parentBookId;
|
public $parentBookId;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(int $id, int $sort, ?int $parentChapterId, string $type, int $parentBookId)
|
public function __construct(int $id, int $sort, ?int $parentChapterId, string $type, int $parentBookId)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
@ -39,6 +37,4 @@ class BookSortMapItem
|
|||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->parentBookId = $parentBookId;
|
$this->parentBookId = $parentBookId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -30,6 +30,7 @@ class RoleController extends Controller
|
|||||||
$roles = $this->permissionsRepo->getAllRoles();
|
$roles = $this->permissionsRepo->getAllRoles();
|
||||||
|
|
||||||
$this->setPageTitle(trans('settings.roles'));
|
$this->setPageTitle(trans('settings.roles'));
|
||||||
|
|
||||||
return view('settings.roles.index', ['roles' => $roles]);
|
return view('settings.roles.index', ['roles' => $roles]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ class RoleController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->setPageTitle(trans('settings.role_create'));
|
$this->setPageTitle(trans('settings.role_create'));
|
||||||
|
|
||||||
return view('settings.roles.create', ['role' => $role]);
|
return view('settings.roles.create', ['role' => $role]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +87,7 @@ class RoleController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->setPageTitle(trans('settings.role_edit'));
|
$this->setPageTitle(trans('settings.role_edit'));
|
||||||
|
|
||||||
return view('settings.roles.edit', ['role' => $role]);
|
return view('settings.roles.edit', ['role' => $role]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +123,7 @@ class RoleController extends Controller
|
|||||||
$roles->prepend($blankRole);
|
$roles->prepend($blankRole);
|
||||||
|
|
||||||
$this->setPageTitle(trans('settings.role_delete'));
|
$this->setPageTitle(trans('settings.role_delete'));
|
||||||
|
|
||||||
return view('settings.roles.delete', ['role' => $role, 'roles' => $roles]);
|
return view('settings.roles.delete', ['role' => $role, 'roles' => $roles]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ class WebhookController extends Controller
|
|||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$this->setPageTitle(trans('settings.webhooks_create'));
|
$this->setPageTitle(trans('settings.webhooks_create'));
|
||||||
|
|
||||||
return view('settings.webhooks.create');
|
return view('settings.webhooks.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ class ThemeEvents
|
|||||||
* If the listener returns a non-null value, that will be used as the POST data instead
|
* If the listener returns a non-null value, that will be used as the POST data instead
|
||||||
* of the system default.
|
* of the system default.
|
||||||
*
|
*
|
||||||
* @param string $event
|
* @param string $event
|
||||||
* @param \BookStack\Actions\Webhook $webhook
|
* @param \BookStack\Actions\Webhook $webhook
|
||||||
* @param string|\BookStack\Interfaces\Loggable $detail
|
* @param string|\BookStack\Interfaces\Loggable $detail
|
||||||
*/
|
*/
|
||||||
const WEBHOOK_CALL_BEFORE = 'webhook_call_before';
|
const WEBHOOK_CALL_BEFORE = 'webhook_call_before';
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace BookStack\Uploads;
|
namespace BookStack\Uploads;
|
||||||
|
|
||||||
use BookStack\Exceptions\ImageUploadException;
|
use BookStack\Exceptions\ImageUploadException;
|
||||||
use BookStack\Util\WebSafeMimeSniffer;
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Contracts\Cache\Repository as Cache;
|
use Illuminate\Contracts\Cache\Repository as Cache;
|
||||||
@ -240,6 +239,7 @@ class ImageService
|
|||||||
}
|
}
|
||||||
|
|
||||||
$initialHeader = substr($imageData, 0, strpos($imageData, 'IDAT'));
|
$initialHeader = substr($imageData, 0, strpos($imageData, 'IDAT'));
|
||||||
|
|
||||||
return strpos($initialHeader, 'acTL') !== false;
|
return strpos($initialHeader, 'acTL') !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,6 +274,7 @@ class ImageService
|
|||||||
$storage = $this->getStorageDisk($image->type);
|
$storage = $this->getStorageDisk($image->type);
|
||||||
if ($storage->exists($this->adjustPathForStorageDisk($thumbFilePath, $image->type))) {
|
if ($storage->exists($this->adjustPathForStorageDisk($thumbFilePath, $image->type))) {
|
||||||
$this->cache->put($thumbCacheKey, $thumbFilePath, 60 * 60 * 72);
|
$this->cache->put($thumbCacheKey, $thumbFilePath, 60 * 60 * 72);
|
||||||
|
|
||||||
return $this->getPublicUrl($thumbFilePath);
|
return $this->getPublicUrl($thumbFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,6 +283,7 @@ class ImageService
|
|||||||
// Do not resize apng images where we're not cropping
|
// Do not resize apng images where we're not cropping
|
||||||
if ($keepRatio && $this->isApngData($image, $imageData)) {
|
if ($keepRatio && $this->isApngData($image, $imageData)) {
|
||||||
$this->cache->put($thumbCacheKey, $image->path, 60 * 60 * 72);
|
$this->cache->put($thumbCacheKey, $image->path, 60 * 60 * 72);
|
||||||
|
|
||||||
return $this->getPublicUrl($image->path);
|
return $this->getPublicUrl($image->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class WebhookManagementTest extends TestCase
|
|||||||
'endpoint' => 'https://example.com/updated-webhook',
|
'endpoint' => 'https://example.com/updated-webhook',
|
||||||
'events' => [ActivityType::PAGE_CREATE, ActivityType::PAGE_UPDATE],
|
'events' => [ActivityType::PAGE_CREATE, ActivityType::PAGE_UPDATE],
|
||||||
'active' => 'true',
|
'active' => 'true',
|
||||||
'timeout' => 5
|
'timeout' => 5,
|
||||||
]);
|
]);
|
||||||
$resp->assertRedirect('/settings/webhooks');
|
$resp->assertRedirect('/settings/webhooks');
|
||||||
|
|
||||||
|
@ -264,20 +264,20 @@ class SortTest extends TestCase
|
|||||||
// Create request data
|
// Create request data
|
||||||
$reqData = [
|
$reqData = [
|
||||||
[
|
[
|
||||||
'id' => $chapterToMove->id,
|
'id' => $chapterToMove->id,
|
||||||
'sort' => 0,
|
'sort' => 0,
|
||||||
'parentChapter' => false,
|
'parentChapter' => false,
|
||||||
'type' => 'chapter',
|
'type' => 'chapter',
|
||||||
'book' => $newBook->id,
|
'book' => $newBook->id,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
foreach ($pagesToMove as $index => $page) {
|
foreach ($pagesToMove as $index => $page) {
|
||||||
$reqData[] = [
|
$reqData[] = [
|
||||||
'id' => $page->id,
|
'id' => $page->id,
|
||||||
'sort' => $index,
|
'sort' => $index,
|
||||||
'parentChapter' => $index === count($pagesToMove) - 1 ? $chapterToMove->id : false,
|
'parentChapter' => $index === count($pagesToMove) - 1 ? $chapterToMove->id : false,
|
||||||
'type' => 'page',
|
'type' => 'page',
|
||||||
'book' => $newBook->id,
|
'book' => $newBook->id,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,8 +285,8 @@ class SortTest extends TestCase
|
|||||||
$sortResp->assertRedirect($newBook->getUrl());
|
$sortResp->assertRedirect($newBook->getUrl());
|
||||||
$sortResp->assertStatus(302);
|
$sortResp->assertStatus(302);
|
||||||
$this->assertDatabaseHas('chapters', [
|
$this->assertDatabaseHas('chapters', [
|
||||||
'id' => $chapterToMove->id,
|
'id' => $chapterToMove->id,
|
||||||
'book_id' => $newBook->id,
|
'book_id' => $newBook->id,
|
||||||
'priority' => 0,
|
'priority' => 0,
|
||||||
]);
|
]);
|
||||||
$this->assertTrue($newBook->chapters()->count() === 1);
|
$this->assertTrue($newBook->chapters()->count() === 1);
|
||||||
@ -304,11 +304,11 @@ class SortTest extends TestCase
|
|||||||
$otherChapter = Chapter::query()->where('book_id', '!=', $page->book_id)->first();
|
$otherChapter = Chapter::query()->where('book_id', '!=', $page->book_id)->first();
|
||||||
|
|
||||||
$sortData = [
|
$sortData = [
|
||||||
'id' => $page->id,
|
'id' => $page->id,
|
||||||
'sort' => 0,
|
'sort' => 0,
|
||||||
'parentChapter' => $otherChapter->id,
|
'parentChapter' => $otherChapter->id,
|
||||||
'type' => 'page',
|
'type' => 'page',
|
||||||
'book' => $page->book_id,
|
'book' => $page->book_id,
|
||||||
];
|
];
|
||||||
$this->asEditor()->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
$this->asEditor()->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
||||||
|
|
||||||
@ -326,11 +326,11 @@ class SortTest extends TestCase
|
|||||||
$this->setEntityRestrictions($otherChapter);
|
$this->setEntityRestrictions($otherChapter);
|
||||||
|
|
||||||
$sortData = [
|
$sortData = [
|
||||||
'id' => $page->id,
|
'id' => $page->id,
|
||||||
'sort' => 0,
|
'sort' => 0,
|
||||||
'parentChapter' => $otherChapter->id,
|
'parentChapter' => $otherChapter->id,
|
||||||
'type' => 'page',
|
'type' => 'page',
|
||||||
'book' => $otherChapter->book_id,
|
'book' => $otherChapter->book_id,
|
||||||
];
|
];
|
||||||
$this->asEditor()->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
$this->asEditor()->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
||||||
|
|
||||||
@ -349,11 +349,11 @@ class SortTest extends TestCase
|
|||||||
$this->setEntityRestrictions($otherChapter->book, ['update', 'delete'], [$editor->roles()->first()]);
|
$this->setEntityRestrictions($otherChapter->book, ['update', 'delete'], [$editor->roles()->first()]);
|
||||||
|
|
||||||
$sortData = [
|
$sortData = [
|
||||||
'id' => $page->id,
|
'id' => $page->id,
|
||||||
'sort' => 0,
|
'sort' => 0,
|
||||||
'parentChapter' => $otherChapter->id,
|
'parentChapter' => $otherChapter->id,
|
||||||
'type' => 'page',
|
'type' => 'page',
|
||||||
'book' => $otherChapter->book_id,
|
'book' => $otherChapter->book_id,
|
||||||
];
|
];
|
||||||
$this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
$this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
||||||
|
|
||||||
@ -372,11 +372,11 @@ class SortTest extends TestCase
|
|||||||
$this->setEntityRestrictions($otherChapter, ['view', 'delete'], [$editor->roles()->first()]);
|
$this->setEntityRestrictions($otherChapter, ['view', 'delete'], [$editor->roles()->first()]);
|
||||||
|
|
||||||
$sortData = [
|
$sortData = [
|
||||||
'id' => $page->id,
|
'id' => $page->id,
|
||||||
'sort' => 0,
|
'sort' => 0,
|
||||||
'parentChapter' => $otherChapter->id,
|
'parentChapter' => $otherChapter->id,
|
||||||
'type' => 'page',
|
'type' => 'page',
|
||||||
'book' => $otherChapter->book_id,
|
'book' => $otherChapter->book_id,
|
||||||
];
|
];
|
||||||
$this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
$this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
||||||
|
|
||||||
@ -395,11 +395,11 @@ class SortTest extends TestCase
|
|||||||
$this->setEntityRestrictions($page, ['view', 'delete'], [$editor->roles()->first()]);
|
$this->setEntityRestrictions($page, ['view', 'delete'], [$editor->roles()->first()]);
|
||||||
|
|
||||||
$sortData = [
|
$sortData = [
|
||||||
'id' => $page->id,
|
'id' => $page->id,
|
||||||
'sort' => 0,
|
'sort' => 0,
|
||||||
'parentChapter' => $otherChapter->id,
|
'parentChapter' => $otherChapter->id,
|
||||||
'type' => 'page',
|
'type' => 'page',
|
||||||
'book' => $otherChapter->book_id,
|
'book' => $otherChapter->book_id,
|
||||||
];
|
];
|
||||||
$this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
$this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
||||||
|
|
||||||
@ -418,11 +418,11 @@ class SortTest extends TestCase
|
|||||||
$this->setEntityRestrictions($page, ['view', 'update'], [$editor->roles()->first()]);
|
$this->setEntityRestrictions($page, ['view', 'update'], [$editor->roles()->first()]);
|
||||||
|
|
||||||
$sortData = [
|
$sortData = [
|
||||||
'id' => $page->id,
|
'id' => $page->id,
|
||||||
'sort' => 0,
|
'sort' => 0,
|
||||||
'parentChapter' => $otherChapter->id,
|
'parentChapter' => $otherChapter->id,
|
||||||
'type' => 'page',
|
'type' => 'page',
|
||||||
'book' => $otherChapter->book_id,
|
'book' => $otherChapter->book_id,
|
||||||
];
|
];
|
||||||
$this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
$this->actingAs($editor)->put($page->book->getUrl('/sort'), ['sort-tree' => json_encode([$sortData])])->assertRedirect();
|
||||||
|
|
||||||
@ -431,7 +431,6 @@ class SortTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function test_book_sort_item_returns_book_content()
|
public function test_book_sort_item_returns_book_content()
|
||||||
{
|
{
|
||||||
$books = Book::all();
|
$books = Book::all();
|
||||||
|
@ -170,6 +170,7 @@ class ThemeTest extends TestCase
|
|||||||
$args = [];
|
$args = [];
|
||||||
$callback = function (...$eventArgs) use (&$args) {
|
$callback = function (...$eventArgs) use (&$args) {
|
||||||
$args = $eventArgs;
|
$args = $eventArgs;
|
||||||
|
|
||||||
return ['test' => 'hello!'];
|
return ['test' => 'hello!'];
|
||||||
};
|
};
|
||||||
Theme::listen(ThemeEvents::WEBHOOK_CALL_BEFORE, $callback);
|
Theme::listen(ThemeEvents::WEBHOOK_CALL_BEFORE, $callback);
|
||||||
|
Loading…
Reference in New Issue
Block a user