mirror of
https://github.com/phpmon/website
synced 2025-08-06 06:20:07 +02:00
Set up redirects
This commit is contained in:
16
app/Http/Redirection.php
Normal file
16
app/Http/Redirection.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
class Redirection
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $url,
|
||||
public readonly string $target,
|
||||
public readonly string $name
|
||||
) {}
|
||||
|
||||
public static function named($name, $url, $target): Redirection {
|
||||
return new Redirection($url, $target,$name);
|
||||
}
|
||||
}
|
@ -43,9 +43,9 @@
|
||||
</h1>
|
||||
<p class="text-2xl leading-8 mt-8"><b>PHP Monitor</b> (“phpmon”) is a lightweight, native Mac menu bar app that interacts with <a href="https://github.com/laravel/valet" class="text-blue-800 underline">Valet</a>.</p>
|
||||
<div class="flex space-x-3 mt-6">
|
||||
<a href="https://nicoverbruggen.be/sponsor" class="mt-4 text-lg px-3 py-2 inline-block bg-blue-900 hover:bg-blue-800 text-white rounded-lg shadow-md">Sponsor</a>
|
||||
<a href="https://github.com/nicoverbruggen/phpmon" class="mt-4 text-lg px-3 py-2 inline-block bg-blue-900 hover:bg-blue-800 text-white rounded-lg shadow-md">GitHub</a>
|
||||
<a href="https://github.com/nicoverbruggen/phpmon/releases" class="mt-4 text-lg px-3 py-2 inline-block bg-green-800 hover:bg-blue-800 text-white rounded-lg shadow-md">Download</a>
|
||||
<a href="{{ url()->route('sponsor') }}" class="mt-4 text-lg px-3 py-2 inline-block bg-blue-900 hover:bg-blue-800 text-white rounded-lg shadow-md">Sponsor</a>
|
||||
<a href="{{ url()->route('github') }}" class="mt-4 text-lg px-3 py-2 inline-block bg-blue-900 hover:bg-blue-800 text-white rounded-lg shadow-md">GitHub</a>
|
||||
<a href="{{ url()->route('releases') }}" class="mt-4 text-lg px-3 py-2 inline-block bg-green-800 hover:bg-blue-800 text-white rounded-lg shadow-md">Download</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
@ -1,9 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use App\Http\Redirection;
|
||||
|
||||
Route::get('/', fn () => view('homepage'));
|
||||
|
||||
Route::get('/github', fn () => redirect()->to('https://github.com/nicoverbruggen/phpmon'));
|
||||
Route::get('/sponsor', fn () => redirect()->to('https://nicoverbruggen.be/sponsor'));
|
||||
Route::get('/donate', fn () => redirect()->to('https://nicoverbruggen.be/sponsor'));
|
||||
collect([
|
||||
Redirection::named('github', '/github', 'https://github.com/nicoverbruggen/phpmon'),
|
||||
Redirection::named('releases', '/releases', 'https://github.com/nicoverbruggen/phpmon/releases'),
|
||||
Redirection::named('faq', '/faq', 'https://github.com/nicoverbruggen/phpmon#%EF%B8%8F-faq--troubleshooting'),
|
||||
Redirection::named('sponsor', '/sponsor', 'https://nicoverbruggen.be/sponsor'),
|
||||
Redirection::named('sponsor.now', '/sponsor/now', 'https://nicoverbruggen.be/sponsor#pay-now'),
|
||||
])->each(function (Redirection $r) {
|
||||
Route::get($r->url, fn () => redirect()->to($r->target))->name($r->name);
|
||||
});
|
20
tests/Feature/RedirectReachabilityTest.php
Normal file
20
tests/Feature/RedirectReachabilityTest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class RedirectReachabilityTest extends TestCase
|
||||
{
|
||||
public function test_redirects_work()
|
||||
{
|
||||
$response = $this->get('/github');
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect('https://github.com/nicoverbruggen/phpmon');
|
||||
|
||||
$this->get('/faq')->assertStatus(302);
|
||||
$this->get('/releases')->assertStatus(302);
|
||||
$this->get('/sponsor')->assertStatus(302);
|
||||
$this->get('/sponsor/now')->assertStatus(302);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user