Skip to content

Commit 918fc53

Browse files
committed
wip
1 parent 22f0604 commit 918fc53

File tree

10 files changed

+52
-14
lines changed

10 files changed

+52
-14
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"type": "project",
44
"description": "Documentation website for the Tempest framework",
55
"require": {
6-
"tempest/framework": "^2.6.1",
6+
"tempest/framework": "^2.7.0",
77
"league/commonmark": "^2.7.1",
88
"symfony/yaml": "^7.3.3",
99
"spatie/yaml-front-matter": "^2.1",

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace App\Support\Sessions;
4+
5+
use Tempest\Database\MigratesUp;
6+
use Tempest\Database\QueryStatement;
7+
use Tempest\Database\QueryStatements\CreateTableStatement;
8+
9+
final class CreateSessionsTable implements MigratesUp
10+
{
11+
private(set) string $name = '0000-00-00_create_sessions_table';
12+
13+
public function up(): QueryStatement
14+
{
15+
return new CreateTableStatement('sessions')
16+
->primary('id')
17+
->string('session_id')
18+
->text('data')
19+
->datetime('created_at')
20+
->datetime('last_active_at')
21+
->index('session_id');
22+
}
23+
}

src/Support/session.config.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
use Tempest\DateTime\Duration;
4+
use Tempest\Http\Session\Config\DatabaseSessionConfig;
5+
6+
return new DatabaseSessionConfig(
7+
expiration: Duration::days(30),
8+
);

src/Web/Blog/BlogController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
namespace App\Web\Blog;
44

55
use App\Web\Meta\MetaType;
6-
use DateTimeImmutable;
76
use Tempest\Cache\Cache;
87
use Tempest\DateTime\DateTime;
98
use Tempest\Http\Response;
109
use Tempest\Http\Responses\NotFound;
1110
use Tempest\Http\Responses\Ok;
11+
use Tempest\Http\Session\VerifyCsrfMiddleware;
1212
use Tempest\Router\Get;
13+
use Tempest\Router\SetCurrentUrlMiddleware;
14+
use Tempest\Router\Stateless;
1315
use Tempest\Router\StaticPage;
14-
use Tempest\Support\Arr\ImmutableArray;
1516
use Tempest\View\View;
1617

1718
use Tempest\View\ViewRenderer;
@@ -41,7 +42,7 @@ public function show(string $slug, BlogRepository $repository): Response|View
4142
return view('./show.view.php', post: $post);
4243
}
4344

44-
#[Get('/rss')]
45+
#[Stateless, Get('/rss', without: [SetCurrentUrlMiddleware::class, VerifyCsrfMiddleware::class])]
4546
public function rss(
4647
Cache $cache,
4748
ViewRenderer $viewRenderer,

src/Web/Documentation/DocumentationController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Tempest\Http\Responses\NotFound;
1010
use Tempest\Http\Responses\Redirect;
1111
use Tempest\Router\Get;
12+
use Tempest\Router\Stateless;
1213
use Tempest\Router\StaticPage;
1314
use Tempest\Support\Arr\ImmutableArray;
1415
use Tempest\Support\Str\ImmutableString;
@@ -20,6 +21,7 @@
2021

2122
final readonly class DocumentationController
2223
{
24+
#[Stateless]
2325
#[Get('/current/{path:.*}')]
2426
#[Get('/main/{path:.*}')]
2527
#[Get('/docs/{path:.*}')]
@@ -28,6 +30,7 @@ public function redirect(string $path): Redirect
2830
return new Redirect(sprintf('/%s/%s', Version::default()->getUrlSegment(), $path));
2931
}
3032

33+
#[Stateless]
3134
#[Get('/documentation')]
3235
#[Get('/docs')]
3336
#[Get('/{version}')]

src/Web/Meta/MetaImageController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
use Tempest\Http\Response;
1313
use Tempest\Http\Responses\File;
1414
use Tempest\Http\Responses\Ok;
15+
use Tempest\Http\Session\VerifyCsrfMiddleware;
1516
use Tempest\Router\Get;
17+
use Tempest\Router\SetCurrentUrlMiddleware;
18+
use Tempest\Router\Stateless;
1619
use Tempest\View\ViewRenderer;
1720

1821
use function Tempest\support\path;
@@ -28,7 +31,7 @@ public function __construct(
2831
private Browsershot $browsershot,
2932
) {}
3033

31-
#[Get('/meta/blog/{slug}')]
34+
#[Stateless, Get('/meta/blog/{slug}')]
3235
public function blog(string $slug, Request $request, BlogRepository $repository): Response
3336
{
3437
$post = $repository->find($slug);
@@ -55,7 +58,7 @@ public function blog(string $slug, Request $request, BlogRepository $repository)
5558
return new File($path);
5659
}
5760

58-
#[Get('/meta/documentation/{version}/{category}/{slug}')]
61+
#[Get('/meta/documentation/{version}/{category}/{slug}', without: [SetCurrentUrlMiddleware::class, VerifyCsrfMiddleware::class])]
5962
public function documentation(string $version, string $category, string $slug, Request $request, ChapterRepository $repository): Response
6063
{
6164
$version = Version::from($version);
@@ -83,7 +86,7 @@ public function documentation(string $version, string $category, string $slug, R
8386
return new File($path);
8487
}
8588

86-
#[Get('/meta/{type}')]
89+
#[Get('/meta/{type}', without: [SetCurrentUrlMiddleware::class, VerifyCsrfMiddleware::class])]
8790
public function default(string $type, Request $request): Response
8891
{
8992
$type = MetaType::tryFrom($type) ?? MetaType::HOME;

0 commit comments

Comments
 (0)