Skip to content

Commit 8377e18

Browse files
committed
updated no-route redirect, error message design
Signed-off-by: bidi <bidi@apidemia.com>
1 parent 6298e79 commit 8377e18

7 files changed

Lines changed: 30 additions & 121 deletions

File tree

public/css/app.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/App/assets/scss/components/_custom.scss

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,10 @@ html[data-theme="light"] .theme-toggle {
519519

520520
p.sub {
521521
font-size: 18px;
522-
margin-top: 20px;
523-
max-width: 520px;
522+
max-width: 547px;
524523
color: var(--text-muted);
524+
margin: 20px auto;
525+
text-align: center;
525526

526527
strong {
527528
color: var(--page-accent, var(--teal));
@@ -537,8 +538,25 @@ html[data-theme="light"] .theme-toggle {
537538
align-items: center;
538539
}
539540

541+
/* ============================================================
542+
Error pages
543+
============================================================ */
544+
545+
h1.error-code {
546+
text-align: center;
547+
}
548+
549+
.hero h1.error-code {
550+
font-size: 88px;
551+
}
552+
553+
.page-intro h1.error-code {
554+
font-size: 80px;
555+
}
556+
540557
.hero-ctas {
541558
display: flex;
559+
justify-content: center;
542560
gap: 14px;
543561
margin-top: 32px;
544562
flex-wrap: wrap;
@@ -1460,6 +1478,10 @@ footer {
14601478
font-size: 32px;
14611479
}
14621480

1481+
.hero h1.error-code {
1482+
font-size: 64px;
1483+
}
1484+
14631485
.products-grid {
14641486
grid-template-columns: 1fr;
14651487
}

src/App/src/RoutesDelegator.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,6 @@ public function __invoke(ContainerInterface $container, string $serviceName, cal
3434
GetPackagesViewHandler::TEMPLATE
3535
);
3636

37-
$app->get('/{wpPath:wp-.*}', function () {
38-
return new RedirectResponse('/', 301);
39-
});
40-
41-
$app->get('/{first}', function ($request) {
42-
$uri = $request->getUri();
43-
return new RedirectResponse((string) $uri . '/', 301);
44-
});
45-
46-
$app->get('/{first}/{second}', function ($request) {
47-
$uri = $request->getUri();
48-
return new RedirectResponse((string) $uri . '/', 301);
49-
});
50-
5137
return $app;
5238
}
5339
}

src/App/templates/error/404.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<section class="hero">
88
<div class="wrap">
99
<span class="eyebrow">Oops! This is awkward.</span>
10-
<h1>404</h1>
10+
<h1 class="error-code">404</h1>
1111
<p class="sub">
12-
You are looking for something that doesn't exist or may have moved.
12+
You are looking for something that doesn't exist or may have moved.<br>
1313
Check out one of the categories below, or head back home.
1414
</p>
1515

src/App/templates/error/410.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<section class="hero">
88
<div class="wrap">
99
<span class="eyebrow">Gone. This article was removed.</span>
10-
<h1>410</h1>
10+
<h1 class="error-code">410</h1>
1111
<p class="sub">
12-
The content was misleading, old and obsolete, so we removed it.
12+
The content was misleading, old and obsolete, so we removed it.<br>
1313
It is gone for good and won't be coming back.
1414
</p>
1515

src/App/templates/error/error.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<div class="page-intro home-intro error-messages">
88
<div class="container">
99
<span class="eyebrow">Oops! This is awkward.</span>
10-
<h1>{{ status }}</h1>
10+
<h1 class="error-code">{{ status }}</h1>
1111
<h2 class="message">{{ reason }}</h2>
1212
</div>
1313
</div>

test/Unit/App/RoutesDelegatorTest.php

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace LightTest\Unit\App;
66

7-
use Laminas\Diactoros\Response\RedirectResponse;
87
use Light\App\Handler\GetFeedViewHandler;
98
use Light\App\Handler\GetIndexViewHandler;
109
use Light\App\Handler\GetMarkdownArticleHandler;
@@ -18,10 +17,6 @@
1817
use Psr\Container\ContainerExceptionInterface;
1918
use Psr\Container\ContainerInterface;
2019
use Psr\Container\NotFoundExceptionInterface;
21-
use Psr\Http\Message\ServerRequestInterface;
22-
use Psr\Http\Message\UriInterface;
23-
24-
use function sprintf;
2520

2621
class RoutesDelegatorTest extends UnitTest
2722
{
@@ -71,99 +66,5 @@ public function testWillRegisterAllRoutes(): void
7166
GetPackagesViewHandler::TEMPLATE,
7267
$this->registeredRoutes['/dotkernel-packages-oss-lifecycle/']['name']
7368
);
74-
75-
$this->assertArrayHasKey('/{wpPath:wp-.*}', $this->registeredRoutes);
76-
$this->assertArrayHasKey('/{first}', $this->registeredRoutes);
77-
$this->assertArrayHasKey('/{first}/{second}', $this->registeredRoutes);
78-
}
79-
80-
/**
81-
* @throws ContainerExceptionInterface
82-
* @throws Exception
83-
* @throws NotFoundExceptionInterface
84-
*/
85-
public function testWpPrefixedPathRouteRedirectsToHomepage(): void
86-
{
87-
$handler = $this->captureRouteHandler('/{wpPath:wp-.*}');
88-
89-
$response = $handler();
90-
91-
$this->assertInstanceOf(RedirectResponse::class, $response);
92-
$this->assertSame(301, $response->getStatusCode());
93-
$this->assertSame('/', $response->getHeaderLine('Location'));
94-
}
95-
96-
/**
97-
* @throws ContainerExceptionInterface
98-
* @throws Exception
99-
* @throws NotFoundExceptionInterface
100-
*/
101-
public function testFirstSegmentCatchAllAppendsTrailingSlash(): void
102-
{
103-
$handler = $this->captureRouteHandler('/{first}');
104-
$request = $this->createRequestForUri('/some-page');
105-
106-
$response = $handler($request);
107-
108-
$this->assertInstanceOf(RedirectResponse::class, $response);
109-
$this->assertSame(301, $response->getStatusCode());
110-
$this->assertSame('/some-page/', $response->getHeaderLine('Location'));
111-
}
112-
113-
/**
114-
* @throws ContainerExceptionInterface
115-
* @throws Exception
116-
* @throws NotFoundExceptionInterface
117-
*/
118-
public function testTwoSegmentCatchAllAppendsTrailingSlash(): void
119-
{
120-
$handler = $this->captureRouteHandler('/{first}/{second}');
121-
$request = $this->createRequestForUri('/some-category/some-slug');
122-
123-
$response = $handler($request);
124-
125-
$this->assertInstanceOf(RedirectResponse::class, $response);
126-
$this->assertSame(301, $response->getStatusCode());
127-
$this->assertSame('/some-category/some-slug/', $response->getHeaderLine('Location'));
128-
}
129-
130-
/**
131-
* @throws Exception
132-
*/
133-
private function createRequestForUri(string $uri): ServerRequestInterface
134-
{
135-
$uriStub = $this->createStub(UriInterface::class);
136-
$uriStub->method('__toString')->willReturn($uri);
137-
138-
$request = $this->createStub(ServerRequestInterface::class);
139-
$request->method('getUri')->willReturn($uriStub);
140-
141-
return $request;
142-
}
143-
144-
/**
145-
* @throws ContainerExceptionInterface
146-
* @throws Exception
147-
* @throws NotFoundExceptionInterface
148-
*/
149-
private function captureRouteHandler(string $routeUri): callable
150-
{
151-
$container = $this->createStub(ContainerInterface::class);
152-
$app = $this->createStub(Application::class);
153-
$captured = null;
154-
155-
$app->method('get')->willReturnCallback(function (...$args) use ($routeUri, &$captured) {
156-
if ($args[0] === $routeUri) {
157-
$captured = $args[1];
158-
}
159-
160-
return $this->createStub(Route::class);
161-
});
162-
163-
(new RoutesDelegator())($container, '', fn () => $app);
164-
165-
$this->assertIsCallable($captured, sprintf('No callable handler was registered for route "%s".', $routeUri));
166-
167-
return $captured;
16869
}
16970
}

0 commit comments

Comments
 (0)