2020-06-10 15:00:12 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
namespace Config;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
|
|
// Create a new instance of our RouteCollection class.
|
|
|
|
$routes = Services::routes();
|
|
|
|
|
|
|
|
// Load the system's routing file first, so that the app and ENVIRONMENT
|
|
|
|
// can override as needed.
|
2020-06-01 21:23:14 +00:00
|
|
|
if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
|
|
|
|
require SYSTEMPATH . 'Config/Routes.php';
|
2020-05-27 18:46:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
* Router Setup
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
$routes->setDefaultNamespace('App\Controllers');
|
|
|
|
$routes->setDefaultController('Home');
|
|
|
|
$routes->setDefaultMethod('index');
|
|
|
|
$routes->setTranslateURIDashes(false);
|
|
|
|
$routes->set404Override();
|
2020-06-01 21:23:14 +00:00
|
|
|
$routes->setAutoRoute(false);
|
2020-07-31 16:05:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
* Placeholder definitions
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2021-07-26 13:10:46 +00:00
|
|
|
$routes->addPlaceholder('podcastHandle', '[a-zA-Z0-9\_]{1,32}');
|
2021-08-13 11:07:29 +00:00
|
|
|
$routes->addPlaceholder('slug', '[a-zA-Z0-9\-]{1,128}');
|
2020-10-29 17:27:16 +01:00
|
|
|
$routes->addPlaceholder('base64', '[A-Za-z0-9\.\_]+\-{0,2}');
|
2020-11-18 17:17:56 +00:00
|
|
|
$routes->addPlaceholder('platformType', '\bpodcasting|\bsocial|\bfunding');
|
2021-08-13 11:07:29 +00:00
|
|
|
$routes->addPlaceholder('postAction', '\bfavourite|\breblog|\breply');
|
2021-10-20 14:22:58 +00:00
|
|
|
$routes->addPlaceholder('embedTheme', '\blight|\bdark|\blight-transparent|\bdark-transparent');
|
2021-04-02 17:20:02 +00:00
|
|
|
$routes->addPlaceholder(
|
|
|
|
'uuid',
|
|
|
|
'[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}',
|
|
|
|
);
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
* Route Definitions
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2021-10-26 15:54:56 +00:00
|
|
|
$routes->get('manifest.webmanifest', 'WebmanifestController', [
|
|
|
|
'as' => 'webmanifest',
|
|
|
|
]);
|
2022-01-20 11:26:18 +00:00
|
|
|
$routes->get('themes/colors', 'ColorsController', [
|
|
|
|
'as' => 'themes-colors-css',
|
2021-12-07 13:46:08 +00:00
|
|
|
]);
|
2021-10-26 15:54:56 +00:00
|
|
|
|
2020-05-27 18:46:16 +02:00
|
|
|
// We get a performance increase by specifying the default
|
|
|
|
// route since we don't have to scan directories.
|
2021-10-26 15:54:56 +00:00
|
|
|
$routes->get('/', 'HomeController', [
|
2021-05-19 16:35:13 +00:00
|
|
|
'as' => 'home',
|
|
|
|
]);
|
2020-06-10 15:00:12 +00:00
|
|
|
|
2020-11-18 17:17:56 +00:00
|
|
|
$routes->get('.well-known/platforms', 'Platform');
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
// Podcast's Public routes
|
2021-07-26 13:10:46 +00:00
|
|
|
$routes->group('@(:podcastHandle)', function ($routes): void {
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->get('/', 'PodcastController::activity/$1', [
|
2021-04-02 17:20:02 +00:00
|
|
|
'as' => 'podcast-activity',
|
|
|
|
]);
|
2021-11-23 11:54:34 +00:00
|
|
|
$routes->get('manifest.webmanifest', 'WebmanifestController::podcastManifest/$1', [
|
|
|
|
'as' => 'podcast-webmanifest',
|
|
|
|
]);
|
|
|
|
|
2021-08-23 11:05:16 +00:00
|
|
|
// override default Fediverse Library's actor route
|
2021-11-22 14:35:44 +00:00
|
|
|
$routes->options('/', 'ActivityPubController::preflight');
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->get('/', 'PodcastController::activity/$1', [
|
2021-04-02 17:20:02 +00:00
|
|
|
'as' => 'actor',
|
|
|
|
'alternate-content' => [
|
|
|
|
'application/activity+json' => [
|
2021-08-23 11:05:16 +00:00
|
|
|
'namespace' => 'Modules\Fediverse\Controllers',
|
2021-04-02 17:20:02 +00:00
|
|
|
'controller-method' => 'ActorController/$1',
|
|
|
|
],
|
2021-07-12 18:40:22 +00:00
|
|
|
'application/podcast-activity+json' => [
|
|
|
|
'namespace' => 'App\Controllers',
|
|
|
|
'controller-method' => 'PodcastController::podcastActor/$1',
|
|
|
|
],
|
2021-04-02 17:20:02 +00:00
|
|
|
'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
|
2021-08-23 11:05:16 +00:00
|
|
|
'namespace' => 'Modules\Fediverse\Controllers',
|
2021-04-02 17:20:02 +00:00
|
|
|
'controller-method' => 'ActorController/$1',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
]);
|
2021-10-04 15:56:43 +00:00
|
|
|
$routes->get('about', 'PodcastController::about/$1', [
|
|
|
|
'as' => 'podcast-about',
|
|
|
|
]);
|
2021-11-22 14:35:44 +00:00
|
|
|
$routes->options('episodes', 'ActivityPubController::preflight');
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->get('episodes', 'PodcastController::episodes/$1', [
|
2021-04-02 17:20:02 +00:00
|
|
|
'as' => 'podcast-episodes',
|
2021-07-12 18:40:22 +00:00
|
|
|
'alternate-content' => [
|
|
|
|
'application/activity+json' => [
|
|
|
|
'controller-method' => 'PodcastController::episodeCollection/$1',
|
|
|
|
],
|
|
|
|
'application/podcast-activity+json' => [
|
|
|
|
'controller-method' => 'PodcastController::episodeCollection/$1',
|
|
|
|
],
|
|
|
|
'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
|
|
|
|
'controller-method' => 'PodcastController::episodeCollection/$1',
|
|
|
|
],
|
|
|
|
],
|
2021-04-02 17:20:02 +00:00
|
|
|
]);
|
2021-05-06 14:00:48 +00:00
|
|
|
$routes->group('episodes/(:slug)', function ($routes): void {
|
2021-11-22 14:35:44 +00:00
|
|
|
$routes->options('/', 'ActivityPubController::preflight');
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->get('/', 'EpisodeController/$1/$2', [
|
2021-02-27 21:21:26 +00:00
|
|
|
'as' => 'episode',
|
2021-07-12 18:40:22 +00:00
|
|
|
'alternate-content' => [
|
|
|
|
'application/activity+json' => [
|
|
|
|
'controller-method' => 'EpisodeController::episodeObject/$1/$2',
|
|
|
|
],
|
|
|
|
'application/podcast-activity+json' => [
|
|
|
|
'controller-method' => 'EpisodeController::episodeObject/$1/$2',
|
|
|
|
],
|
|
|
|
'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
|
|
|
|
'controller-method' => 'EpisodeController::episodeObject/$1/$2',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
]);
|
2021-10-13 15:43:40 +00:00
|
|
|
$routes->get('activity', 'EpisodeController::activity/$1/$2', [
|
|
|
|
'as' => 'episode-activity',
|
|
|
|
]);
|
2021-11-22 14:35:44 +00:00
|
|
|
$routes->options('comments', 'ActivityPubController::preflight');
|
2021-07-12 18:40:22 +00:00
|
|
|
$routes->get('comments', 'EpisodeController::comments/$1/$2', [
|
|
|
|
'as' => 'episode-comments',
|
|
|
|
'application/activity+json' => [
|
|
|
|
'controller-method' => 'EpisodeController::comments/$1/$2',
|
|
|
|
],
|
|
|
|
'application/podcast-activity+json' => [
|
|
|
|
'controller-method' => 'EpisodeController::comments/$1/$2',
|
|
|
|
],
|
|
|
|
'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
|
|
|
|
'controller-method' => 'EpisodeController::comments/$1/$2',
|
|
|
|
],
|
2021-02-27 21:21:26 +00:00
|
|
|
]);
|
2021-08-13 16:07:45 +00:00
|
|
|
$routes->get('comments/(:uuid)', 'EpisodeCommentController::view/$1/$2/$3', [
|
2021-10-13 15:43:40 +00:00
|
|
|
'as' => 'episode-comment',
|
2021-08-13 16:07:45 +00:00
|
|
|
'application/activity+json' => [
|
|
|
|
'controller-method' => 'EpisodeController::commentObject/$1/$2',
|
|
|
|
],
|
|
|
|
'application/podcast-activity+json' => [
|
|
|
|
'controller-method' => 'EpisodeController::commentObject/$1/$2',
|
|
|
|
],
|
|
|
|
'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
|
|
|
|
'controller-method' => 'EpisodeController::commentObject/$1/$2',
|
|
|
|
],
|
2021-08-13 11:07:29 +00:00
|
|
|
]);
|
2021-08-13 16:07:45 +00:00
|
|
|
$routes->get('comments/(:uuid)/replies', 'EpisodeCommentController::replies/$1/$2/$3', [
|
2021-10-13 15:43:40 +00:00
|
|
|
'as' => 'episode-comment-replies',
|
2021-08-13 11:07:29 +00:00
|
|
|
]);
|
2021-08-13 16:07:45 +00:00
|
|
|
$routes->post('comments/(:uuid)/like', 'EpisodeCommentController::attemptLike/$1/$2/$3', [
|
2021-10-13 15:43:40 +00:00
|
|
|
'as' => 'episode-comment-attempt-like',
|
2021-08-13 16:07:45 +00:00
|
|
|
]);
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->get('oembed.json', 'EpisodeController::oembedJSON/$1/$2', [
|
2021-04-02 17:20:02 +00:00
|
|
|
'as' => 'episode-oembed-json',
|
|
|
|
]);
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->get('oembed.xml', 'EpisodeController::oembedXML/$1/$2', [
|
2021-04-02 17:20:02 +00:00
|
|
|
'as' => 'episode-oembed-xml',
|
|
|
|
]);
|
2021-10-20 14:22:58 +00:00
|
|
|
$routes->group('embed', function ($routes): void {
|
|
|
|
$routes->get('/', 'EpisodeController::embed/$1/$2', [
|
|
|
|
'as' => 'embed',
|
2021-02-27 21:21:26 +00:00
|
|
|
]);
|
2021-10-20 14:22:58 +00:00
|
|
|
$routes->get('(:embedTheme)', 'EpisodeController::embed/$1/$2/$3', [
|
|
|
|
'as' => 'embed-theme',
|
|
|
|
],);
|
2021-02-27 21:21:26 +00:00
|
|
|
});
|
|
|
|
});
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2021-05-19 16:35:13 +00:00
|
|
|
$routes->head('feed.xml', 'FeedController/$1', [
|
|
|
|
'as' => 'podcast_feed',
|
|
|
|
]);
|
|
|
|
$routes->get('feed.xml', 'FeedController/$1', [
|
|
|
|
'as' => 'podcast_feed',
|
|
|
|
]);
|
2020-08-18 16:31:28 +00:00
|
|
|
});
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
// Other pages
|
2021-05-19 16:35:13 +00:00
|
|
|
$routes->get('/credits', 'CreditsController', [
|
|
|
|
'as' => 'credits',
|
|
|
|
]);
|
2021-11-12 16:31:35 +00:00
|
|
|
$routes->get('/map', 'MapController', [
|
2021-09-17 15:50:55 +00:00
|
|
|
'as' => 'map',
|
|
|
|
]);
|
2021-11-12 16:31:35 +00:00
|
|
|
$routes->get('/episodes-markers', 'MapController::getEpisodesMarkers', [
|
2021-09-17 15:50:55 +00:00
|
|
|
'as' => 'episodes-markers',
|
|
|
|
]);
|
2021-05-19 16:35:13 +00:00
|
|
|
$routes->get('/pages/(:slug)', 'PageController/$1', [
|
|
|
|
'as' => 'page',
|
|
|
|
]);
|
2020-08-18 16:31:28 +00:00
|
|
|
|
2020-05-27 18:46:16 +02:00
|
|
|
/**
|
2021-08-23 11:05:16 +00:00
|
|
|
* Overwriting Fediverse routes file
|
2021-04-02 17:20:02 +00:00
|
|
|
*/
|
2021-07-26 13:10:46 +00:00
|
|
|
$routes->group('@(:podcastHandle)', function ($routes): void {
|
2021-08-13 11:07:29 +00:00
|
|
|
$routes->post('posts/new', 'PostController::attemptCreate/$1', [
|
|
|
|
'as' => 'post-attempt-create',
|
2021-04-02 17:20:02 +00:00
|
|
|
'filter' => 'permission:podcast-manage_publications',
|
|
|
|
]);
|
2021-08-13 11:07:29 +00:00
|
|
|
|
|
|
|
// Post
|
|
|
|
$routes->group('posts/(:uuid)', function ($routes): void {
|
2021-11-22 14:35:44 +00:00
|
|
|
$routes->options('/', 'ActivityPubController::preflight');
|
2021-08-13 11:07:29 +00:00
|
|
|
$routes->get('/', 'PostController::view/$1/$2', [
|
|
|
|
'as' => 'post',
|
2021-04-02 17:20:02 +00:00
|
|
|
'alternate-content' => [
|
|
|
|
'application/activity+json' => [
|
2021-08-23 11:05:16 +00:00
|
|
|
'namespace' => 'Modules\Fediverse\Controllers',
|
2021-08-13 11:07:29 +00:00
|
|
|
'controller-method' => 'PostController/$2',
|
2021-04-02 17:20:02 +00:00
|
|
|
],
|
|
|
|
'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
|
2021-08-23 11:05:16 +00:00
|
|
|
'namespace' => 'Modules\Fediverse\Controllers',
|
2021-08-13 11:07:29 +00:00
|
|
|
'controller-method' => 'PostController/$2',
|
2021-04-02 17:20:02 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
]);
|
2021-11-22 14:35:44 +00:00
|
|
|
$routes->options('replies', 'ActivityPubController::preflight');
|
2021-08-13 11:07:29 +00:00
|
|
|
$routes->get('replies', 'PostController/$1/$2', [
|
|
|
|
'as' => 'post-replies',
|
2021-04-02 17:20:02 +00:00
|
|
|
'alternate-content' => [
|
|
|
|
'application/activity+json' => [
|
2021-08-23 11:05:16 +00:00
|
|
|
'namespace' => 'Modules\Fediverse\Controllers',
|
2021-08-13 11:07:29 +00:00
|
|
|
'controller-method' => 'PostController::replies/$2',
|
2021-04-02 17:20:02 +00:00
|
|
|
],
|
|
|
|
'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
|
2021-08-23 11:05:16 +00:00
|
|
|
'namespace' => 'Modules\Fediverse\Controllers',
|
2021-08-13 11:07:29 +00:00
|
|
|
'controller-method' => 'PostController::replies/$2',
|
2021-04-02 17:20:02 +00:00
|
|
|
],
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Actions
|
2021-08-13 11:07:29 +00:00
|
|
|
$routes->post('action', 'PostController::attemptAction/$1/$2', [
|
|
|
|
'as' => 'post-attempt-action',
|
2021-04-02 17:20:02 +00:00
|
|
|
'filter' => 'permission:podcast-interact_as',
|
|
|
|
]);
|
|
|
|
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->post(
|
|
|
|
'block-actor',
|
2021-08-13 11:07:29 +00:00
|
|
|
'PostController::attemptBlockActor/$1/$2',
|
2021-05-12 14:00:25 +00:00
|
|
|
[
|
2021-08-13 11:07:29 +00:00
|
|
|
'as' => 'post-attempt-block-actor',
|
2021-05-12 14:00:25 +00:00
|
|
|
'filter' => 'permission:fediverse-block_actors',
|
|
|
|
],
|
|
|
|
);
|
|
|
|
$routes->post(
|
|
|
|
'block-domain',
|
2021-08-13 11:07:29 +00:00
|
|
|
'PostController::attemptBlockDomain/$1/$2',
|
2021-05-12 14:00:25 +00:00
|
|
|
[
|
2021-08-13 11:07:29 +00:00
|
|
|
'as' => 'post-attempt-block-domain',
|
2021-05-12 14:00:25 +00:00
|
|
|
'filter' => 'permission:fediverse-block_domains',
|
|
|
|
],
|
|
|
|
);
|
2021-08-13 11:07:29 +00:00
|
|
|
$routes->post('delete', 'PostController::attemptDelete/$1/$2', [
|
|
|
|
'as' => 'post-attempt-delete',
|
2021-04-02 17:20:02 +00:00
|
|
|
'filter' => 'permission:podcast-manage_publications',
|
|
|
|
]);
|
|
|
|
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->get(
|
2021-08-13 11:07:29 +00:00
|
|
|
'remote/(:postAction)',
|
|
|
|
'PostController::remoteAction/$1/$2/$3',
|
2021-05-12 14:00:25 +00:00
|
|
|
[
|
2021-08-13 11:07:29 +00:00
|
|
|
'as' => 'post-remote-action',
|
2021-05-12 14:00:25 +00:00
|
|
|
],
|
|
|
|
);
|
2021-04-02 17:20:02 +00:00
|
|
|
});
|
|
|
|
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->get('follow', 'ActorController::follow/$1', [
|
2021-04-02 17:20:02 +00:00
|
|
|
'as' => 'follow',
|
|
|
|
]);
|
2021-05-12 14:00:25 +00:00
|
|
|
$routes->get('outbox', 'ActorController::outbox/$1', [
|
2021-04-02 17:20:02 +00:00
|
|
|
'as' => 'outbox',
|
|
|
|
'filter' => 'activity-pub:verify-activitystream',
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
2020-05-27 18:46:16 +02:00
|
|
|
* --------------------------------------------------------------------
|
|
|
|
* Additional Routing
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* There will often be times that you need additional routing and you
|
2021-04-02 17:20:02 +00:00
|
|
|
* need it to be able to override any defaults in this file. Environment
|
2020-05-27 18:46:16 +02:00
|
|
|
* based routes is one such time. require() additional route files here
|
|
|
|
* to make that happen.
|
|
|
|
*
|
|
|
|
* You will have access to the $routes object within that file without
|
|
|
|
* needing to reload it.
|
|
|
|
*/
|
2020-06-01 21:23:14 +00:00
|
|
|
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
|
|
|
|
require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
|
2020-05-27 18:46:16 +02:00
|
|
|
}
|