Upgrade to Laravel 8

This commit is contained in:
Jonny Barnes 2020-10-17 17:15:06 +01:00
parent 1ad58f10c5
commit 57186c3e2e
27 changed files with 945 additions and 1003 deletions

View file

@ -37,16 +37,6 @@ class ShortURLsController extends Controller
return redirect('https://twitter.com/jonnybarnes'); return redirect('https://twitter.com/jonnybarnes');
} }
/**
* Redirect from '/+' to a Google+ profile.
*
* @return RedirectResponse
*/
public function googlePlus(): RedirectResponse
{
return redirect('https://plus.google.com/u/0/117317270900655269082/about');
}
/** /**
* Redirect a short url of this site out to a long one based on post type. * Redirect a short url of this site out to a long one based on post type.
* Further redirects may happen. * Further redirects may happen.

View file

@ -7,6 +7,7 @@ namespace App\Models;
use App\Traits\FilterHtml; use App\Traits\FilterHtml;
use Eloquent; use Eloquent;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
@ -37,6 +38,7 @@ use Mf2;
class Like extends Model class Like extends Model
{ {
use FilterHtml; use FilterHtml;
use HasFactory;
protected $fillable = ['url']; protected $fillable = ['url'];

View file

@ -7,6 +7,7 @@ namespace App\Models;
use Eloquent; use Eloquent;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
@ -33,6 +34,8 @@ use Illuminate\Support\Carbon;
*/ */
class MicropubClient extends Model class MicropubClient extends Model
{ {
use HasFactory;
/** /**
* The table associated with the model. * The table associated with the model.
* *

View file

@ -10,7 +10,7 @@ use Eloquent;
use Exception; use Exception;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Illuminate\Database\Eloquent\Relations\{BelongsTo, BelongsToMany, HasMany, MorphMany}; use Illuminate\Database\Eloquent\Relations\{BelongsTo, BelongsToMany, HasMany, MorphMany};
use Illuminate\Database\Eloquent\{Builder, Collection, Model, SoftDeletes}; use Illuminate\Database\Eloquent\{Builder, Collection, Factories\HasFactory, Model, SoftDeletes};
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Cache;
use Jonnybarnes\IndieWeb\Numbers; use Jonnybarnes\IndieWeb\Numbers;
@ -88,6 +88,7 @@ use Spatie\CommonMarkHighlighter\{FencedCodeRenderer, IndentedCodeRenderer};
*/ */
class Note extends Model class Note extends Model
{ {
use HasFactory;
use Searchable; use Searchable;
use SoftDeletes; use SoftDeletes;

View file

@ -7,7 +7,7 @@ namespace App\Models;
use Cviebrock\EloquentSluggable\Sluggable; use Cviebrock\EloquentSluggable\Sluggable;
use Eloquent; use Eloquent;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\{Builder, Collection, Model}; use Illuminate\Database\Eloquent\{Builder, Collection, Factories\HasFactory, Model};
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Str; use Illuminate\Support\Str;
@ -51,6 +51,7 @@ use Illuminate\Support\Str;
*/ */
class Place extends Model class Place extends Model
{ {
use HasFactory;
use Sluggable; use Sluggable;
/** /**

View file

@ -2,7 +2,10 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider
@ -12,9 +15,9 @@ class RouteServiceProvider extends ServiceProvider
* *
* In addition, it is set as the URL generator's root namespace. * In addition, it is set as the URL generator's root namespace.
* *
* @var string * @var string|null
*/ */
protected $namespace = 'App\Http\Controllers'; // protected $namespace = 'App\Http\Controllers';
/** /**
* Define your route model bindings, pattern filters, etc. * Define your route model bindings, pattern filters, etc.
@ -23,51 +26,29 @@ class RouteServiceProvider extends ServiceProvider
*/ */
public function boot() public function boot()
{ {
// $this->configureRateLimiting();
parent::boot(); $this->routes(function () {
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api') Route::prefix('api')
->middleware('api') ->middleware('api')
->namespace($this->namespace) ->namespace($this->namespace)
->group(base_path('routes/api.php')); ->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60);
});
} }
} }

View file

@ -1,7 +1,7 @@
{ {
"name": "jonnybarnes/jonnybarnes.uk", "name": "jonnybarnes/jonnybarnes.uk",
"type": "project", "type": "project",
"description": "The code for jonnybarnes.uk, based on Laravel 5.8", "description": "The code for jonnybarnes.uk, based on Laravel 8",
"keywords": [ "keywords": [
"framework", "framework",
"laravel", "laravel",
@ -13,18 +13,18 @@
"ext-intl": "*", "ext-intl": "*",
"ext-json": "*", "ext-json": "*",
"ext-dom": "*", "ext-dom": "*",
"cviebrock/eloquent-sluggable": "~7.0", "cviebrock/eloquent-sluggable": "^8.0",
"fideloper/proxy": "~4.0", "fideloper/proxy": "~4.0",
"guzzlehttp/guzzle": "~6.0", "guzzlehttp/guzzle": "^7.0.1",
"indieauth/client": "~0.1", "indieauth/client": "~0.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": "^7.0", "laravel/framework": "^8.0",
"laravel/horizon": "^4.0", "laravel/horizon": "^5.0",
"laravel/scout": "^8.0", "laravel/scout": "^8.0",
"laravel/telescope": "^3.0", "laravel/telescope": "^4.0",
"laravel/tinker": "^2.0", "laravel/tinker": "^2.0",
"lcobucci/jwt": "^3.1", "lcobucci/jwt": "^3.1",
"league/commonmark": "^1.0", "league/commonmark": "^1.0",
@ -32,7 +32,6 @@
"mf2/mf2": "~0.3", "mf2/mf2": "~0.3",
"pmatseykanets/laravel-scout-postgres": "^7.0", "pmatseykanets/laravel-scout-postgres": "^7.0",
"predis/predis": "~1.0", "predis/predis": "~1.0",
"ramsey/uuid": "^3.5",
"sensiolabs/security-checker": "^6.0", "sensiolabs/security-checker": "^6.0",
"spatie/browsershot": "~3.0", "spatie/browsershot": "~3.0",
"spatie/commonmark-highlighter": "^2.0", "spatie/commonmark-highlighter": "^2.0",
@ -42,11 +41,11 @@
"barryvdh/laravel-debugbar": "^3.0", "barryvdh/laravel-debugbar": "^3.0",
"barryvdh/laravel-ide-helper": "^2.6", "barryvdh/laravel-ide-helper": "^2.6",
"beyondcode/laravel-dump-server": "^1.0", "beyondcode/laravel-dump-server": "^1.0",
"facade/ignition": "^2.0", "facade/ignition": "^2.3.6",
"fzaninotto/faker": "^1.9.1", "fzaninotto/faker": "^1.9.1",
"laravel/dusk": "^6.0", "laravel/dusk": "^6.0",
"mockery/mockery": "^1.0", "mockery/mockery": "^1.0",
"nunomaduro/collision": "^4.1", "nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.0", "phpunit/phpunit": "^9.0",
"vimeo/psalm": "^3.9" "vimeo/psalm": "^3.9"
}, },
@ -62,12 +61,10 @@
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"App\\": "app/" "App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
}, },
"classmap": [
"database/seeds",
"database/factories"
],
"files": [ "files": [
"helpers.php" "helpers.php"
] ]

1286
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,35 @@
<?php <?php
use App\Models\Bookmark; namespace Database\Factories;
use Faker\Generator as Faker;
use App\Models\Bookmark;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
class BookmarkFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Bookmark::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$now = Carbon::now()->subDays(rand(5, 15));
$factory->define(Bookmark::class, function (Faker $faker) {
return [ return [
'url' => $faker->url, 'url' => $this->faker->url,
'name' => $faker->sentence, 'name' => $this->faker->sentence,
'content' => $faker->text, 'content' => $this->faker->text,
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]; ];
}); }
}

View file

@ -1,13 +1,36 @@
<?php <?php
use App\Models\Like; namespace Database\Factories;
use Faker\Generator as Faker;
use App\Models\Like;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
class LikeFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Like::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$now = Carbon::now()->subDays(rand(5, 15));
$factory->define(Like::class, function (Faker $faker) {
return [ return [
'url' => $faker->url, 'url' => $this->faker->url,
'author_name' => $faker->name, 'author_name' => $this->faker->name,
'author_url' => $faker->url, 'author_url' => $this->faker->url,
'content' => '<html><body><div class="h-entry"><div class="e-content">' . $faker->realtext() . '</div></div></body></html>', 'content' => '<html><body><div class="h-entry"><div class="e-content">' . $this->faker->realtext() . '</div></div></body></html>',
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]; ];
}); }
}

View file

@ -0,0 +1,29 @@
<?php
namespace Database\Factories;
use App\Models\MicropubClient;
use Illuminate\Database\Eloquent\Factories\Factory;
class MicropubClientFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = MicropubClient::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'client_url' => $this->faker->url,
'client_name' => $this->faker->company,
];
}
}

View file

@ -1,14 +1,33 @@
<?php <?php
namespace Database\Factories;
use App\Models\Note; use App\Models\Note;
use Faker\Generator as Faker; use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
$factory->define(Note::class, function (Faker $faker) { class NoteFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Note::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$now = Carbon::now()->subDays(rand(5, 15)); $now = Carbon::now()->subDays(rand(5, 15));
return [ return [
'note' => $faker->paragraph, 'note' => $this->faker->paragraph,
'created_at' => $now, 'created_at' => $now,
'updated_at' => $now, 'updated_at' => $now,
]; ];
}); }
}

View file

@ -0,0 +1,32 @@
<?php
namespace Database\Factories;
use App\Models\Place;
use Illuminate\Database\Eloquent\Factories\Factory;
class PlaceFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Place::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
'name' => $this->faker->company,
'description' => $this->faker->sentence,
'latitude' => $this->faker->latitude,
'longitude' => $this->faker->longitude,
'external_urls' => $this->faker->url,
];
}
}

View file

@ -1,10 +1,28 @@
<?php <?php
use App\Models\Tag; namespace Database\Factories;
use Faker\Generator as Faker;
$factory->define(Tag::class, function (Faker $faker) { use App\Models\Tag;
use Illuminate\Database\Eloquent\Factories\Factory;
class TagFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Tag::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'tag' => $faker->word, 'tag' => $this->faker->word,
]; ];
}); }
}

View file

@ -1,24 +1,31 @@
<?php <?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Faker\Generator as Faker;
/* class UserFactory extends Factory
|-------------------------------------------------------------------------- {
| Model Factories /**
|-------------------------------------------------------------------------- * The name of the factory's corresponding model.
| *
| This directory should contain each of the model factory definitions for * @var string
| your application. Factories provide a convenient way to generate new */
| model instances for testing / seeding your application's database. protected $model = User::class;
|
*/
$factory->define(App\Models\User::class, function (Faker $faker) {
static $password;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [ return [
'name' => mb_strtolower($faker->firstName), 'name' => $this->faker->name,
'password' => $password ?: $password = bcrypt('secret'), 'password' => bcrypt('password'),
'remember_token' => Str::random(10), 'remember_token' => Str::random(10),
]; ];
}); }
}

View file

@ -1,5 +1,7 @@
<?php <?php
namespace Database\Seeders;
use App\Models\Article; use App\Models\Article;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;

View file

@ -1,5 +1,7 @@
<?php <?php
namespace Database\Seeders;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use App\Models\{Bookmark, Tag}; use App\Models\{Bookmark, Tag};
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@ -14,6 +16,7 @@ class BookmarksTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
Bookmark::factory(10)->create();
factory(Bookmark::class, 10)->create()->each(function ($bookmark) { factory(Bookmark::class, 10)->create()->each(function ($bookmark) {
$bookmark->tags()->save(factory(Tag::class)->make()); $bookmark->tags()->save(factory(Tag::class)->make());

View file

@ -1,7 +1,11 @@
<?php <?php
namespace Database\Seeders;
use App\Models\MicropubClient;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class ClientsTableSeeder extends Seeder class ClientsTableSeeder extends Seeder
{ {
@ -25,5 +29,7 @@ class ClientsTableSeeder extends Seeder
'created_at' => Carbon::now()->toDateTimeString(), 'created_at' => Carbon::now()->toDateTimeString(),
'updated_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString(),
]); ]);
MicropubClient::factory(5)->create();
} }
} }

View file

@ -1,5 +1,7 @@
<?php <?php
namespace Database\Seeders;
use App\Models\Contact; use App\Models\Contact;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\FileSystem\FileSystem; use Illuminate\FileSystem\FileSystem;

View file

@ -1,5 +1,7 @@
<?php <?php
namespace Database\Seeders;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder class DatabaseSeeder extends Seeder

View file

@ -1,5 +1,7 @@
<?php <?php
namespace Database\Seeders;
use App\Models\Like; use App\Models\Like;
use Faker\Generator; use Faker\Generator;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
@ -15,15 +17,7 @@ class LikesTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
factory(Like::class, 10)->create()->each(function ($like) { Like::factory(10)->create();
$now = Carbon::now()->subDays(rand(5, 15));
DB::table('likes')
->where('id', $like->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
});
$now = Carbon::now()->subDays(rand(3, 6)); $now = Carbon::now()->subDays(rand(3, 6));
$faker = new Generator(); $faker = new Generator();

View file

@ -1,9 +1,12 @@
<?php <?php
namespace Database\Seeders;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use App\Models\{Media, Note, Place}; use App\Models\{Media, Note, Place};
use SplFileInfo;
class NotesTableSeeder extends Seeder class NotesTableSeeder extends Seeder
{ {
@ -205,5 +208,7 @@ EOF;
DB::table('notes') DB::table('notes')
->where('id', $noteWithLongUrl->id) ->where('id', $noteWithLongUrl->id)
->update(['updated_at' => $now->toDateTimeString()]); ->update(['updated_at' => $now->toDateTimeString()]);
Note::factory(10)->create();
} }
} }

View file

@ -1,5 +1,7 @@
<?php <?php
namespace Database\Seeders;
use App\Models\Place; use App\Models\Place;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@ -20,5 +22,7 @@ class PlacesTableSeeder extends Seeder
$place->external_urls = 'https://foursquare.com/v/123435/the-bridgewater-pub'; $place->external_urls = 'https://foursquare.com/v/123435/the-bridgewater-pub';
$place->external_urls = 'https://www.openstreetmap.org/way/987654'; $place->external_urls = 'https://www.openstreetmap.org/way/987654';
$place->save(); $place->save();
Place::factory(10)->create();
} }
} }

View file

@ -1,5 +1,7 @@
<?php <?php
namespace Database\Seeders;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;

View file

@ -1,5 +1,7 @@
<?php <?php
namespace Database\Seeders;
use App\Models\WebMention; use App\Models\WebMention;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
@ -12,7 +14,8 @@ class WebMentionsTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
$webmentionAaron = WebMention::create([ // WebMention Aaron
WebMention::create([
'source' => 'https://aaronpk.localhost/reply/1', 'source' => 'https://aaronpk.localhost/reply/1',
'target' => config('app.url') . '/notes/E', 'target' => config('app.url') . '/notes/E',
'commentable_id' => '14', 'commentable_id' => '14',
@ -20,7 +23,8 @@ class WebMentionsTableSeeder extends Seeder
'type' => 'in-reply-to', 'type' => 'in-reply-to',
'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"url": ["https://aaronpk.localhost/reply/1"], "name": ["Hi too"], "author": [{"type": ["h-card"], "value": "Aaron Parecki", "properties": {"url": ["https://aaronpk.localhost"], "name": ["Aaron Parecki"], "photo": ["https://aaronparecki.com/images/profile.jpg"]}}], "content": [{"html": "Hi too", "value": "Hi too"}], "published": ["' . date(DATE_W3C) . '"], "in-reply-to": ["https://aaronpk.loclahost/reply/1", "' . config('app.url') .'/notes/E"]}}]}' 'mf2' => '{"rels": [], "items": [{"type": ["h-entry"], "properties": {"url": ["https://aaronpk.localhost/reply/1"], "name": ["Hi too"], "author": [{"type": ["h-card"], "value": "Aaron Parecki", "properties": {"url": ["https://aaronpk.localhost"], "name": ["Aaron Parecki"], "photo": ["https://aaronparecki.com/images/profile.jpg"]}}], "content": [{"html": "Hi too", "value": "Hi too"}], "published": ["' . date(DATE_W3C) . '"], "in-reply-to": ["https://aaronpk.loclahost/reply/1", "' . config('app.url') .'/notes/E"]}}]}'
]); ]);
$webmentionTantek = WebMention::create([ // WebMention Tantek
WebMention::create([
'source' => 'http://tantek.com/', 'source' => 'http://tantek.com/',
'target' => config('app.url') . '/notes/D', 'target' => config('app.url') . '/notes/D',
'commentable_id' => '13', 'commentable_id' => '13',

View file

@ -1,60 +1,55 @@
<?php <?php
/** use Illuminate\Contracts\Http\Kernel;
* Laravel - A PHP Framework For Web Artisans use Illuminate\Http\Request;
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
define('LARAVEL_START', microtime(true)); define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Check If 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
| 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 | Register The Auto Loader
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Composer provides a convenient, automatically generated class loader for | Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it | this 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 | into the script here so we don't need to manually load our classes.
| loading any of our classes later on. It feels great to relax.
| |
*/ */
require __DIR__.'/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| 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.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Run The Application | Run The Application
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Once we have the application, we can handle the incoming request | Once we have the application, we can handle the incoming request using
| through the kernel, and send the associated response back to | the application's HTTP kernel. Then, we will send the response back
| the client's browser allowing them to enjoy the creative | to this client's browser, allowing them to enjoy our application.
| and wonderful application we have prepared for them.
| |
*/ */
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); $app = require_once __DIR__ . '/../bootstrap/app.php';
$response = $kernel->handle( $kernel = $app->make(Kernel::class);
$request = Illuminate\Http\Request::capture()
);
$response->send(); $response = tap($kernel->handle(
$request = Request::capture()
))->send();
$kernel->terminate($request, $response); $kernel->terminate($request, $response);

View file

@ -11,10 +11,32 @@
| |
*/ */
use App\Http\Controllers\Admin\ArticlesController as AdminArticlesController;
use App\Http\Controllers\Admin\ClientsController;
use App\Http\Controllers\Admin\ContactsController as AdminContactsController;
use App\Http\Controllers\Admin\HomeController;
use App\Http\Controllers\Admin\LikesController as AdminLikesController;
use App\Http\Controllers\Admin\NotesController as AdminNotesController;
use App\Http\Controllers\Admin\PlacesController as AdminPlacesController;
use App\Http\Controllers\ArticlesController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\BookmarksController;
use App\Http\Controllers\ContactsController;
use App\Http\Controllers\FeedsController;
use App\Http\Controllers\FrontPageController;
use App\Http\Controllers\LikesController;
use App\Http\Controllers\MicropubController;
use App\Http\Controllers\MicropubMediaController;
use App\Http\Controllers\NotesController;
use App\Http\Controllers\PlacesController;
use App\Http\Controllers\SearchController;
use App\Http\Controllers\ShortURLsController;
use App\Http\Controllers\TokenEndpointController;
use App\Http\Controllers\WebMentionsController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
Route::group(['domain' => config('url.longurl')], function () { Route::group(['domain' => config('url.longurl')], function () {
Route::get('/', 'FrontPageController@index'); Route::get('/', [FrontPageController::class, 'index']);
// Static project page // Static project page
Route::view('projects', 'projects'); Route::view('projects', 'projects');
@ -23,12 +45,12 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::view('colophon', 'colophon'); Route::view('colophon', 'colophon');
// The login routes to get authd for admin // The login routes to get authd for admin
Route::get('login', 'AuthController@showLogin')->name('login'); Route::get('login', [AuthController::class, 'showLogin'])->name('login');
Route::post('login', 'AuthController@login'); Route::post('login', [AuthController::class, 'login']);
// And the logout routes // And the logout routes
Route::get('logout', 'AuthController@showLogout')->name('logout'); Route::get('logout', [AuthController::class, 'showLogout'])->name('logout');
Route::post('logout', 'AuthController@logout'); Route::post('logout', [AuthController::class, 'logout']);
// Admin pages grouped for filter // Admin pages grouped for filter
Route::group([ Route::group([
@ -36,149 +58,146 @@ Route::group(['domain' => config('url.longurl')], function () {
'namespace' => 'Admin', 'namespace' => 'Admin',
'prefix' => 'admin', 'prefix' => 'admin',
], function () { ], function () {
Route::get('/', 'HomeController@welcome'); Route::get('/', [HomeController::class, 'welcome']);
//Articles //Articles
Route::group(['prefix' => 'blog'], function () { Route::group(['prefix' => 'blog'], function () {
Route::get('/', 'ArticlesController@index'); Route::get('/', [AdminArticlesController::class, 'index']);
Route::get('/create', 'ArticlesController@create'); Route::get('/create', [AdminArticlesController::class, 'create']);
Route::post('/', 'ArticlesController@store'); Route::post('/', [AdminArticlesController::class, 'store']);
Route::get('/{id}/edit', 'ArticlesController@edit'); Route::get('/{id}/edit', [AdminArticlesController::class, 'edit']);
Route::put('/{id}', 'ArticlesController@update'); Route::put('/{id}', [AdminArticlesController::class, 'update']);
Route::delete('/{id}', 'ArticlesController@destroy'); Route::delete('/{id}', [AdminArticlesController::class, 'destroy']);
}); });
// Notes // Notes
Route::group(['prefix' => 'notes'], function () { Route::group(['prefix' => 'notes'], function () {
Route::get('/', 'NotesController@index'); Route::get('/', [AdminNotesController::class, 'index']);
Route::get('/create', 'NotesController@create'); Route::get('/create', [AdminNotesController::class, 'create']);
Route::post('/', 'NotesController@store'); Route::post('/', [AdminNotesController::class, 'store']);
Route::get('/{id}/edit', 'NotesController@edit'); Route::get('/{id}/edit', [AdminNotesController::class, 'edit']);
Route::put('/{id}', 'NotesController@update'); Route::put('/{id}', [AdminNotesController::class, 'update']);
Route::delete('/{id}', 'NotesController@destroy'); Route::delete('/{id}', [AdminNotesController::class, 'destroy']);
}); });
// Micropub Clients // Micropub Clients
Route::group(['prefix' => 'clients'], function () { Route::group(['prefix' => 'clients'], function () {
Route::get('/', 'ClientsController@index'); Route::get('/', [ClientsController::class, 'index']);
Route::get('/create', 'ClientsController@create'); Route::get('/create', [ClientsController::class, 'create']);
Route::post('/', 'ClientsController@store'); Route::post('/', [ClientsController::class, 'store']);
Route::get('/{id}/edit', 'ClientsController@edit'); Route::get('/{id}/edit', [ClientsController::class, 'edit']);
Route::put('/{id}', 'ClientsController@update'); Route::put('/{id}', [ClientsController::class, 'update']);
Route::delete('/{id}', 'ClientsController@destroy'); Route::delete('/{id}', [ClientsController::class, 'destroy']);
}); });
// Contacts // Contacts
Route::group(['prefix' => 'contacts'], function () { Route::group(['prefix' => 'contacts'], function () {
Route::get('/', 'ContactsController@index'); Route::get('/', [AdminContactsController::class, 'index']);
Route::get('/create', 'ContactsController@create'); Route::get('/create', [AdminContactsController::class, 'create']);
Route::post('/', 'ContactsController@store'); Route::post('/', [AdminContactsController::class, 'store']);
Route::get('/{id}/edit', 'ContactsController@edit'); Route::get('/{id}/edit', [AdminContactsController::class, 'edit']);
Route::put('/{id}', 'ContactsController@update'); Route::put('/{id}', [AdminContactsController::class, 'update']);
Route::delete('/{id}', 'ContactsController@destroy'); Route::delete('/{id}', [AdminContactsController::class, 'destroy']);
Route::get('/{id}/getavatar', 'ContactsController@getAvatar'); Route::get('/{id}/getavatar', [AdminContactsController::class, 'getAvatar']);
}); });
// Places // Places
Route::group(['prefix' => 'places'], function () { Route::group(['prefix' => 'places'], function () {
Route::get('/', 'PlacesController@index'); Route::get('/', [AdminPlacesController::class, 'index']);
Route::get('/create', 'PlacesController@create'); Route::get('/create', [AdminPlacesController::class, 'create']);
Route::post('/', 'PlacesController@store'); Route::post('/', [AdminPlacesController::class, 'store']);
Route::get('/{id}/edit', 'PlacesController@edit'); Route::get('/{id}/edit', [AdminPlacesController::class, 'edit']);
Route::put('/{id}', 'PlacesController@update'); Route::put('/{id}', [AdminPlacesController::class, 'update']);
Route::get('/{id}/merge', 'PlacesController@mergeIndex'); Route::get('/{id}/merge', [AdminPlacesController::class, 'mergeIndex']);
Route::get('/{place1_id}/merge/{place2_id}', 'PlacesController@mergeEdit'); Route::get('/{place1_id}/merge/{place2_id}', [AdminPlacesController::class, 'mergeEdit']);
Route::post('/merge', 'PlacesController@mergeStore'); Route::post('/merge', [AdminPlacesController::class, 'mergeStore']);
Route::delete('/{id}', 'PlacesController@destroy'); Route::delete('/{id}', [AdminPlacesController::class, 'destroy']);
}); });
// Likes // Likes
Route::group(['prefix' => 'likes'], function () { Route::group(['prefix' => 'likes'], function () {
Route::get('/', 'LikesController@index'); Route::get('/', [AdminLikesController::class, 'index']);
Route::get('/create', 'LikesController@create'); Route::get('/create', [AdminLikesController::class, 'create']);
Route::post('/', 'LikesController@store'); Route::post('/', [AdminLikesController::class, 'store']);
Route::get('/{id}/edit', 'LikesController@edit'); Route::get('/{id}/edit', [AdminLikesController::class, 'edit']);
Route::put('/{id}', 'LikesController@update'); Route::put('/{id}', [AdminLikesController::class, 'update']);
Route::delete('/{id}', 'LikesController@destroy'); Route::delete('/{id}', [AdminLikesController::class, 'destroy']);
}); });
}); });
// Blog pages using ArticlesController // Blog pages using ArticlesController
Route::group(['prefix' => 'blog'], function () { Route::group(['prefix' => 'blog'], function () {
Route::get('/feed.rss', 'FeedsController@blogRss'); Route::get('/feed.rss', [FeedsController::class, 'blogRss']);
Route::get('/feed.atom', 'FeedsController@blogAtom'); Route::get('/feed.atom', [FeedsController::class, 'blogAtom']);
Route::get('/feed.json', 'FeedsController@blogJson'); Route::get('/feed.json', [FeedsController::class, 'blogJson']);
Route::get('/feed.jf2', 'Feedscontroller@blogJf2'); Route::get('/feed.jf2', [Feedscontroller::class, 'blogJf2']);
Route::get('/s/{id}', 'ArticlesController@onlyIdInURL'); Route::get('/s/{id}', [ArticlesController::class, 'onlyIdInURL']);
Route::get('/{year?}/{month?}', 'ArticlesController@index'); Route::get('/{year?}/{month?}', [ArticlesController::class, 'index']);
Route::get('/{year}/{month}/{slug}', 'ArticlesController@show'); Route::get('/{year}/{month}/{slug}', [ArticlesController::class, 'show']);
}); });
// Notes pages using NotesController // Notes pages using NotesController
Route::group(['prefix' => 'notes'], function () { Route::group(['prefix' => 'notes'], function () {
Route::get('/', 'NotesController@index'); Route::get('/', [NotesController::class, 'index']);
Route::get('/feed.rss', 'FeedsController@notesRss'); Route::get('/feed.rss', [FeedsController::class, 'notesRss']);
Route::get('/feed.atom', 'FeedsController@notesAtom'); Route::get('/feed.atom', [FeedsController::class, 'notesAtom']);
Route::get('/feed.json', 'FeedsController@notesJson'); Route::get('/feed.json', [FeedsController::class, 'notesJson']);
Route::get('/feed.jf2', 'FeedsController@notesJf2'); Route::get('/feed.jf2', [FeedsController::class, 'notesJf2']);
Route::get('/{id}', 'NotesController@show'); Route::get('/{id}', [NotesController::class, 'show']);
Route::get('/tagged/{tag}', 'NotesController@tagged'); Route::get('/tagged/{tag}', [NotesController::class, 'tagged']);
}); });
Route::get('note/{id}', 'NotesController@redirect'); // for legacy note URLs Route::get('note/{id}', [NotesController::class, 'redirect']); // for legacy note URLs
// Likes // Likes
Route::group(['prefix' => 'likes'], function () { Route::group(['prefix' => 'likes'], function () {
Route::get('/', 'LikesController@index'); Route::get('/', [LikesController::class, 'index']);
Route::get('/{like}', 'LikesController@show'); Route::get('/{like}', [LikesController::class, 'show']);
}); });
// Bookmarks // Bookmarks
Route::group(['prefix' => 'bookmarks'], function () { Route::group(['prefix' => 'bookmarks'], function () {
Route::get('/', 'BookmarksController@index'); Route::get('/', [BookmarksController::class, 'index']);
Route::get('/{bookmark}', 'BookmarksController@show'); Route::get('/{bookmark}', [BookmarksController::class, 'show']);
}); });
// Token Endpoint // Token Endpoint
Route::post('api/token', 'TokenEndpointController@create'); Route::post('api/token', [TokenEndpointController::class, 'create']);
// Micropub Endpoints // Micropub Endpoints
Route::get('api/post', 'MicropubController@get')->middleware('micropub.token'); Route::get('api/post', [MicropubController::class, 'get'])->middleware('micropub.token');
Route::post('api/post', 'MicropubController@post')->middleware('micropub.token'); Route::post('api/post', [MicropubController::class, 'post'])->middleware('micropub.token');
Route::get('api/media', 'MicropubMediaController@getHandler')->middleware('micropub.token'); Route::get('api/media', [MicropubMediaController::class, 'getHandler'])->middleware('micropub.token');
Route::post('api/media', 'MicropubMediaController@media') Route::post('api/media', [MicropubMediaController:: class, 'media'])
->middleware('micropub.token', 'cors') ->middleware('micropub.token', 'cors')
->name('media-endpoint'); ->name('media-endpoint');
Route::options('/api/media', 'MicropubMediaController@mediaOptionsResponse')->middleware('cors'); Route::options('/api/media', [MicropubMediaController::class, 'mediaOptionsResponse'])->middleware('cors');
// Webmention // Webmention
Route::get('webmention', 'WebMentionsController@get'); Route::get('webmention', [WebMentionsController::class, 'get']);
Route::post('webmention', 'WebMentionsController@receive'); Route::post('webmention', [WebMentionsController::class, 'receive']);
// Contacts // Contacts
Route::get('contacts', 'ContactsController@index'); Route::get('contacts', [ContactsController::class, 'index']);
Route::get('contacts/{contact:nick}', 'ContactsController@show'); Route::get('contacts/{contact:nick}', [ContactsController::class, 'show']);
// Places // Places
Route::get('places', 'PlacesController@index'); Route::get('places', [PlacesController::class, 'index']);
Route::get('places/{place}', 'PlacesController@show'); Route::get('places/{place}', [PlacesController::class, 'show']);
Route::get('search', 'SearchController@search'); Route::get('search', [SearchController::class, 'search']);
Route::post('update-colour-scheme', 'SessionStoreController@saveColour');
}); });
// Short URL // Short URL
Route::group(['domain' => config('url.shorturl')], function () { Route::group(['domain' => config('url.shorturl')], function () {
Route::get('/', 'ShortURLsController@baseURL'); Route::get('/', [ShortURLsController::class, 'baseURL']);
Route::get('@', 'ShortURLsController@twitter'); Route::get('@', [ShortURLsController::class, 'twitter']);
Route::get('+', 'ShortURLsController@googlePlus');
Route::get('{type}/{id}', 'ShortURLsController@expandType')->where( Route::get('{type}/{id}', [ShortURLsController::class, 'expandType'])->where(
[ [
'type' => '[bt]', 'type' => '[bt]',
'id' => '[0-9A-HJ-NP-Z_a-km-z]+', 'id' => '[0-9A-HJ-NP-Z_a-km-z]+',
] ]
); );
Route::get('h/{id}', 'ShortURLsController@redirect'); Route::get('h/{id}', [ShortURLsController::class, 'redirect']);
}); });