Upgrade to 4.2.0
This commit is contained in:
@@ -8,7 +8,15 @@ $parentPattern = '(account|pages/[^/]+|site|users/[^/]+)/files';
|
||||
* Files Routes
|
||||
*/
|
||||
return [
|
||||
|
||||
[
|
||||
'pattern' => $filePattern . '/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $parent, string $filename, string $fieldName, string|null $path = null) {
|
||||
if ($file = $this->file($parent, $filename)) {
|
||||
return $this->fieldApi($file, $fieldName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $filePattern . '/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
@@ -17,11 +25,11 @@ return [
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => $filePattern . '/fields/(:any)/(:all?)',
|
||||
'pattern' => $filePattern . '/sections/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $parent, string $filename, string $fieldName, string $path = null) {
|
||||
'action' => function (string $parent, string $filename, string $sectionName, string|null $path = null) {
|
||||
if ($file = $this->file($parent, $filename)) {
|
||||
return $this->fieldApi($file, $fieldName, $path);
|
||||
return $this->sectionApi($file, $sectionName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@@ -4,9 +4,8 @@
|
||||
/**
|
||||
* Page Routes
|
||||
*/
|
||||
|
||||
|
||||
return [
|
||||
// @codeCoverageIgnoreStart
|
||||
[
|
||||
'pattern' => 'pages/(:any)',
|
||||
'method' => 'GET',
|
||||
@@ -101,6 +100,15 @@ return [
|
||||
return $this->page($id)->changeTitle($this->requestBody('title'));
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string|null $path = null) {
|
||||
if ($page = $this->page($id)) {
|
||||
return $this->fieldApi($page, $fieldName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
@@ -109,12 +117,13 @@ return [
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'pages/(:any)/fields/(:any)/(:all?)',
|
||||
'pattern' => 'pages/(:any)/sections/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string $path = null) {
|
||||
'action' => function (string $id, string $sectionName, string|null $path = null) {
|
||||
if ($page = $this->page($id)) {
|
||||
return $this->fieldApi($page, $fieldName, $path);
|
||||
return $this->sectionApi($page, $sectionName, $path);
|
||||
}
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreEnd
|
||||
];
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* Site Routes
|
||||
*/
|
||||
return [
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
[
|
||||
'pattern' => 'site',
|
||||
'action' => function () {
|
||||
@@ -84,6 +84,13 @@ return [
|
||||
return $pages->query($this->requestBody());
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/fields/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $fieldName, string|null $path = null) {
|
||||
return $this->fieldApi($this->site(), $fieldName, $path);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/sections/(:any)',
|
||||
'method' => 'GET',
|
||||
@@ -92,11 +99,11 @@ return [
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'site/fields/(:any)/(:all?)',
|
||||
'pattern' => 'site/sections/(:any)/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $fieldName, string $path = null) {
|
||||
return $this->fieldApi($this->site(), $fieldName, $path);
|
||||
'action' => function (string $sectionName, string|null $path = null) {
|
||||
return $this->sectionApi($this->site(), $sectionName, $path);
|
||||
}
|
||||
]
|
||||
|
||||
],
|
||||
// @codeCoverageIgnoreEnd
|
||||
];
|
||||
|
@@ -8,6 +8,7 @@ use Kirby\Toolkit\Str;
|
||||
* User Routes
|
||||
*/
|
||||
return [
|
||||
// @codeCoverageIgnoreStart
|
||||
[
|
||||
'pattern' => 'users',
|
||||
'method' => 'GET',
|
||||
@@ -205,6 +206,16 @@ return [
|
||||
return $this->user($id)->roles();
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/fields/(:any)/(:all?)',
|
||||
'users/(:any)/fields/(:any)/(:all?)',
|
||||
],
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string|null $path = null) {
|
||||
return $this->fieldApi($this->user($id), $fieldName, $path);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/sections/(:any)',
|
||||
@@ -219,12 +230,13 @@ return [
|
||||
],
|
||||
[
|
||||
'pattern' => [
|
||||
'(account)/fields/(:any)/(:all?)',
|
||||
'users/(:any)/fields/(:any)/(:all?)',
|
||||
'(account)/sections/(:any)/(:all?)',
|
||||
'users/(:any)/sections/(:any)/(:all?)',
|
||||
],
|
||||
'method' => 'ALL',
|
||||
'action' => function (string $id, string $fieldName, string $path = null) {
|
||||
return $this->fieldApi($this->user($id), $fieldName, $path);
|
||||
'action' => function (string $id, string $sectionName, string|null $path = null) {
|
||||
return $this->sectionApi($this->user($id), $sectionName, $path);
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreEnd
|
||||
];
|
||||
|
@@ -109,6 +109,16 @@ return [
|
||||
$props = $example->props();
|
||||
$vue = $example->vue();
|
||||
|
||||
if (Docs::installed() === true && $docs = $props['docs'] ?? null) {
|
||||
$docs = new Docs($docs);
|
||||
}
|
||||
|
||||
$github = $docs?->github();
|
||||
|
||||
if ($source = $props['source'] ?? null) {
|
||||
$github ??= 'https://github.com/getkirby/kirby/tree/main/' . $source;
|
||||
}
|
||||
|
||||
return [
|
||||
'component' => 'k-lab-playground-view',
|
||||
'breadcrumb' => [
|
||||
@@ -121,10 +131,10 @@ return [
|
||||
]
|
||||
],
|
||||
'props' => [
|
||||
'docs' => $props['docs'] ?? null,
|
||||
'docs' => $docs?->name(),
|
||||
'examples' => $vue['examples'],
|
||||
'file' => $example->module(),
|
||||
'github' => $example->github(),
|
||||
'github' => $github,
|
||||
'props' => $props,
|
||||
'styles' => $vue['style'],
|
||||
'tab' => $example->tab(),
|
||||
|
@@ -2,12 +2,30 @@
|
||||
use Kirby\Cms\Html;
|
||||
|
||||
/** @var \Kirby\Cms\Block $block */
|
||||
$caption = $block->caption();
|
||||
|
||||
if (
|
||||
$block->location() == 'kirby' &&
|
||||
$video = $block->video()->toFile()
|
||||
) {
|
||||
$url = $video->url();
|
||||
$attrs = array_filter([
|
||||
'autoplay' => $block->autoplay()->toBool(),
|
||||
'controls' => $block->controls()->toBool(),
|
||||
'loop' => $block->loop()->toBool(),
|
||||
'muted' => $block->muted()->toBool(),
|
||||
'poster' => $block->poster()->toFile()?->url(),
|
||||
'preload' => $block->preload()->value(),
|
||||
]);
|
||||
} else {
|
||||
$url = $block->url();
|
||||
}
|
||||
?>
|
||||
<?php if ($video = Html::video($block->url())): ?>
|
||||
<?php if ($video = Html::video($url, [], $attrs ?? [])): ?>
|
||||
<figure>
|
||||
<?= $video ?>
|
||||
<?php if ($block->caption()->isNotEmpty()): ?>
|
||||
<figcaption><?= $block->caption() ?></figcaption>
|
||||
<?php if ($caption->isNotEmpty()): ?>
|
||||
<figcaption><?= $caption ?></figcaption>
|
||||
<?php endif ?>
|
||||
</figure>
|
||||
<?php endif ?>
|
||||
|
@@ -2,11 +2,77 @@ name: field.blocks.video.name
|
||||
icon: video
|
||||
preview: video
|
||||
fields:
|
||||
location:
|
||||
label: field.blocks.video.location
|
||||
type: radio
|
||||
columns: 2
|
||||
default: "web"
|
||||
options:
|
||||
kirby: "{{ t('field.blocks.image.location.internal') }}"
|
||||
web: "{{ t('field.blocks.image.location.external') }}"
|
||||
url:
|
||||
label: field.blocks.video.url.label
|
||||
type: url
|
||||
placeholder: field.blocks.video.url.placeholder
|
||||
when:
|
||||
location: web
|
||||
video:
|
||||
label: field.blocks.video.name
|
||||
type: files
|
||||
query: model.videos
|
||||
multiple: false
|
||||
# you might want to add a template for videos here
|
||||
when:
|
||||
location: kirby
|
||||
poster:
|
||||
label: field.blocks.video.poster
|
||||
type: files
|
||||
query: model.images
|
||||
multiple: false
|
||||
image:
|
||||
back: black
|
||||
uploads:
|
||||
template: blocks/image
|
||||
when:
|
||||
location: kirby
|
||||
caption:
|
||||
label: field.blocks.video.caption
|
||||
type: writer
|
||||
inline: true
|
||||
autoplay:
|
||||
label: field.blocks.video.autoplay
|
||||
type: toggle
|
||||
width: 1/3
|
||||
when:
|
||||
location: kirby
|
||||
muted:
|
||||
label: field.blocks.video.muted
|
||||
type: toggle
|
||||
width: 1/3
|
||||
default: true
|
||||
when:
|
||||
location: kirby
|
||||
loop:
|
||||
label: field.blocks.video.loop
|
||||
type: toggle
|
||||
width: 1/3
|
||||
when:
|
||||
location: kirby
|
||||
controls:
|
||||
label: field.blocks.video.controls
|
||||
type: toggle
|
||||
width: 1/3
|
||||
default: true
|
||||
when:
|
||||
location: kirby
|
||||
preload:
|
||||
label: field.blocks.video.preload
|
||||
type: select
|
||||
width: 2/3
|
||||
default: auto
|
||||
options:
|
||||
- auto
|
||||
- metadata
|
||||
- none
|
||||
when:
|
||||
location: kirby
|
||||
|
@@ -39,7 +39,7 @@ return [
|
||||
'template' => $template
|
||||
]);
|
||||
|
||||
$uploads['accept'] = $file->blueprint()->acceptMime();
|
||||
$uploads['accept'] = $file->blueprint()->acceptAttribute();
|
||||
}
|
||||
|
||||
return $uploads;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Kirby\Toolkit\I18n;
|
||||
|
||||
return [
|
||||
'extends' => 'number',
|
||||
'props' => [
|
||||
@@ -18,6 +20,13 @@ return [
|
||||
* Enables/disables the tooltip and set the before and after values
|
||||
*/
|
||||
'tooltip' => function ($tooltip = true) {
|
||||
if (is_array($tooltip) === true) {
|
||||
$after = $tooltip['after'] ?? null;
|
||||
$before = $tooltip['before'] ?? null;
|
||||
$tooltip['after'] = I18n::translate($after, $after);
|
||||
$tooltip['before'] = I18n::translate($before, $before);
|
||||
}
|
||||
|
||||
return $tooltip;
|
||||
},
|
||||
]
|
||||
|
@@ -47,7 +47,7 @@ return [
|
||||
'template' => $this->template
|
||||
]);
|
||||
|
||||
return $file->blueprint()->acceptMime();
|
||||
return $file->blueprint()->acceptAttribute();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -205,13 +205,31 @@ return [
|
||||
];
|
||||
}
|
||||
],
|
||||
// @codeCoverageIgnoreStart
|
||||
'api' => function () {
|
||||
return [
|
||||
[
|
||||
'pattern' => 'sort',
|
||||
'method' => 'PATCH',
|
||||
'action' => function () {
|
||||
$this->section()->model()->files()->changeSort(
|
||||
$this->requestBody('files'),
|
||||
$this->requestBody('index')
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
]
|
||||
];
|
||||
},
|
||||
// @codeCoverageIgnoreEnd
|
||||
'toArray' => function () {
|
||||
return [
|
||||
'data' => $this->data,
|
||||
'errors' => $this->errors,
|
||||
'options' => [
|
||||
'accept' => $this->accept,
|
||||
'apiUrl' => $this->parent->apiUrl(true),
|
||||
'apiUrl' => $this->parent->apiUrl(true) . '/sections/' . $this->name,
|
||||
'columns' => $this->columnsWithTypes(),
|
||||
'empty' => $this->empty,
|
||||
'headline' => $this->headline,
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Kirby\Cms\ModelWithContent;
|
||||
use Kirby\Form\Form;
|
||||
use Kirby\Toolkit\I18n;
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
@@ -77,9 +78,12 @@ return [
|
||||
// keep the original column name as id
|
||||
$column['id'] = $columnName;
|
||||
|
||||
// add the custom column to the array with a key that won't
|
||||
// override the system columns
|
||||
$columns[$columnName . 'Cell'] = $column;
|
||||
// add the custom column to the array
|
||||
// allowing to extend/overwrite existing columns
|
||||
$columns[$columnName] = [
|
||||
...$columns[$columnName] ?? [],
|
||||
...$column
|
||||
];
|
||||
}
|
||||
|
||||
if ($this->type === 'pages') {
|
||||
@@ -129,19 +133,20 @@ return [
|
||||
$item['info'] = $model->toString($this->info);
|
||||
}
|
||||
|
||||
// Use form to get the proper values for the columns
|
||||
$form = Form::for($model)->values();
|
||||
|
||||
foreach ($this->columns as $columnName => $column) {
|
||||
// don't overwrite essential columns
|
||||
if (isset($item[$columnName]) === true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($column['value']) === false) {
|
||||
$value = $model->toString($column['value']);
|
||||
} else {
|
||||
$value = $model->content()->get($column['id'] ?? $columnName)->value();
|
||||
}
|
||||
|
||||
$item[$columnName] = $value;
|
||||
$item[$columnName] = match (empty($column['value'])) {
|
||||
// if column value defined, resolve the query
|
||||
false => $model->toString($column['value']),
|
||||
// otherwise use the form value,
|
||||
// but don't overwrite columns
|
||||
default =>
|
||||
$item[$columnName] ??
|
||||
$form[$column['id'] ?? $columnName] ??
|
||||
null,
|
||||
};
|
||||
}
|
||||
|
||||
return $item;
|
||||
|
Reference in New Issue
Block a user