Initial commit
This commit is contained in:
commit
65e0da7e11
1397 changed files with 596542 additions and 0 deletions
9
site/OFF_plugins/embed/registry/field-method.php
Normal file
9
site/OFF_plugins/embed/registry/field-method.php
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
// ================================================
|
||||
// $page->video()->embed()
|
||||
// ================================================
|
||||
|
||||
$kirby->set('field::method', 'embed', function($field, $args = []) {
|
||||
return embed($field->value, $args);
|
||||
});
|
||||
7
site/OFF_plugins/embed/registry/field.php
Normal file
7
site/OFF_plugins/embed/registry/field.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
// ================================================
|
||||
// Register panel field
|
||||
// ================================================
|
||||
|
||||
$kirby->set('field', 'embed', dirname(__DIR__) . DS . 'field');
|
||||
32
site/OFF_plugins/embed/registry/route.php
Normal file
32
site/OFF_plugins/embed/registry/route.php
Normal 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'
|
||||
]);
|
||||
31
site/OFF_plugins/embed/registry/tag.php
Normal file
31
site/OFF_plugins/embed/registry/tag.php
Normal 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);
|
||||
}
|
||||
]);
|
||||
Loading…
Add table
Add a link
Reference in a new issue