mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-27 20:21:59 +02:00
fix: validate slug length when submitting episode form + clean permalink edit prefix
This commit is contained in:
parent
5a2ca0cc4a
commit
b07ac093b2
@ -25,6 +25,9 @@ export class PermalinkEdit extends LitElement {
|
|||||||
@property({ attribute: "copy-label" })
|
@property({ attribute: "copy-label" })
|
||||||
copyLabel = "Copy";
|
copyLabel = "Copy";
|
||||||
|
|
||||||
|
@property({ attribute: "permalink-base" })
|
||||||
|
permalinkBase = "";
|
||||||
|
|
||||||
@state()
|
@state()
|
||||||
isEditable = false;
|
isEditable = false;
|
||||||
|
|
||||||
@ -68,6 +71,8 @@ export class PermalinkEdit extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
firstUpdated(): void {
|
firstUpdated(): void {
|
||||||
|
this.permalinkBase += this.permalinkBase.endsWith("/") ? "" : "/";
|
||||||
|
|
||||||
// set permalink value
|
// set permalink value
|
||||||
this.setPermalink();
|
this.setPermalink();
|
||||||
|
|
||||||
@ -130,7 +135,7 @@ export class PermalinkEdit extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setPermalink(): void {
|
setPermalink(): void {
|
||||||
this.permalink = this._domain[0].innerHTML + this._slugInput[0].value;
|
this.permalink = this.permalinkBase + this._slugInput[0].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static styles = css`
|
static styles = css`
|
||||||
|
@ -135,6 +135,7 @@ class EpisodeController extends BaseController
|
|||||||
public function attemptCreate(): RedirectResponse
|
public function attemptCreate(): RedirectResponse
|
||||||
{
|
{
|
||||||
$rules = [
|
$rules = [
|
||||||
|
'slug' => 'max_length[128]',
|
||||||
'audio_file' => 'uploaded[audio_file]|ext_in[audio_file,mp3,m4a]',
|
'audio_file' => 'uploaded[audio_file]|ext_in[audio_file,mp3,m4a]',
|
||||||
'cover' =>
|
'cover' =>
|
||||||
'is_image[cover]|ext_in[cover,jpg,png]|min_dims[cover,1400,1400]|is_image_ratio[cover,1,1]',
|
'is_image[cover]|ext_in[cover,jpg,png]|min_dims[cover,1400,1400]|is_image_ratio[cover,1,1]',
|
||||||
@ -272,6 +273,7 @@ class EpisodeController extends BaseController
|
|||||||
public function attemptEdit(): RedirectResponse
|
public function attemptEdit(): RedirectResponse
|
||||||
{
|
{
|
||||||
$rules = [
|
$rules = [
|
||||||
|
'slug' => 'max_length[128]',
|
||||||
'audio_file' =>
|
'audio_file' =>
|
||||||
'uploaded[audio_file]|ext_in[audio_file,mp3,m4a]|permit_empty',
|
'uploaded[audio_file]|ext_in[audio_file,mp3,m4a]|permit_empty',
|
||||||
'cover' =>
|
'cover' =>
|
||||||
|
@ -45,8 +45,8 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Forms.Label for="slug"><?= lang('Episode.form.permalink') ?></Forms.Label>
|
<Forms.Label for="slug"><?= lang('Episode.form.permalink') ?></Forms.Label>
|
||||||
<permalink-edit class="inline-flex items-center text-xs" edit-label="<?= lang('Common.edit') ?>" copy-label="<?= lang('Common.copy') ?>" copied-label="<?= lang('Common.copied') ?>">
|
<permalink-edit class="inline-flex items-center w-full text-xs" edit-label="<?= lang('Common.edit') ?>" copy-label="<?= lang('Common.copy') ?>" copied-label="<?= lang('Common.copied') ?>" permalink-base="<?= url_to('podcast-episodes', $podcast->handle) ?>">
|
||||||
<span slot="domain"><?= base_url('/@' . esc($podcast->handle) . '/episodes') . '/' ?></span>
|
<span slot="domain"><?= '…/' . esc($podcast->at_handle) . '/' ?></span>
|
||||||
<Forms.Input name="slug" required="true" data-slugify="slug" slot="slug-input" class="flex-1 text-xs" />
|
<Forms.Input name="slug" required="true" data-slugify="slug" slot="slug-input" class="flex-1 text-xs" />
|
||||||
</permalink-edit>
|
</permalink-edit>
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,8 +49,8 @@
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Forms.Label for="slug"><?= lang('Episode.form.permalink') ?></Forms.Label>
|
<Forms.Label for="slug"><?= lang('Episode.form.permalink') ?></Forms.Label>
|
||||||
<permalink-edit class="inline-flex items-center text-xs" edit-label="<?= lang('Common.edit') ?>" copy-label="<?= lang('Common.copy') ?>" copied-label="<?= lang('Common.copied') ?>">
|
<permalink-edit class="inline-flex items-center w-full text-xs" edit-label="<?= lang('Common.edit') ?>" copy-label="<?= lang('Common.copy') ?>" copied-label="<?= lang('Common.copied') ?>" permalink-base="<?= url_to('podcast-episodes', esc($podcast->handle)) ?>">
|
||||||
<span slot="domain"><?= base_url('/@' . esc($podcast->handle) . '/episodes') . '/' ?></span>
|
<span slot="domain"><?= '…/' . esc($podcast->handle) . '/' ?></span>
|
||||||
<Forms.Input name="slug" value="<?= esc($episode->slug) ?>" required="true" data-slugify="slug" slot="slug-input" class="flex-1 text-xs" />
|
<Forms.Input name="slug" value="<?= esc($episode->slug) ?>" required="true" data-slugify="slug" slot="slug-input" class="flex-1 text-xs" />
|
||||||
</permalink-edit>
|
</permalink-edit>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
<div class="flex flex-col max-w-sm">
|
<div class="flex flex-col max-w-sm">
|
||||||
<Forms.Label for="slug"><?= lang('Page.form.permalink') ?></Forms.Label>
|
<Forms.Label for="slug"><?= lang('Page.form.permalink') ?></Forms.Label>
|
||||||
<permalink-edit class="inline-flex items-center text-xs" edit-label="<?= lang('Common.edit') ?>" copy-label="<?= lang('Common.copy') ?>" copied-label="<?= lang('Common.copied') ?>">
|
<permalink-edit class="inline-flex items-center w-full text-xs" edit-label="<?= lang('Common.edit') ?>" copy-label="<?= lang('Common.copy') ?>" copied-label="<?= lang('Common.copied') ?>" permalink-base="<?= base_url('pages') ?>">
|
||||||
<span slot="domain" class="flex-shrink-0"><?= base_url('pages') . '/' ?></span>
|
<span slot="domain" class="flex-shrink-0">…/pages/</span>
|
||||||
<Forms.Input name="slug" required="true" data-slugify="slug" slot="slug-input" class="flex-1 text-xs" />
|
<Forms.Input name="slug" required="true" data-slugify="slug" slot="slug-input" class="flex-1 text-xs" />
|
||||||
</permalink-edit>
|
</permalink-edit>
|
||||||
</div>
|
</div>
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
<div class="flex flex-col max-w-sm">
|
<div class="flex flex-col max-w-sm">
|
||||||
<Forms.Label for="slug"><?= lang('Page.form.permalink') ?></Forms.Label>
|
<Forms.Label for="slug"><?= lang('Page.form.permalink') ?></Forms.Label>
|
||||||
<permalink-edit class="inline-flex items-center text-xs" edit-label="<?= lang('Common.edit') ?>" copy-label="<?= lang('Common.copy') ?>" copied-label="<?= lang('Common.copied') ?>">
|
<permalink-edit class="inline-flex items-center text-xs" edit-label="<?= lang('Common.edit') ?>" copy-label="<?= lang('Common.copy') ?>" copied-label="<?= lang('Common.copied') ?>" permalink-base="<?= base_url('pages') ?>">
|
||||||
<span slot="domain" class="flex-shrink-0"><?= base_url('pages') . '/' ?></span>
|
<span slot="domain" class="flex-shrink-0">…/pages/<span>
|
||||||
<Forms.Input name="slug" value="<?= esc($page->slug) ?>" required="true" data-slugify="slug" slot="slug-input" class="flex-1 text-xs" value="<?= esc($page->slug) ?>"/>
|
<Forms.Input name="slug" value="<?= esc($page->slug) ?>" required="true" data-slugify="slug" slot="slug-input" class="flex-1 text-xs" value="<?= esc($page->slug) ?>"/>
|
||||||
</permalink-edit>
|
</permalink-edit>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user