Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • adaures/castopod
  • mkljczk/castopod-host
  • spaetz/castopod-host
  • PatrykMis/castopod
  • jonas/castopod
  • ajeremias/castopod
  • misuzu/castopod
  • KrzysztofDomanczyk/castopod
  • Behel/castopod
  • nebulon/castopod
  • ewen/castopod
  • NeoluxConsulting/castopod
  • nateritter/castopod-og
  • prcutler/castopod
14 results
Show changes
Showing
with 226 additions and 117 deletions
...@@ -8,8 +8,11 @@ use App\Filters\AllowCorsFilter; ...@@ -8,8 +8,11 @@ use App\Filters\AllowCorsFilter;
use CodeIgniter\Config\BaseConfig; use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Filters\CSRF; use CodeIgniter\Filters\CSRF;
use CodeIgniter\Filters\DebugToolbar; use CodeIgniter\Filters\DebugToolbar;
use CodeIgniter\Filters\ForceHTTPS;
use CodeIgniter\Filters\Honeypot; use CodeIgniter\Filters\Honeypot;
use CodeIgniter\Filters\InvalidChars; use CodeIgniter\Filters\InvalidChars;
use CodeIgniter\Filters\PageCache;
use CodeIgniter\Filters\PerformanceMetrics;
use CodeIgniter\Filters\SecureHeaders; use CodeIgniter\Filters\SecureHeaders;
use Modules\Auth\Filters\PermissionFilter; use Modules\Auth\Filters\PermissionFilter;
...@@ -18,9 +21,10 @@ class Filters extends BaseConfig ...@@ -18,9 +21,10 @@ class Filters extends BaseConfig
/** /**
* Configures aliases for Filter classes to make reading things nicer and simpler. * Configures aliases for Filter classes to make reading things nicer and simpler.
* *
* @var array<string, array<int, string>|string> [filter_name => classname] * @var array<string, class-string|list<class-string>>
* or [filter_name => [classname1, classname2, ...]] *
* @phpstan-var array<string, class-string|list<class-string>> * [filter_name => classname]
* or [filter_name => [classname1, classname2, ...]]
*/ */
public array $aliases = [ public array $aliases = [
'csrf' => CSRF::class, 'csrf' => CSRF::class,
...@@ -29,24 +33,55 @@ class Filters extends BaseConfig ...@@ -29,24 +33,55 @@ class Filters extends BaseConfig
'invalidchars' => InvalidChars::class, 'invalidchars' => InvalidChars::class,
'secureheaders' => SecureHeaders::class, 'secureheaders' => SecureHeaders::class,
'allow-cors' => AllowCorsFilter::class, 'allow-cors' => AllowCorsFilter::class,
'cors' => Cors::class,
'forcehttps' => ForceHTTPS::class,
'pagecache' => PageCache::class,
'performance' => PerformanceMetrics::class,
];
/**
* List of special required filters.
*
* The filters listed here are special. They are applied before and after
* other kinds of filters, and always applied even if a route does not exist.
*
* Filters set by default provide framework functionality. If removed,
* those functions will no longer work.
*
* @see https://codeigniter.com/user_guide/incoming/filters.html#provided-filters
*
* @var array{before: list<string>, after: list<string>}
*/
public array $required = [
'before' => [
'forcehttps', // Force Global Secure Requests
'pagecache', // Web Page Caching
],
'after' => [
'pagecache', // Web Page Caching
'performance', // Performance Metrics
'toolbar', // Debug Toolbar
],
]; ];
/** /**
* List of filter aliases that are always applied before and after every request. * List of filter aliases that are always applied before and after every request.
* *
* @var array<string, array<string, array<string, string>>>|array<string, array<string>> * @var array<string, array<string, array<string, string|array<string>>>>|array<string, list<string>>
* @phpstan-var array<string, list<string>>|array<string, array<string, array<string, string>>>
*/ */
public array $globals = [ public array $globals = [
'before' => [ 'before' => [
// 'honeypot', // 'honeypot',
'csrf' => [ 'csrf' => [
'except' => ['@[a-zA-Z0-9\_]{1,32}/inbox'], 'except' => [
'@[a-zA-Z0-9\_]{1,32}/inbox',
'api/rest/v1/episodes',
'api/rest/v1/episodes/[0-9]+/publish',
],
], ],
// 'invalidchars', // 'invalidchars',
], ],
'after' => [ 'after' => [
'toolbar',
// 'honeypot', // 'honeypot',
// 'secureheaders', // 'secureheaders',
], ],
...@@ -55,12 +90,12 @@ class Filters extends BaseConfig ...@@ -55,12 +90,12 @@ class Filters extends BaseConfig
/** /**
* List of filter aliases that works on a particular HTTP method (GET, POST, etc.). * List of filter aliases that works on a particular HTTP method (GET, POST, etc.).
* *
* Example: 'post' => ['foo', 'bar'] * Example: 'POST' => ['foo', 'bar']
* *
* If you use this, you should disable auto-routing because auto-routing permits any HTTP method to access a * If you use this, you should disable auto-routing because auto-routing permits any HTTP method to access a
* controller. Accessing the controller with a method you don’t expect could bypass the filter. * controller. Accessing the controller with a method you don’t expect could bypass the filter.
* *
* @var array<string, string[]> * @var array<string, list<string>>
*/ */
public array $methods = []; public array $methods = [];
...@@ -69,7 +104,7 @@ class Filters extends BaseConfig ...@@ -69,7 +104,7 @@ class Filters extends BaseConfig
* *
* Example: 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']] * Example: 'isLoggedIn' => ['before' => ['account/*', 'profiles/*']]
* *
* @var array<string, array<string, string[]>> * @var array<string, array<string, list<string>>>
*/ */
public array $filters = []; public array $filters = [];
......
...@@ -5,7 +5,6 @@ declare(strict_types=1); ...@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace Config; namespace Config;
use CodeIgniter\Config\BaseConfig; use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Format\FormatterInterface;
use CodeIgniter\Format\JSONFormatter; use CodeIgniter\Format\JSONFormatter;
use CodeIgniter\Format\XMLFormatter; use CodeIgniter\Format\XMLFormatter;
...@@ -24,7 +23,7 @@ class Format extends BaseConfig ...@@ -24,7 +23,7 @@ class Format extends BaseConfig
* These formats are only checked when the data passed to the respond() * These formats are only checked when the data passed to the respond()
* method is an array. * method is an array.
* *
* @var string[] * @var list<string>
*/ */
public array $supportedResponseFormats = [ public array $supportedResponseFormats = [
'application/json', 'application/json',
...@@ -64,16 +63,4 @@ class Format extends BaseConfig ...@@ -64,16 +63,4 @@ class Format extends BaseConfig
'application/xml' => 0, 'application/xml' => 0,
'text/xml' => 0, 'text/xml' => 0,
]; ];
//--------------------------------------------------------------------
/**
* A Factory method to return the appropriate formatter for the given mime type.
*
* @deprecated This is an alias of `\CodeIgniter\Format\Format::getFormatter`. Use that instead.
*/
public function getFormatter(string $mime): FormatterInterface
{
return Services::format()->getFormatter($mime);
}
} }
...@@ -25,11 +25,13 @@ class Generators extends BaseConfig ...@@ -25,11 +25,13 @@ class Generators extends BaseConfig
* *
* YOU HAVE BEEN WARNED! * YOU HAVE BEEN WARNED!
* *
* @var array<string, string> * @var array<string, string|array<string,string>>
*/ */
public array $views = [ public array $views = [
'make:cell' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php', 'make:cell' => [
'make:cell_view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php', 'class' => 'CodeIgniter\Commands\Generators\Views\cell.tpl.php',
'view' => 'CodeIgniter\Commands\Generators\Views\cell_view.tpl.php',
],
'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php', 'make:command' => 'CodeIgniter\Commands\Generators\Views\command.tpl.php',
'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php', 'make:config' => 'CodeIgniter\Commands\Generators\Views\config.tpl.php',
'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php', 'make:controller' => 'CodeIgniter\Commands\Generators\Views\controller.tpl.php',
......
...@@ -130,7 +130,7 @@ class Images extends BaseConfig ...@@ -130,7 +130,7 @@ class Images extends BaseConfig
], ],
]; ];
public string $avatarDefaultPath = 'castopod-avatar.jpg'; public string $avatarDefaultPath = 'assets/images/castopod-avatar.jpg';
public string $avatarDefaultMimeType = 'image/jpg'; public string $avatarDefaultMimeType = 'image/jpg';
...@@ -139,31 +139,31 @@ class Images extends BaseConfig ...@@ -139,31 +139,31 @@ class Images extends BaseConfig
*/ */
public array $podcastBannerDefaultPaths = [ public array $podcastBannerDefaultPaths = [
'default' => [ 'default' => [
'path' => 'castopod-banner-pine.jpg', 'path' => 'assets/images/castopod-banner-pine.jpg',
'mimetype' => 'image/jpeg', 'mimetype' => 'image/jpeg',
], ],
'pine' => [ 'pine' => [
'path' => 'castopod-banner-pine.jpg', 'path' => 'assets/images/castopod-banner-pine.jpg',
'mimetype' => 'image/jpeg', 'mimetype' => 'image/jpeg',
], ],
'crimson' => [ 'crimson' => [
'path' => 'castopod-banner-crimson.jpg', 'path' => 'assets/images/castopod-banner-crimson.jpg',
'mimetype' => 'image/jpeg', 'mimetype' => 'image/jpeg',
], ],
'amber' => [ 'amber' => [
'path' => 'castopod-banner-amber.jpg', 'path' => 'assets/images/castopod-banner-amber.jpg',
'mimetype' => 'image/jpeg', 'mimetype' => 'image/jpeg',
], ],
'lake' => [ 'lake' => [
'path' => 'castopod-banner-lake.jpg', 'path' => 'assets/images/castopod-banner-lake.jpg',
'mimetype' => 'image/jpeg', 'mimetype' => 'image/jpeg',
], ],
'jacaranda' => [ 'jacaranda' => [
'path' => 'castopod-banner-jacaranda.jpg', 'path' => 'assets/images/castopod-banner-jacaranda.jpg',
'mimetype' => 'image/jpeg', 'mimetype' => 'image/jpeg',
], ],
'onyx' => [ 'onyx' => [
'path' => 'castopod-banner-onyx.jpg', 'path' => 'assets/images/castopod-banner-onyx.jpg',
'mimetype' => 'image/jpeg', 'mimetype' => 'image/jpeg',
], ],
]; ];
......
...@@ -4,12 +4,12 @@ declare(strict_types=1); ...@@ -4,12 +4,12 @@ declare(strict_types=1);
namespace Config; namespace Config;
use CodeIgniter\Config\BaseConfig; use Kint\Parser\ConstructablePluginInterface;
use Kint\Renderer\AbstractRenderer; use Kint\Renderer\Rich\TabPluginInterface;
use Kint\Renderer\Rich\ValuePluginInterface;
/** /**
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* Kint
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options * We use Kint's `RichRenderer` and `CLIRenderer`. This area contains options
...@@ -17,7 +17,7 @@ use Kint\Renderer\AbstractRenderer; ...@@ -17,7 +17,7 @@ use Kint\Renderer\AbstractRenderer;
* *
* @see https://kint-php.github.io/kint/ for details on these settings. * @see https://kint-php.github.io/kint/ for details on these settings.
*/ */
class Kint extends BaseConfig class Kint
{ {
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -26,9 +26,9 @@ class Kint extends BaseConfig ...@@ -26,9 +26,9 @@ class Kint extends BaseConfig
*/ */
/** /**
* @var string[] * @var list<class-string<ConstructablePluginInterface>|ConstructablePluginInterface>|null
*/ */
public array $plugins = []; public ?array $plugins = [];
public int $maxDepth = 6; public int $maxDepth = 6;
...@@ -46,17 +46,15 @@ class Kint extends BaseConfig ...@@ -46,17 +46,15 @@ class Kint extends BaseConfig
public bool $richFolder = false; public bool $richFolder = false;
public int $richSort = AbstractRenderer::SORT_FULL;
/** /**
* @var string[] * @var array<string, class-string<ValuePluginInterface>>|null
*/ */
public array $richObjectPlugins = []; public ?array $richObjectPlugins = [];
/** /**
* @var string[] * @var array<string, class-string<TabPluginInterface>>|null
*/ */
public array $richTabPlugins = []; public ?array $richTabPlugins = [];
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
......
...@@ -38,7 +38,7 @@ class Logger extends BaseConfig ...@@ -38,7 +38,7 @@ class Logger extends BaseConfig
* For a live site you'll usually enable Critical or higher (3) to be logged otherwise * For a live site you'll usually enable Critical or higher (3) to be logged otherwise
* your log files will fill up very fast. * your log files will fill up very fast.
* *
* @var int|int[] * @var int|list<int>
*/ */
public int | array $threshold = (ENVIRONMENT === 'production') ? 4 : 9; public int | array $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
...@@ -75,7 +75,7 @@ class Logger extends BaseConfig ...@@ -75,7 +75,7 @@ class Logger extends BaseConfig
* Handlers are executed in the order defined in this array, starting with * Handlers are executed in the order defined in this array, starting with
* the handler on top and continuing down. * the handler on top and continuing down.
* *
* @var array<string, mixed> * @var array<class-string, array<string, int|list<string>|string>>
*/ */
public array $handlers = [ public array $handlers = [
/* /*
......
...@@ -5,8 +5,6 @@ declare(strict_types=1); ...@@ -5,8 +5,6 @@ declare(strict_types=1);
namespace Config; namespace Config;
/** /**
* Mimes
*
* This file contains an array of mime types. It is used by the Upload class to help identify allowed file types. * This file contains an array of mime types. It is used by the Upload class to help identify allowed file types.
* *
* When more than one variation for an extension exist (like jpg, jpeg, etc) the most common one should be first in the * When more than one variation for an extension exist (like jpg, jpeg, etc) the most common one should be first in the
...@@ -22,7 +20,7 @@ class Mimes ...@@ -22,7 +20,7 @@ class Mimes
/** /**
* Map of extensions to mime types. * Map of extensions to mime types.
* *
* @var array<string, string|string[]> * @var array<string, list<string>|string>
*/ */
public static $mimes = [ public static $mimes = [
'hqx' => [ 'hqx' => [
...@@ -310,7 +308,7 @@ class Mimes ...@@ -310,7 +308,7 @@ class Mimes
* @param string|null $proposedExtension - default extension (in case there is more than one with the same mime type) * @param string|null $proposedExtension - default extension (in case there is more than one with the same mime type)
* @return string|null The extension determined, or null if unable to match. * @return string|null The extension determined, or null if unable to match.
*/ */
public static function guessExtensionFromType(string $type, string $proposedExtension = null): ?string public static function guessExtensionFromType(string $type, ?string $proposedExtension = null): ?string
{ {
$type = trim(strtolower($type), '. '); $type = trim(strtolower($type), '. ');
......
...@@ -60,7 +60,7 @@ class Modules extends BaseModules ...@@ -60,7 +60,7 @@ class Modules extends BaseModules
* ], * ],
* ] * ]
* *
* @var array{only?:string[], exclude?:string[]} * @var array{only?: list<string>, exclude?: list<string>}
*/ */
public $composerPackages = []; public $composerPackages = [];
...@@ -74,7 +74,7 @@ class Modules extends BaseModules ...@@ -74,7 +74,7 @@ class Modules extends BaseModules
* *
* If it is not listed, only the base application elements will be used. * If it is not listed, only the base application elements will be used.
* *
* @var string[] * @var list<string>
*/ */
public $aliases = ['events', 'filters', 'registrars', 'routes', 'services']; public $aliases = ['events', 'filters', 'registrars', 'routes', 'services'];
} }
<?php
declare(strict_types=1);
namespace Config;
/**
* Optimization Configuration.
*
* NOTE: This class does not extend BaseConfig for performance reasons.
* So you cannot replace the property values with Environment Variables.
*
* @immutable
*/
class Optimize
{
/**
* --------------------------------------------------------------------------
* Config Caching
* --------------------------------------------------------------------------
*
* @see https://codeigniter.com/user_guide/concepts/factories.html#config-caching
*/
public bool $configCacheEnabled = false;
/**
* --------------------------------------------------------------------------
* Config Caching
* --------------------------------------------------------------------------
*
* @see https://codeigniter.com/user_guide/concepts/autoloader.html#file-locator-caching
*/
public bool $locatorCacheEnabled = false;
}
...@@ -5,8 +5,6 @@ declare(strict_types=1); ...@@ -5,8 +5,6 @@ declare(strict_types=1);
namespace Config; namespace Config;
/** /**
* Paths
*
* Holds the paths that are used by the system to locate the main directories, app, system, etc. * Holds the paths that are used by the system to locate the main directories, app, system, etc.
* *
* Modifying these allows you to restructure your application, share a system folder between multiple applications, and * Modifying these allows you to restructure your application, share a system folder between multiple applications, and
...@@ -72,7 +70,7 @@ class Paths ...@@ -72,7 +70,7 @@ class Paths
* This variable must contain the name of the directory that * This variable must contain the name of the directory that
* contains the view files used by your application. By * contains the view files used by your application. By
* default this is in `app/Views`. This value * default this is in `app/Views`. This value
* is used when no value is provided to `Services::renderer()`. * is used when no value is provided to `service('renderer')`.
*/ */
public string $viewDirectory = __DIR__ . '/../Views'; public string $viewDirectory = __DIR__ . '/../Views';
} }
...@@ -19,7 +19,7 @@ class Publisher extends BasePublisher ...@@ -19,7 +19,7 @@ class Publisher extends BasePublisher
* to directories not in this list will result in a PublisherException. Files that do no fit the pattern will cause * to directories not in this list will result in a PublisherException. Files that do no fit the pattern will cause
* copy/merge to fail. * copy/merge to fail.
* *
* @var array<string,string> * @var array<string, string>
*/ */
public $restrictions = [ public $restrictions = [
ROOTPATH => '*', ROOTPATH => '*',
......
...@@ -15,7 +15,6 @@ use CodeIgniter\Router\RouteCollection; ...@@ -15,7 +15,6 @@ use CodeIgniter\Router\RouteCollection;
$routes->addPlaceholder('podcastHandle', '[a-zA-Z0-9\_]{1,32}'); $routes->addPlaceholder('podcastHandle', '[a-zA-Z0-9\_]{1,32}');
$routes->addPlaceholder('slug', '[a-zA-Z0-9\-]{1,128}'); $routes->addPlaceholder('slug', '[a-zA-Z0-9\-]{1,128}');
$routes->addPlaceholder('base64', '[A-Za-z0-9\.\_]+\-{0,2}'); $routes->addPlaceholder('base64', '[A-Za-z0-9\.\_]+\-{0,2}');
$routes->addPlaceholder('platformType', '\bpodcasting|\bsocial|\bfunding');
$routes->addPlaceholder('postAction', '\bfavourite|\breblog|\breply'); $routes->addPlaceholder('postAction', '\bfavourite|\breblog|\breply');
$routes->addPlaceholder('embedTheme', '\blight|\bdark|\blight-transparent|\bdark-transparent'); $routes->addPlaceholder('embedTheme', '\blight|\bdark|\blight-transparent|\bdark-transparent');
$routes->addPlaceholder( $routes->addPlaceholder(
...@@ -125,6 +124,12 @@ $routes->group('@(:podcastHandle)', static function ($routes): void { ...@@ -125,6 +124,12 @@ $routes->group('@(:podcastHandle)', static function ($routes): void {
$routes->get('activity', 'EpisodeController::activity/$1/$2', [ $routes->get('activity', 'EpisodeController::activity/$1/$2', [
'as' => 'episode-activity', 'as' => 'episode-activity',
]); ]);
$routes->get('chapters', 'EpisodeController::chapters/$1/$2', [
'as' => 'episode-chapters',
]);
$routes->get('transcript', 'EpisodeController::transcript/$1/$2', [
'as' => 'episode-transcript',
]);
$routes->options('comments', 'ActivityPubController::preflight'); $routes->options('comments', 'ActivityPubController::preflight');
$routes->get('comments', 'EpisodeController::comments/$1/$2', [ $routes->get('comments', 'EpisodeController::comments/$1/$2', [
'as' => 'episode-comments', 'as' => 'episode-comments',
...@@ -156,7 +161,7 @@ $routes->group('@(:podcastHandle)', static function ($routes): void { ...@@ -156,7 +161,7 @@ $routes->group('@(:podcastHandle)', static function ($routes): void {
$routes->get('comments/(:uuid)/replies', 'EpisodeCommentController::replies/$1/$2/$3', [ $routes->get('comments/(:uuid)/replies', 'EpisodeCommentController::replies/$1/$2/$3', [
'as' => 'episode-comment-replies', 'as' => 'episode-comment-replies',
]); ]);
$routes->post('comments/(:uuid)/like', 'EpisodeCommentController::attemptLike/$1/$2/$3', [ $routes->post('comments/(:uuid)/like', 'EpisodeCommentController::likeAction/$1/$2/$3', [
'as' => 'episode-comment-attempt-like', 'as' => 'episode-comment-attempt-like',
]); ]);
$routes->get('oembed.json', 'EpisodeController::oembedJSON/$1/$2', [ $routes->get('oembed.json', 'EpisodeController::oembedJSON/$1/$2', [
...@@ -196,10 +201,15 @@ $routes->get('/audio/@(:podcastHandle)/(:slug).(:alphanum)', 'EpisodeAudioContro ...@@ -196,10 +201,15 @@ $routes->get('/audio/@(:podcastHandle)/(:slug).(:alphanum)', 'EpisodeAudioContro
$routes->get('/p/(:uuid)', 'EpisodePreviewController::index/$1', [ $routes->get('/p/(:uuid)', 'EpisodePreviewController::index/$1', [
'as' => 'episode-preview', 'as' => 'episode-preview',
]); ]);
$routes->get('/p/(:uuid)/activity', 'EpisodePreviewController::activity/$1', [ $routes->get('/p/(:uuid)/activity', 'EpisodePreviewController::activity/$1', [
'as' => 'episode-preview-activity', 'as' => 'episode-preview-activity',
]); ]);
$routes->get('/p/(:uuid)/chapters', 'EpisodePreviewController::chapters/$1', [
'as' => 'episode-preview-chapters',
]);
$routes->get('/p/(:uuid)/transcript', 'EpisodePreviewController::transcript/$1', [
'as' => 'episode-preview-transcript',
]);
// Other pages // Other pages
$routes->get('/credits', 'CreditsController', [ $routes->get('/credits', 'CreditsController', [
...@@ -219,9 +229,9 @@ $routes->get('/pages/(:slug)', 'PageController::index/$1', [ ...@@ -219,9 +229,9 @@ $routes->get('/pages/(:slug)', 'PageController::index/$1', [
* Overwriting Fediverse routes file * Overwriting Fediverse routes file
*/ */
$routes->group('@(:podcastHandle)', static function ($routes): void { $routes->group('@(:podcastHandle)', static function ($routes): void {
$routes->post('posts/new', 'PostController::attemptCreate/$1', [ $routes->post('posts/new', 'PostController::createAction/$1', [
'as' => 'post-attempt-create', 'as' => 'post-attempt-create',
'filter' => 'permission:podcast#.manage-publications', 'filter' => 'permission:podcast$1.manage-publications',
]); ]);
// Post // Post
$routes->group('posts/(:uuid)', static function ($routes): void { $routes->group('posts/(:uuid)', static function ($routes): void {
...@@ -256,13 +266,13 @@ $routes->group('@(:podcastHandle)', static function ($routes): void { ...@@ -256,13 +266,13 @@ $routes->group('@(:podcastHandle)', static function ($routes): void {
'filter' => 'allow-cors', 'filter' => 'allow-cors',
]); ]);
// Actions // Actions
$routes->post('action', 'PostController::attemptAction/$1/$2', [ $routes->post('action', 'PostController::action/$1/$2', [
'as' => 'post-attempt-action', 'as' => 'post-attempt-action',
'filter' => 'permission:podcast#.interact-as', 'filter' => 'permission:podcast$1.interact-as',
]); ]);
$routes->post( $routes->post(
'block-actor', 'block-actor',
'PostController::attemptBlockActor/$1/$2', 'PostController::blockActorAction/$1/$2',
[ [
'as' => 'post-attempt-block-actor', 'as' => 'post-attempt-block-actor',
'filter' => 'permission:fediverse.manage-blocks', 'filter' => 'permission:fediverse.manage-blocks',
...@@ -270,25 +280,25 @@ $routes->group('@(:podcastHandle)', static function ($routes): void { ...@@ -270,25 +280,25 @@ $routes->group('@(:podcastHandle)', static function ($routes): void {
); );
$routes->post( $routes->post(
'block-domain', 'block-domain',
'PostController::attemptBlockDomain/$1/$2', 'PostController::blockDomainAction/$1/$2',
[ [
'as' => 'post-attempt-block-domain', 'as' => 'post-attempt-block-domain',
'filter' => 'permission:fediverse.manage-blocks', 'filter' => 'permission:fediverse.manage-blocks',
], ],
); );
$routes->post('delete', 'PostController::attemptDelete/$1/$2', [ $routes->post('delete', 'PostController::deleteAction/$1/$2', [
'as' => 'post-attempt-delete', 'as' => 'post-attempt-delete',
'filter' => 'permission:podcast#.manage-publications', 'filter' => 'permission:podcast$1.manage-publications',
]); ]);
$routes->get( $routes->get(
'remote/(:postAction)', 'remote/(:postAction)',
'PostController::remoteAction/$1/$2/$3', 'PostController::remoteActionAction/$1/$2/$3',
[ [
'as' => 'post-remote-action', 'as' => 'post-remote-action',
], ],
); );
}); });
$routes->get('follow', 'ActorController::follow/$1', [ $routes->get('follow', 'ActorController::followView/$1', [
'as' => 'follow', 'as' => 'follow',
]); ]);
$routes->get('outbox', 'ActorController::outbox/$1', [ $routes->get('outbox', 'ActorController::outbox/$1', [
......
...@@ -12,13 +12,14 @@ use CodeIgniter\Config\Routing as BaseRouting; ...@@ -12,13 +12,14 @@ use CodeIgniter\Config\Routing as BaseRouting;
class Routing extends BaseRouting class Routing extends BaseRouting
{ {
/** /**
* For Defined Routes.
* An array of files that contain route definitions. * An array of files that contain route definitions.
* Route files are read in order, with the first match * Route files are read in order, with the first match
* found taking precedence. * found taking precedence.
* *
* Default: APPPATH . 'Config/Routes.php' * Default: APPPATH . 'Config/Routes.php'
* *
* @var string[] * @var list<string>
*/ */
public array $routeFiles = [ public array $routeFiles = [
APPPATH . 'Config/Routes.php', APPPATH . 'Config/Routes.php',
...@@ -28,12 +29,13 @@ class Routing extends BaseRouting ...@@ -28,12 +29,13 @@ class Routing extends BaseRouting
ROOTPATH . 'modules/Auth/Config/Routes.php', ROOTPATH . 'modules/Auth/Config/Routes.php',
ROOTPATH . 'modules/Fediverse/Config/Routes.php', ROOTPATH . 'modules/Fediverse/Config/Routes.php',
ROOTPATH . 'modules/Install/Config/Routes.php', ROOTPATH . 'modules/Install/Config/Routes.php',
ROOTPATH . 'modules/Media/Config/Routes.php', ROOTPATH . 'modules/Platforms/Config/Routes.php',
ROOTPATH . 'modules/PodcastImport/Config/Routes.php', ROOTPATH . 'modules/PodcastImport/Config/Routes.php',
ROOTPATH . 'modules/PremiumPodcasts/Config/Routes.php', ROOTPATH . 'modules/PremiumPodcasts/Config/Routes.php',
]; ];
/** /**
* For Defined Routes and Auto Routing.
* The default namespace to use for Controllers when no other * The default namespace to use for Controllers when no other
* namespace has been specified. * namespace has been specified.
* *
...@@ -42,6 +44,7 @@ class Routing extends BaseRouting ...@@ -42,6 +44,7 @@ class Routing extends BaseRouting
public string $defaultNamespace = 'App\Controllers'; public string $defaultNamespace = 'App\Controllers';
/** /**
* For Auto Routing.
* The default controller to use when no other controller has been * The default controller to use when no other controller has been
* specified. * specified.
* *
...@@ -50,6 +53,7 @@ class Routing extends BaseRouting ...@@ -50,6 +53,7 @@ class Routing extends BaseRouting
public string $defaultController = 'HomeController'; public string $defaultController = 'HomeController';
/** /**
* For Defined Routes and Auto Routing.
* The default method to call on the controller when no other * The default method to call on the controller when no other
* method has been set in the route. * method has been set in the route.
* *
...@@ -58,7 +62,8 @@ class Routing extends BaseRouting ...@@ -58,7 +62,8 @@ class Routing extends BaseRouting
public string $defaultMethod = 'index'; public string $defaultMethod = 'index';
/** /**
* Whether to translate dashes in URIs to underscores. * For Auto Routing.
* Whether to translate dashes in URIs for controller/method to underscores.
* Primarily useful when using the auto-routing. * Primarily useful when using the auto-routing.
* *
* Default: false * Default: false
...@@ -67,13 +72,12 @@ class Routing extends BaseRouting ...@@ -67,13 +72,12 @@ class Routing extends BaseRouting
/** /**
* Sets the class/method that should be called if routing doesn't * Sets the class/method that should be called if routing doesn't
* find a match. It can be either a closure or the controller/method * find a match. It can be the controller/method name like: Users::index
* name exactly like a route is defined: Users::index
* *
* This setting is passed to the Router class and handled there. * This setting is passed to the Router class and handled there.
* *
* If you want to use a closure, you will have to set it in the * If you want to use a closure, you will have to set it in the
* class constructor or the routes file by calling: * routes file by calling:
* *
* $routes->set404Override(function() { * $routes->set404Override(function() {
* // Do something here * // Do something here
...@@ -95,6 +99,7 @@ class Routing extends BaseRouting ...@@ -95,6 +99,7 @@ class Routing extends BaseRouting
public bool $autoRoute = false; public bool $autoRoute = false;
/** /**
* For Defined Routes.
* If TRUE, will enable the use of the 'prioritize' option * If TRUE, will enable the use of the 'prioritize' option
* when defining routes. * when defining routes.
* *
...@@ -103,7 +108,16 @@ class Routing extends BaseRouting ...@@ -103,7 +108,16 @@ class Routing extends BaseRouting
public bool $prioritize = false; public bool $prioritize = false;
/** /**
* Map of URI segments and namespaces. For Auto Routing (Improved). * For Defined Routes.
* If TRUE, matched multiple URI segments will be passed as one parameter.
*
* Default: false
*/
public bool $multipleSegmentsOneParam = false;
/**
* For Auto Routing (Improved).
* Map of URI segments and namespaces.
* *
* The key is the first URI segment. The value is the controller namespace. * The key is the first URI segment. The value is the controller namespace.
* E.g., * E.g.,
...@@ -114,4 +128,15 @@ class Routing extends BaseRouting ...@@ -114,4 +128,15 @@ class Routing extends BaseRouting
* @var array<string, string> [ uri_segment => namespace ] * @var array<string, string> [ uri_segment => namespace ]
*/ */
public array $moduleRoutes = []; public array $moduleRoutes = [];
/**
* For Auto Routing (Improved).
* Whether to translate dashes in URIs for controller/method to CamelCase.
* E.g., blog-controller -> BlogController
*
* If you enable this, $translateURIDashes is ignored.
*
* Default: false
*/
public bool $translateUriToCamelCase = true;
} }
...@@ -80,26 +80,7 @@ class Security extends BaseConfig ...@@ -80,26 +80,7 @@ class Security extends BaseConfig
* CSRF Redirect * CSRF Redirect
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* Redirect to previous page with error on failure. * @see https://codeigniter4.github.io/userguide/libraries/security.html#redirection-on-failure
*/ */
public bool $redirect = false; public bool $redirect = (ENVIRONMENT === 'production');
/**
* --------------------------------------------------------------------------
* CSRF SameSite
* --------------------------------------------------------------------------
*
* Setting for CSRF SameSite cookie token.
*
* Allowed values are: None - Lax - Strict - ''.
*
* Defaults to `Lax` as recommended in this link:
*
* @see https://portswigger.net/web-security/csrf/samesite-cookies
*
* @var string
*
* @deprecated `Config\Cookie` $samesite property is used.
*/
public $samesite = 'Lax';
} }
...@@ -5,6 +5,7 @@ declare(strict_types=1); ...@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Config; namespace Config;
use App\Libraries\Breadcrumb; use App\Libraries\Breadcrumb;
use App\Libraries\HtmlHead;
use App\Libraries\Negotiate; use App\Libraries\Negotiate;
use App\Libraries\Router; use App\Libraries\Router;
use CodeIgniter\Config\BaseService; use CodeIgniter\Config\BaseService;
...@@ -31,14 +32,14 @@ class Services extends BaseService ...@@ -31,14 +32,14 @@ class Services extends BaseService
public static function router( public static function router(
?RouteCollectionInterface $routes = null, ?RouteCollectionInterface $routes = null,
?Request $request = null, ?Request $request = null,
bool $getShared = true bool $getShared = true,
): Router { ): Router {
if ($getShared) { if ($getShared) {
return static::getSharedInstance('router', $routes, $request); return static::getSharedInstance('router', $routes, $request);
} }
$routes = $routes ?? static::routes(); $routes ??= static::routes();
$request = $request ?? static::request(); $request ??= static::request();
return new Router($routes, $request); return new Router($routes, $request);
} }
...@@ -53,7 +54,7 @@ class Services extends BaseService ...@@ -53,7 +54,7 @@ class Services extends BaseService
return static::getSharedInstance('negotiator', $request); return static::getSharedInstance('negotiator', $request);
} }
$request = $request ?? static::request(); $request ??= static::request();
return new Negotiate($request); return new Negotiate($request);
} }
...@@ -66,4 +67,13 @@ class Services extends BaseService ...@@ -66,4 +67,13 @@ class Services extends BaseService
return new Breadcrumb(); return new Breadcrumb();
} }
public static function html_head(bool $getShared = true): HtmlHead
{
if ($getShared) {
return self::getSharedInstance('html_head');
}
return new HtmlHead();
}
} }
...@@ -21,7 +21,7 @@ class Session extends BaseConfig ...@@ -21,7 +21,7 @@ class Session extends BaseConfig
* - `CodeIgniter\Session\Handlers\MemcachedHandler` * - `CodeIgniter\Session\Handlers\MemcachedHandler`
* - `CodeIgniter\Session\Handlers\RedisHandler` * - `CodeIgniter\Session\Handlers\RedisHandler`
* *
* @phpstan-var class-string<BaseHandler> * @var class-string<BaseHandler>
*/ */
public string $driver = FileHandler::class; public string $driver = FileHandler::class;
...@@ -101,4 +101,29 @@ class Session extends BaseConfig ...@@ -101,4 +101,29 @@ class Session extends BaseConfig
* DB Group for the database session. * DB Group for the database session.
*/ */
public ?string $DBGroup = null; public ?string $DBGroup = null;
/**
* --------------------------------------------------------------------------
* Lock Retry Interval (microseconds)
* --------------------------------------------------------------------------
*
* This is used for RedisHandler.
*
* Time (microseconds) to wait if lock cannot be acquired.
* The default is 100,000 microseconds (= 0.1 seconds).
*/
public int $lockRetryInterval = 100_000;
/**
* --------------------------------------------------------------------------
* Lock Max Retries
* --------------------------------------------------------------------------
*
* This is used for RedisHandler.
*
* Maximum number of lock acquisition attempts.
* The default is 300 times. That is lock timeout is about 30 (0.1 * 300)
* seconds.
*/
public int $lockMaxRetries = 300;
} }
...@@ -51,5 +51,9 @@ class Tasks extends BaseConfig ...@@ -51,5 +51,9 @@ class Tasks extends BaseConfig
$schedule->command('podcast:import') $schedule->command('podcast:import')
->everyMinute() ->everyMinute()
->named('podcast-import'); ->named('podcast-import');
$schedule->command('episodes:compute-downloads')
->everyHour()
->named('episodes:compute-downloads');
} }
} }
...@@ -33,7 +33,7 @@ class Toolbar extends BaseConfig ...@@ -33,7 +33,7 @@ class Toolbar extends BaseConfig
* List of toolbar collectors that will be called when Debug Toolbar * List of toolbar collectors that will be called when Debug Toolbar
* fires up and collects data from. * fires up and collects data from.
* *
* @var string[] * @var list<class-string>
*/ */
public array $collectors = [ public array $collectors = [
Timers::class, Timers::class,
...@@ -51,7 +51,7 @@ class Toolbar extends BaseConfig ...@@ -51,7 +51,7 @@ class Toolbar extends BaseConfig
* Collect Var Data * Collect Var Data
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
* *
* If set to false var data from the views will not be colleted. Useful to * If set to false var data from the views will not be collected. Useful to
* avoid high memory usage when there are lots of data passed to the view. * avoid high memory usage when there are lots of data passed to the view.
*/ */
public bool $collectVarData = true; public bool $collectVarData = true;
...@@ -102,7 +102,7 @@ class Toolbar extends BaseConfig ...@@ -102,7 +102,7 @@ class Toolbar extends BaseConfig
* *
* NOTE: The ROOTPATH will be prepended to all values. * NOTE: The ROOTPATH will be prepended to all values.
* *
* @var string[] * @var list<string>
*/ */
public array $watchedDirectories = ['app', 'modules', 'themes']; public array $watchedDirectories = ['app', 'modules', 'themes'];
...@@ -114,7 +114,7 @@ class Toolbar extends BaseConfig ...@@ -114,7 +114,7 @@ class Toolbar extends BaseConfig
* Contains an array of file extensions that will be watched for changes and * Contains an array of file extensions that will be watched for changes and
* used to determine if the hot-reload feature should reload the page or not. * used to determine if the hot-reload feature should reload the page or not.
* *
* @var string[] * @var list<string>
*/ */
public array $watchedExtensions = ['php', 'css', 'js', 'html', 'svg', 'json', 'env']; public array $watchedExtensions = ['php', 'css', 'js', 'html', 'svg', 'json', 'env'];
} }
...@@ -5,6 +5,7 @@ declare(strict_types=1); ...@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Config; namespace Config;
use App\Validation\FileRules as AppFileRules; use App\Validation\FileRules as AppFileRules;
use App\Validation\OtherRules;
use CodeIgniter\Config\BaseConfig; use CodeIgniter\Config\BaseConfig;
use CodeIgniter\Validation\StrictRules\CreditCardRules; use CodeIgniter\Validation\StrictRules\CreditCardRules;
use CodeIgniter\Validation\StrictRules\FileRules; use CodeIgniter\Validation\StrictRules\FileRules;
...@@ -16,7 +17,7 @@ class Validation extends BaseConfig ...@@ -16,7 +17,7 @@ class Validation extends BaseConfig
/** /**
* Stores the classes that contain the rules that are available. * Stores the classes that contain the rules that are available.
* *
* @var string[] * @var list<string>
*/ */
public array $ruleSets = [ public array $ruleSets = [
Rules::class, Rules::class,
...@@ -24,6 +25,7 @@ class Validation extends BaseConfig ...@@ -24,6 +25,7 @@ class Validation extends BaseConfig
FileRules::class, FileRules::class,
CreditCardRules::class, CreditCardRules::class,
AppFileRules::class, AppFileRules::class,
OtherRules::class,
]; ];
/** /**
......
...@@ -9,8 +9,8 @@ use CodeIgniter\View\ViewDecoratorInterface; ...@@ -9,8 +9,8 @@ use CodeIgniter\View\ViewDecoratorInterface;
use ViewComponents\Decorator; use ViewComponents\Decorator;
/** /**
* @phpstan-type ParserCallable (callable(mixed): mixed) * @phpstan-type parser_callable (callable(mixed): mixed)
* @phpstan-type ParserCallableString (callable(mixed): mixed)&string * @phpstan-type parser_callable_string (callable(mixed): mixed)&string
*/ */
class View extends BaseView class View extends BaseView
{ {
...@@ -31,8 +31,8 @@ class View extends BaseView ...@@ -31,8 +31,8 @@ class View extends BaseView
* *
* Examples: { title|esc(js) } { created_on|date(Y-m-d)|esc(attr) } * Examples: { title|esc(js) } { created_on|date(Y-m-d)|esc(attr) }
* *
* @var array<string, string> * @var array<string, string>
* @phpstan-var array<string, ParserCallableString> * @phpstan-var array<string, parser_callable_string>
*/ */
public $filters = []; public $filters = [];
...@@ -40,8 +40,8 @@ class View extends BaseView ...@@ -40,8 +40,8 @@ class View extends BaseView
* Parser Plugins provide a way to extend the functionality provided by the core Parser by creating aliases that * Parser Plugins provide a way to extend the functionality provided by the core Parser by creating aliases that
* will be replaced with any callable. Can be single or tag pair. * will be replaced with any callable. Can be single or tag pair.
* *
* @var array<string, array<string>|callable|string> * @var array<string, callable|list<string>|string>
* @phpstan-var array<string, array<ParserCallableString>|ParserCallableString|ParserCallable> * @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable>
*/ */
public $plugins = []; public $plugins = [];
...@@ -51,7 +51,7 @@ class View extends BaseView ...@@ -51,7 +51,7 @@ class View extends BaseView
* *
* All classes must implement CodeIgniter\View\ViewDecoratorInterface * All classes must implement CodeIgniter\View\ViewDecoratorInterface
* *
* @var class-string<ViewDecoratorInterface>[] * @var list<class-string<ViewDecoratorInterface>>
*/ */
public array $decorators = [Decorator::class]; public array $decorators = [Decorator::class];
} }