Skip to content

Commit

Permalink
Merge branch 'release/2.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Feb 11, 2020
2 parents 017fd83 + 47e49cf commit 822c0d0
Show file tree
Hide file tree
Showing 23 changed files with 758 additions and 75 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# v2.4.0
## 02/11/2020

1. [](#new)
* Pass phpstan level 1 tests
* Requires shortcode-core plugin v4.2.0
* Twig 2.0 compatibility
1. [](#improved)
* Code cleanup

# v2.3.0
## 02/06/2019

Expand Down
5 changes: 3 additions & 2 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Shortcode UI
version: 2.3.0
version: 2.4.0
description: "This plugin provides several UI shortcodes"
icon: code
author:
Expand All @@ -13,7 +13,8 @@ bugs: https://github.com/getgrav/grav-plugin-shortcode-ui/issues
license: MIT

dependencies:
- shortcode-core
- { name: grav, version: '>=1.6.4' }
- { name: shortcode-core, version: '>=4.2.0' }

form:
validation: strict
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Grav\Plugin;
namespace Grav\Plugin\ShortcodeUi;

class ShortcodeUiTwigExtension extends \Twig_Extension
{
Expand All @@ -25,8 +25,8 @@ public function parsePositionFunc($position)
preg_match('/(.+), *(.+), *(\w+)/', $position, $matches);

$position = [
'location' => 'top:'.$matches[1].';left:'.$matches[2].';',
'coords' => isset($matches[3]) ? $matches[3] : 'nw',
'location' => 'top:' . $matches[1] . ';left:' . $matches[2] . ';',
'coords' => $matches[3] ?? 'nw',
];

return $position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@

namespace Grav\Plugin\Shortcodes;

use Grav\Plugin\ShortcodeCore\Shortcode;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;


class AccordionsShortcode extends Shortcode
{
public function init()
{
$this->shortcode->getHandlers()->add('ui-accordion', function(ShortcodeInterface $sc) {

// Add assets
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-accordion.css');

$hash = $this->shortcode->getId($sc);

$independent = filter_var($sc->getParameter('independent', false), FILTER_VALIDATE_BOOLEAN);

$output = $this->twig->processTemplate('partials/ui-accordion.html.twig', [
'hash' => $hash,
'open' => $sc->getParameter('open'),
'type' => $independent ? 'checkbox' : 'radio',
'accordion_items' => $this->shortcode->getStates($hash),
]);
$output = $this->twig->processTemplate(
'partials/ui-accordion.html.twig',
[
'hash' => $hash,
'open' => $sc->getParameter('open'),
'type' => $independent ? 'checkbox' : 'radio',
'accordion_items' => $this->shortcode->getStates($hash),
]
);

return $output;
});
Expand All @@ -32,7 +34,8 @@ public function init()
// Add accordion to accordion state using parent accordion id
$hash = $this->shortcode->getId($sc->getParent());
$this->shortcode->setStates($hash, $sc);
return;

return '';
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
namespace Grav\Plugin\Shortcodes;

use Grav\Common\Utils;
use Grav\Plugin\ShortcodeCore\Shortcode;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;


class AnimatedTextShortcode extends Shortcode
{
public function init()
{
$this->shortcode->getHandlers()->add('ui-animated-text', function(ShortcodeInterface $sc) {

// Add assets
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-atext.css');
$this->shortcode->addAssets('js', 'plugin://shortcode-ui/js/ui-atext.js');
Expand All @@ -30,20 +29,21 @@ public function init()
$content = (array) $content;
}

if (intval($visible) > count($words)) {
if ((int)$visible > count($words)) {
$visible = 1;
}

$output = $this->twig->processTemplate('partials/ui-atext.html.twig', [
'content' => $content,
'words' => $words,
'animation' => $animation,
'element' => $sc->getParameter('element', 'h1'),
'wrapper_extra' => Utils::contains($animation, 'type') ? ' waiting' : '',
'visible' => $visible,
]);

return $output;
return $this->twig->processTemplate(
'partials/ui-atext.html.twig',
[
'content' => $content,
'words' => $words,
'animation' => $animation,
'element' => $sc->getParameter('element', 'h1'),
'wrapper_extra' => Utils::contains($animation, 'type') ? ' waiting' : '',
'visible' => $visible,
]
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

namespace Grav\Plugin\Shortcodes;

use Grav\Plugin\ShortcodeCore\Shortcode;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;


class BrowserShortcode extends Shortcode
{
public function init()
{
$this->shortcode->getHandlers()->add('ui-browser', function(ShortcodeInterface $sc) {

// Add assets
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-browser.css');

$output = $this->twig->processTemplate('partials/ui-browser.html.twig', [
'address' => $sc->getParameter('address', 'http://localhost'),
'shortcode' => $sc,
]);

return $output;
return $this->twig->processTemplate(
'partials/ui-browser.html.twig',
[
'address' => $sc->getParameter('address', 'http://localhost'),
'shortcode' => $sc,
]
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace Grav\Plugin\Shortcodes;

use Grav\Plugin\ShortcodeCore\Shortcode;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;


class CalloutShortcode extends Shortcode
{
public function init()
{
$this->shortcode->getHandlers()->add('ui-callout', function(ShortcodeInterface $sc) {

// Add assets
$this->shortcode->addAssets('js', ['jquery', 101]);
$this->shortcode->addAssets('js', 'plugin://shortcode-ui/js/ui-tooltips.js');
Expand All @@ -19,12 +18,15 @@ public function init()

$hash = $this->shortcode->getId($sc);

$output = $this->twig->processTemplate('partials/ui-callouts.html.twig', [
'hash' => $hash,
'shortcode' => $sc,
'classes' => $sc->getParameter('class'),
'callouts' => $this->shortcode->getStates($hash),
]);
$output = $this->twig->processTemplate(
'partials/ui-callouts.html.twig',
[
'hash' => $hash,
'shortcode' => $sc,
'classes' => $sc->getParameter('class'),
'callouts' => $this->shortcode->getStates($hash),
]
);

return $output;
});
Expand All @@ -33,7 +35,8 @@ public function init()
// Add tab to tab state using parent tabs id
$hash = $this->shortcode->getId($sc->getParent());
$this->shortcode->setStates($hash, $sc);
return;

return '';
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace Grav\Plugin\Shortcodes;

use Grav\Plugin\ShortcodeCore\Shortcode;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;


class ImageCompareShortcode extends Shortcode
{
public function init()
{
$this->shortcode->getHandlers()->add('ui-image-compare', function(ShortcodeInterface $sc) {

// Add assets
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-cslider.css');
$this->shortcode->addAssets('js', 'plugin://shortcode-ui/js/ui-cslider.js');
Expand All @@ -19,13 +18,16 @@ public function init()

preg_match_all('/<img.*(?:alt="(.*?)").*\/>/', $content, $matches);

if (sizeof($matches) == 2 && sizeof($matches[0]) == 2) {
$output = $this->twig->processTemplate('partials/ui-cslider.html.twig', [
'matches' => $matches,
]);

return $output;
if (count($matches) === 2 && count($matches[0]) === 2) {
return $this->twig->processTemplate(
'partials/ui-cslider.html.twig',
[
'matches' => $matches,
]
);
}

return '';
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

namespace Grav\Plugin\Shortcodes;

use Grav\Plugin\ShortcodeCore\Shortcode;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;


class PolaroidShortcode extends Shortcode
{
public function init()
{
$this->shortcode->getHandlers()->add('ui-polaroid', function(ShortcodeInterface $sc) {

// Add assets
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-polaroid.css');

$output = $this->twig->processTemplate('partials/ui-polaroid.html.twig', [
'shortcode' => $sc,
]);

return $output;
return $this->twig->processTemplate(
'partials/ui-polaroid.html.twig',
[
'shortcode' => $sc,
]
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,39 @@

namespace Grav\Plugin\Shortcodes;

use Grav\Plugin\ShortcodeCore\Shortcode;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;


class TabsShortcode extends Shortcode
{
public function init()
{
$this->shortcode->getHandlers()->add('ui-tabs', function(ShortcodeInterface $sc) {

// Add assets
$this->shortcode->addAssets('js', ['jquery', 101]);
$this->shortcode->addAssets('js', 'plugin://shortcode-ui/js/ui-tabs.js');
$this->shortcode->addAssets('css', 'plugin://shortcode-ui/css/ui-tabs.css');

$hash = $this->shortcode->getId($sc);

$output = $this->twig->processTemplate('partials/ui-tabs.html.twig', [
'hash' => $hash,
'active' => $sc->getParameter('active', 0),
'position' => $sc->getParameter('position', 'top-left'),
'theme' => $sc->getParameter('theme', $this->config->get('plugins.shortcode-ui.theme.tabs', 'default')),
'child_tabs' => $this->shortcode->getStates($hash),
]);

return $output;
return $this->twig->processTemplate(
'partials/ui-tabs.html.twig',
[
'hash' => $hash,
'active' => $sc->getParameter('active', 0),
'position' => $sc->getParameter('position', 'top-left'),
'theme' => $sc->getParameter('theme', $this->config->get('plugins.shortcode-ui.theme.tabs', 'default')),
'child_tabs' => $this->shortcode->getStates($hash),
]
);
});

$this->shortcode->getHandlers()->add('ui-tab', function(ShortcodeInterface $sc) {
// Add tab to tab state using parent tabs id
$hash = $this->shortcode->getId($sc->getParent());
$this->shortcode->setStates($hash, $sc);
return;

return '';
});
}
}
31 changes: 31 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "grav-plugin-shortcode-ui",
"type": "grav-plugin",
"description": "Shortcode UI plugin for Grav CMS",
"keywords": ["shortcode"],
"homepage": "https://github.com/getgrav/grav-plugin-shortcode-ui/",
"license": "MIT",
"authors": [
{
"name": "Team Grav",
"email": "[email protected]",
"homepage": "http://getgrav.org",
"role": "Developer"
}
],
"require": {
"php": ">=7.1.3"
},
"autoload": {
"psr-4": {
"Grav\\Plugin\\ShortcodeUi\\": "classes/plugin",
"Grav\\Plugin\\Shortcodes\\": "classes/shortcodes"
},
"classmap": ["shortcode-ui.php"]
},
"config": {
"platform": {
"php": "7.1.3"
}
}
}
Loading

0 comments on commit 822c0d0

Please sign in to comment.