1
0

downgrade to kirby v3

This commit is contained in:
Philip Wagner
2024-09-01 10:47:15 +02:00
parent a4b2aece7b
commit af86acb7a1
1085 changed files with 54743 additions and 65042 deletions

View File

@@ -1,15 +1,13 @@
<?php
use Kirby\Cms\App;
use Kirby\Cms\LanguageRoutes;
use Kirby\Cms\Media;
use Kirby\Cms\PluginAssets;
use Kirby\Panel\Panel;
use Kirby\Panel\Plugins;
use Kirby\Toolkit\Str;
use Kirby\Uuid\Uuid;
return function (App $kirby) {
return function ($kirby) {
$api = $kirby->option('api.slug', 'api');
$panel = $kirby->option('panel.slug', 'panel');
$index = $kirby->url('index');
@@ -33,7 +31,7 @@ return function (App $kirby) {
'pattern' => $api . '/(:all)',
'method' => 'ALL',
'env' => 'api',
'action' => function (string $path = null) use ($kirby) {
'action' => function ($path = null) use ($kirby) {
if ($kirby->option('api') === false) {
return null;
}
@@ -61,63 +59,37 @@ return function (App $kirby) {
}
],
[
// TODO: change to '/plugins/(:any)/(:any)/(:any)/(:all)' once
// the hash is made mandatory
'pattern' => $media . '/plugins/(:any)/(:any)/(?:(:any)/)?(:all)',
'pattern' => $media . '/plugins/(:any)/(:any)/(:all).(css|map|gif|js|mjs|jpg|png|svg|webp|avif|woff2|woff|json)',
'env' => 'media',
'action' => function (
string $provider,
string $pluginName,
string $hash,
string $path
) {
return PluginAssets::resolve(
$provider . '/' . $pluginName,
$hash,
$path
);
'action' => function (string $provider, string $pluginName, string $filename, string $extension) {
return PluginAssets::resolve($provider . '/' . $pluginName, $filename . '.' . $extension);
}
],
[
'pattern' => $media . '/pages/(:all)/(:any)/(:any)',
'env' => 'media',
'action' => function (
string $path,
string $hash,
string $filename
) use ($kirby) {
'action' => function ($path, $hash, $filename) use ($kirby) {
return Media::link($kirby->page($path), $hash, $filename);
}
],
[
'pattern' => $media . '/site/(:any)/(:any)',
'env' => 'media',
'action' => function (
string $hash,
string $filename
) use ($kirby) {
'action' => function ($hash, $filename) use ($kirby) {
return Media::link($kirby->site(), $hash, $filename);
}
],
[
'pattern' => $media . '/users/(:any)/(:any)/(:any)',
'env' => 'media',
'action' => function (
string $id,
string $hash,
string $filename
) use ($kirby) {
'action' => function ($id, $hash, $filename) use ($kirby) {
return Media::link($kirby->user($id), $hash, $filename);
}
],
[
'pattern' => $media . '/assets/(:all)/(:any)/(:any)',
'env' => 'media',
'action' => function (
string $path,
string $hash,
string $filename
) {
'action' => function ($path, $hash, $filename) {
return Media::thumb($path, $hash, $filename);
}
],
@@ -125,30 +97,10 @@ return function (App $kirby) {
'pattern' => $panel . '/(:all?)',
'method' => 'ALL',
'env' => 'panel',
'action' => function (string $path = null) {
'action' => function ($path = null) {
return Panel::router($path);
}
],
// permalinks for page/file UUIDs
[
'pattern' => '@/(page|file)/(:all)',
'method' => 'ALL',
'env' => 'site',
'action' => function (string $type, string $id) use ($kirby) {
// try to resolve to model, but only from UUID cache;
// this ensures that only existing UUIDs can be queried
// and attackers can't force Kirby to go through the whole
// site index with a non-existing UUID
if ($model = Uuid::for($type . '://' . $id)?->model(true)) {
return $kirby
->response()
->redirect($model->url());
}
// render the error page
return false;
}
],
];
// Multi-language setup