chore: Refactor configuration files based on Laravel 10 skeleton

This commit is contained in:
Jonny Barnes 2023-06-09 18:31:53 +01:00
parent 3f78d5118a
commit bebbfec510
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8
35 changed files with 205 additions and 284 deletions

View file

@ -1,9 +1,5 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true root = true
# Unix-style newlines with a newline ending every file
[*] [*]
charset = utf-8 charset = utf-8
end_of_line = lf end_of_line = lf
@ -12,11 +8,6 @@ indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
# Tab indentation
[Makefile]
indent_style = tab
tab_width = 4
[*.md] [*.md]
trim_trailing_whitespace = false trim_trailing_whitespace = false

14
.gitattributes vendored
View file

@ -1,5 +1,11 @@
* text=auto * text=auto eol=lf
*.css linguist-vendored
*.scss linguist-vendored *.blade.php diff=html
*.js linguist-vendored *.css diff=css
*.html diff=html
*.md diff=markdown
*.php diff=php
/.github export-ignore
CHANGELOG.md export-ignore CHANGELOG.md export-ignore
.styleci.yml export-ignore

23
.gitignore vendored
View file

@ -1,22 +1,23 @@
/.phpunit.cache
/node_modules /node_modules
/public/build
/public/coverage
/public/hot
/public/files
/public/fonts
/public/storage
/storage/*.key /storage/*.key
/vendor /vendor
.env .env
.env.backup
.env.production
.phpunit.result.cache .phpunit.result.cache
Homestead.json Homestead.json
Homestead.yaml Homestead.yaml
auth.json
npm-debug.log npm-debug.log
yarn-error.log yarn-error.log
/.fleet
/.idea /.idea
/lsp /.vscode
.phpstorm.meta.php
_ide_helper.php
ray.php ray.php
# Custom paths in /public
/public/coverage
/public/hot
/public/storage
/public/fonts
/public/files
/public/keybase.txt
/public/assets/*.map

View file

@ -1,8 +1,9 @@
preset: laravel php:
preset: laravel
disabled: disabled:
- concat_without_spaces - no_unused_imports
- single_import_per_statement finder:
not-name:
finder: - index.php
path: app/ js: true
css: true

View file

@ -7,20 +7,8 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
/**
* The Artisan commands provided by your application.
*
* @var array<int, string>
*/
protected $commands = [
Commands\ParseCachedWebMentions::class,
Commands\ReDownloadWebMentions::class,
];
/** /**
* Define the application's command schedule. * Define the application's command schedule.
*
* @codeCoverageIgnore
*/ */
protected function schedule(Schedule $schedule): void protected function schedule(Schedule $schedule): void
{ {
@ -33,7 +21,7 @@ class Kernel extends ConsoleKernel
*/ */
protected function commands(): void protected function commands(): void
{ {
$this->load(__DIR__ . '/Commands'); $this->load(__DIR__.'/Commands');
require base_path('routes/console.php'); require base_path('routes/console.php');
} }

View file

@ -3,13 +3,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController; use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController class Controller extends BaseController
{ {
use AuthorizesRequests; use AuthorizesRequests, ValidatesRequests;
use DispatchesJobs;
use ValidatesRequests;
} }

View file

@ -152,7 +152,7 @@ class FeedsController extends Controller
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.displayname'), 'name' => config('user.displayname'),
'url' => config('app.longurl'), 'url' => config('url.longurl'),
], ],
'children' => $items, 'children' => $items,
], 200, [ ], 200, [
@ -188,7 +188,7 @@ class FeedsController extends Controller
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.displayname'), 'name' => config('user.displayname'),
'url' => config('app.longurl'), 'url' => config('url.longurl'),
], ],
'children' => $items, 'children' => $items,
], 200, [ ], 200, [

View file

@ -45,7 +45,7 @@ class TokenEndpointController extends Controller
public function create(Request $request): JsonResponse public function create(Request $request): JsonResponse
{ {
$auth = $this->verifyIndieAuthCode( $auth = $this->verifyIndieAuthCode(
config('app.authorization_endpoint'), config('url.authorization_endpoint'),
$request->input('code'), $request->input('code'),
$request->input('redirect_uri'), $request->input('redirect_uri'),
$request->input('client_id'), $request->input('client_id'),

View file

@ -33,13 +33,11 @@ class Kernel extends HttpKernel
\App\Http\Middleware\EncryptCookies::class, \App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class, \Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class, \App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class, \Illuminate\Routing\Middleware\SubstituteBindings::class,
\App\Http\Middleware\LinkHeadersMiddleware::class, \App\Http\Middleware\LinkHeadersMiddleware::class,
\App\Http\Middleware\LocalhostSessionMiddleware::class, \App\Http\Middleware\LocalhostSessionMiddleware::class,
\App\Http\Middleware\ActivityStreamLinks::class,
\App\Http\Middleware\CSPHeader::class, \App\Http\Middleware\CSPHeader::class,
], ],
@ -53,7 +51,7 @@ class Kernel extends HttpKernel
/** /**
* The application's middleware aliases. * 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<string, class-string|string> * @var array<string, class-string|string>
*/ */
@ -65,7 +63,8 @@ class Kernel extends HttpKernel
'can' => \Illuminate\Auth\Middleware\Authorize::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::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, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
'micropub.token' => \App\Http\Middleware\VerifyMicropubToken::class, 'micropub.token' => \App\Http\Middleware\VerifyMicropubToken::class,

View file

@ -1,28 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class ActivityStreamLinks
{
/**
* Handle an incoming request.
*/
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);
if ($request->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;
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace App\Http\Middleware;
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
class ValidateSignature extends Middleware
{
/**
* The names of the query string parameters that should be ignored.
*
* @var array<int, string>
*/
protected $except = [
// 'fbclid',
// 'utm_campaign',
// 'utm_content',
// 'utm_medium',
// 'utm_source',
// 'utm_term',
];
}

View file

@ -62,7 +62,7 @@ class SendWebMentions implements ShouldQueue
public function discoverWebmentionEndpoint(string $url): ?string public function discoverWebmentionEndpoint(string $url): ?string
{ {
// lets not send webmentions to myself // lets 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; return null;
} }
if (Str::startsWith($url, '/notes/tagged/')) { if (Str::startsWith($url, '/notes/tagged/')) {

View file

@ -179,7 +179,7 @@ class Note extends Model
public function getShorturlAttribute(): string public function getShorturlAttribute(): string
{ {
return config('app.shorturl') . '/notes/' . $this->nb60id; return config('url.shorturl') . '/notes/' . $this->nb60id;
} }
public function getIso8601Attribute(): string public function getIso8601Attribute(): string

View file

@ -84,7 +84,7 @@ class Place extends Model
protected function shorturl(): Attribute protected function shorturl(): Attribute
{ {
return Attribute::get( return Attribute::get(
get: fn ($value, $attributes) => config('app.shorturl') . '/places/' . $attributes['slug'], get: fn ($value, $attributes) => config('url.shorturl') . '/places/' . $attributes['slug'],
); );
} }

View file

@ -2,6 +2,7 @@
namespace App\Providers; namespace App\Providers;
// use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
class AuthServiceProvider extends ServiceProvider class AuthServiceProvider extends ServiceProvider
@ -12,7 +13,7 @@ class AuthServiceProvider extends ServiceProvider
* @var array<class-string, class-string> * @var array<class-string, class-string>
*/ */
protected $policies = [ protected $policies = [
// 'App\Models\Model' => 'App\Policies\ModelPolicy', //
]; ];
/** /**

View file

@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider 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. * Typically, users are redirected here after authentication.
* *
@ -24,7 +24,9 @@ class RouteServiceProvider extends ServiceProvider
*/ */
public function boot(): void 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 () { $this->routes(function () {
Route::middleware('api') Route::middleware('api')
@ -35,14 +37,4 @@ class RouteServiceProvider extends ServiceProvider
->group(base_path('routes/web.php')); ->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());
});
}
} }

View file

@ -1,30 +1,26 @@
{ {
"name": "jonnybarnes/jonnybarnes.uk", "name": "jonnybarnes/jonnybarnes.uk",
"type": "project", "type": "project",
"description": "The code for jonnybarnes.uk, based on Laravel 8", "description": "The code for jonnybarnes.uk, based on Laravel 10",
"keywords": [ "keywords": ["laravel", "framework", "indieweb"],
"framework",
"laravel",
"indieweb"
],
"license": "CC0-1.0", "license": "CC0-1.0",
"require": { "require": {
"php": "^8.0", "php": "^8.1",
"ext-dom": "*", "ext-dom": "*",
"ext-intl": "*", "ext-intl": "*",
"ext-json": "*", "ext-json": "*",
"cviebrock/eloquent-sluggable": "^10.0", "cviebrock/eloquent-sluggable": "^10.0",
"guzzlehttp/guzzle": "^7.0.1", "guzzlehttp/guzzle": "^7.2",
"indieauth/client": "^1.1", "indieauth/client": "^1.1",
"intervention/image": "^2.4", "intervention/image": "^2.4",
"jonnybarnes/indieweb": "~0.2", "jonnybarnes/indieweb": "~0.2",
"jonnybarnes/webmentions-parser": "~0.5", "jonnybarnes/webmentions-parser": "~0.5",
"jublonet/codebird-php": "4.0.0-beta.1", "jublonet/codebird-php": "4.0.0-beta.1",
"laravel/framework": "^10.0", "laravel/framework": "^10.10",
"laravel/horizon": "^5.0", "laravel/horizon": "^5.0",
"laravel/sanctum": "^3.0", "laravel/sanctum": "^3.2",
"laravel/scout": "^10.1", "laravel/scout": "^10.1",
"laravel/tinker": "^2.0", "laravel/tinker": "^2.8",
"lcobucci/jwt": "^5.0", "lcobucci/jwt": "^5.0",
"league/commonmark": "^2.0", "league/commonmark": "^2.0",
"league/flysystem-aws-s3-v3": "^3.0", "league/flysystem-aws-s3-v3": "^3.0",
@ -39,29 +35,15 @@
"beyondcode/laravel-dump-server": "^1.0", "beyondcode/laravel-dump-server": "^1.0",
"fakerphp/faker": "^1.9.2", "fakerphp/faker": "^1.9.2",
"laravel/dusk": "^7.0", "laravel/dusk": "^7.0",
"laravel/pint": "^1.0.0", "laravel/pint": "^1.0",
"laravel/sail": "^1.15", "laravel/sail": "^1.18",
"mockery/mockery": "^1.0", "mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0", "nunomaduro/collision": "^7.0",
"phpunit/php-code-coverage": "^10.0", "phpunit/php-code-coverage": "^10.0",
"phpunit/phpunit": "^10.0", "phpunit/phpunit": "^10.1",
"spatie/laravel-ray": "^1.12", "spatie/laravel-ray": "^1.12",
"vimeo/psalm": "^5.0" "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": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/", "App\\": "app/",
@ -74,24 +56,38 @@
}, },
"autoload-dev": { "autoload-dev": {
"psr-4": { "psr-4": {
"Tests\\": "tests" "Tests\\": "tests/"
} }
}, },
"minimum-stability": "stable",
"prefer-stable": true,
"scripts": { "scripts": {
"post-autoload-dump": [ "post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi" "@php artisan package:discover --ansi"
], ],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"post-root-package-install": [ "post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
], ],
"post-create-project-cmd": [ "post-create-project-cmd": [
"@php artisan key:generate --ansi" "@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
} }

View file

@ -1,6 +1,7 @@
<?php <?php
use Illuminate\Support\Facades\Facade; use Illuminate\Support\Facades\Facade;
use Illuminate\Support\ServiceProvider;
return [ return [
@ -58,50 +59,6 @@ return [
'asset_url' => env('ASSET_URL'), 'asset_url' => 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 | Application Timezone
@ -209,34 +166,7 @@ return [
| |
*/ */
'providers' => [ 'providers' => ServiceProvider::defaultProviders()->merge([
/*
* 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,
/* /*
* Package Service Providers... * Package Service Providers...
*/ */
@ -248,10 +178,9 @@ return [
App\Providers\AuthServiceProvider::class, App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class, // App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\HorizonServiceProvider::class, App\Providers\HorizonServiceProvider::class,
App\Providers\RouteServiceProvider::class,
], ])->toArray(),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -265,7 +194,7 @@ return [
*/ */
'aliases' => Facade::defaultAliases()->merge([ 'aliases' => Facade::defaultAliases()->merge([
// 'ExampleClass' => App\Example\ExampleClass::class, // 'Example' => App\Facades\Example::class,
])->toArray(), ])->toArray(),
]; ];

View file

@ -80,7 +80,7 @@ return [
| than one user table or model in the application and you want to have | than one user table or model in the application and you want to have
| separate password reset settings based on the specific user types. | 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 | considered valid. This security feature keeps tokens short-lived so
| they have less time to be guessed. You may change this as needed. | they have less time to be guessed. You may change this as needed.
| |

View file

@ -36,6 +36,7 @@ return [
'secret' => env('PUSHER_APP_SECRET'), 'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'), 'app_id' => env('PUSHER_APP_ID'),
'options' => [ 'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
'port' => env('PUSHER_PORT', 443), 'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'), 'scheme' => env('PUSHER_SCHEME', 'https'),

View file

@ -52,6 +52,7 @@ return [
'file' => [ 'file' => [
'driver' => 'file', 'driver' => 'file',
'path' => storage_path('framework/cache/data'), 'path' => storage_path('framework/cache/data'),
'lock_path' => storage_path('framework/cache/data'),
], ],
'memcached' => [ 'memcached' => [

View file

@ -36,6 +36,7 @@ return [
'mailers' => [ 'mailers' => [
'smtp' => [ 'smtp' => [
'transport' => 'smtp', 'transport' => 'smtp',
'url' => env('MAIL_URL'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587), 'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'), 'encryption' => env('MAIL_ENCRYPTION', 'tls'),

View file

@ -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 | Failed Queue Jobs

View file

@ -6,6 +6,38 @@
*/ */
return [ 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'),
]; ];

View file

@ -3,34 +3,30 @@
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php" bootstrap="vendor/autoload.php"
colors="true" colors="true"
stopOnFailure="true"
> >
<testsuites> <testsuites>
<testsuite name="Unit"> <testsuite name="Unit">
<directory>./tests/Unit</directory> <directory suffix="Test.php">./tests/Unit</directory>
</testsuite> </testsuite>
<testsuite name="Feature"> <testsuite name="Feature">
<directory>./tests/Feature</directory> <directory suffix="Test.php">./tests/Feature</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<coverage pathCoverage="true"> <source>
<include> <include>
<directory suffix=".php">./app</directory> <directory suffix=".php">./app</directory>
</include> </include>
<report> </source>
<html outputDirectory="./public/coverage"/>
</report>
</coverage>
<php> <php>
<env name="APP_ENV" value="testing"/> <env name="APP_ENV" value="testing"/>
<env name="DB_DATABASE" value="jbukdev_testing"/> <env name="DB_DATABASE" value="jbukdev_testing"/>
<env name="BCRYPT_ROUNDS" value="4"/> <env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_DRIVER" value="array"/> <env name="CACHE_DRIVER" value="array"/>
<env name="MAIL_DRIVER" value="array"/> <!-- <env name="DB_CONNECTION" value="sqlite"/> -->
<!-- <env name="DB_DATABASE" value=":memory:"/> -->
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/> <env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/> <env name="SESSION_DRIVER" value="array"/>
<env name="TELESCOPE_ENABLED" value="false"/> <env name="TELESCOPE_ENABLED" value="false"/>
<ini name="memory_limit" value="512M"/>
</php> </php>
</phpunit> </phpunit>

View file

@ -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 | If the application is in maintenance / demo mode via the "down" command
| will require this file so that any prerendered template can be shown | we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception. | instead of starting the framework, which could cause an exception.
| |
*/ */
if (file_exists(__DIR__ . '/../storage/framework/maintenance.php')) { if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require __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); $kernel = $app->make(Kernel::class);
$response = tap($kernel->handle( $response = $kernel->handle(
$request = Request::capture() $request = Request::capture()
))->send(); )->send();
$kernel->terminate($request, $response); $kernel->terminate($request, $response);

View file

@ -1,23 +0,0 @@
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)/$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="/{R:1}" />
</rule>
<rule name="Imported Rule 2" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

View file

@ -21,7 +21,7 @@
<link rel="alternate" type="application/jf2feed+json" title="Notes JF2 Feed" href="/blog/feed.jf2"> <link rel="alternate" type="application/jf2feed+json" title="Notes JF2 Feed" href="/blog/feed.jf2">
<link rel="openid.server" href="https://indieauth.com/openid"> <link rel="openid.server" href="https://indieauth.com/openid">
<link rel="openid.delegate" href="{{ config('app.url') }}"> <link rel="openid.delegate" href="{{ config('app.url') }}">
<link rel="authorization_endpoint" href="{{ config('app.authorization_endpoint') }}"> <link rel="authorization_endpoint" href="{{ config('url.authorization_endpoint') }}">
<link rel="token_endpoint" href="{{ config('app.url') }}/api/token"> <link rel="token_endpoint" href="{{ config('app.url') }}/api/token">
<link rel="micropub" href="{{ config('app.url') }}/api/post"> <link rel="micropub" href="{{ config('app.url') }}/api/post">
<link rel="webmention" href="{{ config('app.url') }}/webmention"> <link rel="webmention" href="{{ config('app.url') }}/webmention">

View file

@ -1,6 +1,7 @@
<?php <?php
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View file

@ -1,16 +1,5 @@
<?php <?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
use App\Http\Controllers\Admin\ArticlesController as AdminArticlesController; use App\Http\Controllers\Admin\ArticlesController as AdminArticlesController;
use App\Http\Controllers\Admin\BioController; use App\Http\Controllers\Admin\BioController;
use App\Http\Controllers\Admin\ClientsController; use App\Http\Controllers\Admin\ClientsController;
@ -37,6 +26,17 @@ use App\Http\Controllers\TokenEndpointController;
use App\Http\Controllers\WebMentionsController; use App\Http\Controllers\WebMentionsController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "web" middleware group. Make something great!
|
*/
Route::group(['domain' => config('url.longurl')], function () { Route::group(['domain' => config('url.longurl')], function () {
Route::get('/', [FrontPageController::class, 'index']); Route::get('/', [FrontPageController::class, 'index']);

View file

@ -1,8 +1,9 @@
config.php
routes.php
schedule-*
compiled.php compiled.php
services.json config.php
events.scanned.php
routes.scanned.php
down down
events.scanned.php
maintenance.php
routes.php
routes.scanned.php
schedule-*
services.json

View file

@ -65,7 +65,7 @@ class FeedsTest extends TestCase
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.displayname'), 'name' => config('user.displayname'),
'url' => config('app.longurl'), 'url' => config('url.longurl'),
], ],
'children' => [[ 'children' => [[
'type' => 'entry', 'type' => 'entry',
@ -126,7 +126,7 @@ class FeedsTest extends TestCase
'author' => [ 'author' => [
'type' => 'card', 'type' => 'card',
'name' => config('user.displayname'), 'name' => config('user.displayname'),
'url' => config('app.longurl'), 'url' => config('url.longurl'),
], ],
'children' => [[ 'children' => [[
'type' => 'entry', 'type' => 'entry',

View file

@ -11,28 +11,28 @@ class ShortURLsControllerTest extends TestCase
/** @test */ /** @test */
public function shortDomainRedirectsToLongDomain(): void public function shortDomainRedirectsToLongDomain(): void
{ {
$response = $this->get('https://' . config('app.shorturl')); $response = $this->get('https://' . config('url.shorturl'));
$response->assertRedirect(config('app.url')); $response->assertRedirect(config('app.url'));
} }
/** @test */ /** @test */
public function shortDomainSlashAtRedirectsToTwitter(): void public function shortDomainSlashAtRedirectsToTwitter(): void
{ {
$response = $this->get('https://' . config('app.shorturl') . '/@'); $response = $this->get('https://' . config('url.shorturl') . '/@');
$response->assertRedirect('https://twitter.com/jonnybarnes'); $response->assertRedirect('https://twitter.com/jonnybarnes');
} }
/** @test */ /** @test */
public function shortDomainSlashTRedirectsToLongDomainSlashNotes(): void 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'); $response->assertRedirect(config('app.url') . '/notes/E');
} }
/** @test */ /** @test */
public function shortDomainSlashBRedirectsToLongDomainSlashBlog(): void 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'); $response->assertRedirect(config('app.url') . '/blog/s/1');
} }
} }

View file

@ -123,7 +123,7 @@ class NotesTest extends TestCase
{ {
$note = Note::factory()->make(); $note = Note::factory()->make();
$note->id = 14; $note->id = 14;
$this->assertEquals(config('app.shorturl') . '/notes/E', $note->shorturl); $this->assertEquals(config('url.shorturl') . '/notes/E', $note->shorturl);
} }
/** @test */ /** @test */

View file

@ -54,7 +54,7 @@ class PlacesTest extends TestCase
$place = Place::factory()->create([ $place = Place::factory()->create([
'name' => 'The Bridgewater Pub', '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 */ /** @test */