From bebbfec51088c2b993016b818f25dba3c602ee07 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Fri, 9 Jun 2023 18:31:53 +0100 Subject: [PATCH] chore: Refactor configuration files based on Laravel 10 skeleton --- .editorconfig | 9 --- .gitattributes | 14 +++- .gitignore | 23 +++--- .styleci.yml | 17 ++-- app/Console/Kernel.php | 14 +--- app/Http/Controllers/Controller.php | 5 +- app/Http/Controllers/FeedsController.php | 4 +- .../Controllers/TokenEndpointController.php | 2 +- app/Http/Kernel.php | 7 +- app/Http/Middleware/ActivityStreamLinks.php | 28 ------- app/Http/Middleware/ValidateSignature.php | 22 +++++ app/Jobs/SendWebMentions.php | 2 +- app/Models/Note.php | 2 +- app/Models/Place.php | 2 +- app/Providers/AuthServiceProvider.php | 3 +- app/Providers/RouteServiceProvider.php | 16 +--- composer.json | 68 ++++++++-------- config/app.php | 81 ++----------------- config/auth.php | 2 +- config/broadcasting.php | 1 + config/cache.php | 1 + config/mail.php | 1 + config/queue.php | 16 ++++ config/url.php | 36 ++++++++- phpunit.xml | 18 ++--- public/index.php | 18 ++--- public/web.config | 23 ------ resources/views/master.blade.php | 2 +- routes/api.php | 1 + routes/web.php | 22 ++--- storage/framework/.gitignore | 13 +-- tests/Feature/FeedsTest.php | 4 +- tests/Feature/ShortURLsControllerTest.php | 8 +- tests/Unit/NotesTest.php | 2 +- tests/Unit/PlacesTest.php | 2 +- 35 files changed, 205 insertions(+), 284 deletions(-) delete mode 100644 app/Http/Middleware/ActivityStreamLinks.php create mode 100644 app/Http/Middleware/ValidateSignature.php delete mode 100644 public/web.config diff --git a/.editorconfig b/.editorconfig index 0dede531..8f0de65c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,5 @@ -# EditorConfig is awesome: http://EditorConfig.org - -# top-most EditorConfig file root = true -# Unix-style newlines with a newline ending every file [*] charset = utf-8 end_of_line = lf @@ -12,11 +8,6 @@ indent_style = space insert_final_newline = true trim_trailing_whitespace = true -# Tab indentation -[Makefile] -indent_style = tab -tab_width = 4 - [*.md] trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index 967315dd..fcb21d39 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,11 @@ -* text=auto -*.css linguist-vendored -*.scss linguist-vendored -*.js linguist-vendored +* text=auto eol=lf + +*.blade.php diff=html +*.css diff=css +*.html diff=html +*.md diff=markdown +*.php diff=php + +/.github export-ignore CHANGELOG.md export-ignore +.styleci.yml export-ignore diff --git a/.gitignore b/.gitignore index 9cf612ac..5a9b11c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,23 @@ +/.phpunit.cache /node_modules +/public/build +/public/coverage +/public/hot +/public/files +/public/fonts +/public/storage /storage/*.key /vendor .env +.env.backup +.env.production .phpunit.result.cache Homestead.json Homestead.yaml +auth.json npm-debug.log yarn-error.log +/.fleet /.idea -/lsp -.phpstorm.meta.php -_ide_helper.php +/.vscode ray.php -# Custom paths in /public -/public/coverage -/public/hot -/public/storage -/public/fonts -/public/files -/public/keybase.txt -/public/assets/*.map diff --git a/.styleci.yml b/.styleci.yml index 0fb4a09b..9daadf16 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,8 +1,9 @@ -preset: laravel - -disabled: - - concat_without_spaces - - single_import_per_statement - -finder: - path: app/ +php: + preset: laravel + disabled: + - no_unused_imports + finder: + not-name: + - index.php +js: true +css: true diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 3ba67df6..432844ad 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -7,20 +7,8 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { - /** - * The Artisan commands provided by your application. - * - * @var array - */ - protected $commands = [ - Commands\ParseCachedWebMentions::class, - Commands\ReDownloadWebMentions::class, - ]; - /** * Define the application's command schedule. - * - * @codeCoverageIgnore */ protected function schedule(Schedule $schedule): void { @@ -33,7 +21,7 @@ class Kernel extends ConsoleKernel */ protected function commands(): void { - $this->load(__DIR__ . '/Commands'); + $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index ce1176dd..77ec359a 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -3,13 +3,10 @@ namespace App\Http\Controllers; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; -use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; class Controller extends BaseController { - use AuthorizesRequests; - use DispatchesJobs; - use ValidatesRequests; + use AuthorizesRequests, ValidatesRequests; } diff --git a/app/Http/Controllers/FeedsController.php b/app/Http/Controllers/FeedsController.php index 01b6b3c0..3b483af8 100644 --- a/app/Http/Controllers/FeedsController.php +++ b/app/Http/Controllers/FeedsController.php @@ -152,7 +152,7 @@ class FeedsController extends Controller 'author' => [ 'type' => 'card', 'name' => config('user.displayname'), - 'url' => config('app.longurl'), + 'url' => config('url.longurl'), ], 'children' => $items, ], 200, [ @@ -188,7 +188,7 @@ class FeedsController extends Controller 'author' => [ 'type' => 'card', 'name' => config('user.displayname'), - 'url' => config('app.longurl'), + 'url' => config('url.longurl'), ], 'children' => $items, ], 200, [ diff --git a/app/Http/Controllers/TokenEndpointController.php b/app/Http/Controllers/TokenEndpointController.php index 73e86deb..c0bda71e 100644 --- a/app/Http/Controllers/TokenEndpointController.php +++ b/app/Http/Controllers/TokenEndpointController.php @@ -45,7 +45,7 @@ class TokenEndpointController extends Controller public function create(Request $request): JsonResponse { $auth = $this->verifyIndieAuthCode( - config('app.authorization_endpoint'), + config('url.authorization_endpoint'), $request->input('code'), $request->input('redirect_uri'), $request->input('client_id'), diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index d2be1cb7..3557e09c 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -33,13 +33,11 @@ class Kernel extends HttpKernel \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, - // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, \App\Http\Middleware\LinkHeadersMiddleware::class, \App\Http\Middleware\LocalhostSessionMiddleware::class, - \App\Http\Middleware\ActivityStreamLinks::class, \App\Http\Middleware\CSPHeader::class, ], @@ -53,7 +51,7 @@ class Kernel extends HttpKernel /** * The application's middleware aliases. * - * Aliases may be used to conveniently assign middleware to routes and groups. + * Aliases may be used instead of class names to conveniently assign middleware to routes and groups. * * @var array */ @@ -65,7 +63,8 @@ class Kernel extends HttpKernel 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, - 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class, + 'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class, + 'signed' => \App\Http\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'micropub.token' => \App\Http\Middleware\VerifyMicropubToken::class, diff --git a/app/Http/Middleware/ActivityStreamLinks.php b/app/Http/Middleware/ActivityStreamLinks.php deleted file mode 100644 index 47727d98..00000000 --- a/app/Http/Middleware/ActivityStreamLinks.php +++ /dev/null @@ -1,28 +0,0 @@ -path() === '/') { - $response->header('Link', '<' . config('app.url') . '>; rel="application/activity+json"', false); - } - if ($request->is('notes/*')) { - $response->header('Link', '<' . $request->url() . '>; rel="application/activity+json"', false); - } - - return $response; - } -} diff --git a/app/Http/Middleware/ValidateSignature.php b/app/Http/Middleware/ValidateSignature.php new file mode 100644 index 00000000..093bf64a --- /dev/null +++ b/app/Http/Middleware/ValidateSignature.php @@ -0,0 +1,22 @@ + + */ + protected $except = [ + // 'fbclid', + // 'utm_campaign', + // 'utm_content', + // 'utm_medium', + // 'utm_source', + // 'utm_term', + ]; +} diff --git a/app/Jobs/SendWebMentions.php b/app/Jobs/SendWebMentions.php index b481f69d..eda128a4 100644 --- a/app/Jobs/SendWebMentions.php +++ b/app/Jobs/SendWebMentions.php @@ -62,7 +62,7 @@ class SendWebMentions implements ShouldQueue public function discoverWebmentionEndpoint(string $url): ?string { // let’s not send webmentions to myself - if (parse_url($url, PHP_URL_HOST) === config('app.longurl')) { + if (parse_url($url, PHP_URL_HOST) === config('url.longurl')) { return null; } if (Str::startsWith($url, '/notes/tagged/')) { diff --git a/app/Models/Note.php b/app/Models/Note.php index a9778f0b..bbed5e62 100644 --- a/app/Models/Note.php +++ b/app/Models/Note.php @@ -179,7 +179,7 @@ class Note extends Model public function getShorturlAttribute(): string { - return config('app.shorturl') . '/notes/' . $this->nb60id; + return config('url.shorturl') . '/notes/' . $this->nb60id; } public function getIso8601Attribute(): string diff --git a/app/Models/Place.php b/app/Models/Place.php index dd8320d6..2a36aa32 100644 --- a/app/Models/Place.php +++ b/app/Models/Place.php @@ -84,7 +84,7 @@ class Place extends Model protected function shorturl(): Attribute { return Attribute::get( - get: fn ($value, $attributes) => config('app.shorturl') . '/places/' . $attributes['slug'], + get: fn ($value, $attributes) => config('url.shorturl') . '/places/' . $attributes['slug'], ); } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index faa84c0d..54756cd1 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +// use Illuminate\Support\Facades\Gate; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; class AuthServiceProvider extends ServiceProvider @@ -12,7 +13,7 @@ class AuthServiceProvider extends ServiceProvider * @var array */ protected $policies = [ - // 'App\Models\Model' => 'App\Policies\ModelPolicy', + // ]; /** diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index caecf5f4..28da75d5 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Route; class RouteServiceProvider extends ServiceProvider { /** - * The path to the "home" route for your application. + * The path to your application's "home" route. * * Typically, users are redirected here after authentication. * @@ -24,7 +24,9 @@ class RouteServiceProvider extends ServiceProvider */ public function boot(): void { - $this->configureRateLimiting(); + RateLimiter::for('api', function (Request $request) { + return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); + }); $this->routes(function () { Route::middleware('api') @@ -35,14 +37,4 @@ class RouteServiceProvider extends ServiceProvider ->group(base_path('routes/web.php')); }); } - - /** - * Configure the rate limiters for the application. - */ - protected function configureRateLimiting(): void - { - RateLimiter::for('api', function (Request $request) { - return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); - }); - } } diff --git a/composer.json b/composer.json index b2a23934..905fd1f3 100644 --- a/composer.json +++ b/composer.json @@ -1,30 +1,26 @@ { "name": "jonnybarnes/jonnybarnes.uk", "type": "project", - "description": "The code for jonnybarnes.uk, based on Laravel 8", - "keywords": [ - "framework", - "laravel", - "indieweb" - ], + "description": "The code for jonnybarnes.uk, based on Laravel 10", + "keywords": ["laravel", "framework", "indieweb"], "license": "CC0-1.0", "require": { - "php": "^8.0", + "php": "^8.1", "ext-dom": "*", "ext-intl": "*", "ext-json": "*", "cviebrock/eloquent-sluggable": "^10.0", - "guzzlehttp/guzzle": "^7.0.1", + "guzzlehttp/guzzle": "^7.2", "indieauth/client": "^1.1", "intervention/image": "^2.4", "jonnybarnes/indieweb": "~0.2", "jonnybarnes/webmentions-parser": "~0.5", "jublonet/codebird-php": "4.0.0-beta.1", - "laravel/framework": "^10.0", + "laravel/framework": "^10.10", "laravel/horizon": "^5.0", - "laravel/sanctum": "^3.0", + "laravel/sanctum": "^3.2", "laravel/scout": "^10.1", - "laravel/tinker": "^2.0", + "laravel/tinker": "^2.8", "lcobucci/jwt": "^5.0", "league/commonmark": "^2.0", "league/flysystem-aws-s3-v3": "^3.0", @@ -39,29 +35,15 @@ "beyondcode/laravel-dump-server": "^1.0", "fakerphp/faker": "^1.9.2", "laravel/dusk": "^7.0", - "laravel/pint": "^1.0.0", - "laravel/sail": "^1.15", - "mockery/mockery": "^1.0", + "laravel/pint": "^1.0", + "laravel/sail": "^1.18", + "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", "phpunit/php-code-coverage": "^10.0", - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^10.1", "spatie/laravel-ray": "^1.12", "vimeo/psalm": "^5.0" }, - "config": { - "optimize-autoloader": true, - "preferred-install": "dist", - "sort-packages": true, - "allow-plugins": { - "composer/package-versions-deprecated": false, - "composer/installers": false - } - }, - "extra": { - "laravel": { - "dont-discover": [] - } - }, "autoload": { "psr-4": { "App\\": "app/", @@ -74,24 +56,38 @@ }, "autoload-dev": { "psr-4": { - "Tests\\": "tests" + "Tests\\": "tests/" } }, - "minimum-stability": "stable", - "prefer-stable": true, "scripts": { "post-autoload-dump": [ "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "@php artisan package:discover --ansi" ], + "post-update-cmd": [ + "@php artisan vendor:publish --tag=laravel-assets --ansi --force" + ], "post-root-package-install": [ "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ "@php artisan key:generate --ansi" - ], - "test": [ - "vendor/bin/phpunit --stop-on-failure" ] - } + }, + "extra": { + "laravel": { + "dont-discover": [] + } + }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true, + "php-http/discovery": true + } + }, + "minimum-stability": "stable", + "prefer-stable": true } diff --git a/config/app.php b/config/app.php index 0c0fd785..2c80a4e3 100644 --- a/config/app.php +++ b/config/app.php @@ -1,6 +1,7 @@ env('ASSET_URL'), - /* - |-------------------------------------------------------------------------- - | Application Long URL - |-------------------------------------------------------------------------- - | - | The long URL for the application - | - */ - - 'longurl' => env('APP_LONGURL', 'longurl.local'), - - /* - |-------------------------------------------------------------------------- - | Application Short URL - |-------------------------------------------------------------------------- - | - | The short URL for the application - | - */ - - 'shorturl' => env('APP_SHORTURL', 'shorturl.local'), - - /* - |-------------------------------------------------------------------------- - | Authorization endpoint - |-------------------------------------------------------------------------- - | - | The authorization endpoint for the application, used primarily for Micropub - | - */ - - 'authorization_endpoint' => env('AUTHORIZATION_ENDPOINT', 'https://indieauth.com/auth'), - - /* - |-------------------------------------------------------------------------- - | Application Display Name - |-------------------------------------------------------------------------- - | - | The display name for the application, used for example in titles. - | - */ - - 'display_name' => env('DISPLAY_NAME', 'Joe Bloggs'), - /* |-------------------------------------------------------------------------- | Application Timezone @@ -209,34 +166,7 @@ return [ | */ - 'providers' => [ - - /* - * Laravel Framework Service Providers... - */ - Illuminate\Auth\AuthServiceProvider::class, - Illuminate\Broadcasting\BroadcastServiceProvider::class, - Illuminate\Bus\BusServiceProvider::class, - Illuminate\Cache\CacheServiceProvider::class, - Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, - Illuminate\Cookie\CookieServiceProvider::class, - Illuminate\Database\DatabaseServiceProvider::class, - Illuminate\Encryption\EncryptionServiceProvider::class, - Illuminate\Filesystem\FilesystemServiceProvider::class, - Illuminate\Foundation\Providers\FoundationServiceProvider::class, - Illuminate\Hashing\HashServiceProvider::class, - Illuminate\Mail\MailServiceProvider::class, - Illuminate\Notifications\NotificationServiceProvider::class, - Illuminate\Pagination\PaginationServiceProvider::class, - Illuminate\Pipeline\PipelineServiceProvider::class, - Illuminate\Queue\QueueServiceProvider::class, - Illuminate\Redis\RedisServiceProvider::class, - Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, - Illuminate\Session\SessionServiceProvider::class, - Illuminate\Translation\TranslationServiceProvider::class, - Illuminate\Validation\ValidationServiceProvider::class, - Illuminate\View\ViewServiceProvider::class, - + 'providers' => ServiceProvider::defaultProviders()->merge([ /* * Package Service Providers... */ @@ -248,10 +178,9 @@ return [ App\Providers\AuthServiceProvider::class, // App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, - App\Providers\RouteServiceProvider::class, App\Providers\HorizonServiceProvider::class, - - ], + App\Providers\RouteServiceProvider::class, + ])->toArray(), /* |-------------------------------------------------------------------------- @@ -265,7 +194,7 @@ return [ */ 'aliases' => Facade::defaultAliases()->merge([ - // 'ExampleClass' => App\Example\ExampleClass::class, + // 'Example' => App\Facades\Example::class, ])->toArray(), ]; diff --git a/config/auth.php b/config/auth.php index cae00280..9548c15d 100644 --- a/config/auth.php +++ b/config/auth.php @@ -80,7 +80,7 @@ return [ | than one user table or model in the application and you want to have | separate password reset settings based on the specific user types. | - | The expire time is the number of minutes that each reset token will be + | The expiry time is the number of minutes that each reset token will be | considered valid. This security feature keeps tokens short-lived so | they have less time to be guessed. You may change this as needed. | diff --git a/config/broadcasting.php b/config/broadcasting.php index 9e4d4aa4..24104853 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -36,6 +36,7 @@ return [ 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ + 'cluster' => env('PUSHER_APP_CLUSTER'), 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 'port' => env('PUSHER_PORT', 443), 'scheme' => env('PUSHER_SCHEME', 'https'), diff --git a/config/cache.php b/config/cache.php index 33bb2954..d4171e22 100644 --- a/config/cache.php +++ b/config/cache.php @@ -52,6 +52,7 @@ return [ 'file' => [ 'driver' => 'file', 'path' => storage_path('framework/cache/data'), + 'lock_path' => storage_path('framework/cache/data'), ], 'memcached' => [ diff --git a/config/mail.php b/config/mail.php index 542d98c3..e652bd02 100644 --- a/config/mail.php +++ b/config/mail.php @@ -36,6 +36,7 @@ return [ 'mailers' => [ 'smtp' => [ 'transport' => 'smtp', + 'url' => env('MAIL_URL'), 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 'port' => env('MAIL_PORT', 587), 'encryption' => env('MAIL_ENCRYPTION', 'tls'), diff --git a/config/queue.php b/config/queue.php index 25ea5a81..01c6b054 100644 --- a/config/queue.php +++ b/config/queue.php @@ -73,6 +73,22 @@ return [ ], + /* + |-------------------------------------------------------------------------- + | Job Batching + |-------------------------------------------------------------------------- + | + | The following options configure the database and table that store job + | batching information. These options can be updated to any database + | connection and table which has been defined by your application. + | + */ + + 'batching' => [ + 'database' => env('DB_CONNECTION', 'mysql'), + 'table' => 'job_batches', + ], + /* |-------------------------------------------------------------------------- | Failed Queue Jobs diff --git a/config/url.php b/config/url.php index c0fd5b48..a1962ade 100644 --- a/config/url.php +++ b/config/url.php @@ -6,6 +6,38 @@ */ return [ - 'longurl' => env('APP_LONGURL', 'jonnybarnes.uk'), - 'shorturl' => env('APP_SHORTURL', 'jmb.lv'), + + /* + |-------------------------------------------------------------------------- + | Application Long URL + |-------------------------------------------------------------------------- + | + | The long URL for the application + | + */ + + 'longurl' => env('APP_LONGURL', 'longurl.local'), + + /* + |-------------------------------------------------------------------------- + | Application Short URL + |-------------------------------------------------------------------------- + | + | The short URL for the application + | + */ + + 'shorturl' => env('APP_SHORTURL', 'shorturl.local'), + + /* + |-------------------------------------------------------------------------- + | Authorization endpoint + |-------------------------------------------------------------------------- + | + | The authorization endpoint for the application, used primarily for Micropub + | + */ + + 'authorization_endpoint' => env('AUTHORIZATION_ENDPOINT', 'https://indieauth.com/auth'), + ]; diff --git a/phpunit.xml b/phpunit.xml index 29e2843f..6a0ec00e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -3,34 +3,30 @@ xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" - stopOnFailure="true" > - ./tests/Unit + ./tests/Unit - - ./tests/Feature + ./tests/Feature - + ./app - - - - + - + + + - diff --git a/public/index.php b/public/index.php index 0fbc0c43..1d69f3a2 100644 --- a/public/index.php +++ b/public/index.php @@ -7,17 +7,17 @@ define('LARAVEL_START', microtime(true)); /* |-------------------------------------------------------------------------- -| Check If Application Is Under Maintenance +| Check If The Application Is Under Maintenance |-------------------------------------------------------------------------- | -| If the application is maintenance / demo mode via the "down" command we -| will require this file so that any prerendered template can be shown +| 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'; +if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) { + require $maintenance; } /* @@ -31,7 +31,7 @@ if (file_exists(__DIR__ . '/../storage/framework/maintenance.php')) { | */ -require __DIR__ . '/../vendor/autoload.php'; +require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- @@ -44,12 +44,12 @@ require __DIR__ . '/../vendor/autoload.php'; | */ -$app = require_once __DIR__ . '/../bootstrap/app.php'; +$app = require_once __DIR__.'/../bootstrap/app.php'; $kernel = $app->make(Kernel::class); -$response = tap($kernel->handle( +$response = $kernel->handle( $request = Request::capture() -))->send(); +)->send(); $kernel->terminate($request, $response); diff --git a/public/web.config b/public/web.config deleted file mode 100644 index 624c1760..00000000 --- a/public/web.config +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/views/master.blade.php b/resources/views/master.blade.php index d387c93b..428ab0d0 100644 --- a/resources/views/master.blade.php +++ b/resources/views/master.blade.php @@ -21,7 +21,7 @@ - + diff --git a/routes/api.php b/routes/api.php index c9b0b965..415727bc 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,6 +1,7 @@ config('url.longurl')], function () { Route::get('/', [FrontPageController::class, 'index']); diff --git a/storage/framework/.gitignore b/storage/framework/.gitignore index b02b700f..05c4471f 100644 --- a/storage/framework/.gitignore +++ b/storage/framework/.gitignore @@ -1,8 +1,9 @@ -config.php -routes.php -schedule-* 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 diff --git a/tests/Feature/FeedsTest.php b/tests/Feature/FeedsTest.php index 6bc9cd9c..dd77bd66 100644 --- a/tests/Feature/FeedsTest.php +++ b/tests/Feature/FeedsTest.php @@ -65,7 +65,7 @@ class FeedsTest extends TestCase 'author' => [ 'type' => 'card', 'name' => config('user.displayname'), - 'url' => config('app.longurl'), + 'url' => config('url.longurl'), ], 'children' => [[ 'type' => 'entry', @@ -126,7 +126,7 @@ class FeedsTest extends TestCase 'author' => [ 'type' => 'card', 'name' => config('user.displayname'), - 'url' => config('app.longurl'), + 'url' => config('url.longurl'), ], 'children' => [[ 'type' => 'entry', diff --git a/tests/Feature/ShortURLsControllerTest.php b/tests/Feature/ShortURLsControllerTest.php index 0fbfff65..55774b91 100644 --- a/tests/Feature/ShortURLsControllerTest.php +++ b/tests/Feature/ShortURLsControllerTest.php @@ -11,28 +11,28 @@ class ShortURLsControllerTest extends TestCase /** @test */ public function shortDomainRedirectsToLongDomain(): void { - $response = $this->get('https://' . config('app.shorturl')); + $response = $this->get('https://' . config('url.shorturl')); $response->assertRedirect(config('app.url')); } /** @test */ public function shortDomainSlashAtRedirectsToTwitter(): void { - $response = $this->get('https://' . config('app.shorturl') . '/@'); + $response = $this->get('https://' . config('url.shorturl') . '/@'); $response->assertRedirect('https://twitter.com/jonnybarnes'); } /** @test */ public function shortDomainSlashTRedirectsToLongDomainSlashNotes(): void { - $response = $this->get('https://' . config('app.shorturl') . '/t/E'); + $response = $this->get('https://' . config('url.shorturl') . '/t/E'); $response->assertRedirect(config('app.url') . '/notes/E'); } /** @test */ public function shortDomainSlashBRedirectsToLongDomainSlashBlog(): void { - $response = $this->get('https://' . config('app.shorturl') . '/b/1'); + $response = $this->get('https://' . config('url.shorturl') . '/b/1'); $response->assertRedirect(config('app.url') . '/blog/s/1'); } } diff --git a/tests/Unit/NotesTest.php b/tests/Unit/NotesTest.php index 0a8d0725..990fe076 100644 --- a/tests/Unit/NotesTest.php +++ b/tests/Unit/NotesTest.php @@ -123,7 +123,7 @@ class NotesTest extends TestCase { $note = Note::factory()->make(); $note->id = 14; - $this->assertEquals(config('app.shorturl') . '/notes/E', $note->shorturl); + $this->assertEquals(config('url.shorturl') . '/notes/E', $note->shorturl); } /** @test */ diff --git a/tests/Unit/PlacesTest.php b/tests/Unit/PlacesTest.php index 192458dc..f5d73db0 100644 --- a/tests/Unit/PlacesTest.php +++ b/tests/Unit/PlacesTest.php @@ -54,7 +54,7 @@ class PlacesTest extends TestCase $place = Place::factory()->create([ 'name' => 'The Bridgewater Pub', ]); - $this->assertEquals(config('app.shorturl') . '/places/the-bridgewater-pub', $place->shorturl); + $this->assertEquals(config('url.shorturl') . '/places/the-bridgewater-pub', $place->shorturl); } /** @test */