Commit 043f49c7 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

feat: add platforms form in podcast settings

- set and remove platform links for a podcast
- remove unnecessary fields from platforms and platform_links tables
- add platforms svg icons to show in form
- update platform and auth seeders
- update svgo config for images
parent 9a5d5a15
plugins:
- removeXMLNS: true
- removeDimensions: true
- addAttributesToSVGElement:
attributes:
- width: "1em"
- height: "1em"
- sortAttrs: true
- prefixIds: true
......@@ -196,6 +196,30 @@ $routes->group(
]);
});
});
$routes->group('settings', function ($routes) {
$routes->get('/', 'PodcastSettings/$1', [
'as' => 'podcast-settings',
]);
$routes->get('platforms', 'PodcastSettings::platforms/$1', [
'as' => 'platforms',
'filter' => 'permission:podcast-manage_platforms',
]);
$routes->post(
'platforms',
'PodcastSettings::attemptPlatformsUpdate/$1',
['filter' => 'permission:podcast-manage_platforms']
);
$routes->get(
'platforms/(:num)/remove-link',
'PodcastSettings::removePlatformLink/$1/$2',
[
'as' => 'platforms-remove',
'filter' => 'permission:podcast-manage_platforms',
]
);
});
});
});
......
<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Controllers\Admin;
use App\Models\PlatformModel;
use App\Models\PodcastModel;
use Config\Services;
class PodcastSettings extends BaseController
{
/**
* @var \App\Entities\Podcast|null
*/
protected $podcast;
public function _remap($method, ...$params)
{
if (!($this->podcast = (new PodcastModel())->find($params[0]))) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
}
unset($params[0]);
return $this->$method(...$params);
}
public function index()
{
return view('admin/podcast/settings/dashboard');
}
public function platforms()
{
helper('form');
$data = [
'podcast' => $this->podcast,
'platforms' => (new PlatformModel())->getPlatformsWithLinks(),
];
replace_breadcrumb_params([0 => $this->podcast->title]);
return view('admin/podcast/settings/platforms', $data);
}
public function attemptPlatformsUpdate()
{
$platformModel = new PlatformModel();
$validation = Services::validation();
$platformLinksData = [];
foreach (
$this->request->getPost('platforms')
as $platformName => $platformLink
) {
$platformLinkUrl = $platformLink['url'];
if (
!empty($platformLinkUrl) &&
$validation->check($platformLinkUrl, 'valid_url')
) {
$platformId = $platformModel->getPlatformId($platformName);
array_push($platformLinksData, [
'platform_id' => $platformId,
'podcast_id' => $this->podcast->id,
'link_url' => $platformLinkUrl,
'visible' => array_key_exists('visible', $platformLink)
? $platformLink['visible'] == 'yes'
: false,
]);
}
}
$platformModel->savePlatformLinks(
$this->podcast->id,
$platformLinksData
);
return redirect()
->back()
->with('message', lang('Platforms.messages.updateSuccess'));
}
public function removePlatformLink($platformId)
{
(new PlatformModel())->removePlatformLink(
$this->podcast->id,
$platformId
);
return redirect()
->back()
->with('message', lang('Platforms.messages.removeLinkSuccess'));
}
}
......@@ -29,47 +29,21 @@ class AddPlatforms extends Migration
'constraint' => 191,
'unique' => true,
],
'home_url' => [
'label' => [
'type' => 'VARCHAR',
'constraint' => 191,
],
'submit_url' => [
'type' => 'VARCHAR',
'constraint' => 191,
'null' => true,
],
'iosapp_url' => [
'home_url' => [
'type' => 'VARCHAR',
'constraint' => 191,
'null' => true,
],
'androidapp_url' => [
'submit_url' => [
'type' => 'VARCHAR',
'constraint' => 191,
'null' => true,
'default' => null,
],
'comment' => [
'type' => 'TEXT',
'null' => true,
],
'display_by_default' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
'ios_deeplink' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
],
'android_deeplink' => [
'type' => 'TINYINT',
'constraint' => 1,
'default' => 0,
'comment' =>
'Android deeplinking for this platform: 0=No, 1=Manual, 2=Automatic.',
],
'logo_file_name' => [
'icon_filename' => [
'type' => 'VARCHAR',
'constraint' => 1024,
],
......
......@@ -18,12 +18,6 @@ class AddPlatformLinks extends Migration
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'BIGINT',
'constraint' => 20,
'unsigned' => true,
'auto_increment' => true,
],
'podcast_id' => [
'type' => 'BIGINT',
'constraint' => 20,
......@@ -38,11 +32,6 @@ class AddPlatformLinks extends Migration
'type' => 'VARCHAR',
'constraint' => 191,
],
'comment' => [
'type' => 'TEXT',
'comment' => 'Comment.',
'null' => true,
],
'visible' => [
'type' => 'TINYINT',
'constraint' => 1,
......@@ -55,7 +44,7 @@ class AddPlatformLinks extends Migration
'type' => 'TIMESTAMP',
],
]);
$this->forge->addKey('id', true);
$this->forge->addPrimaryKey(['podcast_id', 'platform_id']);
$this->forge->addForeignKey('podcast_id', 'podcasts', 'id');
$this->forge->addForeignKey('platform_id', 'platforms', 'id');
$this->forge->createTable('platform_links');
......
......@@ -203,6 +203,11 @@ class AuthSeeder extends Seeder
'description' => 'Publish / unpublish a podcast',
'has_permission' => ['podcast_admin'],
],
[
'name' => 'manage_platforms',
'description' => 'Set / remove platform links of a podcast',
'has_permission' => ['podcast_admin'],
],
],
'podcast_episodes' => [
[
......
......@@ -19,328 +19,148 @@ class PlatformSeeder extends Seeder
{
$data = [
[
'name' => 'Apple Podcasts',
'name' => 'apple-podcasts',
'label' => 'Apple Podcasts',
'home_url' => 'https://www.apple.com/itunes/podcasts/',
'submit_url' =>
'https://podcastsconnect.apple.com/my-podcasts/new-feed',
'iosapp_url' =>
'https://apps.apple.com/app/apple-podcasts/id525463029',
'androidapp_url' => '',
'comment' => '',
'display_by_default' => 1,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'ApplePodcasts.png',
'icon_filename' => 'apple-podcasts.svg',
],
[
'name' => 'Blubrry',
'name' => 'blubrry',
'label' => 'Blubrry',
'home_url' => 'https://www.blubrry.com/',
'submit_url' => 'https://www.blubrry.com/addpodcast.php',
'iosapp_url' => '',
'androidapp_url' => '',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'blubrry.png',
'icon_filename' => 'blubrry.svg',
],
[
'name' => 'Castbox',
'name' => 'castbox',
'label' => 'Castbox',
'home_url' => 'https://castbox.fm/',
'submit_url' =>
'https://helpcenter.castbox.fm/portal/kb/articles/submit-my-podcast',
'iosapp_url' =>
'https://apps.apple.com/app/castbox-the-podcast-app/id1243410543',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=fm.castbox.audiobook.radio.podcast&hl=fr',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 2,
'logo_file_name' => 'Castbox.png',
'icon_filename' => 'castbox.svg',
],
[
'name' => 'Castro',
'name' => 'castro',
'label' => 'Castro',
'home_url' => 'http://castro.fm/',
'submit_url' => '',
'iosapp_url' =>
'https://apps.apple.com/app/apple-store/id1080840241?ign-mpt=uo%3D4',
'androidapp_url' => '',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'Castro.png',
'submit_url' => null,
'icon_filename' => 'castro.svg',
],
[
'name' => 'Chartable',
'home_url' => 'https://chartable.com/',
'submit_url' => 'https://chartable.com/podcasts/submit',
'iosapp_url' => '',
'androidapp_url' => '',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'Chartable.png',
],
[
'name' => 'Deezer',
'name' => 'deezer',
'label' => 'Deezer',
'home_url' => 'https://www.deezer.com/',
'submit_url' => 'https://podcasters.deezer.com/submission',
'iosapp_url' =>
'https://apps.apple.com/app/deezer-music-podcast-player/id292738169',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=deezer.android.app',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 2,
'logo_file_name' => 'Deezer.png',
'icon_filename' => 'deezer.svg',
],
[
'name' => 'Google Podcasts',
'name' => 'google-podcasts',
'label' => 'Google Podcasts',
'home_url' => 'https://podcasts.google.com/about',
'submit_url' =>
'https://search.google.com/search-console/about',
'iosapp_url' => '',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.google.android.apps.podcasts',
'comment' => '',
'display_by_default' => 1,
'ios_deeplink' => 0,
'android_deeplink' => 1,
'logo_file_name' => 'GooglePodcasts.png',
'icon_filename' => 'google-podcasts.svg',
],
[
'name' => 'Ivoox',
'name' => 'ivoox',
'label' => 'Ivoox',
'home_url' => 'https://www.ivoox.com/',
'submit_url' => '',
'iosapp_url' =>
'https://apps.apple.com/app/apple-store/id542673545',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.ivoox.app',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'ivoox.png',
'submit_url' => null,
'icon_filename' => 'ivoox.svg',
],
[
'name' => 'ListenNotes',
'name' => 'listennotes',
'label' => 'ListenNotes',
'home_url' => 'https://www.listennotes.com/',
'submit_url' => 'https://www.listennotes.com/submit/',
'iosapp_url' => '',
'androidapp_url' => '',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'ListenNotes.png',
'icon_filename' => 'listennotes.svg',
],
//array('name' => 'Majelan', 'home_url' => 'https://www.majelan.com/', 'submit_url' => 'https://support.majelan.com/article/64-how-to-add-my-podcast-on-majelan', 'iosapp_url' => 'https://apps.apple.com/app/majelan-best-audio-stories/id1443711081', 'androidapp_url' => 'https://play.google.com/store/apps/details?id=com.majelanapp', 'comment' => 'Uses public podcasts indexes. Send a DM if you are not listed.', 'display_by_default' => 0, 'ios_deeplink' => 0, 'android_deeplink' => 2, 'logo_file_name' => 'Majelan.png'), // https://aide.majelan.com/article/130-pourquoi-nouvelle-application-7-juillet
[
'name' => 'Mytuner',
'home_url' => 'https://mytuner-radio.com/',
'submit_url' => 'https://mytuner-radio.com/broadcasters/',
'iosapp_url' =>
'https://apps.apple.com/app/apple-store/id520502858',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.appgeneration.itunerfree',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 1,
'logo_file_name' => 'myTuner.png',
],
[
'name' => 'Overcast',
'name' => 'overcast',
'label' => 'Overcast',
'home_url' => 'https://overcast.fm/',
'submit_url' => 'https://overcast.fm/podcasterinfo',
'iosapp_url' =>
'https://apps.apple.com/us/app/overcast-podcast-player/id888422857',
'androidapp_url' => '',
'comment' =>
'Overcast uses Apple Podcasts index, no podcast submission needed.',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 1,
'logo_file_name' => 'Overcast.png',
'icon_filename' => 'overcast.svg',
],
[
'name' => 'Player.Fm',
'name' => 'playerfm',
'label' => 'Player.Fm',
'home_url' => 'https://player.fm/',
'submit_url' => 'https://player.fm/importer/feed',
'iosapp_url' =>
'https://apps.apple.com/app/podcast-app-by-player-fm/id940568467',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=fm.player',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 1,
'logo_file_name' => 'PlayerFM.png',
'icon_filename' => 'playerfm.svg',
],
[
'name' => 'Pocketcasts',
'name' => 'pocketcasts',
'label' => 'Pocketcasts',
'home_url' => 'https://www.pocketcasts.com/',
'submit_url' => 'https://www.pocketcasts.com/submit/',
'iosapp_url' =>
'https://apps.apple.com/app/pocket-casts/id414834813',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=au.com.shiftyjelly.pocketcasts',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'PocketCasts.png',
'icon_filename' => 'pocketcasts.svg',
],
[
'name' => 'Podbean',
'name' => 'podbean',
'label' => 'Podbean',
'home_url' => 'https://www.podbean.com/',
'submit_url' => 'https://www.podbean.com/site/submitPodcast',
'iosapp_url' =>
'https://apps.apple.com/app/apple-store/id973361050',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.podbean.app.podcast',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 2,
'logo_file_name' => 'Podbean.png',
'icon_filename' => 'podbean.svg',
],
[
'name' => 'Podcast Addict',
'name' => 'podcast-addict',
'label' => 'Podcast Addict',
'home_url' => 'https://podcastaddict.com/',
'submit_url' => 'https://podcastaddict.com/submit',
'iosapp_url' => '',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.bambuna.podcastaddict',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 2,
'logo_file_name' => 'podcastaddict.svg',
],
[
'name' => 'Podcastland',
'home_url' => 'https://podcastland.com/',
'submit_url' => '',
'iosapp_url' => '',
'androidapp_url' => '',
'comment' => 'Uses Apple Podcasts index.',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'PodcastLand.png',
],
[
'name' => 'Podcastrepublic',
'home_url' => 'https://www.podcastrepublic.net/',
'submit_url' =>
'https://www.podcastrepublic.net/for-podcast-publisher',
'iosapp_url' => '',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.itunestoppodcastplayer.app',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 1,
'logo_file_name' => 'PodcastRepublic.png',
'icon_filename' => 'podcast-addict.svg',
],
[
'name' => 'Podchaser',
'name' => 'podchaser',
'label' => 'Podchaser',
'home_url' => 'https://www.podchaser.com/',
'submit_url' => 'https://www.podchaser.com/creators/edit',
'iosapp_url' => '',
'androidapp_url' => '',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'Podchaser.png',
'icon_filename' => 'podchaser.svg',
],
[
'name' => 'Podtail',
'name' => 'podtail',
'label' => 'Podtail',
'home_url' => 'https://podtail.com/',
'submit_url' => 'https://podtail.com/about/faq/',
'iosapp_url' => '',
'androidapp_url' => '',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 0,
'logo_file_name' => 'Podtail.png',
'icon_filename' => 'podtail.svg',
],
[
'name' => 'Radiopublic',
'name' => 'radiopublic',
'label' => 'Radiopublic',
'home_url' => 'https://radiopublic.com/',
'submit_url' => 'https://podcasters.radiopublic.com/signup',
'iosapp_url' =>
'https://apps.apple.com/app/radiopublic-free-podcasts/id1113752736',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.radiopublic.android',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 1,
'logo_file_name' => 'RadioPublic.png',
'icon_filename' => 'radiopublic.svg',
],
[
'name' => 'Spotify',
'name' => 'spotify',
'label' => 'Spotify',
'home_url' => 'https://www.spotify.com/',
'submit_url' => 'https://podcasters.spotify.com/submit',
'iosapp_url' =>
'https://apps.apple.com/app/spotify-music/id324684580',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.spotify.music',
'comment' => '',
'display_by_default' => 1,
'ios_deeplink' => 0,
'android_deeplink' => 2,
'logo_file_name' => 'Spotify.png',
'icon_filename' => 'spotify.svg',
],
[
'name' => 'Spreaker',
'name' => 'spreaker',
'label' => 'Spreaker',
'home_url' => 'https://www.spreaker.com/',
'submit_url' => 'https://www.spreaker.com/cms/shows/rss-import',
'iosapp_url' =>
'https://apps.apple.com/app/spreaker-podcast-radio/id388449677',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.spreaker.android',
'comment' => '',
'display_by_default' => 0,
'ios_deeplink' => 0,
'android_deeplink' => 1,
'logo_file_name' => 'Spreaker.png',
'icon_filename' => 'spreaker.svg',
],
[
'name' => 'Stitcher',
'name' => 'stitcher',
'label' => 'Stitcher',
'home_url' => 'https://www.stitcher.com/',
'submit_url' => 'https://www.stitcher.com/content-providers',
'iosapp_url' => 'https://apps.apple.com/app/id288087905',
'androidapp_url' =>
'https://play.google.com/store/apps/details?id=com.stitcher.app',