mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Laravel 8 shift squash & merge (#3029)
* Temporarily moved back config path * Apply Laravel coding style * Shift exception handler * Shift HTTP kernel and middleware * Shift service providers * Convert options array to fluent methods * Shift to class based routes * Shift console routes * Ignore temporary framework files * Shift to class based factories * Namespace seeders * Shift PSR-4 autoloading * Shift config files * Default config files * Shift Laravel dependencies * Shift return type of base TestCase methods * Shift cleanup * Applied stylci style changes * Reverted config files location * Applied manual changes to Laravel 8 shift Co-authored-by: Shift <shift@laravelshift.com>
This commit is contained in:
parent
f77236aa38
commit
f139cded78
@ -4,6 +4,7 @@ namespace BookStack\Actions;
|
||||
|
||||
use BookStack\Model;
|
||||
use BookStack\Traits\HasCreatorAndUpdater;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
/**
|
||||
@ -15,6 +16,7 @@ use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
*/
|
||||
class Comment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasCreatorAndUpdater;
|
||||
|
||||
protected $fillable = ['text', 'parent_id'];
|
||||
|
@ -3,10 +3,13 @@
|
||||
namespace BookStack\Actions;
|
||||
|
||||
use BookStack\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['name', 'value', 'order'];
|
||||
protected $hidden = ['id', 'entity_id', 'entity_type', 'created_at', 'updated_at'];
|
||||
|
||||
|
@ -7,6 +7,7 @@ use BookStack\Auth\Permissions\RolePermission;
|
||||
use BookStack\Interfaces\Loggable;
|
||||
use BookStack\Model;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
@ -23,6 +24,8 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
*/
|
||||
class Role extends Model implements Loggable
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = ['display_name', 'description', 'external_auth_id'];
|
||||
|
||||
/**
|
||||
|
@ -18,6 +18,7 @@ use Illuminate\Auth\Passwords\CanResetPassword;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@ -43,6 +44,7 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, Loggable, Sluggable
|
||||
{
|
||||
use HasFactory;
|
||||
use Authenticatable;
|
||||
use CanResetPassword;
|
||||
use Notifiable;
|
||||
|
11
app/Config/app.php
Executable file → Normal file
11
app/Config/app.php
Executable file → Normal file
@ -143,7 +143,6 @@ return [
|
||||
|
||||
// Class aliases, Registered on application start
|
||||
'aliases' => [
|
||||
|
||||
// Laravel
|
||||
'App' => Illuminate\Support\Facades\App::class,
|
||||
'Arr' => Illuminate\Support\Arr::class,
|
||||
@ -155,21 +154,23 @@ return [
|
||||
'Config' => Illuminate\Support\Facades\Config::class,
|
||||
'Cookie' => Illuminate\Support\Facades\Cookie::class,
|
||||
'Crypt' => Illuminate\Support\Facades\Crypt::class,
|
||||
'Date' => Illuminate\Support\Facades\Date::class,
|
||||
'DB' => Illuminate\Support\Facades\DB::class,
|
||||
'Eloquent' => Illuminate\Database\Eloquent\Model::class,
|
||||
'Event' => Illuminate\Support\Facades\Event::class,
|
||||
'File' => Illuminate\Support\Facades\File::class,
|
||||
'Gate' => Illuminate\Support\Facades\Gate::class,
|
||||
'Hash' => Illuminate\Support\Facades\Hash::class,
|
||||
'Input' => Illuminate\Support\Facades\Input::class,
|
||||
'Inspiring' => Illuminate\Foundation\Inspiring::class,
|
||||
'Http' => Illuminate\Support\Facades\Http::class,
|
||||
'Lang' => Illuminate\Support\Facades\Lang::class,
|
||||
'Log' => Illuminate\Support\Facades\Log::class,
|
||||
'Mail' => Illuminate\Support\Facades\Mail::class,
|
||||
'Notification' => Illuminate\Support\Facades\Notification::class,
|
||||
'Password' => Illuminate\Support\Facades\Password::class,
|
||||
'Queue' => Illuminate\Support\Facades\Queue::class,
|
||||
'RateLimiter' => Illuminate\Support\Facades\RateLimiter::class,
|
||||
'Redirect' => Illuminate\Support\Facades\Redirect::class,
|
||||
'Redis' => Illuminate\Support\Facades\Redis::class,
|
||||
// 'Redis' => Illuminate\Support\Facades\Redis::class,
|
||||
'Request' => Illuminate\Support\Facades\Request::class,
|
||||
'Response' => Illuminate\Support\Facades\Response::class,
|
||||
'Route' => Illuminate\Support\Facades\Route::class,
|
||||
@ -180,6 +181,8 @@ return [
|
||||
'URL' => Illuminate\Support\Facades\URL::class,
|
||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||
'View' => Illuminate\Support\Facades\View::class,
|
||||
|
||||
// Laravel Packages
|
||||
'Socialite' => Laravel\Socialite\Facades\Socialite::class,
|
||||
|
||||
// Third Party
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
return [
|
||||
|
||||
// Method of authentication to use
|
||||
// Options: standard, ldap, saml2, oidc
|
||||
'method' => env('AUTH_METHOD', 'standard'),
|
||||
|
||||
@ -58,10 +57,16 @@ return [
|
||||
'driver' => 'eloquent',
|
||||
'model' => \BookStack\Auth\User::class,
|
||||
],
|
||||
|
||||
'external' => [
|
||||
'driver' => 'external-users',
|
||||
'model' => \BookStack\Auth\User::class,
|
||||
],
|
||||
|
||||
// 'users' => [
|
||||
// 'driver' => 'database',
|
||||
// 'table' => 'users',
|
||||
// ],
|
||||
],
|
||||
|
||||
// Resetting Passwords
|
||||
@ -78,4 +83,10 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
// Password Confirmation Timeout
|
||||
// Here you may define the amount of seconds before a password confirmation
|
||||
// times out and the user is prompted to re-enter their password via the
|
||||
// confirmation screen. By default, the timeout lasts for three hours.
|
||||
'password_timeout' => 10800,
|
||||
|
||||
];
|
||||
|
@ -1,51 +1,79 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Broadcasting configuration options.
|
||||
* Caching configuration options.
|
||||
*
|
||||
* Changes to these config files are not supported by BookStack and may break upon updates.
|
||||
* Configuration should be altered via the `.env` file or environment variables.
|
||||
* Do not edit this file unless you're happy to maintain any changes yourself.
|
||||
*/
|
||||
|
||||
// MEMCACHED - Split out configuration into an array
|
||||
if (env('CACHE_DRIVER') === 'memcached') {
|
||||
$memcachedServerKeys = ['host', 'port', 'weight'];
|
||||
$memcachedServers = explode(',', trim(env('MEMCACHED_SERVERS', '127.0.0.1:11211:100'), ','));
|
||||
foreach ($memcachedServers as $index => $memcachedServer) {
|
||||
$memcachedServerDetails = explode(':', $memcachedServer);
|
||||
if (count($memcachedServerDetails) < 2) {
|
||||
$memcachedServerDetails[] = '11211';
|
||||
}
|
||||
if (count($memcachedServerDetails) < 3) {
|
||||
$memcachedServerDetails[] = '100';
|
||||
}
|
||||
$memcachedServers[$index] = array_combine($memcachedServerKeys, $memcachedServerDetails);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
// Default Broadcaster
|
||||
// This option controls the default broadcaster that will be used by the
|
||||
// framework when an event needs to be broadcast. This can be set to
|
||||
// any of the connections defined in the "connections" array below.
|
||||
'default' => env('BROADCAST_DRIVER', 'pusher'),
|
||||
// Default cache store to use
|
||||
// Can be overridden at cache call-time
|
||||
'default' => env('CACHE_DRIVER', 'file'),
|
||||
|
||||
// Broadcast Connections
|
||||
// Here you may define all of the broadcast connections that will be used
|
||||
// to broadcast events to other systems or over websockets. Samples of
|
||||
// each available type of connection are provided inside this array.
|
||||
'connections' => [
|
||||
// Available caches stores
|
||||
'stores' => [
|
||||
|
||||
'pusher' => [
|
||||
'driver' => 'pusher',
|
||||
'key' => env('PUSHER_APP_KEY'),
|
||||
'secret' => env('PUSHER_APP_SECRET'),
|
||||
'app_id' => env('PUSHER_APP_ID'),
|
||||
'options' => [
|
||||
'cluster' => env('PUSHER_APP_CLUSTER'),
|
||||
'useTLS' => true,
|
||||
'apc' => [
|
||||
'driver' => 'apc',
|
||||
],
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'cache',
|
||||
'connection' => null,
|
||||
'lock_connection' => null,
|
||||
],
|
||||
|
||||
'file' => [
|
||||
'driver' => 'file',
|
||||
'path' => storage_path('framework/cache'),
|
||||
],
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'servers' => env('CACHE_DRIVER') === 'memcached' ? $memcachedServers : [],
|
||||
'options' => [],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
'lock_connection' => 'default',
|
||||
],
|
||||
|
||||
'log' => [
|
||||
'driver' => 'log',
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'null',
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
// Cache key prefix
|
||||
// Used to prevent collisions in shared cache systems.
|
||||
'prefix' => env('CACHE_PREFIX', 'bookstack_cache'),
|
||||
|
||||
];
|
||||
|
@ -1,36 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Caching configuration options.
|
||||
*
|
||||
* Changes to these config files are not supported by BookStack and may break upon updates.
|
||||
* Configuration should be altered via the `.env` file or environment variables.
|
||||
* Do not edit this file unless you're happy to maintain any changes yourself.
|
||||
*/
|
||||
|
||||
// MEMCACHED - Split out configuration into an array
|
||||
if (env('CACHE_DRIVER') === 'memcached') {
|
||||
$memcachedServerKeys = ['host', 'port', 'weight'];
|
||||
$memcachedServers = explode(',', trim(env('MEMCACHED_SERVERS', '127.0.0.1:11211:100'), ','));
|
||||
foreach ($memcachedServers as $index => $memcachedServer) {
|
||||
$memcachedServerDetails = explode(':', $memcachedServer);
|
||||
if (count($memcachedServerDetails) < 2) {
|
||||
$memcachedServerDetails[] = '11211';
|
||||
}
|
||||
if (count($memcachedServerDetails) < 3) {
|
||||
$memcachedServerDetails[] = '100';
|
||||
}
|
||||
$memcachedServers[$index] = array_combine($memcachedServerKeys, $memcachedServerDetails);
|
||||
}
|
||||
}
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
return [
|
||||
|
||||
// Default cache store to use
|
||||
// Can be overridden at cache call-time
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Cache Store
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the default cache connection that gets used while
|
||||
| using this caching library. This connection is used when another is
|
||||
| not explicitly specified when executing a given caching function.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('CACHE_DRIVER', 'file'),
|
||||
|
||||
// Available caches stores
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Stores
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of the cache "stores" for your application as
|
||||
| well as their drivers. You may even define multiple stores for the
|
||||
| same cache driver to group types of items stored in your caches.
|
||||
|
|
||||
| Supported drivers: "apc", "array", "database", "file",
|
||||
| "memcached", "redis", "dynamodb", "octane", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'stores' => [
|
||||
|
||||
'apc' => [
|
||||
@ -39,12 +39,14 @@ return [
|
||||
|
||||
'array' => [
|
||||
'driver' => 'array',
|
||||
'serialize' => false,
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'cache',
|
||||
'connection' => null,
|
||||
'lock_connection' => null,
|
||||
],
|
||||
|
||||
'file' => [
|
||||
@ -54,18 +56,49 @@ return [
|
||||
|
||||
'memcached' => [
|
||||
'driver' => 'memcached',
|
||||
'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
|
||||
'sasl' => [
|
||||
env('MEMCACHED_USERNAME'),
|
||||
env('MEMCACHED_PASSWORD'),
|
||||
],
|
||||
'options' => [
|
||||
// Memcached::OPT_CONNECT_TIMEOUT => 2000,
|
||||
],
|
||||
'servers' => env('CACHE_DRIVER') === 'memcached' ? $memcachedServers : [],
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
'lock_connection' => 'default',
|
||||
],
|
||||
|
||||
'dynamodb' => [
|
||||
'driver' => 'dynamodb',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
|
||||
'endpoint' => env('DYNAMODB_ENDPOINT'),
|
||||
],
|
||||
|
||||
'octane' => [
|
||||
'driver' => 'octane',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
// Cache key prefix
|
||||
// Used to prevent collisions in shared cache systems.
|
||||
'prefix' => env('CACHE_PREFIX', 'bookstack_cache'),
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Cache Key Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When utilizing a RAM based store such as APC or Memcached, there might
|
||||
| be other applications utilizing the same cache. So, we'll specify a
|
||||
| value to get prefixed to all our keys so we can avoid collisions.
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
|
||||
|
||||
];
|
||||
|
@ -25,9 +25,6 @@ return [
|
||||
// file storage service, such as s3, to store publicly accessible assets.
|
||||
'url' => env('STORAGE_URL', false),
|
||||
|
||||
// Default Cloud Filesystem Disk
|
||||
'cloud' => 's3',
|
||||
|
||||
// Available filesystem disks
|
||||
// Only local, local_secure & s3 are supported by BookStack
|
||||
'disks' => [
|
||||
@ -35,6 +32,7 @@ return [
|
||||
'local' => [
|
||||
'driver' => 'local',
|
||||
'root' => public_path(),
|
||||
'visibility' => 'public',
|
||||
],
|
||||
|
||||
'local_secure_attachments' => [
|
||||
@ -45,6 +43,7 @@ return [
|
||||
'local_secure_images' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('uploads/images/'),
|
||||
'visibility' => 'public',
|
||||
],
|
||||
|
||||
's3' => [
|
||||
@ -59,4 +58,12 @@ return [
|
||||
|
||||
],
|
||||
|
||||
// Symbolic Links
|
||||
// Here you may configure the symbolic links that will be created when the
|
||||
// `storage:link` Artisan command is executed. The array keys should be
|
||||
// the locations of the links and the values should be their targets.
|
||||
'links' => [
|
||||
public_path('storage') => storage_path('app/public'),
|
||||
],
|
||||
|
||||
];
|
||||
|
@ -49,16 +49,9 @@ return [
|
||||
'days' => 7,
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => 'Laravel Log',
|
||||
'emoji' => ':boom:',
|
||||
'level' => 'critical',
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => 'debug',
|
||||
'handler' => StreamHandler::class,
|
||||
'with' => [
|
||||
'stream' => 'php://stderr',
|
||||
@ -99,6 +92,10 @@ return [
|
||||
'testing' => [
|
||||
'driver' => 'testing',
|
||||
],
|
||||
|
||||
'emergency' => [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
],
|
||||
|
||||
// Failed Login Message
|
||||
|
@ -26,6 +26,7 @@ return [
|
||||
'table' => 'jobs',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
@ -34,13 +35,16 @@ return [
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => 90,
|
||||
'block_for' => null,
|
||||
'after_commit' => false,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
// Failed queue job logging
|
||||
'failed' => [
|
||||
'database' => 'mysql', 'table' => 'failed_jobs',
|
||||
'driver' => 'database-uuids',
|
||||
'database' => 'mysql',
|
||||
'table' => 'failed_jobs',
|
||||
],
|
||||
|
||||
];
|
||||
|
@ -4,6 +4,7 @@ namespace BookStack\Entities\Models;
|
||||
|
||||
use BookStack\Uploads\Image;
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@ -21,6 +22,8 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class Book extends Entity implements HasCoverImage
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $searchFactor = 2;
|
||||
|
||||
protected $fillable = ['name', 'description'];
|
||||
|
@ -3,11 +3,14 @@
|
||||
namespace BookStack\Entities\Models;
|
||||
|
||||
use BookStack\Uploads\Image;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Bookshelf extends Entity implements HasCoverImage
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'bookshelves';
|
||||
|
||||
public $searchFactor = 3;
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace BookStack\Entities\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@ -12,6 +13,8 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class Chapter extends BookChild
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $searchFactor = 1.3;
|
||||
|
||||
protected $fillable = ['name', 'description', 'priority', 'book_id'];
|
||||
|
@ -6,6 +6,7 @@ use BookStack\Entities\Tools\PageContent;
|
||||
use BookStack\Uploads\Attachment;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Permissions;
|
||||
@ -25,6 +26,8 @@ use Permissions;
|
||||
*/
|
||||
class Page extends BookChild
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public static $listAttributes = ['name', 'id', 'slug', 'book_id', 'chapter_id', 'draft', 'template', 'text', 'created_at', 'updated_at', 'priority'];
|
||||
public static $contentAttributes = ['name', 'id', 'slug', 'book_id', 'chapter_id', 'draft', 'template', 'html', 'text', 'created_at', 'updated_at', 'priority'];
|
||||
|
||||
|
@ -28,6 +28,7 @@ class Handler extends ExceptionHandler
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
@ -11,7 +11,7 @@ class Kernel extends HttpKernel
|
||||
* These middleware are run during every request to your application.
|
||||
*/
|
||||
protected $middleware = [
|
||||
\BookStack\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\BookStack\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\BookStack\Http\Middleware\TrimStrings::class,
|
||||
\BookStack\Http\Middleware\TrustProxies::class,
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace BookStack\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class CheckForMaintenanceMode extends Middleware
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
@ -2,43 +2,29 @@
|
||||
|
||||
namespace BookStack\Http\Middleware;
|
||||
|
||||
use BookStack\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @param string|null ...$guards
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
public function handle(Request $request, Closure $next, ...$guards)
|
||||
{
|
||||
$requireConfirmation = setting('registration-confirmation');
|
||||
if ($this->auth->check() && (!$requireConfirmation || ($requireConfirmation && $this->auth->user()->email_confirmed))) {
|
||||
return redirect('/');
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
namespace BookStack\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace BookStack\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
@ -20,7 +20,7 @@ class TrustProxies extends Middleware
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers = Request::HEADER_X_FORWARDED_ALL;
|
||||
protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
|
||||
/**
|
||||
* Handle the request, Set the correct user-configured proxy information.
|
||||
|
@ -16,6 +16,7 @@ use BookStack\Util\CspService;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Contracts\Cache\Repository;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Pagination\Paginator;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
@ -60,6 +61,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
// View Composers
|
||||
View::composer('entities.breadcrumbs', BreadcrumbsViewComposer::class);
|
||||
|
||||
// Set paginator to use bootstrap-style pagination
|
||||
Paginator::useBootstrap();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,6 +30,5 @@ class EventServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,23 @@
|
||||
|
||||
namespace BookStack\Providers;
|
||||
|
||||
use Illuminate\Cache\RateLimiting\Limit;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The path to the "home" route for your application.
|
||||
*
|
||||
* This is used by Laravel authentication to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const HOME = '/';
|
||||
|
||||
/**
|
||||
* This namespace is applied to the controller routes in your routes file.
|
||||
*
|
||||
@ -14,7 +26,6 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'BookStack\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
@ -23,18 +34,12 @@ class RouteServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
$this->configureRateLimiting();
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->routes(function () {
|
||||
$this->mapWebRoutes();
|
||||
$this->mapApiRoutes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,4 +76,16 @@ class RouteServiceProvider extends ServiceProvider
|
||||
require base_path('routes/api.php');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the rate limiters for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function configureRateLimiting()
|
||||
{
|
||||
RateLimiter::for('api', function (Request $request) {
|
||||
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace BookStack\Uploads;
|
||||
use BookStack\Entities\Models\Page;
|
||||
use BookStack\Model;
|
||||
use BookStack\Traits\HasCreatorAndUpdater;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@ -18,6 +19,7 @@ use BookStack\Traits\HasCreatorAndUpdater;
|
||||
*/
|
||||
class Image extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use HasCreatorAndUpdater;
|
||||
|
||||
protected $fillable = ['name'];
|
||||
|
@ -20,11 +20,13 @@
|
||||
"barryvdh/laravel-dompdf": "^0.9.0",
|
||||
"barryvdh/laravel-snappy": "^0.4.8",
|
||||
"doctrine/dbal": "^3.1",
|
||||
"fideloper/proxy": "^4.4.1",
|
||||
"filp/whoops": "^2.14",
|
||||
"guzzlehttp/guzzle": "^7.4",
|
||||
"intervention/image": "^2.7",
|
||||
"laravel/framework": "^7.29",
|
||||
"laravel/framework": "^8.68",
|
||||
"laravel/socialite": "^5.2",
|
||||
"laravel/tinker": "^2.5",
|
||||
"laravel/ui": "^3.3",
|
||||
"league/commonmark": "^1.5",
|
||||
"league/flysystem-aws-s3-v3": "^1.0.29",
|
||||
"league/html-to-markdown": "^5.0.0",
|
||||
@ -32,33 +34,28 @@
|
||||
"onelogin/php-saml": "^4.0",
|
||||
"phpseclib/phpseclib": "~3.0",
|
||||
"pragmarx/google2fa": "^8.0",
|
||||
"predis/predis": "^1.1.6",
|
||||
"predis/predis": "^1.1",
|
||||
"socialiteproviders/discord": "^4.1",
|
||||
"socialiteproviders/gitlab": "^4.1",
|
||||
"socialiteproviders/microsoft-azure": "^4.1",
|
||||
"socialiteproviders/okta": "^4.1",
|
||||
"socialiteproviders/slack": "^4.1",
|
||||
"socialiteproviders/twitch": "^5.3",
|
||||
"ssddanbrown/htmldiff": "^1.0.1",
|
||||
"laravel/ui": "^2.5",
|
||||
"guzzlehttp/guzzle": "^7.4.0",
|
||||
"laravel/tinker": "^2.5"
|
||||
"ssddanbrown/htmldiff": "^1.0.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "^3.6",
|
||||
"fakerphp/faker": "^1.13.0",
|
||||
"mockery/mockery": "^1.3.3",
|
||||
"mockery/mockery": "^1.4.2",
|
||||
"phpunit/phpunit": "^9.5.3",
|
||||
"symfony/dom-crawler": "^5.3",
|
||||
"nunomaduro/collision": "^4.3"
|
||||
"nunomaduro/collision": "^5.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
],
|
||||
"psr-4": {
|
||||
"BookStack\\": "app/"
|
||||
"BookStack\\": "app/",
|
||||
"Database\\Factories\\": "database/factories/",
|
||||
"Database\\Seeders\\": "database/seeders/"
|
||||
},
|
||||
"files": [
|
||||
"app/helpers.php"
|
||||
@ -70,6 +67,10 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"post-root-package-install": [
|
||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
|
||||
],
|
||||
@ -83,10 +84,6 @@
|
||||
"@php artisan cache:clear",
|
||||
"@php artisan view:clear"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
],
|
||||
"refresh-test-database": [
|
||||
"@php artisan migrate:refresh --database=mysql_testing",
|
||||
"@php artisan db:seed --class=DummyContentSeeder --database=mysql_testing"
|
||||
|
629
composer.lock
generated
629
composer.lock
generated
File diff suppressed because it is too large
Load Diff
32
database/factories/Actions/CommentFactory.php
Normal file
32
database/factories/Actions/CommentFactory.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Actions;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class CommentFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Actions\Comment::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$text = $this->faker->paragraph(1);
|
||||
$html = '<p>' . $text . '</p>';
|
||||
|
||||
return [
|
||||
'html' => $html,
|
||||
'text' => $text,
|
||||
'parent_id' => null,
|
||||
];
|
||||
}
|
||||
}
|
28
database/factories/Actions/TagFactory.php
Normal file
28
database/factories/Actions/TagFactory.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Actions;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class TagFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Actions\Tag::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->city,
|
||||
'value' => $this->faker->sentence(3),
|
||||
];
|
||||
}
|
||||
}
|
28
database/factories/Auth/RoleFactory.php
Normal file
28
database/factories/Auth/RoleFactory.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class RoleFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Auth\Role::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'display_name' => $this->faker->sentence(3),
|
||||
'description' => $this->faker->sentence(10),
|
||||
];
|
||||
}
|
||||
}
|
35
database/factories/Auth/UserFactory.php
Normal file
35
database/factories/Auth/UserFactory.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Auth;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Auth\User::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$name = $this->faker->name;
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'email' => $this->faker->email,
|
||||
'slug' => \Illuminate\Support\Str::slug($name . '-' . \Illuminate\Support\Str::random(5)),
|
||||
'password' => Str::random(10),
|
||||
'remember_token' => Str::random(10),
|
||||
'email_confirmed' => 1,
|
||||
];
|
||||
}
|
||||
}
|
30
database/factories/Entities/Models/BookFactory.php
Normal file
30
database/factories/Entities/Models/BookFactory.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Entities\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BookFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Entities\Models\Book::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $this->faker->paragraph,
|
||||
];
|
||||
}
|
||||
}
|
30
database/factories/Entities/Models/BookshelfFactory.php
Normal file
30
database/factories/Entities/Models/BookshelfFactory.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Entities\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class BookshelfFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Entities\Models\Bookshelf::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $this->faker->paragraph,
|
||||
];
|
||||
}
|
||||
}
|
30
database/factories/Entities/Models/ChapterFactory.php
Normal file
30
database/factories/Entities/Models/ChapterFactory.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Entities\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ChapterFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Entities\Models\Chapter::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $this->faker->paragraph,
|
||||
];
|
||||
}
|
||||
}
|
34
database/factories/Entities/Models/PageFactory.php
Normal file
34
database/factories/Entities/Models/PageFactory.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Entities\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Entities\Models\Page::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
$html = '<p>' . implode('</p>', $this->faker->paragraphs(5)) . '</p>';
|
||||
|
||||
return [
|
||||
'name' => $this->faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'html' => $html,
|
||||
'text' => strip_tags($html),
|
||||
'revision_count' => 1,
|
||||
];
|
||||
}
|
||||
}
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may define all of your model factories. Model factories give
|
||||
| you a convenient way to create models for testing and seeding your
|
||||
| database. Just tell the factory how a default model should look.
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(\BookStack\Auth\User::class, function ($faker) {
|
||||
$name = $faker->name;
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'email' => $faker->email,
|
||||
'slug' => \Illuminate\Support\Str::slug($name . '-' . \Illuminate\Support\Str::random(5)),
|
||||
'password' => Str::random(10),
|
||||
'remember_token' => Str::random(10),
|
||||
'email_confirmed' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Models\Bookshelf::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $faker->paragraph,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Models\Book::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $faker->paragraph,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Models\Chapter::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'description' => $faker->paragraph,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Entities\Models\Page::class, function ($faker) {
|
||||
$html = '<p>' . implode('</p>', $faker->paragraphs(5)) . '</p>';
|
||||
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => Str::random(10),
|
||||
'html' => $html,
|
||||
'text' => strip_tags($html),
|
||||
'revision_count' => 1,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Auth\Role::class, function ($faker) {
|
||||
return [
|
||||
'display_name' => $faker->sentence(3),
|
||||
'description' => $faker->sentence(10),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Actions\Tag::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->city,
|
||||
'value' => $faker->sentence(3),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Uploads\Image::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->slug . '.jpg',
|
||||
'url' => $faker->url,
|
||||
'path' => $faker->url,
|
||||
'type' => 'gallery',
|
||||
'uploaded_to' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
$factory->define(\BookStack\Actions\Comment::class, function ($faker) {
|
||||
$text = $faker->paragraph(1);
|
||||
$html = '<p>' . $text . '</p>';
|
||||
|
||||
return [
|
||||
'html' => $html,
|
||||
'text' => $text,
|
||||
'parent_id' => null,
|
||||
];
|
||||
});
|
31
database/factories/Uploads/ImageFactory.php
Normal file
31
database/factories/Uploads/ImageFactory.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories\Uploads;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ImageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The name of the factory's corresponding model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $model = \BookStack\Uploads\Image::class;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'name' => $this->faker->slug . '.jpg',
|
||||
'url' => $this->faker->url,
|
||||
'path' => $this->faker->url,
|
||||
'type' => 'gallery',
|
||||
'uploaded_to' => 0,
|
||||
];
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use BookStack\Api\ApiToken;
|
||||
use BookStack\Auth\Permissions\PermissionService;
|
||||
use BookStack\Auth\Permissions\RolePermission;
|
||||
@ -10,6 +12,7 @@ use BookStack\Entities\Models\Chapter;
|
||||
use BookStack\Entities\Models\Page;
|
||||
use BookStack\Entities\Tools\SearchIndex;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DummyContentSeeder extends Seeder
|
||||
@ -22,36 +25,36 @@ class DummyContentSeeder extends Seeder
|
||||
public function run()
|
||||
{
|
||||
// Create an editor user
|
||||
$editorUser = factory(User::class)->create();
|
||||
$editorUser = User::factory()->create();
|
||||
$editorRole = Role::getRole('editor');
|
||||
$editorUser->attachRole($editorRole);
|
||||
|
||||
// Create a viewer user
|
||||
$viewerUser = factory(User::class)->create();
|
||||
$viewerUser = User::factory()->create();
|
||||
$role = Role::getRole('viewer');
|
||||
$viewerUser->attachRole($role);
|
||||
|
||||
$byData = ['created_by' => $editorUser->id, 'updated_by' => $editorUser->id, 'owned_by' => $editorUser->id];
|
||||
|
||||
factory(\BookStack\Entities\Models\Book::class, 5)->create($byData)
|
||||
\BookStack\Entities\Models\Book::factory()->count(5)->create($byData)
|
||||
->each(function ($book) use ($byData) {
|
||||
$chapters = factory(Chapter::class, 3)->create($byData)
|
||||
$chapters = Chapter::factory()->count(3)->create($byData)
|
||||
->each(function ($chapter) use ($book, $byData) {
|
||||
$pages = factory(Page::class, 3)->make(array_merge($byData, ['book_id' => $book->id]));
|
||||
$pages = Page::factory()->count(3)->make(array_merge($byData, ['book_id' => $book->id]));
|
||||
$chapter->pages()->saveMany($pages);
|
||||
});
|
||||
$pages = factory(Page::class, 3)->make($byData);
|
||||
$pages = Page::factory()->count(3)->make($byData);
|
||||
$book->chapters()->saveMany($chapters);
|
||||
$book->pages()->saveMany($pages);
|
||||
});
|
||||
|
||||
$largeBook = factory(\BookStack\Entities\Models\Book::class)->create(array_merge($byData, ['name' => 'Large book' . Str::random(10)]));
|
||||
$pages = factory(Page::class, 200)->make($byData);
|
||||
$chapters = factory(Chapter::class, 50)->make($byData);
|
||||
$largeBook = \BookStack\Entities\Models\Book::factory()->create(array_merge($byData, ['name' => 'Large book' . Str::random(10)]));
|
||||
$pages = Page::factory()->count(200)->make($byData);
|
||||
$chapters = Chapter::factory()->count(50)->make($byData);
|
||||
$largeBook->pages()->saveMany($pages);
|
||||
$largeBook->chapters()->saveMany($chapters);
|
||||
|
||||
$shelves = factory(Bookshelf::class, 10)->create($byData);
|
||||
$shelves = Bookshelf::factory()->count(10)->create($byData);
|
||||
$largeBook->shelves()->attach($shelves->pluck('id'));
|
||||
|
||||
// Assign API permission to editor role and create an API key
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use BookStack\Auth\Permissions\PermissionService;
|
||||
use BookStack\Auth\Role;
|
||||
use BookStack\Auth\User;
|
||||
@ -19,13 +21,13 @@ class LargeContentSeeder extends Seeder
|
||||
public function run()
|
||||
{
|
||||
// Create an editor user
|
||||
$editorUser = factory(User::class)->create();
|
||||
$editorUser = User::factory()->create();
|
||||
$editorRole = Role::getRole('editor');
|
||||
$editorUser->attachRole($editorRole);
|
||||
|
||||
$largeBook = factory(\BookStack\Entities\Models\Book::class)->create(['name' => 'Large book' . Str::random(10), 'created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$pages = factory(Page::class, 200)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$chapters = factory(Chapter::class, 50)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$largeBook = \BookStack\Entities\Models\Book::factory()->create(['name' => 'Large book' . Str::random(10), 'created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$pages = Page::factory()->count(200)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$chapters = Chapter::factory()->count(50)->make(['created_by' => $editorUser->id, 'updated_by' => $editorUser->id]);
|
||||
$largeBook->pages()->saveMany($pages);
|
||||
$largeBook->chapters()->saveMany($chapters);
|
||||
app(PermissionService::class)->buildJointPermissions();
|
@ -1,21 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Laravel - A PHP Framework For Web Artisans.
|
||||
*
|
||||
* @author Taylor Otwell <taylor@laravel.com>
|
||||
*/
|
||||
use Illuminate\Contracts\Http\Kernel;
|
||||
use BookStack\Http\Request;
|
||||
|
||||
define('LARAVEL_START', microtime(true));
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Check If The Application Is Under Maintenance
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If the application is in maintenance / demo mode via the "down" command
|
||||
| we will load this file so that any pre-rendered content can be shown
|
||||
| instead of starting the framework, which could cause an exception.
|
||||
|
|
||||
*/
|
||||
|
||||
if (file_exists(__DIR__ . '/../storage/framework/maintenance.php')) {
|
||||
require __DIR__ . '/../storage/framework/maintenance.php';
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Composer provides a convenient, automatically generated class loader for
|
||||
| our application. We just need to utilize it! We'll simply require it
|
||||
| into the script here so that we don't have to worry about manual
|
||||
| loading any of our classes later on. It feels great to relax.
|
||||
| this application. We just need to utilize it! We'll simply require it
|
||||
| into the script here so we don't need to manually load our classes.
|
||||
|
|
||||
*/
|
||||
|
||||
@ -23,37 +35,22 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Turn On The Lights
|
||||
| Run The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| We need to illuminate PHP development, so let us turn on the lights.
|
||||
| This bootstraps the framework and gets it ready for use, then it
|
||||
| will load up this application so that we can run it and send
|
||||
| the responses back to the browser and delight our users.
|
||||
| Once we have the application, we can handle the incoming request using
|
||||
| the application's HTTP kernel. Then, we will send the response back
|
||||
| to this client's browser, allowing them to enjoy our application.
|
||||
|
|
||||
*/
|
||||
|
||||
$app = require_once __DIR__ . '/../bootstrap/app.php';
|
||||
$app->alias('request', \BookStack\Http\Request::class);
|
||||
$app->alias('request', Request::class);
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Run The Application
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Once we have the application, we can handle the incoming request
|
||||
| through the kernel, and send the associated response back to
|
||||
| the client's browser allowing them to enjoy the creative
|
||||
| and wonderful application we have prepared for them.
|
||||
|
|
||||
*/
|
||||
$kernel = $app->make(Kernel::class);
|
||||
|
||||
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
|
||||
|
||||
$response = $kernel->handle(
|
||||
$request = \BookStack\Http\Request::capture()
|
||||
);
|
||||
|
||||
$response->send();
|
||||
$response = tap($kernel->handle(
|
||||
$request = Request::capture()
|
||||
))->send();
|
||||
|
||||
$kernel->terminate($request, $response);
|
@ -1,53 +1,64 @@
|
||||
<?php
|
||||
|
||||
use BookStack\Http\Controllers\Api\ApiDocsController;
|
||||
use BookStack\Http\Controllers\Api\AttachmentApiController;
|
||||
use BookStack\Http\Controllers\Api\BookApiController;
|
||||
use BookStack\Http\Controllers\Api\BookExportApiController;
|
||||
use BookStack\Http\Controllers\Api\BookshelfApiController;
|
||||
use BookStack\Http\Controllers\Api\ChapterApiController;
|
||||
use BookStack\Http\Controllers\Api\ChapterExportApiController;
|
||||
use BookStack\Http\Controllers\Api\PageApiController;
|
||||
use BookStack\Http\Controllers\Api\PageExportApiController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/**
|
||||
* Routes for the BookStack API.
|
||||
* Routes have a uri prefix of /api/.
|
||||
* Controllers are all within app/Http/Controllers/Api.
|
||||
*/
|
||||
Route::get('docs.json', 'ApiDocsController@json');
|
||||
Route::get('docs.json', [ApiDocsController::class, 'json']);
|
||||
|
||||
Route::get('attachments', 'AttachmentApiController@list');
|
||||
Route::post('attachments', 'AttachmentApiController@create');
|
||||
Route::get('attachments/{id}', 'AttachmentApiController@read');
|
||||
Route::put('attachments/{id}', 'AttachmentApiController@update');
|
||||
Route::delete('attachments/{id}', 'AttachmentApiController@delete');
|
||||
Route::get('attachments', [AttachmentApiController::class, 'list']);
|
||||
Route::post('attachments', [AttachmentApiController::class, 'create']);
|
||||
Route::get('attachments/{id}', [AttachmentApiController::class, 'read']);
|
||||
Route::put('attachments/{id}', [AttachmentApiController::class, 'update']);
|
||||
Route::delete('attachments/{id}', [AttachmentApiController::class, 'delete']);
|
||||
|
||||
Route::get('books', 'BookApiController@list');
|
||||
Route::post('books', 'BookApiController@create');
|
||||
Route::get('books/{id}', 'BookApiController@read');
|
||||
Route::put('books/{id}', 'BookApiController@update');
|
||||
Route::delete('books/{id}', 'BookApiController@delete');
|
||||
Route::get('books', [BookApiController::class, 'list']);
|
||||
Route::post('books', [BookApiController::class, 'create']);
|
||||
Route::get('books/{id}', [BookApiController::class, 'read']);
|
||||
Route::put('books/{id}', [BookApiController::class, 'update']);
|
||||
Route::delete('books/{id}', [BookApiController::class, 'delete']);
|
||||
|
||||
Route::get('books/{id}/export/html', 'BookExportApiController@exportHtml');
|
||||
Route::get('books/{id}/export/pdf', 'BookExportApiController@exportPdf');
|
||||
Route::get('books/{id}/export/plaintext', 'BookExportApiController@exportPlainText');
|
||||
Route::get('books/{id}/export/markdown', 'BookExportApiController@exportMarkdown');
|
||||
Route::get('books/{id}/export/html', [BookExportApiController::class, 'exportHtml']);
|
||||
Route::get('books/{id}/export/pdf', [BookExportApiController::class, 'exportPdf']);
|
||||
Route::get('books/{id}/export/plaintext', [BookExportApiController::class, 'exportPlainText']);
|
||||
Route::get('books/{id}/export/markdown', [BookExportApiController::class, 'exportMarkdown']);
|
||||
|
||||
Route::get('chapters', 'ChapterApiController@list');
|
||||
Route::post('chapters', 'ChapterApiController@create');
|
||||
Route::get('chapters/{id}', 'ChapterApiController@read');
|
||||
Route::put('chapters/{id}', 'ChapterApiController@update');
|
||||
Route::delete('chapters/{id}', 'ChapterApiController@delete');
|
||||
Route::get('chapters', [ChapterApiController::class, 'list']);
|
||||
Route::post('chapters', [ChapterApiController::class, 'create']);
|
||||
Route::get('chapters/{id}', [ChapterApiController::class, 'read']);
|
||||
Route::put('chapters/{id}', [ChapterApiController::class, 'update']);
|
||||
Route::delete('chapters/{id}', [ChapterApiController::class, 'delete']);
|
||||
|
||||
Route::get('chapters/{id}/export/html', 'ChapterExportApiController@exportHtml');
|
||||
Route::get('chapters/{id}/export/pdf', 'ChapterExportApiController@exportPdf');
|
||||
Route::get('chapters/{id}/export/plaintext', 'ChapterExportApiController@exportPlainText');
|
||||
Route::get('chapters/{id}/export/markdown', 'ChapterExportApiController@exportMarkdown');
|
||||
Route::get('chapters/{id}/export/html', [ChapterExportApiController::class, 'exportHtml']);
|
||||
Route::get('chapters/{id}/export/pdf', [ChapterExportApiController::class, 'exportPdf']);
|
||||
Route::get('chapters/{id}/export/plaintext', [ChapterExportApiController::class, 'exportPlainText']);
|
||||
Route::get('chapters/{id}/export/markdown', [ChapterExportApiController::class, 'exportMarkdown']);
|
||||
|
||||
Route::get('pages', 'PageApiController@list');
|
||||
Route::post('pages', 'PageApiController@create');
|
||||
Route::get('pages/{id}', 'PageApiController@read');
|
||||
Route::put('pages/{id}', 'PageApiController@update');
|
||||
Route::delete('pages/{id}', 'PageApiController@delete');
|
||||
Route::get('pages', [PageApiController::class, 'list']);
|
||||
Route::post('pages', [PageApiController::class, 'create']);
|
||||
Route::get('pages/{id}', [PageApiController::class, 'read']);
|
||||
Route::put('pages/{id}', [PageApiController::class, 'update']);
|
||||
Route::delete('pages/{id}', [PageApiController::class, 'delete']);
|
||||
|
||||
Route::get('pages/{id}/export/html', 'PageExportApiController@exportHtml');
|
||||
Route::get('pages/{id}/export/pdf', 'PageExportApiController@exportPdf');
|
||||
Route::get('pages/{id}/export/plaintext', 'PageExportApiController@exportPlainText');
|
||||
Route::get('pages/{id}/export/markdown', 'PageExportApiController@exportMarkDown');
|
||||
Route::get('pages/{id}/export/html', [PageExportApiController::class, 'exportHtml']);
|
||||
Route::get('pages/{id}/export/pdf', [PageExportApiController::class, 'exportPdf']);
|
||||
Route::get('pages/{id}/export/plaintext', [PageExportApiController::class, 'exportPlainText']);
|
||||
Route::get('pages/{id}/export/markdown', [PageExportApiController::class, 'exportMarkDown']);
|
||||
|
||||
Route::get('shelves', 'BookshelfApiController@list');
|
||||
Route::post('shelves', 'BookshelfApiController@create');
|
||||
Route::get('shelves/{id}', 'BookshelfApiController@read');
|
||||
Route::put('shelves/{id}', 'BookshelfApiController@update');
|
||||
Route::delete('shelves/{id}', 'BookshelfApiController@delete');
|
||||
Route::get('shelves', [BookshelfApiController::class, 'list']);
|
||||
Route::post('shelves', [BookshelfApiController::class, 'create']);
|
||||
Route::get('shelves/{id}', [BookshelfApiController::class, 'read']);
|
||||
Route::put('shelves/{id}', [BookshelfApiController::class, 'update']);
|
||||
Route::delete('shelves/{id}', [BookshelfApiController::class, 'delete']);
|
||||
|
19
routes/console.php
Normal file
19
routes/console.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Console Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is where you may define all of your Closure based console
|
||||
| commands. Each Closure is bound to a command instance allowing a
|
||||
| simple approach to interacting with each command's IO methods.
|
||||
|
|
||||
*/
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
435
routes/web.php
435
routes/web.php
@ -1,287 +1,318 @@
|
||||
<?php
|
||||
|
||||
Route::get('/status', 'StatusController@show');
|
||||
Route::get('/robots.txt', 'HomeController@robots');
|
||||
use BookStack\Http\Controllers\Api;
|
||||
use BookStack\Http\Controllers\AttachmentController;
|
||||
use BookStack\Http\Controllers\AuditLogController;
|
||||
use BookStack\Http\Controllers\Auth;
|
||||
use BookStack\Http\Controllers\BookController;
|
||||
use BookStack\Http\Controllers\BookExportController;
|
||||
use BookStack\Http\Controllers\BookshelfController;
|
||||
use BookStack\Http\Controllers\BookSortController;
|
||||
use BookStack\Http\Controllers\ChapterController;
|
||||
use BookStack\Http\Controllers\ChapterExportController;
|
||||
use BookStack\Http\Controllers\CommentController;
|
||||
use BookStack\Http\Controllers\FavouriteController;
|
||||
use BookStack\Http\Controllers\HomeController;
|
||||
use BookStack\Http\Controllers\Images;
|
||||
use BookStack\Http\Controllers\MaintenanceController;
|
||||
use BookStack\Http\Controllers\PageController;
|
||||
use BookStack\Http\Controllers\PageExportController;
|
||||
use BookStack\Http\Controllers\PageRevisionController;
|
||||
use BookStack\Http\Controllers\PageTemplateController;
|
||||
use BookStack\Http\Controllers\RecycleBinController;
|
||||
use BookStack\Http\Controllers\RoleController;
|
||||
use BookStack\Http\Controllers\SearchController;
|
||||
use BookStack\Http\Controllers\SettingController;
|
||||
use BookStack\Http\Controllers\StatusController;
|
||||
use BookStack\Http\Controllers\TagController;
|
||||
use BookStack\Http\Controllers\UserApiTokenController;
|
||||
use BookStack\Http\Controllers\UserController;
|
||||
use BookStack\Http\Controllers\UserProfileController;
|
||||
use BookStack\Http\Controllers\UserSearchController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/status', [StatusController::class, 'show']);
|
||||
Route::get('/robots.txt', [HomeController::class, 'robots']);
|
||||
|
||||
// Authenticated routes...
|
||||
Route::group(['middleware' => 'auth'], function () {
|
||||
Route::middleware('auth')->group(function () {
|
||||
|
||||
// Secure images routing
|
||||
Route::get('/uploads/images/{path}', 'Images\ImageController@showImage')
|
||||
Route::get('/uploads/images/{path}', [Images\ImageController::class, 'showImage'])
|
||||
->where('path', '.*$');
|
||||
|
||||
// API docs routes
|
||||
Route::get('/api/docs', 'Api\ApiDocsController@display');
|
||||
Route::get('/api/docs', [Api\ApiDocsController::class, 'display']);
|
||||
|
||||
Route::get('/pages/recently-updated', 'PageController@showRecentlyUpdated');
|
||||
Route::get('/pages/recently-updated', [PageController::class, 'showRecentlyUpdated']);
|
||||
|
||||
// Shelves
|
||||
Route::get('/create-shelf', 'BookshelfController@create');
|
||||
Route::group(['prefix' => 'shelves'], function () {
|
||||
Route::get('/', 'BookshelfController@index');
|
||||
Route::post('/', 'BookshelfController@store');
|
||||
Route::get('/{slug}/edit', 'BookshelfController@edit');
|
||||
Route::get('/{slug}/delete', 'BookshelfController@showDelete');
|
||||
Route::get('/{slug}', 'BookshelfController@show');
|
||||
Route::put('/{slug}', 'BookshelfController@update');
|
||||
Route::delete('/{slug}', 'BookshelfController@destroy');
|
||||
Route::get('/{slug}/permissions', 'BookshelfController@showPermissions');
|
||||
Route::put('/{slug}/permissions', 'BookshelfController@permissions');
|
||||
Route::post('/{slug}/copy-permissions', 'BookshelfController@copyPermissions');
|
||||
Route::get('/create-shelf', [BookshelfController::class, 'create']);
|
||||
Route::prefix('shelves')->group(function () {
|
||||
Route::get('/', [BookshelfController::class, 'index']);
|
||||
Route::post('/', [BookshelfController::class, 'store']);
|
||||
Route::get('/{slug}/edit', [BookshelfController::class, 'edit']);
|
||||
Route::get('/{slug}/delete', [BookshelfController::class, 'showDelete']);
|
||||
Route::get('/{slug}', [BookshelfController::class, 'show']);
|
||||
Route::put('/{slug}', [BookshelfController::class, 'update']);
|
||||
Route::delete('/{slug}', [BookshelfController::class, 'destroy']);
|
||||
Route::get('/{slug}/permissions', [BookshelfController::class, 'showPermissions']);
|
||||
Route::put('/{slug}/permissions', [BookshelfController::class, 'permissions']);
|
||||
Route::post('/{slug}/copy-permissions', [BookshelfController::class, 'copyPermissions']);
|
||||
|
||||
Route::get('/{shelfSlug}/create-book', 'BookController@create');
|
||||
Route::post('/{shelfSlug}/create-book', 'BookController@store');
|
||||
Route::get('/{shelfSlug}/create-book', [BookController::class, 'create']);
|
||||
Route::post('/{shelfSlug}/create-book', [BookController::class, 'store']);
|
||||
});
|
||||
|
||||
Route::get('/create-book', 'BookController@create');
|
||||
Route::group(['prefix' => 'books'], function () {
|
||||
Route::get('/create-book', [BookController::class, 'create']);
|
||||
Route::prefix('books')->group(function () {
|
||||
|
||||
// Books
|
||||
Route::get('/', 'BookController@index');
|
||||
Route::post('/', 'BookController@store');
|
||||
Route::get('/{slug}/edit', 'BookController@edit');
|
||||
Route::put('/{slug}', 'BookController@update');
|
||||
Route::delete('/{id}', 'BookController@destroy');
|
||||
Route::get('/{slug}/sort-item', 'BookSortController@showItem');
|
||||
Route::get('/{slug}', 'BookController@show');
|
||||
Route::get('/{bookSlug}/permissions', 'BookController@showPermissions');
|
||||
Route::put('/{bookSlug}/permissions', 'BookController@permissions');
|
||||
Route::get('/{slug}/delete', 'BookController@showDelete');
|
||||
Route::get('/{bookSlug}/sort', 'BookSortController@show');
|
||||
Route::put('/{bookSlug}/sort', 'BookSortController@update');
|
||||
Route::get('/{bookSlug}/export/html', 'BookExportController@html');
|
||||
Route::get('/{bookSlug}/export/pdf', 'BookExportController@pdf');
|
||||
Route::get('/{bookSlug}/export/markdown', 'BookExportController@markdown');
|
||||
Route::get('/{bookSlug}/export/zip', 'BookExportController@zip');
|
||||
Route::get('/{bookSlug}/export/plaintext', 'BookExportController@plainText');
|
||||
Route::get('/', [BookController::class, 'index']);
|
||||
Route::post('/', [BookController::class, 'store']);
|
||||
Route::get('/{slug}/edit', [BookController::class, 'edit']);
|
||||
Route::put('/{slug}', [BookController::class, 'update']);
|
||||
Route::delete('/{id}', [BookController::class, 'destroy']);
|
||||
Route::get('/{slug}/sort-item', [BookSortController::class, 'showItem']);
|
||||
Route::get('/{slug}', [BookController::class, 'show']);
|
||||
Route::get('/{bookSlug}/permissions', [BookController::class, 'showPermissions']);
|
||||
Route::put('/{bookSlug}/permissions', [BookController::class, 'permissions']);
|
||||
Route::get('/{slug}/delete', [BookController::class, 'showDelete']);
|
||||
Route::get('/{bookSlug}/sort', [BookSortController::class, 'show']);
|
||||
Route::put('/{bookSlug}/sort', [BookSortController::class, 'update']);
|
||||
Route::get('/{bookSlug}/export/html', [BookExportController::class, 'html']);
|
||||
Route::get('/{bookSlug}/export/pdf', [BookExportController::class, 'pdf']);
|
||||
Route::get('/{bookSlug}/export/markdown', [BookExportController::class, 'markdown']);
|
||||
Route::get('/{bookSlug}/export/zip', [BookExportController::class, 'zip']);
|
||||
Route::get('/{bookSlug}/export/plaintext', [BookExportController::class, 'plainText']);
|
||||
|
||||
// Pages
|
||||
Route::get('/{bookSlug}/create-page', 'PageController@create');
|
||||
Route::post('/{bookSlug}/create-guest-page', 'PageController@createAsGuest');
|
||||
Route::get('/{bookSlug}/draft/{pageId}', 'PageController@editDraft');
|
||||
Route::post('/{bookSlug}/draft/{pageId}', 'PageController@store');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}', 'PageController@show');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/export/pdf', 'PageExportController@pdf');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/export/html', 'PageExportController@html');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/export/markdown', 'PageExportController@markdown');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/export/plaintext', 'PageExportController@plainText');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/edit', 'PageController@edit');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/move', 'PageController@showMove');
|
||||
Route::put('/{bookSlug}/page/{pageSlug}/move', 'PageController@move');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/copy', 'PageController@showCopy');
|
||||
Route::post('/{bookSlug}/page/{pageSlug}/copy', 'PageController@copy');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/delete', 'PageController@showDelete');
|
||||
Route::get('/{bookSlug}/draft/{pageId}/delete', 'PageController@showDeleteDraft');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/permissions', 'PageController@showPermissions');
|
||||
Route::put('/{bookSlug}/page/{pageSlug}/permissions', 'PageController@permissions');
|
||||
Route::put('/{bookSlug}/page/{pageSlug}', 'PageController@update');
|
||||
Route::delete('/{bookSlug}/page/{pageSlug}', 'PageController@destroy');
|
||||
Route::delete('/{bookSlug}/draft/{pageId}', 'PageController@destroyDraft');
|
||||
Route::get('/{bookSlug}/create-page', [PageController::class, 'create']);
|
||||
Route::post('/{bookSlug}/create-guest-page', [PageController::class, 'createAsGuest']);
|
||||
Route::get('/{bookSlug}/draft/{pageId}', [PageController::class, 'editDraft']);
|
||||
Route::post('/{bookSlug}/draft/{pageId}', [PageController::class, 'store']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}', [PageController::class, 'show']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/export/pdf', [PageExportController::class, 'pdf']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/export/html', [PageExportController::class, 'html']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/export/markdown', [PageExportController::class, 'markdown']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/export/plaintext', [PageExportController::class, 'plainText']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/edit', [PageController::class, 'edit']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/move', [PageController::class, 'showMove']);
|
||||
Route::put('/{bookSlug}/page/{pageSlug}/move', [PageController::class, 'move']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/copy', [PageController::class, 'showCopy']);
|
||||
Route::post('/{bookSlug}/page/{pageSlug}/copy', [PageController::class, 'copy']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/delete', [PageController::class, 'showDelete']);
|
||||
Route::get('/{bookSlug}/draft/{pageId}/delete', [PageController::class, 'showDeleteDraft']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/permissions', [PageController::class, 'showPermissions']);
|
||||
Route::put('/{bookSlug}/page/{pageSlug}/permissions', [PageController::class, 'permissions']);
|
||||
Route::put('/{bookSlug}/page/{pageSlug}', [PageController::class, 'update']);
|
||||
Route::delete('/{bookSlug}/page/{pageSlug}', [PageController::class, 'destroy']);
|
||||
Route::delete('/{bookSlug}/draft/{pageId}', [PageController::class, 'destroyDraft']);
|
||||
|
||||
// Revisions
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/revisions', 'PageRevisionController@index');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/revisions/{revId}', 'PageRevisionController@show');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/revisions/{revId}/changes', 'PageRevisionController@changes');
|
||||
Route::put('/{bookSlug}/page/{pageSlug}/revisions/{revId}/restore', 'PageRevisionController@restore');
|
||||
Route::delete('/{bookSlug}/page/{pageSlug}/revisions/{revId}/delete', 'PageRevisionController@destroy');
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/revisions', [PageRevisionController::class, 'index']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/revisions/{revId}', [PageRevisionController::class, 'show']);
|
||||
Route::get('/{bookSlug}/page/{pageSlug}/revisions/{revId}/changes', [PageRevisionController::class, 'changes']);
|
||||
Route::put('/{bookSlug}/page/{pageSlug}/revisions/{revId}/restore', [PageRevisionController::class, 'restore']);
|
||||
Route::delete('/{bookSlug}/page/{pageSlug}/revisions/{revId}/delete', [PageRevisionController::class, 'destroy']);
|
||||
|
||||
// Chapters
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/create-page', 'PageController@create');
|
||||
Route::post('/{bookSlug}/chapter/{chapterSlug}/create-guest-page', 'PageController@createAsGuest');
|
||||
Route::get('/{bookSlug}/create-chapter', 'ChapterController@create');
|
||||
Route::post('/{bookSlug}/create-chapter', 'ChapterController@store');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}', 'ChapterController@show');
|
||||
Route::put('/{bookSlug}/chapter/{chapterSlug}', 'ChapterController@update');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/move', 'ChapterController@showMove');
|
||||
Route::put('/{bookSlug}/chapter/{chapterSlug}/move', 'ChapterController@move');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/edit', 'ChapterController@edit');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/permissions', 'ChapterController@showPermissions');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/export/pdf', 'ChapterExportController@pdf');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/export/html', 'ChapterExportController@html');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/export/markdown', 'ChapterExportController@markdown');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/export/plaintext', 'ChapterExportController@plainText');
|
||||
Route::put('/{bookSlug}/chapter/{chapterSlug}/permissions', 'ChapterController@permissions');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/delete', 'ChapterController@showDelete');
|
||||
Route::delete('/{bookSlug}/chapter/{chapterSlug}', 'ChapterController@destroy');
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/create-page', [PageController::class, 'create']);
|
||||
Route::post('/{bookSlug}/chapter/{chapterSlug}/create-guest-page', [PageController::class, 'createAsGuest']);
|
||||
Route::get('/{bookSlug}/create-chapter', [ChapterController::class, 'create']);
|
||||
Route::post('/{bookSlug}/create-chapter', [ChapterController::class, 'store']);
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}', [ChapterController::class, 'show']);
|
||||
Route::put('/{bookSlug}/chapter/{chapterSlug}', [ChapterController::class, 'update']);
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/move', [ChapterController::class, 'showMove']);
|
||||
Route::put('/{bookSlug}/chapter/{chapterSlug}/move', [ChapterController::class, 'move']);
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/edit', [ChapterController::class, 'edit']);
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/permissions', [ChapterController::class, 'showPermissions']);
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/export/pdf', [ChapterExportController::class, 'pdf']);
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/export/html', [ChapterExportController::class, 'html']);
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/export/markdown', [ChapterExportController::class, 'markdown']);
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/export/plaintext', [ChapterExportController::class, 'plainText']);
|
||||
Route::put('/{bookSlug}/chapter/{chapterSlug}/permissions', [ChapterController::class, 'permissions']);
|
||||
Route::get('/{bookSlug}/chapter/{chapterSlug}/delete', [ChapterController::class, 'showDelete']);
|
||||
Route::delete('/{bookSlug}/chapter/{chapterSlug}', [ChapterController::class, 'destroy']);
|
||||
});
|
||||
|
||||
// User Profile routes
|
||||
Route::get('/user/{slug}', 'UserProfileController@show');
|
||||
Route::get('/user/{slug}', [UserProfileController::class, 'show']);
|
||||
|
||||
// Image routes
|
||||
Route::get('/images/gallery', 'Images\GalleryImageController@list');
|
||||
Route::post('/images/gallery', 'Images\GalleryImageController@create');
|
||||
Route::get('/images/drawio', 'Images\DrawioImageController@list');
|
||||
Route::get('/images/drawio/base64/{id}', 'Images\DrawioImageController@getAsBase64');
|
||||
Route::post('/images/drawio', 'Images\DrawioImageController@create');
|
||||
Route::get('/images/edit/{id}', 'Images\ImageController@edit');
|
||||
Route::put('/images/{id}', 'Images\ImageController@update');
|
||||
Route::delete('/images/{id}', 'Images\ImageController@destroy');
|
||||
Route::get('/images/gallery', [Images\GalleryImageController::class, 'list']);
|
||||
Route::post('/images/gallery', [Images\GalleryImageController::class, 'create']);
|
||||
Route::get('/images/drawio', [Images\DrawioImageController::class, 'list']);
|
||||
Route::get('/images/drawio/base64/{id}', [Images\DrawioImageController::class, 'getAsBase64']);
|
||||
Route::post('/images/drawio', [Images\DrawioImageController::class, 'create']);
|
||||
Route::get('/images/edit/{id}', [Images\ImageController::class, 'edit']);
|
||||
Route::put('/images/{id}', [Images\ImageController::class, 'update']);
|
||||
Route::delete('/images/{id}', [Images\ImageController::class, 'destroy']);
|
||||
|
||||
// Attachments routes
|
||||
Route::get('/attachments/{id}', 'AttachmentController@get');
|
||||
Route::post('/attachments/upload', 'AttachmentController@upload');
|
||||
Route::post('/attachments/upload/{id}', 'AttachmentController@uploadUpdate');
|
||||
Route::post('/attachments/link', 'AttachmentController@attachLink');
|
||||
Route::put('/attachments/{id}', 'AttachmentController@update');
|
||||
Route::get('/attachments/edit/{id}', 'AttachmentController@getUpdateForm');
|
||||
Route::get('/attachments/get/page/{pageId}', 'AttachmentController@listForPage');
|
||||
Route::put('/attachments/sort/page/{pageId}', 'AttachmentController@sortForPage');
|
||||
Route::delete('/attachments/{id}', 'AttachmentController@delete');
|
||||
Route::get('/attachments/{id}', [AttachmentController::class, 'get']);
|
||||
Route::post('/attachments/upload', [AttachmentController::class, 'upload']);
|
||||
Route::post('/attachments/upload/{id}', [AttachmentController::class, 'uploadUpdate']);
|
||||
Route::post('/attachments/link', [AttachmentController::class, 'attachLink']);
|
||||
Route::put('/attachments/{id}', [AttachmentController::class, 'update']);
|
||||
Route::get('/attachments/edit/{id}', [AttachmentController::class, 'getUpdateForm']);
|
||||
Route::get('/attachments/get/page/{pageId}', [AttachmentController::class, 'listForPage']);
|
||||
Route::put('/attachments/sort/page/{pageId}', [AttachmentController::class, 'sortForPage']);
|
||||
Route::delete('/attachments/{id}', [AttachmentController::class, 'delete']);
|
||||
|
||||
// AJAX routes
|
||||
Route::put('/ajax/page/{id}/save-draft', 'PageController@saveDraft');
|
||||
Route::get('/ajax/page/{id}', 'PageController@getPageAjax');
|
||||
Route::delete('/ajax/page/{id}', 'PageController@ajaxDestroy');
|
||||
Route::put('/ajax/page/{id}/save-draft', [PageController::class, 'saveDraft']);
|
||||
Route::get('/ajax/page/{id}', [PageController::class, 'getPageAjax']);
|
||||
Route::delete('/ajax/page/{id}', [PageController::class, 'ajaxDestroy']);
|
||||
|
||||
// Tag routes (AJAX)
|
||||
Route::group(['prefix' => 'ajax/tags'], function () {
|
||||
Route::get('/suggest/names', 'TagController@getNameSuggestions');
|
||||
Route::get('/suggest/values', 'TagController@getValueSuggestions');
|
||||
Route::prefix('ajax/tags')->group(function () {
|
||||
Route::get('/suggest/names', [TagController::class, 'getNameSuggestions']);
|
||||
Route::get('/suggest/values', [TagController::class, 'getValueSuggestions']);
|
||||
});
|
||||
|
||||
Route::get('/ajax/search/entities', 'SearchController@searchEntitiesAjax');
|
||||
Route::get('/ajax/search/entities', [SearchController::class, 'searchEntitiesAjax']);
|
||||
|
||||
// Comments
|
||||
Route::post('/comment/{pageId}', 'CommentController@savePageComment');
|
||||
Route::put('/comment/{id}', 'CommentController@update');
|
||||
Route::delete('/comment/{id}', 'CommentController@destroy');
|
||||
Route::post('/comment/{pageId}', [CommentController::class, 'savePageComment']);
|
||||
Route::put('/comment/{id}', [CommentController::class, 'update']);
|
||||
Route::delete('/comment/{id}', [CommentController::class, 'destroy']);
|
||||
|
||||
// Links
|
||||
Route::get('/link/{id}', 'PageController@redirectFromLink');
|
||||
Route::get('/link/{id}', [PageController::class, 'redirectFromLink']);
|
||||
|
||||
// Search
|
||||
Route::get('/search', 'SearchController@search');
|
||||
Route::get('/search/book/{bookId}', 'SearchController@searchBook');
|
||||
Route::get('/search/chapter/{bookId}', 'SearchController@searchChapter');
|
||||
Route::get('/search/entity/siblings', 'SearchController@searchSiblings');
|
||||
Route::get('/search', [SearchController::class, 'search']);
|
||||
Route::get('/search/book/{bookId}', [SearchController::class, 'searchBook']);
|
||||
Route::get('/search/chapter/{bookId}', [SearchController::class, 'searchChapter']);
|
||||
Route::get('/search/entity/siblings', [SearchController::class, 'searchSiblings']);
|
||||
|
||||
// User Search
|
||||
Route::get('/search/users/select', 'UserSearchController@forSelect');
|
||||
Route::get('/search/users/select', [UserSearchController::class, 'forSelect']);
|
||||
|
||||
// Template System
|
||||
Route::get('/templates', 'PageTemplateController@list');
|
||||
Route::get('/templates/{templateId}', 'PageTemplateController@get');
|
||||
Route::get('/templates', [PageTemplateController::class, 'list']);
|
||||
Route::get('/templates/{templateId}', [PageTemplateController::class, 'get']);
|
||||
|
||||
// Favourites
|
||||
Route::get('/favourites', 'FavouriteController@index');
|
||||
Route::post('/favourites/add', 'FavouriteController@add');
|
||||
Route::post('/favourites/remove', 'FavouriteController@remove');
|
||||
Route::get('/favourites', [FavouriteController::class, 'index']);
|
||||
Route::post('/favourites/add', [FavouriteController::class, 'add']);
|
||||
Route::post('/favourites/remove', [FavouriteController::class, 'remove']);
|
||||
|
||||
// Other Pages
|
||||
Route::get('/', 'HomeController@index');
|
||||
Route::get('/home', 'HomeController@index');
|
||||
Route::get('/custom-head-content', 'HomeController@customHeadContent');
|
||||
Route::get('/', [HomeController::class, 'index']);
|
||||
Route::get('/home', [HomeController::class, 'index']);
|
||||
Route::get('/custom-head-content', [HomeController::class, 'customHeadContent']);
|
||||
|
||||
// Settings
|
||||
Route::group(['prefix' => 'settings'], function () {
|
||||
Route::get('/', 'SettingController@index')->name('settings');
|
||||
Route::post('/', 'SettingController@update');
|
||||
Route::prefix('settings')->group(function () {
|
||||
Route::get('/', [SettingController::class, 'index'])->name('settings');
|
||||
Route::post('/', [SettingController::class, 'update']);
|
||||
|
||||
// Maintenance
|
||||
Route::get('/maintenance', 'MaintenanceController@index');
|
||||
Route::delete('/maintenance/cleanup-images', 'MaintenanceController@cleanupImages');
|
||||
Route::post('/maintenance/send-test-email', 'MaintenanceController@sendTestEmail');
|
||||
Route::get('/maintenance', [MaintenanceController::class, 'index']);
|
||||
Route::delete('/maintenance/cleanup-images', [MaintenanceController::class, 'cleanupImages']);
|
||||
Route::post('/maintenance/send-test-email', [MaintenanceController::class, 'sendTestEmail']);
|
||||
|
||||
// Recycle Bin
|
||||
Route::get('/recycle-bin', 'RecycleBinController@index');
|
||||
Route::post('/recycle-bin/empty', 'RecycleBinController@empty');
|
||||
Route::get('/recycle-bin/{id}/destroy', 'RecycleBinController@showDestroy');
|
||||
Route::delete('/recycle-bin/{id}', 'RecycleBinController@destroy');
|
||||
Route::get('/recycle-bin/{id}/restore', 'RecycleBinController@showRestore');
|
||||
Route::post('/recycle-bin/{id}/restore', 'RecycleBinController@restore');
|
||||
Route::get('/recycle-bin', [RecycleBinController::class, 'index']);
|
||||
Route::post('/recycle-bin/empty', [RecycleBinController::class, 'empty']);
|
||||
Route::get('/recycle-bin/{id}/destroy', [RecycleBinController::class, 'showDestroy']);
|
||||
Route::delete('/recycle-bin/{id}', [RecycleBinController::class, 'destroy']);
|
||||
Route::get('/recycle-bin/{id}/restore', [RecycleBinController::class, 'showRestore']);
|
||||
Route::post('/recycle-bin/{id}/restore', [RecycleBinController::class, 'restore']);
|
||||
|
||||
// Audit Log
|
||||
Route::get('/audit', 'AuditLogController@index');
|
||||
Route::get('/audit', [AuditLogController::class, 'index']);
|
||||
|
||||
// Users
|
||||
Route::get('/users', 'UserController@index');
|
||||
Route::get('/users/create', 'UserController@create');
|
||||
Route::get('/users/{id}/delete', 'UserController@delete');
|
||||
Route::patch('/users/{id}/switch-books-view', 'UserController@switchBooksView');
|
||||
Route::patch('/users/{id}/switch-shelves-view', 'UserController@switchShelvesView');
|
||||
Route::patch('/users/{id}/switch-shelf-view', 'UserController@switchShelfView');
|
||||
Route::patch('/users/{id}/change-sort/{type}', 'UserController@changeSort');
|
||||
Route::patch('/users/{id}/update-expansion-preference/{key}', 'UserController@updateExpansionPreference');
|
||||
Route::patch('/users/toggle-dark-mode', 'UserController@toggleDarkMode');
|
||||
Route::post('/users/create', 'UserController@store');
|
||||
Route::get('/users/{id}', 'UserController@edit');
|
||||
Route::put('/users/{id}', 'UserController@update');
|
||||
Route::delete('/users/{id}', 'UserController@destroy');
|
||||
Route::get('/users', [UserController::class, 'index']);
|
||||
Route::get('/users/create', [UserController::class, 'create']);
|
||||
Route::get('/users/{id}/delete', [UserController::class, 'delete']);
|
||||
Route::patch('/users/{id}/switch-books-view', [UserController::class, 'switchBooksView']);
|
||||
Route::patch('/users/{id}/switch-shelves-view', [UserController::class, 'switchShelvesView']);
|
||||
Route::patch('/users/{id}/switch-shelf-view', [UserController::class, 'switchShelfView']);
|
||||
Route::patch('/users/{id}/change-sort/{type}', [UserController::class, 'changeSort']);
|
||||
Route::patch('/users/{id}/update-expansion-preference/{key}', [UserController::class, 'updateExpansionPreference']);
|
||||
Route::patch('/users/toggle-dark-mode', [UserController::class, 'toggleDarkMode']);
|
||||
Route::post('/users/create', [UserController::class, 'store']);
|
||||
Route::get('/users/{id}', [UserController::class, 'edit']);
|
||||
Route::put('/users/{id}', [UserController::class, 'update']);
|
||||
Route::delete('/users/{id}', [UserController::class, 'destroy']);
|
||||
|
||||
// User API Tokens
|
||||
Route::get('/users/{userId}/create-api-token', 'UserApiTokenController@create');
|
||||
Route::post('/users/{userId}/create-api-token', 'UserApiTokenController@store');
|
||||
Route::get('/users/{userId}/api-tokens/{tokenId}', 'UserApiTokenController@edit');
|
||||
Route::put('/users/{userId}/api-tokens/{tokenId}', 'UserApiTokenController@update');
|
||||
Route::get('/users/{userId}/api-tokens/{tokenId}/delete', 'UserApiTokenController@delete');
|
||||
Route::delete('/users/{userId}/api-tokens/{tokenId}', 'UserApiTokenController@destroy');
|
||||
Route::get('/users/{userId}/create-api-token', [UserApiTokenController::class, 'create']);
|
||||
Route::post('/users/{userId}/create-api-token', [UserApiTokenController::class, 'store']);
|
||||
Route::get('/users/{userId}/api-tokens/{tokenId}', [UserApiTokenController::class, 'edit']);
|
||||
Route::put('/users/{userId}/api-tokens/{tokenId}', [UserApiTokenController::class, 'update']);
|
||||
Route::get('/users/{userId}/api-tokens/{tokenId}/delete', [UserApiTokenController::class, 'delete']);
|
||||
Route::delete('/users/{userId}/api-tokens/{tokenId}', [UserApiTokenController::class, 'destroy']);
|
||||
|
||||
// Roles
|
||||
Route::get('/roles', 'RoleController@list');
|
||||
Route::get('/roles/new', 'RoleController@create');
|
||||
Route::post('/roles/new', 'RoleController@store');
|
||||
Route::get('/roles/delete/{id}', 'RoleController@showDelete');
|
||||
Route::delete('/roles/delete/{id}', 'RoleController@delete');
|
||||
Route::get('/roles/{id}', 'RoleController@edit');
|
||||
Route::put('/roles/{id}', 'RoleController@update');
|
||||
Route::get('/roles', [RoleController::class, 'list']);
|
||||
Route::get('/roles/new', [RoleController::class, 'create']);
|
||||
Route::post('/roles/new', [RoleController::class, 'store']);
|
||||
Route::get('/roles/delete/{id}', [RoleController::class, 'showDelete']);
|
||||
Route::delete('/roles/delete/{id}', [RoleController::class, 'delete']);
|
||||
Route::get('/roles/{id}', [RoleController::class, 'edit']);
|
||||
Route::put('/roles/{id}', [RoleController::class, 'update']);
|
||||
});
|
||||
});
|
||||
|
||||
// MFA routes
|
||||
Route::group(['middleware' => 'mfa-setup'], function () {
|
||||
Route::get('/mfa/setup', 'Auth\MfaController@setup');
|
||||
Route::get('/mfa/totp/generate', 'Auth\MfaTotpController@generate');
|
||||
Route::post('/mfa/totp/confirm', 'Auth\MfaTotpController@confirm');
|
||||
Route::get('/mfa/backup_codes/generate', 'Auth\MfaBackupCodesController@generate');
|
||||
Route::post('/mfa/backup_codes/confirm', 'Auth\MfaBackupCodesController@confirm');
|
||||
Route::middleware('mfa-setup')->group(function () {
|
||||
Route::get('/mfa/setup', [Auth\MfaController::class, 'setup']);
|
||||
Route::get('/mfa/totp/generate', [Auth\MfaTotpController::class, 'generate']);
|
||||
Route::post('/mfa/totp/confirm', [Auth\MfaTotpController::class, 'confirm']);
|
||||
Route::get('/mfa/backup_codes/generate', [Auth\MfaBackupCodesController::class, 'generate']);
|
||||
Route::post('/mfa/backup_codes/confirm', [Auth\MfaBackupCodesController::class, 'confirm']);
|
||||
});
|
||||
Route::group(['middleware' => 'guest'], function () {
|
||||
Route::get('/mfa/verify', 'Auth\MfaController@verify');
|
||||
Route::post('/mfa/totp/verify', 'Auth\MfaTotpController@verify');
|
||||
Route::post('/mfa/backup_codes/verify', 'Auth\MfaBackupCodesController@verify');
|
||||
Route::middleware('guest')->group(function () {
|
||||
Route::get('/mfa/verify', [Auth\MfaController::class, 'verify']);
|
||||
Route::post('/mfa/totp/verify', [Auth\MfaTotpController::class, 'verify']);
|
||||
Route::post('/mfa/backup_codes/verify', [Auth\MfaBackupCodesController::class, 'verify']);
|
||||
});
|
||||
Route::delete('/mfa/{method}/remove', 'Auth\MfaController@remove')->middleware('auth');
|
||||
Route::delete('/mfa/{method}/remove', [Auth\MfaController::class, 'remove'])->middleware('auth');
|
||||
|
||||
// Social auth routes
|
||||
Route::get('/login/service/{socialDriver}', 'Auth\SocialController@login');
|
||||
Route::get('/login/service/{socialDriver}/callback', 'Auth\SocialController@callback');
|
||||
Route::post('/login/service/{socialDriver}/detach', 'Auth\SocialController@detach')->middleware('auth');
|
||||
Route::get('/register/service/{socialDriver}', 'Auth\SocialController@register');
|
||||
Route::get('/login/service/{socialDriver}', [Auth\SocialController::class, 'login']);
|
||||
Route::get('/login/service/{socialDriver}/callback', [Auth\SocialController::class, 'callback']);
|
||||
Route::post('/login/service/{socialDriver}/detach', [Auth\SocialController::class, 'detach'])->middleware('auth');
|
||||
Route::get('/register/service/{socialDriver}', [Auth\SocialController::class, 'register']);
|
||||
|
||||
// Login/Logout routes
|
||||
Route::get('/login', 'Auth\LoginController@getLogin');
|
||||
Route::post('/login', 'Auth\LoginController@login');
|
||||
Route::get('/logout', 'Auth\LoginController@logout');
|
||||
Route::get('/register', 'Auth\RegisterController@getRegister');
|
||||
Route::get('/register/confirm', 'Auth\ConfirmEmailController@show');
|
||||
Route::get('/register/confirm/awaiting', 'Auth\ConfirmEmailController@showAwaiting');
|
||||
Route::post('/register/confirm/resend', 'Auth\ConfirmEmailController@resend');
|
||||
Route::get('/register/confirm/{token}', 'Auth\ConfirmEmailController@confirm');
|
||||
Route::post('/register', 'Auth\RegisterController@postRegister');
|
||||
Route::get('/login', [Auth\LoginController::class, 'getLogin']);
|
||||
Route::post('/login', [Auth\LoginController::class, 'login']);
|
||||
Route::get('/logout', [Auth\LoginController::class, 'logout']);
|
||||
Route::get('/register', [Auth\RegisterController::class, 'getRegister']);
|
||||
Route::get('/register/confirm', [Auth\ConfirmEmailController::class, 'show']);
|
||||
Route::get('/register/confirm/awaiting', [Auth\ConfirmEmailController::class, 'showAwaiting']);
|
||||
Route::post('/register/confirm/resend', [Auth\ConfirmEmailController::class, 'resend']);
|
||||
Route::get('/register/confirm/{token}', [Auth\ConfirmEmailController::class, 'confirm']);
|
||||
Route::post('/register', [Auth\RegisterController::class, 'postRegister']);
|
||||
|
||||
// SAML routes
|
||||
Route::post('/saml2/login', 'Auth\Saml2Controller@login');
|
||||
Route::get('/saml2/logout', 'Auth\Saml2Controller@logout');
|
||||
Route::get('/saml2/metadata', 'Auth\Saml2Controller@metadata');
|
||||
Route::get('/saml2/sls', 'Auth\Saml2Controller@sls');
|
||||
Route::post('/saml2/acs', 'Auth\Saml2Controller@startAcs');
|
||||
Route::get('/saml2/acs', 'Auth\Saml2Controller@processAcs');
|
||||
Route::post('/saml2/login', [Auth\Saml2Controller::class, 'login']);
|
||||
Route::get('/saml2/logout', [Auth\Saml2Controller::class, 'logout']);
|
||||
Route::get('/saml2/metadata', [Auth\Saml2Controller::class, 'metadata']);
|
||||
Route::get('/saml2/sls', [Auth\Saml2Controller::class, 'sls']);
|
||||
Route::post('/saml2/acs', [Auth\Saml2Controller::class, 'startAcs']);
|
||||
Route::get('/saml2/acs', [Auth\Saml2Controller::class, 'processAcs']);
|
||||
|
||||
// OIDC routes
|
||||
Route::post('/oidc/login', 'Auth\OidcController@login');
|
||||
Route::get('/oidc/callback', 'Auth\OidcController@callback');
|
||||
Route::post('/oidc/login', [Auth\OidcController::class, 'login']);
|
||||
Route::get('/oidc/callback', [Auth\OidcController::class, 'callback']);
|
||||
|
||||
// User invitation routes
|
||||
Route::get('/register/invite/{token}', 'Auth\UserInviteController@showSetPassword');
|
||||
Route::post('/register/invite/{token}', 'Auth\UserInviteController@setPassword');
|
||||
Route::get('/register/invite/{token}', [Auth\UserInviteController::class, 'showSetPassword']);
|
||||
Route::post('/register/invite/{token}', [Auth\UserInviteController::class, 'setPassword']);
|
||||
|
||||
// Password reset link request routes...
|
||||
Route::get('/password/email', 'Auth\ForgotPasswordController@showLinkRequestForm');
|
||||
Route::post('/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
|
||||
Route::get('/password/email', [Auth\ForgotPasswordController::class, 'showLinkRequestForm']);
|
||||
Route::post('/password/email', [Auth\ForgotPasswordController::class, 'sendResetLinkEmail']);
|
||||
|
||||
// Password reset routes...
|
||||
Route::get('/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
|
||||
Route::post('/password/reset', 'Auth\ResetPasswordController@reset');
|
||||
Route::get('/password/reset/{token}', [Auth\ResetPasswordController::class, 'showResetForm']);
|
||||
Route::post('/password/reset', [Auth\ResetPasswordController::class, 'reset']);
|
||||
|
||||
Route::fallback('HomeController@notFound')->name('fallback');
|
||||
Route::fallback([HomeController::class, 'notFound'])->name('fallback');
|
||||
|
12
storage/framework/.gitignore
vendored
12
storage/framework/.gitignore
vendored
@ -1,7 +1,9 @@
|
||||
config.php
|
||||
routes.php
|
||||
compiled.php
|
||||
services.json
|
||||
events.scanned.php
|
||||
routes.scanned.php
|
||||
config.php
|
||||
down
|
||||
events.scanned.php
|
||||
maintenance.php
|
||||
routes.php
|
||||
routes.scanned.php
|
||||
schedule-*
|
||||
services.json
|
||||
|
@ -17,7 +17,7 @@ class AuditLogTest extends TestCase
|
||||
/** @var ActivityService */
|
||||
protected $activityService;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->activityService = app(ActivityService::class);
|
||||
|
@ -44,7 +44,7 @@ class AuthTest extends TestCase
|
||||
{
|
||||
// Set settings and get user instance
|
||||
$this->setSettings(['registration-enabled' => 'true']);
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
|
||||
// Test form and ensure user is created
|
||||
$this->get('/register')
|
||||
@ -102,7 +102,7 @@ class AuthTest extends TestCase
|
||||
|
||||
// Set settings and get user instance
|
||||
$this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'true']);
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
|
||||
// Go through registration process
|
||||
$resp = $this->post('/register', $user->only('name', 'email', 'password'));
|
||||
@ -140,7 +140,7 @@ class AuthTest extends TestCase
|
||||
public function test_restricted_registration()
|
||||
{
|
||||
$this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'true', 'registration-restrict' => 'example.com']);
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
|
||||
// Go through registration process
|
||||
$this->post('/register', $user->only('name', 'email', 'password'))
|
||||
@ -166,7 +166,7 @@ class AuthTest extends TestCase
|
||||
public function test_restricted_registration_with_confirmation_disabled()
|
||||
{
|
||||
$this->setSettings(['registration-enabled' => 'true', 'registration-confirmation' => 'false', 'registration-restrict' => 'example.com']);
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
|
||||
// Go through registration process
|
||||
$this->post('/register', $user->only('name', 'email', 'password'))
|
||||
|
@ -20,7 +20,7 @@ class LdapTest extends TestCase
|
||||
protected $mockUser;
|
||||
protected $resourceId = 'resource-test';
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
if (!defined('LDAP_OPT_REFERRALS')) {
|
||||
@ -42,7 +42,7 @@ class LdapTest extends TestCase
|
||||
]);
|
||||
$this->mockLdap = \Mockery::mock(Ldap::class);
|
||||
$this->app[Ldap::class] = $this->mockLdap;
|
||||
$this->mockUser = factory(User::class)->make();
|
||||
$this->mockUser = User::factory()->make();
|
||||
}
|
||||
|
||||
protected function runFailedAuthLogin()
|
||||
@ -264,9 +264,9 @@ class LdapTest extends TestCase
|
||||
|
||||
public function test_login_maps_roles_and_retains_existing_roles()
|
||||
{
|
||||
$roleToReceive = factory(Role::class)->create(['display_name' => 'LdapTester']);
|
||||
$roleToReceive2 = factory(Role::class)->create(['display_name' => 'LdapTester Second']);
|
||||
$existingRole = factory(Role::class)->create(['display_name' => 'ldaptester-existing']);
|
||||
$roleToReceive = Role::factory()->create(['display_name' => 'LdapTester']);
|
||||
$roleToReceive2 = Role::factory()->create(['display_name' => 'LdapTester Second']);
|
||||
$existingRole = Role::factory()->create(['display_name' => 'ldaptester-existing']);
|
||||
$this->mockUser->forceFill(['external_auth_id' => $this->mockUser->name])->save();
|
||||
$this->mockUser->attachRole($existingRole);
|
||||
|
||||
@ -310,8 +310,8 @@ class LdapTest extends TestCase
|
||||
|
||||
public function test_login_maps_roles_and_removes_old_roles_if_set()
|
||||
{
|
||||
$roleToReceive = factory(Role::class)->create(['display_name' => 'LdapTester']);
|
||||
$existingRole = factory(Role::class)->create(['display_name' => 'ldaptester-existing']);
|
||||
$roleToReceive = Role::factory()->create(['display_name' => 'LdapTester']);
|
||||
$existingRole = Role::factory()->create(['display_name' => 'ldaptester-existing']);
|
||||
$this->mockUser->forceFill(['external_auth_id' => $this->mockUser->name])->save();
|
||||
$this->mockUser->attachRole($existingRole);
|
||||
|
||||
@ -350,15 +350,15 @@ class LdapTest extends TestCase
|
||||
|
||||
public function test_external_auth_id_visible_in_roles_page_when_ldap_active()
|
||||
{
|
||||
$role = factory(Role::class)->create(['display_name' => 'ldaptester', 'external_auth_id' => 'ex-auth-a, test-second-param']);
|
||||
$role = Role::factory()->create(['display_name' => 'ldaptester', 'external_auth_id' => 'ex-auth-a, test-second-param']);
|
||||
$this->asAdmin()->get('/settings/roles/' . $role->id)
|
||||
->assertSee('ex-auth-a');
|
||||
}
|
||||
|
||||
public function test_login_maps_roles_using_external_auth_ids_if_set()
|
||||
{
|
||||
$roleToReceive = factory(Role::class)->create(['display_name' => 'ldaptester', 'external_auth_id' => 'test-second-param, ex-auth-a']);
|
||||
$roleToNotReceive = factory(Role::class)->create(['display_name' => 'ex-auth-a', 'external_auth_id' => 'test-second-param']);
|
||||
$roleToReceive = Role::factory()->create(['display_name' => 'ldaptester', 'external_auth_id' => 'test-second-param, ex-auth-a']);
|
||||
$roleToNotReceive = Role::factory()->create(['display_name' => 'ex-auth-a', 'external_auth_id' => 'test-second-param']);
|
||||
|
||||
app('config')->set([
|
||||
'services.ldap.user_to_groups' => true,
|
||||
@ -395,8 +395,8 @@ class LdapTest extends TestCase
|
||||
|
||||
public function test_login_group_mapping_does_not_conflict_with_default_role()
|
||||
{
|
||||
$roleToReceive = factory(Role::class)->create(['display_name' => 'LdapTester']);
|
||||
$roleToReceive2 = factory(Role::class)->create(['display_name' => 'LdapTester Second']);
|
||||
$roleToReceive = Role::factory()->create(['display_name' => 'LdapTester']);
|
||||
$roleToReceive2 = Role::factory()->create(['display_name' => 'LdapTester Second']);
|
||||
$this->mockUser->forceFill(['external_auth_id' => $this->mockUser->name])->save();
|
||||
|
||||
setting()->put('registration-role', $roleToReceive->id);
|
||||
@ -641,8 +641,8 @@ class LdapTest extends TestCase
|
||||
|
||||
public function test_login_with_email_confirmation_required_maps_groups_but_shows_confirmation_screen()
|
||||
{
|
||||
$roleToReceive = factory(Role::class)->create(['display_name' => 'LdapTester']);
|
||||
$user = factory(User::class)->make();
|
||||
$roleToReceive = Role::factory()->create(['display_name' => 'LdapTester']);
|
||||
$user = User::factory()->make();
|
||||
setting()->put('registration-confirmation', 'true');
|
||||
|
||||
app('config')->set([
|
||||
|
@ -16,7 +16,7 @@ class OidcTest extends TestCase
|
||||
protected $keyFilePath;
|
||||
protected $keyFile;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
// Set default config for OpenID Connect
|
||||
@ -41,7 +41,7 @@ class OidcTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
if (file_exists($this->keyFilePath)) {
|
||||
|
@ -8,7 +8,7 @@ use Tests\TestCase;
|
||||
|
||||
class Saml2Test extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
// Set default config for SAML2
|
||||
@ -119,7 +119,7 @@ class Saml2Test extends TestCase
|
||||
'saml2.remove_from_groups' => false,
|
||||
]);
|
||||
|
||||
$memberRole = factory(Role::class)->create(['external_auth_id' => 'member']);
|
||||
$memberRole = Role::factory()->create(['external_auth_id' => 'member']);
|
||||
$adminRole = Role::getSystemRole('admin');
|
||||
|
||||
$this->followingRedirects()->post('/saml2/acs', ['SAMLResponse' => $this->acsPostData]);
|
||||
@ -141,7 +141,7 @@ class Saml2Test extends TestCase
|
||||
$acsPost = $this->followingRedirects()->post('/saml2/acs', ['SAMLResponse' => $this->acsPostData]);
|
||||
$user = User::query()->where('external_auth_id', '=', 'user')->first();
|
||||
|
||||
$randomRole = factory(Role::class)->create(['external_auth_id' => 'random']);
|
||||
$randomRole = Role::factory()->create(['external_auth_id' => 'random']);
|
||||
$user->attachRole($randomRole);
|
||||
$this->assertContains($randomRole->id, $user->roles()->pluck('id'));
|
||||
|
||||
@ -295,7 +295,7 @@ class Saml2Test extends TestCase
|
||||
'saml2.remove_from_groups' => false,
|
||||
]);
|
||||
|
||||
$memberRole = factory(Role::class)->create(['external_auth_id' => 'member']);
|
||||
$memberRole = Role::factory()->create(['external_auth_id' => 'member']);
|
||||
$adminRole = Role::getSystemRole('admin');
|
||||
|
||||
$acsPost = $this->followingRedirects()->post('/saml2/acs', ['SAMLResponse' => $this->acsPostData]);
|
||||
|
@ -15,7 +15,7 @@ class SocialAuthTest extends TestCase
|
||||
{
|
||||
public function test_social_registration()
|
||||
{
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
|
||||
$this->setSettings(['registration-enabled' => 'true']);
|
||||
config(['GOOGLE_APP_ID' => 'abc123', 'GOOGLE_APP_SECRET' => '123abc', 'APP_URL' => 'http://localhost']);
|
||||
@ -118,7 +118,7 @@ class SocialAuthTest extends TestCase
|
||||
'APP_URL' => 'http://localhost',
|
||||
]);
|
||||
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
$mockSocialite = $this->mock(Factory::class);
|
||||
$mockSocialDriver = Mockery::mock(Provider::class);
|
||||
$mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
|
||||
@ -156,7 +156,7 @@ class SocialAuthTest extends TestCase
|
||||
'APP_URL' => 'http://localhost', 'services.google.auto_register' => true, 'services.google.auto_confirm' => true,
|
||||
]);
|
||||
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
$mockSocialite = $this->mock(Factory::class);
|
||||
$mockSocialDriver = Mockery::mock(Provider::class);
|
||||
$mockSocialUser = Mockery::mock(\Laravel\Socialite\Contracts\User::class);
|
||||
@ -188,7 +188,7 @@ class SocialAuthTest extends TestCase
|
||||
|
||||
public function test_social_registration_with_no_name_uses_email_as_name()
|
||||
{
|
||||
$user = factory(User::class)->make(['email' => 'nonameuser@example.com']);
|
||||
$user = User::factory()->make(['email' => 'nonameuser@example.com']);
|
||||
|
||||
$this->setSettings(['registration-enabled' => 'true']);
|
||||
config(['GITHUB_APP_ID' => 'abc123', 'GITHUB_APP_SECRET' => '123abc', 'APP_URL' => 'http://localhost']);
|
||||
|
@ -37,7 +37,7 @@ class BookShelfTest extends TestCase
|
||||
|
||||
public function test_shelves_shows_in_header_if_have_any_shelve_view_permission()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
$this->giveUserPermissions($user, ['image-create-all']);
|
||||
$shelf = Bookshelf::first();
|
||||
$userRole = $user->roles()->first();
|
||||
|
@ -9,7 +9,7 @@ class BookTest extends TestCase
|
||||
{
|
||||
public function test_create()
|
||||
{
|
||||
$book = factory(Book::class)->make([
|
||||
$book = Book::factory()->make([
|
||||
'name' => 'My First Book',
|
||||
]);
|
||||
|
||||
@ -29,7 +29,7 @@ class BookTest extends TestCase
|
||||
|
||||
public function test_create_uses_different_slugs_when_name_reused()
|
||||
{
|
||||
$book = factory(Book::class)->make([
|
||||
$book = Book::factory()->make([
|
||||
'name' => 'My First Book',
|
||||
]);
|
||||
|
||||
|
@ -13,7 +13,7 @@ class ChapterTest extends TestCase
|
||||
/** @var Book $book */
|
||||
$book = Book::query()->first();
|
||||
|
||||
$chapter = factory(Chapter::class)->make([
|
||||
$chapter = Chapter::factory()->make([
|
||||
'name' => 'My First Chapter',
|
||||
]);
|
||||
|
||||
|
@ -9,7 +9,7 @@ class CommentSettingTest extends TestCase
|
||||
{
|
||||
protected $page;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->page = Page::query()->first();
|
||||
|
@ -13,7 +13,7 @@ class CommentTest extends TestCase
|
||||
$this->asAdmin();
|
||||
$page = Page::first();
|
||||
|
||||
$comment = factory(Comment::class)->make(['parent_id' => 2]);
|
||||
$comment = Comment::factory()->make(['parent_id' => 2]);
|
||||
$resp = $this->postJson("/comment/$page->id", $comment->getAttributes());
|
||||
|
||||
$resp->assertStatus(200);
|
||||
@ -36,7 +36,7 @@ class CommentTest extends TestCase
|
||||
$this->asAdmin();
|
||||
$page = Page::first();
|
||||
|
||||
$comment = factory(Comment::class)->make();
|
||||
$comment = Comment::factory()->make();
|
||||
$this->postJson("/comment/$page->id", $comment->getAttributes());
|
||||
|
||||
$comment = $page->comments()->first();
|
||||
@ -60,7 +60,7 @@ class CommentTest extends TestCase
|
||||
$this->asAdmin();
|
||||
$page = Page::first();
|
||||
|
||||
$comment = factory(Comment::class)->make();
|
||||
$comment = Comment::factory()->make();
|
||||
$this->postJson("/comment/$page->id", $comment->getAttributes());
|
||||
|
||||
$comment = $page->comments()->first();
|
||||
|
@ -20,7 +20,7 @@ class PageDraftTest extends TestCase
|
||||
*/
|
||||
protected $pageRepo;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->page = Page::query()->first();
|
||||
|
@ -11,7 +11,7 @@ class PageEditorTest extends TestCase
|
||||
/** @var Page */
|
||||
protected $page;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->page = Page::query()->first();
|
||||
|
@ -14,7 +14,7 @@ class PageTest extends TestCase
|
||||
{
|
||||
/** @var Chapter $chapter */
|
||||
$chapter = Chapter::query()->first();
|
||||
$page = factory(Page::class)->make([
|
||||
$page = Page::factory()->make([
|
||||
'name' => 'My First Page',
|
||||
]);
|
||||
|
||||
|
@ -12,7 +12,7 @@ class SortTest extends TestCase
|
||||
{
|
||||
protected $book;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->book = Book::first();
|
||||
|
@ -19,7 +19,7 @@ class TagTest extends TestCase
|
||||
$entity = $class::first();
|
||||
|
||||
if (is_null($tags)) {
|
||||
$tags = factory(Tag::class, $this->defaultTagCount)->make();
|
||||
$tags = Tag::factory()->count($this->defaultTagCount)->make();
|
||||
}
|
||||
|
||||
$entity->tags()->saveMany($tags);
|
||||
@ -31,63 +31,63 @@ class TagTest extends TestCase
|
||||
{
|
||||
// Create some tags with similar names to test with
|
||||
$attrs = collect();
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'country']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'color']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'city']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'county']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'planet']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'plans']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'country']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'color']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'city']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'county']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'planet']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'plans']));
|
||||
$page = $this->getEntityWithTags(Page::class, $attrs->all());
|
||||
|
||||
$this->asAdmin()->get('/ajax/tags/suggest/names?search=dog')->assertExactJson([]);
|
||||
$this->get('/ajax/tags/suggest/names?search=co')->assertExactJson(['color', 'country', 'county']);
|
||||
$this->get('/ajax/tags/suggest/names?search=cou')->assertExactJson(['country', 'county']);
|
||||
$this->get('/ajax/tags/suggest/names?search=pla')->assertExactJson(['planet', 'plans']);
|
||||
$this->asAdmin()->get('/ajax/tags/suggest/names?search=dog')->assertSimilarJson([]);
|
||||
$this->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country', 'county']);
|
||||
$this->get('/ajax/tags/suggest/names?search=cou')->assertSimilarJson(['country', 'county']);
|
||||
$this->get('/ajax/tags/suggest/names?search=pla')->assertSimilarJson(['planet', 'plans']);
|
||||
}
|
||||
|
||||
public function test_tag_value_suggestions()
|
||||
{
|
||||
// Create some tags with similar values to test with
|
||||
$attrs = collect();
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'country', 'value' => 'cats']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'color', 'value' => 'cattery']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'city', 'value' => 'castle']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'county', 'value' => 'dog']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'planet', 'value' => 'catapult']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'plans', 'value' => 'dodgy']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'country', 'value' => 'cats']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'color', 'value' => 'cattery']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'city', 'value' => 'castle']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'county', 'value' => 'dog']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'planet', 'value' => 'catapult']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'plans', 'value' => 'dodgy']));
|
||||
$page = $this->getEntityWithTags(Page::class, $attrs->all());
|
||||
|
||||
$this->asAdmin()->get('/ajax/tags/suggest/values?search=ora')->assertExactJson([]);
|
||||
$this->get('/ajax/tags/suggest/values?search=cat')->assertExactJson(['cats', 'cattery', 'catapult']);
|
||||
$this->get('/ajax/tags/suggest/values?search=do')->assertExactJson(['dog', 'dodgy']);
|
||||
$this->get('/ajax/tags/suggest/values?search=cas')->assertExactJson(['castle']);
|
||||
$this->asAdmin()->get('/ajax/tags/suggest/values?search=ora')->assertSimilarJson([]);
|
||||
$this->get('/ajax/tags/suggest/values?search=cat')->assertSimilarJson(['cats', 'cattery', 'catapult']);
|
||||
$this->get('/ajax/tags/suggest/values?search=do')->assertSimilarJson(['dog', 'dodgy']);
|
||||
$this->get('/ajax/tags/suggest/values?search=cas')->assertSimilarJson(['castle']);
|
||||
}
|
||||
|
||||
public function test_entity_permissions_effect_tag_suggestions()
|
||||
{
|
||||
// Create some tags with similar names to test with and save to a page
|
||||
$attrs = collect();
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'country']));
|
||||
$attrs = $attrs->merge(factory(Tag::class, 5)->make(['name' => 'color']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'country']));
|
||||
$attrs = $attrs->merge(Tag::factory()->count(5)->make(['name' => 'color']));
|
||||
$page = $this->getEntityWithTags(Page::class, $attrs->all());
|
||||
|
||||
$this->asAdmin()->get('/ajax/tags/suggest/names?search=co')->assertExactJson(['color', 'country']);
|
||||
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertExactJson(['color', 'country']);
|
||||
$this->asAdmin()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country']);
|
||||
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country']);
|
||||
|
||||
// Set restricted permission the page
|
||||
$page->restricted = true;
|
||||
$page->save();
|
||||
$page->rebuildPermissions();
|
||||
|
||||
$this->asAdmin()->get('/ajax/tags/suggest/names?search=co')->assertExactJson(['color', 'country']);
|
||||
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertExactJson([]);
|
||||
$this->asAdmin()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson(['color', 'country']);
|
||||
$this->asEditor()->get('/ajax/tags/suggest/names?search=co')->assertSimilarJson([]);
|
||||
}
|
||||
|
||||
public function test_tags_shown_on_search_listing()
|
||||
{
|
||||
$tags = [
|
||||
factory(Tag::class)->make(['name' => 'category', 'value' => 'buckets']),
|
||||
factory(Tag::class)->make(['name' => 'color', 'value' => 'red']),
|
||||
Tag::factory()->make(['name' => 'category', 'value' => 'buckets']),
|
||||
Tag::factory()->make(['name' => 'color', 'value' => 'red']),
|
||||
];
|
||||
|
||||
$page = $this->getEntityWithTags(Page::class, $tags);
|
||||
|
@ -167,7 +167,7 @@ class HomepageTest extends TestCase
|
||||
|
||||
public function test_new_users_dont_have_any_recently_viewed()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
$user = User::factory()->create();
|
||||
$viewRole = Role::getRole('Viewer');
|
||||
$user->attachRole($viewRole);
|
||||
|
||||
|
@ -9,7 +9,7 @@ class LanguageTest extends TestCase
|
||||
/**
|
||||
* LanguageTest constructor.
|
||||
*/
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->langs = array_diff(scandir(resource_path('lang')), ['..', '.']);
|
||||
|
@ -23,7 +23,7 @@ class EntityPermissionsTest extends TestCase
|
||||
*/
|
||||
protected $viewer;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->user = $this->getEditor();
|
||||
|
@ -19,7 +19,7 @@ class RolesTest extends TestCase
|
||||
{
|
||||
protected $user;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->user = $this->getViewer();
|
||||
@ -769,7 +769,7 @@ class RolesTest extends TestCase
|
||||
$this->giveUserPermissions($this->user, ['image-update-all']);
|
||||
/** @var Page $page */
|
||||
$page = Page::query()->first();
|
||||
$image = factory(Image::class)->create([
|
||||
$image = Image::factory()->create([
|
||||
'uploaded_to' => $page->id,
|
||||
'created_by' => $this->user->id,
|
||||
'updated_by' => $this->user->id,
|
||||
@ -789,7 +789,7 @@ class RolesTest extends TestCase
|
||||
$admin = $this->getAdmin();
|
||||
/** @var Page $page */
|
||||
$page = Page::query()->first();
|
||||
$image = factory(Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
|
||||
$image = Image::factory()->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
|
||||
|
||||
$this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
|
||||
|
||||
@ -825,14 +825,14 @@ class RolesTest extends TestCase
|
||||
{
|
||||
$admin = $this->getAdmin();
|
||||
// Book links
|
||||
$book = factory(Book::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
|
||||
$book = Book::factory()->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
|
||||
$this->regenEntityPermissions($book);
|
||||
$this->actingAs($this->getViewer())->get($book->getUrl())
|
||||
->assertDontSee('Create a new page')
|
||||
->assertDontSee('Add a chapter');
|
||||
|
||||
// Chapter links
|
||||
$chapter = factory(Chapter::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
|
||||
$chapter = Chapter::factory()->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
|
||||
$this->regenEntityPermissions($chapter);
|
||||
$this->actingAs($this->getViewer())->get($chapter->getUrl())
|
||||
->assertDontSee('Create a new page')
|
||||
@ -926,14 +926,14 @@ class RolesTest extends TestCase
|
||||
|
||||
private function addComment(Page $page): TestResponse
|
||||
{
|
||||
$comment = factory(Comment::class)->make();
|
||||
$comment = Comment::factory()->make();
|
||||
|
||||
return $this->postJson("/comment/$page->id", $comment->only('text', 'html'));
|
||||
}
|
||||
|
||||
private function updateComment(Comment $comment): TestResponse
|
||||
{
|
||||
$commentData = factory(Comment::class)->make();
|
||||
$commentData = Comment::factory()->make();
|
||||
|
||||
return $this->putJson("/comment/{$comment->id}", $commentData->only('text', 'html'));
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ trait SharedTestHelpers
|
||||
protected function createNewRole(array $permissions = []): Role
|
||||
{
|
||||
$permissionRepo = app(PermissionsRepo::class);
|
||||
$roleData = factory(Role::class)->make()->toArray();
|
||||
$roleData = Role::factory()->make()->toArray();
|
||||
$roleData['permissions'] = array_flip($permissions);
|
||||
|
||||
return $permissionRepo->saveNewRole($roleData);
|
||||
@ -228,9 +228,9 @@ trait SharedTestHelpers
|
||||
}
|
||||
|
||||
$userAttrs = ['created_by' => $creatorUser->id, 'owned_by' => $creatorUser->id, 'updated_by' => $updaterUser->id];
|
||||
$book = factory(Book::class)->create($userAttrs);
|
||||
$chapter = factory(Chapter::class)->create(array_merge(['book_id' => $book->id], $userAttrs));
|
||||
$page = factory(Page::class)->create(array_merge(['book_id' => $book->id, 'chapter_id' => $chapter->id], $userAttrs));
|
||||
$book = Book::factory()->create($userAttrs);
|
||||
$chapter = Chapter::factory()->create(array_merge(['book_id' => $book->id], $userAttrs));
|
||||
$page = Page::factory()->create(array_merge(['book_id' => $book->id, 'chapter_id' => $chapter->id], $userAttrs));
|
||||
$restrictionService = $this->app[PermissionService::class];
|
||||
$restrictionService->buildJointPermissionsForEntity($book);
|
||||
|
||||
|
@ -150,7 +150,7 @@ class ThemeTest extends TestCase
|
||||
Theme::listen(ThemeEvents::AUTH_REGISTER, $callback);
|
||||
$this->setSettings(['registration-enabled' => 'true']);
|
||||
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
$this->post('/register', ['email' => $user->email, 'name' => $user->name, 'password' => 'password']);
|
||||
|
||||
$this->assertCount(2, $args);
|
||||
|
@ -42,7 +42,7 @@ class AvatarTest extends TestCase
|
||||
config()->set([
|
||||
'services.disable_services' => false,
|
||||
]);
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
$this->assertImageFetchFrom('https://www.gravatar.com/avatar/' . md5(strtolower($user->email)) . '?s=500&d=identicon');
|
||||
|
||||
$user = $this->createUserRequest($user);
|
||||
@ -60,7 +60,7 @@ class AvatarTest extends TestCase
|
||||
'services.avatar_url' => 'https://example.com/${email}/${hash}/${size}',
|
||||
]);
|
||||
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
$url = 'https://example.com/' . urlencode(strtolower($user->email)) . '/' . md5(strtolower($user->email)) . '/500';
|
||||
$this->assertImageFetchFrom($url);
|
||||
|
||||
@ -74,7 +74,7 @@ class AvatarTest extends TestCase
|
||||
'services.disable_services' => true,
|
||||
]);
|
||||
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
|
||||
$http = $this->mock(HttpFetcher::class);
|
||||
$http->shouldNotReceive('fetch');
|
||||
@ -93,7 +93,7 @@ class AvatarTest extends TestCase
|
||||
|
||||
$logger = $this->withTestLogger();
|
||||
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
$this->createUserRequest($user);
|
||||
$this->assertTrue($logger->hasError('Failed to save user avatar image'));
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class UserManagementTest extends TestCase
|
||||
public function test_user_creation()
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = factory(User::class)->make();
|
||||
$user = User::factory()->make();
|
||||
$adminRole = Role::getRole('admin');
|
||||
|
||||
$resp = $this->asAdmin()->get('/settings/users');
|
||||
|
@ -14,7 +14,7 @@ class UserProfileTest extends TestCase
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->user = User::all()->last();
|
||||
@ -42,7 +42,7 @@ class UserProfileTest extends TestCase
|
||||
|
||||
public function test_profile_page_shows_created_content_counts()
|
||||
{
|
||||
$newUser = factory(User::class)->create();
|
||||
$newUser = User::factory()->create();
|
||||
|
||||
$this->asAdmin()->get('/user/' . $newUser->slug)
|
||||
->assertSee($newUser->name)
|
||||
@ -61,7 +61,7 @@ class UserProfileTest extends TestCase
|
||||
|
||||
public function test_profile_page_shows_recent_activity()
|
||||
{
|
||||
$newUser = factory(User::class)->create();
|
||||
$newUser = User::factory()->create();
|
||||
$this->actingAs($newUser);
|
||||
$entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
|
||||
Activity::addForEntity($entities['book'], ActivityType::BOOK_UPDATE);
|
||||
@ -75,7 +75,7 @@ class UserProfileTest extends TestCase
|
||||
|
||||
public function test_user_activity_has_link_leading_to_profile()
|
||||
{
|
||||
$newUser = factory(User::class)->create();
|
||||
$newUser = User::factory()->create();
|
||||
$this->actingAs($newUser);
|
||||
$entities = $this->createEntityChainBelongingToUser($newUser, $newUser);
|
||||
Activity::addForEntity($entities['book'], ActivityType::BOOK_UPDATE);
|
||||
|
Loading…
Reference in New Issue
Block a user