Initial commit

This commit is contained in:
isUnknown 2026-02-12 15:22:46 +01:00
commit 65e0da7e11
1397 changed files with 596542 additions and 0 deletions

View file

@ -0,0 +1,9 @@
<?php
// ================================================
// $page->video()->embed()
// ================================================
$kirby->set('field::method', 'embed', function($field, $args = []) {
return embed($field->value, $args);
});

View file

@ -0,0 +1,7 @@
<?php
// ================================================
// Register panel field
// ================================================
$kirby->set('field', 'embed', dirname(__DIR__) . DS . 'field');

View file

@ -0,0 +1,32 @@
<?php
use Kirby\Embed\Html;
$kirby->set('route', [
'pattern' => 'api/plugin/embed/preview',
'action' => function() {
$embed = embed(get('url'), ['lazyvideo' => true]);
$response = [];
if($embed->data === false) {
$response['success'] = 'false';
} else {
$response['success'] = 'true';
$response['title'] = Html::removeEmojis($embed->title());
$response['authorName'] = $embed->authorName();
$response['authorUrl'] = $embed->authorUrl();
$response['providerName'] = $embed->providerName();
$response['providerUrl'] = $embed->url();
$response['type'] = ucfirst($embed->type());
$response['parameters'] = Html::cheatsheet($embed->urlParameters());
}
if(get('code') === 'true') {
$response['code'] = (string)$embed;
}
return \response::json($response);
},
'method' => 'POST'
]);

View file

@ -0,0 +1,31 @@
<?php
// ================================================
// (embed: …)
// ================================================
$options = [
'class' => 'string',
'thumb' => 'string',
'autoload' => 'bool',
'lazyvideo' => 'bool',
'jsapi' => 'bool',
];
$kirby->set('tag', 'embed', [
'attr' => array_keys($options),
'html' => function($tag) use($options) {
$args = [];
foreach($options as $option => $mode) {
if($mode === 'bool') {
if($tag->attr($option) === 'true') $args[$option] = true;
if($tag->attr($option) === 'false') $args[$option] = false;
} elseif ($mode === 'string') {
if($tag->attr($option)) $args[$option] = $tag->attr($option);
}
}
return embed($tag->attr('embed'), $args);
}
]);