Commit 9dd4c774 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix: rename podcast name to podcast handle to clarify field usage

- podcast name was too vague and didn't come clearly for users: handle is more relevant
- update
package.json dependencies and remove unnused packages

closes #126
parent 3a0a76d7
......@@ -12,6 +12,7 @@
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[php]": {
"editor.defaultFormatter": "bmewburn.vscode-intelephense-client",
"editor.formatOnSave": false
......
......@@ -31,7 +31,7 @@ $routes->setAutoRoute(false);
* --------------------------------------------------------------------
*/
$routes->addPlaceholder('podcastName', '[a-zA-Z0-9\_]{1,32}');
$routes->addPlaceholder('podcastHandle', '[a-zA-Z0-9\_]{1,32}');
$routes->addPlaceholder('slug', '[a-zA-Z0-9\-]{1,191}');
$routes->addPlaceholder('base64', '[A-Za-z0-9\.\_]+\-{0,2}');
$routes->addPlaceholder('platformType', '\bpodcasting|\bsocial|\bfunding');
......@@ -685,7 +685,7 @@ $routes->group(config('App')->authGateway, function ($routes): void {
});
// Podcast's Public routes
$routes->group('@(:podcastName)', function ($routes): void {
$routes->group('@(:podcastHandle)', function ($routes): void {
$routes->get('/', 'PodcastController::activity/$1', [
'as' => 'podcast-activity',
]);
......@@ -802,7 +802,7 @@ $routes->post('interact-as-actor', 'AuthController::attemptInteractAsActor', [
/**
* Overwriting ActivityPub routes file
*/
$routes->group('@(:podcastName)', function ($routes): void {
$routes->group('@(:podcastHandle)', function ($routes): void {
$routes->post('statuses/new', 'StatusController::attemptCreate/$1', [
'as' => 'status-attempt-create',
'filter' => 'permission:podcast-manage_publications',
......
......@@ -192,9 +192,9 @@ class PodcastController extends BaseController
}
$podcast = new Podcast([
'guid' => podcast_uuid(url_to('podcast_feed', $this->request->getPost('name'))),
'guid' => podcast_uuid(url_to('podcast_feed', $this->request->getPost('handle'))),
'title' => $this->request->getPost('title'),
'name' => $this->request->getPost('name'),
'handle' => $this->request->getPost('handle'),
'description_markdown' => $this->request->getPost('description'),
'image' => new Image($this->request->getFile('image')),
'language_code' => $this->request->getPost('language'),
......
......@@ -131,14 +131,14 @@ class PodcastImportController extends BaseController
if (property_exists($nsPodcast, 'guid') && $nsPodcast->guid !== null) {
$guid = (string) $nsPodcast->guid;
} else {
$guid = podcast_uuid(url_to('podcast_feed', $this->request->getPost('name')));
$guid = podcast_uuid(url_to('podcast_feed', $this->request->getPost('handle')));
}
$podcast = new Podcast([
'guid' => $guid,
'name' => $this->request->getPost('name'),
'handle' => $this->request->getPost('handle'),
'imported_feed_url' => $this->request->getPost('imported_feed_url'),
'new_feed_url' => url_to('podcast_feed', $this->request->getPost('name')),
'new_feed_url' => url_to('podcast_feed', $this->request->getPost('handle')),
'title' => (string) $feed->channel[0]->title,
'description_markdown' => $converter->convert($channelDescriptionHtml),
'description_html' => $channelDescriptionHtml,
......
......@@ -41,7 +41,7 @@ class EpisodeController extends BaseController
}
if (
($podcast = (new PodcastModel())->getPodcastByName($params[0])) === null
($podcast = (new PodcastModel())->getPodcastByHandle($params[0])) === null
) {
throw PageNotFoundException::forPageNotFound();
}
......@@ -50,7 +50,7 @@ class EpisodeController extends BaseController
if (
($episode = (new EpisodeModel())->getEpisodeBySlug($params[0], $params[1])) === null
) {
) {
throw PageNotFoundException::forPageNotFound();
}
......
......@@ -20,11 +20,11 @@ use Opawg\UserAgentsPhp\UserAgentsRSS;
class FeedController extends Controller
{
public function index(string $podcastName): ResponseInterface
public function index(string $podcastHandle): ResponseInterface
{
helper('rss');
$podcast = (new PodcastModel())->where('name', $podcastName)
$podcast = (new PodcastModel())->where('handle', $podcastHandle)
->first();
if (! $podcast) {
throw PageNotFoundException::forPageNotFound();
......
......@@ -31,7 +31,7 @@ class HomeController extends BaseController
// check if there's only one podcast to redirect user to it
if (count($allPodcasts) === 1) {
return redirect()->route('podcast-activity', [$allPodcasts[0]->name]);
return redirect()->route('podcast-activity', [$allPodcasts[0]->handle]);
}
// default behavior: list all podcasts on home page
......
......@@ -20,7 +20,6 @@ use App\Models\EpisodeModel;
use App\Models\PodcastModel;
use App\Models\StatusModel;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\Response;
class PodcastController extends BaseController
......@@ -36,7 +35,7 @@ class PodcastController extends BaseController
}
if (
($podcast = (new PodcastModel())->getPodcastByName($params[0])) === null
($podcast = (new PodcastModel())->getPodcastByHandle($params[0])) === null
) {
throw PageNotFoundException::forPageNotFound();
}
......@@ -48,7 +47,10 @@ class PodcastController extends BaseController
return $this->{$method}(...$params);
}
public function podcastActor(): RedirectResponse
/**
* @noRector ReturnTypeDeclarationRector
*/
public function podcastActor(): Response
{
$podcastActor = new PodcastActor($this->podcast);
......@@ -161,7 +163,7 @@ class PodcastController extends BaseController
'label' => $year['year'],
'number_of_episodes' => $year['number_of_episodes'],
'route' =>
route_to('podcast-episodes', $this->podcast->name) .
route_to('podcast-episodes', $this->podcast->handle) .
'?year=' .
$year['year'],
'is_active' => $isActive,
......@@ -187,7 +189,7 @@ class PodcastController extends BaseController
]),
'number_of_episodes' => $season['number_of_episodes'],
'route' =>
route_to('podcast-episodes', $this->podcast->name) .
route_to('podcast-episodes', $this->podcast->handle) .
'?season=' .
$season['season_number'],
'is_active' => $isActive,
......
......@@ -40,7 +40,7 @@ class StatusController extends ActivityPubStatusController
public function _remap(string $method, string ...$params): mixed
{
if (
($podcast = (new PodcastModel())->getPodcastByName($params[0],)) === null
($podcast = (new PodcastModel())->getPodcastByHandle($params[0],)) === null
) {
throw PageNotFoundException::forPageNotFound();
}
......@@ -127,7 +127,7 @@ class StatusController extends ActivityPubStatusController
if (
$episodeUri &&
($params = extract_params_from_episode_uri(new URI($episodeUri))) &&
($episode = (new EpisodeModel())->getEpisodeBySlug($params['podcastName'], $params['episodeSlug']))
($episode = (new EpisodeModel())->getEpisodeBySlug($params['podcastHandle'], $params['episodeSlug']))
) {
$newStatus->episode_id = $episode->id;
}
......
......@@ -32,7 +32,7 @@ class AddPodcasts extends Migration
'type' => 'INT',
'unsigned' => true,
],
'name' => [
'handle' => [
'type' => 'VARCHAR',
'constraint' => 32,
],
......@@ -193,7 +193,7 @@ class AddPodcasts extends Migration
$this->forge->addPrimaryKey('id');
// TODO: remove name in favor of username from actor
$this->forge->addUniqueKey('name');
$this->forge->addUniqueKey('handle');
$this->forge->addUniqueKey('guid');
$this->forge->addUniqueKey('actor_id');
$this->forge->addForeignKey('actor_id', 'activitypub_actors', 'id', '', 'CASCADE');
......
......@@ -185,7 +185,7 @@ class Episode extends Entity
}
// Save image
$image->saveImage('podcasts/' . $this->getPodcast()->name, $this->attributes['slug']);
$image->saveImage('podcasts/' . $this->getPodcast()->handle, $this->attributes['slug']);
$this->attributes['image_mimetype'] = $image->mimetype;
$this->attributes['image_path'] = $image->path;
......@@ -214,7 +214,7 @@ class Episode extends Entity
$this->attributes['audio_file_path'] = save_media(
$audioFile,
'podcasts/' . $this->getPodcast()->name,
'podcasts/' . $this->getPodcast()->handle,
$this->attributes['slug'],
);
$this->attributes['audio_file_duration'] =
......@@ -237,7 +237,7 @@ class Episode extends Entity
$this->attributes['transcript_file_path'] = save_media(
$transcriptFile,
'podcasts/' . $this->getPodcast()
->name,
->handle,
$this->attributes['slug'] . '-transcript',
);
......@@ -254,7 +254,7 @@ class Episode extends Entity
$this->attributes['chapters_file_path'] = save_media(
$chaptersFile,
'podcasts/' . $this->getPodcast()
->name,
->handle,
$this->attributes['slug'] . '-chapters',
);
......@@ -430,11 +430,11 @@ class Episode extends Entity
? route_to(
'embeddable-player-theme',
$this->getPodcast()
->name,
->handle,
$this->attributes['slug'],
$theme,
)
: route_to('embeddable-player', $this->getPodcast() ->name, $this->attributes['slug']),
: route_to('embeddable-player', $this->getPodcast()->handle, $this->attributes['slug']),
);
}
......
......@@ -26,7 +26,7 @@ use RuntimeException;
* @property string $guid
* @property int $actor_id
* @property Actor|null $actor
* @property string $name
* @property string $handle
* @property string $link
* @property string $feed_url
* @property string $title
......@@ -140,7 +140,7 @@ class Podcast extends Entity
'id' => 'integer',
'guid' => 'string',
'actor_id' => 'integer',
'name' => 'string',
'handle' => 'string',
'title' => 'string',
'description_markdown' => 'string',
'description_html' => 'string',
......@@ -193,7 +193,7 @@ class Podcast extends Entity
public function setImage(Image $image): static
{
// Save image
$image->saveImage('podcasts/' . $this->attributes['name'], 'cover');
$image->saveImage('podcasts/' . $this->attributes['handle'], 'cover');
$this->attributes['image_mimetype'] = $image->mimetype;
$this->attributes['image_path'] = $image->path;
......@@ -208,12 +208,12 @@ class Podcast extends Entity
public function getLink(): string
{
return url_to('podcast-activity', $this->attributes['name']);
return url_to('podcast-activity', $this->attributes['handle']);
}
public function getFeedUrl(): string
{
return url_to('podcast_feed', $this->attributes['name']);
return url_to('podcast_feed', $this->attributes['handle']);
}
/**
......
......@@ -251,7 +251,7 @@ if (! function_exists('get_rss_feed')) {
// add link to episode comments as podcast-activity format
$comments = $item->addChild('comments', null, $podcastNamespace);
$comments->addAttribute('uri', url_to('episode-comments', $podcast->name, $episode->slug));
$comments->addAttribute('uri', url_to('episode-comments', $podcast->handle, $episode->slug));
$comments->addAttribute('contentType', 'application/podcast-activity+json');
if ($episode->transcript_file_url) {
......
......@@ -40,7 +40,7 @@ if (! function_exists('extract_params_from_episode_uri')) {
function extract_params_from_episode_uri(URI $episodeUri): ?array
{
preg_match(
'~@(?P<podcastName>[a-zA-Z0-9\_]{1,32})\/episodes\/(?P<episodeSlug>[a-zA-Z0-9\-]{1,191})~',
'~@(?P<podcastHandle>[a-zA-Z0-9\_]{1,32})\/episodes\/(?P<episodeSlug>[a-zA-Z0-9\-]{1,191})~',
$episodeUri->getPath(),
$matches,
);
......@@ -50,14 +50,14 @@ if (! function_exists('extract_params_from_episode_uri')) {
}
if (
! array_key_exists('podcastName', $matches) ||
! array_key_exists('podcastHandle', $matches) ||
! array_key_exists('episodeSlug', $matches)
) {
return null;
}
return [
'podcastName' => $matches['podcastName'],
'podcastHandle' => $matches['podcastHandle'],
'episodeSlug' => $matches['episodeSlug'],
];
}
......
......@@ -19,17 +19,17 @@ return [
'submit' => 'Proceed to follow',
],
'favourite' => [
'title' => "Favourite {actorDisplayName}'s note",
'title' => "Favourite {actorDisplayName}'s post",
'subtitle' => 'You are going to favourite:',
'submit' => 'Proceed to favourite',
],
'reblog' => [
'title' => "Share {actorDisplayName}'s note",
'title' => "Share {actorDisplayName}'s post",
'subtitle' => 'You are going to share:',
'submit' => 'Proceed to share',
],
'reply' => [
'title' => "Reply to {actorDisplayName}'s note",
'title' => "Reply to {actorDisplayName}'s post",
'subtitle' => 'You are going to reply to:',
'submit' => 'Proceed to reply',
],
......
......@@ -10,7 +10,7 @@ declare(strict_types=1);
return [
'podcast_contributors' => 'Podcast contributors',
'view' => "{username}'s contribution to {podcastName}",
'view' => "{username}'s contribution to {podcastTitle}",
'add' => 'Add contributor',
'add_contributor' => 'Add a contributor for {0}',
'edit_role' => 'Update role for {0}',
......
......@@ -28,9 +28,9 @@ return [
'identity_section_subtitle' => 'These fields allow you to get noticed.',
'image' => 'Cover image',
'title' => 'Title',
'name' => 'Name',
'name_hint' =>
'Used for generating the podcast URL. Uppercase, lowercase, numbers and underscores are accepted.',
'handle' => 'Handle',
'handle_hint' =>
'Used to identify the podcast. Uppercase, lowercase, numbers and underscores are accepted.',
'type' => [
'label' => 'Type',
'hint' =>
......
......@@ -17,8 +17,6 @@ return [
'imported_feed_url' => 'Feed URL',
'imported_feed_url_hint' => 'The feed must be in xml or rss format.',
'new_podcast_section_title' => 'The new podcast',
'name' => 'Name',
'name_hint' => 'Used for generating the podcast URL.',
'advanced_params_section_title' => 'Advanced parameters',
'advanced_params_section_subtitle' =>
'Keep the default values if you have no idea of what the fields are for.',
......
......@@ -9,8 +9,8 @@ declare(strict_types=1);
*/
return [
'title' => "{actorDisplayName}'s Note",
'back_to_actor_statuses' => 'Back to {actor} notes',
'title' => "{actorDisplayName}'s post",
'back_to_actor_statuses' => 'Back to {actor} posts',
'actor_shared' => '{actor} shared',
'reply_to' => 'Reply to @{actorUsername}',
'form' => [
......@@ -33,8 +33,8 @@ return [
one {# reply}
other {# replies}
}',
'expand' => 'Expand note',
'expand' => 'Expand post',
'block_actor' => 'Block user @{actorUsername}',
'block_domain' => 'Block domain @{actorDomain}',
'delete' => 'Delete note',
'delete' => 'Delete post',
];
......@@ -20,17 +20,17 @@ return [
'submit' => 'Poursuivre',
],
'favourite' => [
'title' => 'Mettez la note de {actorDisplayName} en favori',
'title' => 'Mettez la publication de {actorDisplayName} en favori',
'subtitle' => 'Vous allez mettre en favori :',
'submit' => 'Poursuivre',
],
'reblog' => [
'title' => 'Partagez la note de {actorDisplayName}',
'title' => 'Partagez la publication de {actorDisplayName}',
'subtitle' => 'Vous allez partager :',
'submit' => 'Poursuivre',
],
'reply' => [
'title' => 'Répondre à la note de {actorDisplayName}',
'title' => 'Répondre à la publication de {actorDisplayName}',
'subtitle' => 'Vous allez répondre à :',
'submit' => 'Poursuivre',
],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment