Routes.php 35.3 KB
Newer Older
1
2
<?php

3
4
declare(strict_types=1);

5
namespace Config;
6
7
8
9
10
11

// 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.
12
13
if (file_exists(SYSTEMPATH . 'Config/Routes.php')) {
    require SYSTEMPATH . 'Config/Routes.php';
14
15
16
17
18
19
20
21
22
23
24
25
}

/**
 * --------------------------------------------------------------------
 * Router Setup
 * --------------------------------------------------------------------
 */
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
26
$routes->setAutoRoute(false);
27
28
29
30
31
32
33

/**
 * --------------------------------------------------------------------
 * Placeholder definitions
 * --------------------------------------------------------------------
 */

34
$routes->addPlaceholder('podcastName', '[a-zA-Z0-9\_]{1,32}');
35
$routes->addPlaceholder('slug', '[a-zA-Z0-9\-]{1,191}');
36
$routes->addPlaceholder('base64', '[A-Za-z0-9\.\_]+\-{0,2}');
37
$routes->addPlaceholder('platformType', '\bpodcasting|\bsocial|\bfunding');
38
$routes->addPlaceholder('statusAction', '\bfavourite|\breblog|\breply');
39
$routes->addPlaceholder('embeddablePlayerTheme', '\blight|\bdark|\blight-transparent|\bdark-transparent');
40
41
42
43
$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}',
);
44
45
46
47
48
49
50
51
52

/**
 * --------------------------------------------------------------------
 * Route Definitions
 * --------------------------------------------------------------------
 */

// We get a performance increase by specifying the default
// route since we don't have to scan directories.
53
54
55
$routes->get('/', 'HomeController::index', [
    'as' => 'home',
]);
56

57
// Install Wizard route
58
$routes->group(config('App')->installGateway, function ($routes): void {
59
60
61
62
63
    $routes->get('/', 'InstallController', [
        'as' => 'install',
    ]);
    $routes->post('instance-config', 'InstallController::attemptInstanceConfig', [
        'as' => 'instance-config',
64
    ]);
65
66
    $routes->post('database-config', 'InstallController::attemptDatabaseConfig', [
        'as' => 'database-config',
67
    ]);
68
    $routes->post('cache-config', 'InstallController::attemptCacheConfig', [
69
        'as' => 'cache-config',
70
    ]);
71
72
73
74
75
76
77
    $routes->post(
        'create-superadmin',
        'InstallController::attemptCreateSuperAdmin',
        [
            'as' => 'create-superadmin',
        ],
    );
78
79
});

80
81
$routes->get('.well-known/platforms', 'Platform');

82
83
// Admin area
$routes->group(
84
85
86
87
88
    config('App')
        ->adminGateway,
    [
        'namespace' => 'App\Controllers\Admin',
    ],
89
    function ($routes): void {
90
        $routes->get('/', 'HomeController', [
91
            'as' => 'admin',
92
93
        ]);

94
        $routes->group('persons', function ($routes): void {
95
            $routes->get('/', 'PersonController', [
96
97
98
                'as' => 'person-list',
                'filter' => 'permission:person-list',
            ]);
99
            $routes->get('new', 'PersonController::create', [
100
101
102
                'as' => 'person-create',
                'filter' => 'permission:person-create',
            ]);
103
            $routes->post('new', 'PersonController::attemptCreate', [
104
105
                'filter' => 'permission:person-create',
            ]);
106
            $routes->group('(:num)', function ($routes): void {
107
                $routes->get('/', 'PersonController::view/$1', [
108
109
110
                    'as' => 'person-view',
                    'filter' => 'permission:person-view',
                ]);
111
                $routes->get('edit', 'PersonController::edit/$1', [
112
113
114
                    'as' => 'person-edit',
                    'filter' => 'permission:person-edit',
                ]);
115
                $routes->post('edit', 'PersonController::attemptEdit/$1', [
116
117
                    'filter' => 'permission:person-edit',
                ]);
118
                $routes->add('delete', 'PersonController::delete/$1', [
119
120
121
122
123
124
                    'as' => 'person-delete',
                    'filter' => 'permission:person-delete',
                ]);
            });
        });

125
        // Podcasts
126
        $routes->group('podcasts', function ($routes): void {
127
            $routes->get('/', 'PodcastController::list', [
128
                'as' => 'podcast-list',
129
            ]);
130
            $routes->get('new', 'PodcastController::create', [
131
132
                'as' => 'podcast-create',
                'filter' => 'permission:podcasts-create',
133
            ]);
134
            $routes->post('new', 'PodcastController::attemptCreate', [
135
                'filter' => 'permission:podcasts-create',
136
            ]);
137
            $routes->get('import', 'PodcastImportController', [
138
139
140
                'as' => 'podcast-import',
                'filter' => 'permission:podcasts-import',
            ]);
141
            $routes->post('import', 'PodcastImportController::attemptImport', [
142
143
                'filter' => 'permission:podcasts-import',
            ]);
144

145
146
            // Podcast
            // Use ids in admin area to help permission and group lookups
147
            $routes->group('(:num)', function ($routes): void {
148
                $routes->get('/', 'PodcastController::view/$1', [
149
150
151
                    'as' => 'podcast-view',
                    'filter' => 'permission:podcasts-view,podcast-view',
                ]);
152
                $routes->get('edit', 'PodcastController::edit/$1', [
153
                    'as' => 'podcast-edit',
154
                    'filter' => 'permission:podcast-edit',
155
                ]);
156
                $routes->post('edit', 'PodcastController::attemptEdit/$1', [
157
                    'filter' => 'permission:podcast-edit',
158
                ]);
159
                $routes->get('delete', 'PodcastController::delete/$1', [
160
                    'as' => 'podcast-delete',
161
                    'filter' => 'permission:podcasts-delete',
162
                ]);
163

164
                $routes->group('persons', function ($routes): void {
165
                    $routes->get('/', 'PodcastPersonController/$1', [
166
167
168
                        'as' => 'podcast-person-manage',
                        'filter' => 'permission:podcast-edit',
                    ]);
169
170
                    $routes->post(
                        '/',
171
                        'PodcastPersonController::attemptAdd/$1',
172
173
174
175
                        [
                            'filter' => 'permission:podcast-edit',
                        ],
                    );
176
177
178

                    $routes->get(
                        '(:num)/remove',
179
                        'PodcastPersonController::remove/$1/$2',
180
181
182
                        [
                            'as' => 'podcast-person-remove',
                            'filter' => 'permission:podcast-edit',
183
                        ],
184
185
186
                    );
                });

187
                $routes->group('analytics', function ($routes): void {
188
                    $routes->get('/', 'PodcastController::viewAnalytics/$1', [
189
190
191
192
193
                        'as' => 'podcast-analytics',
                        'filter' => 'permission:podcasts-view,podcast-view',
                    ]);
                    $routes->get(
                        'webpages',
194
                        'PodcastController::viewAnalyticsWebpages/$1',
195
196
197
                        [
                            'as' => 'podcast-analytics-webpages',
                            'filter' => 'permission:podcasts-view,podcast-view',
198
                        ],
199
200
201
                    );
                    $routes->get(
                        'locations',
202
                        'PodcastController::viewAnalyticsLocations/$1',
203
204
205
                        [
                            'as' => 'podcast-analytics-locations',
                            'filter' => 'permission:podcasts-view,podcast-view',
206
                        ],
207
208
209
                    );
                    $routes->get(
                        'unique-listeners',
210
                        'PodcastController::viewAnalyticsUniqueListeners/$1',
211
212
213
                        [
                            'as' => 'podcast-analytics-unique-listeners',
                            'filter' => 'permission:podcasts-view,podcast-view',
214
                        ],
215
                    );
216
217
                    $routes->get(
                        'listening-time',
218
                        'PodcastController::viewAnalyticsListeningTime/$1',
219
220
221
                        [
                            'as' => 'podcast-analytics-listening-time',
                            'filter' => 'permission:podcasts-view,podcast-view',
222
                        ],
223
                    );
224
225
                    $routes->get(
                        'time-periods',
226
                        'PodcastController::viewAnalyticsTimePeriods/$1',
227
228
229
                        [
                            'as' => 'podcast-analytics-time-periods',
                            'filter' => 'permission:podcasts-view,podcast-view',
230
                        ],
231
                    );
232
233
                    $routes->get(
                        'players',
234
                        'PodcastController::viewAnalyticsPlayers/$1',
235
236
237
                        [
                            'as' => 'podcast-analytics-players',
                            'filter' => 'permission:podcasts-view,podcast-view',
238
                        ],
239
240
241
                    );
                });

242
                // Podcast episodes
243
                $routes->group('episodes', function ($routes): void {
244
                    $routes->get('/', 'EpisodeController::list/$1', [
245
                        'as' => 'episode-list',
246
247
                        'filter' =>
                            'permission:episodes-list,podcast_episodes-list',
248
                    ]);
249
                    $routes->get('new', 'EpisodeController::create/$1', [
250
                        'as' => 'episode-create',
251
                        'filter' => 'permission:podcast_episodes-create',
252
                    ]);
253
254
255
256
257
258
259
                    $routes->post(
                        'new',
                        'EpisodeController::attemptCreate/$1',
                        [
                            'filter' => 'permission:podcast_episodes-create',
                        ],
                    );
260

261
                    // Episode
262
                    $routes->group('(:num)', function ($routes): void {
263
                        $routes->get('/', 'EpisodeController::view/$1/$2', [
264
265
266
267
                            'as' => 'episode-view',
                            'filter' =>
                                'permission:episodes-view,podcast_episodes-view',
                        ]);
268
                        $routes->get('edit', 'EpisodeController::edit/$1/$2', [
269
                            'as' => 'episode-edit',
270
                            'filter' => 'permission:podcast_episodes-edit',
271
                        ]);
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
                        $routes->post(
                            'edit',
                            'EpisodeController::attemptEdit/$1/$2',
                            [
                                'filter' => 'permission:podcast_episodes-edit',
                            ],
                        );
                        $routes->get(
                            'publish',
                            'EpisodeController::publish/$1/$2',
                            [
                                'as' => 'episode-publish',
                                'filter' =>
                                    'permission:podcast-manage_publications',
                            ],
                        );
288
289
                        $routes->post(
                            'publish',
290
                            'EpisodeController::attemptPublish/$1/$2',
291
292
293
294
295
296
297
                            [
                                'filter' =>
                                    'permission:podcast-manage_publications',
                            ],
                        );
                        $routes->get(
                            'publish-edit',
298
                            'EpisodeController::publishEdit/$1/$2',
299
300
301
302
303
304
305
306
                            [
                                'as' => 'episode-publish_edit',
                                'filter' =>
                                    'permission:podcast-manage_publications',
                            ],
                        );
                        $routes->post(
                            'publish-edit',
307
                            'EpisodeController::attemptPublishEdit/$1/$2',
308
309
310
311
312
                            [
                                'filter' =>
                                    'permission:podcast-manage_publications',
                            ],
                        );
313
314
315
316
317
318
319
320
321
                        $routes->get(
                            'publish-cancel',
                            'EpisodeController::publishCancel/$1/$2',
                            [
                                'as' => 'episode-publish-cancel',
                                'filter' =>
                                    'permission:podcast-manage_publications',
                            ],
                        );
322
323
324
325
326
327
328
329
330
                        $routes->get(
                            'unpublish',
                            'EpisodeController::unpublish/$1/$2',
                            [
                                'as' => 'episode-unpublish',
                                'filter' =>
                                    'permission:podcast-manage_publications',
                            ],
                        );
331
332
                        $routes->post(
                            'unpublish',
333
                            'EpisodeController::attemptUnpublish/$1/$2',
334
335
336
337
338
                            [
                                'filter' =>
                                    'permission:podcast-manage_publications',
                            ],
                        );
339
340
341
342
343
344
345
346
347
                        $routes->get(
                            'delete',
                            'EpisodeController::delete/$1/$2',
                            [
                                'as' => 'episode-delete',
                                'filter' =>
                                    'permission:podcast_episodes-delete',
                            ],
                        );
348
349
                        $routes->get(
                            'transcript-delete',
350
                            'EpisodeController::transcriptDelete/$1/$2',
351
352
353
                            [
                                'as' => 'transcript-delete',
                                'filter' => 'permission:podcast_episodes-edit',
354
                            ],
355
356
357
                        );
                        $routes->get(
                            'chapters-delete',
358
                            'EpisodeController::chaptersDelete/$1/$2',
359
360
361
                            [
                                'as' => 'chapters-delete',
                                'filter' => 'permission:podcast_episodes-edit',
362
                            ],
363
                        );
364
365
                        $routes->get(
                            'soundbites',
366
                            'EpisodeController::soundbitesEdit/$1/$2',
367
368
369
                            [
                                'as' => 'soundbites-edit',
                                'filter' => 'permission:podcast_episodes-edit',
370
                            ],
371
372
373
                        );
                        $routes->post(
                            'soundbites',
374
                            'EpisodeController::soundbitesAttemptEdit/$1/$2',
375
376
                            [
                                'filter' => 'permission:podcast_episodes-edit',
377
                            ],
378
                        );
379
                        $routes->get(
380
                            'soundbites/(:num)/delete',
381
                            'EpisodeController::soundbiteDelete/$1/$2/$3',
382
383
384
                            [
                                'as' => 'soundbite-delete',
                                'filter' => 'permission:podcast_episodes-edit',
385
                            ],
386
                        );
387
388
                        $routes->get(
                            'embeddable-player',
389
                            'EpisodeController::embeddablePlayer/$1/$2',
390
391
392
                            [
                                'as' => 'embeddable-player-add',
                                'filter' => 'permission:podcast_episodes-edit',
393
                            ],
394
                        );
395

396
                        $routes->group('persons', function ($routes): void {
397
                            $routes->get('/', 'EpisodePersonController/$1/$2', [
398
399
400
401
402
                                'as' => 'episode-person-manage',
                                'filter' => 'permission:podcast_episodes-edit',
                            ]);
                            $routes->post(
                                '/',
403
                                'EpisodePersonController::attemptAdd/$1/$2',
404
405
406
                                [
                                    'filter' =>
                                        'permission:podcast_episodes-edit',
407
                                ],
408
409
410
                            );
                            $routes->get(
                                '(:num)/remove',
411
                                'EpisodePersonController::remove/$1/$2/$3',
412
413
414
415
                                [
                                    'as' => 'episode-person-remove',
                                    'filter' =>
                                        'permission:podcast_episodes-edit',
416
                                ],
417
418
                            );
                        });
419
420
421
422
                    });
                });

                // Podcast contributors
423
                $routes->group('contributors', function ($routes): void {
424
                    $routes->get('/', 'ContributorController::list/$1', [
425
426
                        'as' => 'contributor-list',
                        'filter' =>
427
                            'permission:podcasts-view,podcast-manage_contributors',
428
                    ]);
429
                    $routes->get('add', 'ContributorController::add/$1', [
430
                        'as' => 'contributor-add',
431
                        'filter' => 'permission:podcast-manage_contributors',
432
                    ]);
433
434
435
436
437
438
439
440
                    $routes->post(
                        'add',
                        'ContributorController::attemptAdd/$1',
                        [
                            'filter' =>
                                'permission:podcast-manage_contributors',
                        ],
                    );
441
442

                    // Contributor
443
                    $routes->group('(:num)', function ($routes): void {
444
                        $routes->get('/', 'ContributorController::view/$1/$2', [
445
                            'as' => 'contributor-view',
446
447
                            'filter' =>
                                'permission:podcast-manage_contributors',
448
                        ]);
449
450
451
452
453
454
455
456
457
                        $routes->get(
                            'edit',
                            'ContributorController::edit/$1/$2',
                            [
                                'as' => 'contributor-edit',
                                'filter' =>
                                    'permission:podcast-manage_contributors',
                            ],
                        );
458
459
                        $routes->post(
                            'edit',
460
                            'ContributorController::attemptEdit/$1/$2',
461
462
                            [
                                'filter' =>
463
                                    'permission:podcast-manage_contributors',
464
                            ],
465
                        );
466
467
468
469
470
471
472
473
474
                        $routes->get(
                            'remove',
                            'ContributorController::remove/$1/$2',
                            [
                                'as' => 'contributor-remove',
                                'filter' =>
                                    'permission:podcast-manage_contributors',
                            ],
                        );
475
476
                    });
                });
477

478
                $routes->group('platforms', function ($routes): void {
479
480
                    $routes->get(
                        '/',
481
                        'PodcastPlatformController::platforms/$1/podcasting',
482
483
484
                        [
                            'as' => 'platforms-podcasting',
                            'filter' => 'permission:podcast-manage_platforms',
485
                        ],
486
487
488
                    );
                    $routes->get(
                        'social',
489
                        'PodcastPlatformController::platforms/$1/social',
490
491
492
                        [
                            'as' => 'platforms-social',
                            'filter' => 'permission:podcast-manage_platforms',
493
                        ],
494
495
496
                    );
                    $routes->get(
                        'funding',
497
                        'PodcastPlatformController::platforms/$1/funding',
498
499
500
                        [
                            'as' => 'platforms-funding',
                            'filter' => 'permission:podcast-manage_platforms',
501
                        ],
502
                    );
503
                    $routes->post(
504
                        'save/(:platformType)',
505
                        'PodcastPlatformController::attemptPlatformsUpdate/$1/$2',
506
507
508
                        [
                            'as' => 'platforms-save',
                            'filter' => 'permission:podcast-manage_platforms',
509
                        ],
510
                    );
511
                    $routes->get(
512
                        '(:slug)/podcast-platform-remove',
513
                        'PodcastPlatformController::removePodcastPlatform/$1/$2',
514
                        [
515
                            'as' => 'podcast-platform-remove',
516
                            'filter' => 'permission:podcast-manage_platforms',
517
                        ],
518
519
                    );
                });
520
            });
521
522
        });

523
        // Instance wide Fediverse config
524
        $routes->group('fediverse', function ($routes): void {
525
            $routes->get('/', 'FediverseController::dashboard', [
526
527
                'as' => 'fediverse-dashboard',
            ]);
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
            $routes->get(
                'blocked-actors',
                'FediverseController::blockedActors',
                [
                    'as' => 'fediverse-blocked-actors',
                    'filter' => 'permission:fediverse-block_actors',
                ],
            );
            $routes->get(
                'blocked-domains',
                'FediverseController::blockedDomains',
                [
                    'as' => 'fediverse-blocked-domains',
                    'filter' => 'permission:fediverse-block_domains',
                ],
            );
544
545
        });

546
        // Pages
547
        $routes->group('pages', function ($routes): void {
548
549
550
            $routes->get('/', 'PageController::list', [
                'as' => 'page-list',
            ]);
551
            $routes->get('new', 'PageController::create', [
552
                'as' => 'page-create',
553
554
                'filter' => 'permission:pages-manage',
            ]);
555
            $routes->post('new', 'PageController::attemptCreate', [
556
                'filter' => 'permission:pages-manage',
557
558
            ]);

559
            $routes->group('(:num)', function ($routes): void {
560
561
562
563
                $routes->get('/', 'PageController::view/$1', [
                    'as' => 'page-view',
                ]);
                $routes->get('edit', 'PageController::edit/$1', [
564
                    'as' => 'page-edit',
565
566
                    'filter' => 'permission:pages-manage',
                ]);
567
                $routes->post('edit', 'PageController::attemptEdit/$1', [
568
                    'filter' => 'permission:pages-manage',
569
570
                ]);

571
                $routes->get('delete', 'PageController::delete/$1', [
572
                    'as' => 'page-delete',
573
                    'filter' => 'permission:pages-manage',
574
575
576
577
                ]);
            });
        });

578
        // Users
579
        $routes->group('users', function ($routes): void {
580
            $routes->get('/', 'UserController::list', [
581
582
583
                'as' => 'user-list',
                'filter' => 'permission:users-list',
            ]);
584
            $routes->get('new', 'UserController::create', [
585
586
587
                'as' => 'user-create',
                'filter' => 'permission:users-create',
            ]);
588
            $routes->post('new', 'UserController::attemptCreate', [
589
590
                'filter' => 'permission:users-create',
            ]);
591

592
            // User
593
            $routes->group('(:num)', function ($routes): void {
594
                $routes->get('/', 'UserController::view/$1', [
595
596
597
                    'as' => 'user-view',
                    'filter' => 'permission:users-view',
                ]);
598
                $routes->get('edit', 'UserController::edit/$1', [
599
600
601
                    'as' => 'user-edit',
                    'filter' => 'permission:users-manage_authorizations',
                ]);
602
                $routes->post('edit', 'UserController::attemptEdit/$1', [
603
604
                    'filter' => 'permission:users-manage_authorizations',
                ]);
605
                $routes->get('ban', 'UserController::ban/$1', [
606
607
608
                    'as' => 'user-ban',
                    'filter' => 'permission:users-manage_bans',
                ]);
609
                $routes->get('unban', 'UserController::unBan/$1', [
610
611
612
                    'as' => 'user-unban',
                    'filter' => 'permission:users-manage_bans',
                ]);
613
614
615
616
617
618
619
620
621
                $routes->get(
                    'force-pass-reset',
                    'UserController::forcePassReset/$1',
                    [
                        'as' => 'user-force_pass_reset',
                        'filter' => 'permission:users-force_pass_reset',
                    ],
                );
                $routes->get('delete', 'UserController::delete/$1', [
622
623
624
625
626
                    'as' => 'user-delete',
                    'filter' => 'permission:users-delete',
                ]);
            });
        });
627
628

        // My account
629
        $routes->group('my-account', function ($routes): void {
630
            $routes->get('/', 'MyAccountController', [
631
632
                'as' => 'my-account',
            ]);
633
634
635
636
637
638
639
            $routes->get(
                'change-password',
                'MyAccountController::changePassword/$1',
                [
                    'as' => 'change-password',
                ],
            );
640
            $routes->post('change-password', 'MyAccountController::attemptChange/$1');
641
        });
642
    },
643
644
645
646
647
);

/**
 * Overwriting Myth:auth routes file
 */
648
$routes->group(config('App')->authGateway, function ($routes): void {
649
    // Login/out
650
651
652
    $routes->get('login', 'AuthController::login', [
        'as' => 'login',
    ]);
653
654
655
656
    $routes->post('login', 'AuthController::attemptLogin');
    $routes->get('logout', 'AuthController::logout', [
        'as' => 'logout',
    ]);
657

658
    // Registration
659
    $routes->get('register', 'AuthController::register', [
660
661
        'as' => 'register',
    ]);
662
    $routes->post('register', 'AuthController::attemptRegister');
663

664
    // Activation
665
    $routes->get('activate-account', 'AuthController::activateAccount', [
666
667
        'as' => 'activate-account',
    ]);
668
669
670
671
672
673
674
    $routes->get(
        'resend-activate-account',
        'AuthController::resendActivateAccount',
        [
            'as' => 'resend-activate-account',
        ],
    );
675

676
    // Forgot/Resets
677
    $routes->get('forgot', 'AuthController::forgotPassword', [
678
679
        'as' => 'forgot',
    ]);
680
681
    $routes->post('forgot', 'AuthController::attemptForgot');
    $routes->get('reset-password', 'AuthController::resetPassword', [
682
683
        'as' => 'reset-password',
    ]);
684
    $routes->post('reset-password', 'AuthController::attemptReset');
685
});
686

687
// Podcast's Public routes
688
$routes->group('@(:podcastName)', function ($routes): void {
689
    $routes->get('/', 'PodcastController::activity/$1', [
690
691
692
        'as' => 'podcast-activity',
    ]);
    // override default ActivityPub Library's actor route
693
    $routes->get('/', 'PodcastController::activity/$1', [
694
695
696
697
698
699
        'as' => 'actor',
        'alternate-content' => [
            'application/activity+json' => [
                'namespace' => 'ActivityPub\Controllers',
                'controller-method' => 'ActorController/$1',
            ],
700
701
702
703
            'application/podcast-activity+json' => [
                'namespace' => 'App\Controllers',
                'controller-method' => 'PodcastController::podcastActor/$1',
            ],
704
705
706
707
708
709
            'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
                'namespace' => 'ActivityPub\Controllers',
                'controller-method' => 'ActorController/$1',
            ],
        ],
    ]);
710
    $routes->get('episodes', 'PodcastController::episodes/$1', [
711
        'as' => 'podcast-episodes',
712
713
714
715
716
717
718
719
720
721
722
        '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',
            ],
        ],
723
    ]);
724
    $routes->group('episodes/(:slug)', function ($routes): void {
725
        $routes->get('/', 'EpisodeController/$1/$2', [
726
            'as' => 'episode',
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
            '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',
                ],
            ],
        ]);
        $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',
            ],
750
        ]);
751
        $routes->get('oembed.json', 'EpisodeController::oembedJSON/$1/$2', [
752
753
            'as' => 'episode-oembed-json',
        ]);
754
        $routes->get('oembed.xml', 'EpisodeController::oembedXML/$1/$2', [
755
756
            'as' => 'episode-oembed-xml',
        ]);
757
        $routes->group('embeddable-player', function ($routes): void {
758
            $routes->get('/', 'EpisodeController::embeddablePlayer/$1/$2', [
759
760
                'as' => 'embeddable-player',
            ]);
761
762
            $routes->get(
                '(:embeddablePlayerTheme)',
763
                'EpisodeController::embeddablePlayer/$1/$2/$3',
764
765
766
767
                [
                    'as' => 'embeddable-player-theme',
                ],
            );
768
769
        });
    });
770

771
772
773
774
775
776
    $routes->head('feed.xml', 'FeedController/$1', [
        'as' => 'podcast_feed',
    ]);
    $routes->get('feed.xml', 'FeedController/$1', [
        'as' => 'podcast_feed',
    ]);
777
});
778
779

// Other pages
780
781
782
783
784
785
$routes->get('/credits', 'CreditsController', [
    'as' => 'credits',
]);
$routes->get('/pages/(:slug)', 'PageController/$1', [
    'as' => 'page',
]);
786

787
// interacting as an actor
788
$routes->post('interact-as-actor', 'AuthController::attemptInteractAsActor', [
789
790
791
    'as' => 'interact-as-actor',
]);

792
/**
793
794
 * Overwriting ActivityPub routes file
 */
795
$routes->group('@(:podcastName)', function ($routes): void {
796
797
    $routes->post('statuses/new', 'StatusController::attemptCreate/$1', [
        'as' => 'status-attempt-create',
798
799
        'filter' => 'permission:podcast-manage_publications',
    ]);
800
801
802
803
    // Status
    $routes->group('statuses/(:uuid)', function ($routes): void {
        $routes->get('/', 'StatusController::view/$1/$2', [
            'as' => 'status',
804
805
806
            'alternate-content' => [
                'application/activity+json' => [
                    'namespace' => 'ActivityPub\Controllers',
807
                    'controller-method' => 'StatusController/$2',
808
809
810
                ],
                'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
                    'namespace' => 'ActivityPub\Controllers',
811
                    'controller-method' => 'StatusController/$2',
812
813
814
                ],
            ],
        ]);
815
816
        $routes->get('replies', 'StatusController/$1/$2', [
            'as' => 'status-replies',
817
818
819
            'alternate-content' => [
                'application/activity+json' => [
                    'namespace' => 'ActivityPub\Controllers',
820
                    'controller-method' => 'StatusController::replies/$2',
821
822
823
                ],
                'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
                    'namespace' => 'ActivityPub\Controllers',
824
                    'controller-method' => 'StatusController::replies/$2',
825
826
827
828
829
                ],
            ],
        ]);

        // Actions
830
831
        $routes->post('action', 'StatusController::attemptAction/$1/$2', [
            'as' => 'status-attempt-action',
832
833
834
            'filter' => 'permission:podcast-interact_as',
        ]);

835
836
        $routes->post(
            'block-actor',
837
            'StatusController::attemptBlockActor/$1/$2',
838
            [
839
                'as' => 'status-attempt-block-actor',
840
841
842
843
844
                'filter' => 'permission:fediverse-block_actors',
            ],
        );
        $routes->post(
            'block-domain',
845
            'StatusController::attemptBlockDomain/$1/$2',
846
            [
847
                'as' => 'status-attempt-block-domain',
848
849
850
                'filter' => 'permission:fediverse-block_domains',
            ],
        );
851
852
        $routes->post('delete', 'StatusController::attemptDelete/$1/$2', [
            'as' => 'status-attempt-delete',
853
854
855
            'filter' => 'permission:podcast-manage_publications',
        ]);

856
        $routes->get(
857
858
            'remote/(:statusAction)',
            'StatusController::remoteAction/$1/$2/$3',
859
            [
860
                'as' => 'status-remote-action',
861
862
            ],
        );
863
864
    });

865
    $routes->get('follow', 'ActorController::follow/$1', [
866
867
        'as' => 'follow',
    ]);
868
    $routes->get('outbox', 'ActorController::outbox/$1', [
869
870
871
872
873
874
        'as' => 'outbox',
        'filter' => 'activity-pub:verify-activitystream',
    ]);
});

/*
875
876
877
878
879
 * --------------------------------------------------------------------
 * Additional Routing
 * --------------------------------------------------------------------
 *
 * There will often be times that you need additional routing and you
880
 * need it to be able to override any defaults in this file. Environment
881
882
883
884
885
886
 * 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.
 */
887
888
if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) {
    require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php';
889
}