Skip to content

Commit

Permalink
Move tag into separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonja Broda committed Mar 4, 2019
1 parent c076674 commit 8c92f2f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 37 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "texnixe/kirby3-codepen",
"description": "Kirby 3 plugin providing a Kirbytag (shortcode) for CodePen embeds",
"version": "0.9.0",
"description": "Kirby 3 plugin providing a KirbyTag for CodePen embeds",
"version": "0.9.1",
"type": "kirby-plugin",
"license": "MIT",
"authors": [
Expand Down
35 changes: 2 additions & 33 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Kirby 3 CodePen Embeds
*
* @version 0.9.0
* @version 0.9.1
* @author Sonja Broda <[email protected]>
* @copyright Sonja Broda <[email protected]>
* @link https://github.com/texnixe/kirby3-codepen
Expand All @@ -17,37 +17,6 @@
'codepen' => __DIR__ . '/snippets/codepen.php'
],
'tags' => [
'codepen' => [
'attr' => [
'user',
'title',
'preview',
'height',
'defaultTab'
],
'html' => function($tag) {

$id = $tag->value;
$user = $tag->user ?? '';
$title = $tag->title ?? '';
$preview = $tag->preview ?? $tag->kirby()->option('texnixe.codepen.preview', true);
$height = $tag->height ?? $tag->kirby()->option('texnixe.codepen.height', 300);
$defaultTab = $tag->defaultTab ?? $tag->kirby()->option('texnixe.codepen.defaultTab', 'js,result');
$themeId = $tag->kirby()->option('texnixe.codepen.themeId', 1);

$html = snippet('codepen', [
'id' => $id,
'user' => $user,
'title' => $title,
'preview' => $preview,
'height' => $height,
'defaultTab' => $defaultTab,
'themeId' => $themeId
], true);

return $html;

}
]
'codepen' => require __DIR__ . '/tags/codepen.php'
]
]);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Kirby 3 plugin providing a Kirbytag (shortcode) for CodePen embeds",
"author": "Sonja Broda <[email protected]>",
"license": "MIT",
"version": "0.9.0",
"version": "0.9.1",
"repository": {
"type": "git",
"url": "https://github.com/texnixe/kirby3-codepen"
Expand Down
2 changes: 1 addition & 1 deletion snippets/codepen.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="codepen-wrapper">
<p data-height="<?= $height ?>" data-theme-id="<?= $themeId ?>" data-slug-hash="<?= $id ?>" data-default-tab="<?= $defaultTab ?>" data-user="<?= $user ?>" data-embed-version="2" data-pen-title="<?= $title ?>" data-preview="<?= $preview ?>" class="codepen"><?= $content ?></p>
</div>
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
36 changes: 36 additions & 0 deletions tags/codepen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

return [
'attr' => [
'user',
'title',
'preview',
'height',
'defaultTab',
'themeId'
],
'html' => function($tag) {

$id = $tag->value;
$user = $tag->user ?? '';
$title = $tag->title ?? '';
$preview = $tag->preview ?? $tag->kirby()->option('texnixe.codepen.preview', true);
$height = $tag->height ?? $tag->kirby()->option('texnixe.codepen.height', 300);
$defaultTab = $tag->defaultTab ?? $tag->kirby()->option('texnixe.codepen.defaultTab', 'result');
$themeId = $tag->kirby()->option('texnixe.codepen.themeId', 1);


$html = snippet('codepen', [
'id' => $id,
'user' => $user,
'title' => $title,
'preview' => $preview,
'height' => $height,
'defaultTab' => $defaultTab,
'themeId' => $themeId
], true);

return $html;

}
];

0 comments on commit 8c92f2f

Please sign in to comment.