diff --git a/src/LIN3S/PatternLibraryBuilder/Resources/templates/pages/iframe.html.twig b/src/LIN3S/PatternLibraryBuilder/Resources/templates/pages/iframe.html.twig index 63ec9d0..a3207fb 100644 --- a/src/LIN3S/PatternLibraryBuilder/Resources/templates/pages/iframe.html.twig +++ b/src/LIN3S/PatternLibraryBuilder/Resources/templates/pages/iframe.html.twig @@ -27,6 +27,9 @@ {% set current_parameters = params %} {% endif %} {% endfor %} + {% if current_parameters == [] %} + {% set current_parameters = item.preview_parameters|first %} + {% endif %} {{ include(item.twig, current_parameters) }}
{#Prevent bengor-cookies console errors#} diff --git a/src/LIN3S/PatternLibraryBuilder/Symfony/Command/LoadThumbnailsCommand.php b/src/LIN3S/PatternLibraryBuilder/Symfony/Command/LoadThumbnailsCommand.php new file mode 100644 index 0000000..42dbab8 --- /dev/null +++ b/src/LIN3S/PatternLibraryBuilder/Symfony/Command/LoadThumbnailsCommand.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +/* + * This file is part of the Pattern Library Builder project. + * + * Copyright (c) 2017-present LIN3S + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace LIN3S\PatternLibraryBuilder\Symfony\Command; + +use LIN3S\PatternLibraryBuilder\Loader\StyleguideConfigLoader; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * @author Gorka Laucirica + */ +class LoadThumbnailsCommand extends Command +{ + private const CHROME_BIN = "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"; + private $configLoader; + + public function __construct(StyleguideConfigLoader $configLoader) + { + parent::__construct(); + $this->configLoader = $configLoader; + } + + protected function configure() + { + $this->setName('lin3s:pattern-library-builder:load-thumbnails'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $configs = $this->configLoader->allInPlain(); + + foreach ($configs as $config) { + $this->takeScreenshot($config); + } + } + + private function takeScreenshot(array $config) + { + $command = sprintf( + '%s --headless --disable-gpu --screenshot="%s" http://localhost:8000%s?media=mobile', + self::CHROME_BIN, + __DIR__ . '/../' . mt_rand() . '.png', + $config['slug'], + array_keys($config['config']['preview_parameters'])[0] + ); + + exec($command); + } +} diff --git a/src/LIN3S/PatternLibraryBuilder/Symfony/Resources/config/services.xml b/src/LIN3S/PatternLibraryBuilder/Symfony/Resources/config/services.xml index 8fe15d4..1a4bf8d 100644 --- a/src/LIN3S/PatternLibraryBuilder/Symfony/Resources/config/services.xml +++ b/src/LIN3S/PatternLibraryBuilder/Symfony/Resources/config/services.xml @@ -16,6 +16,24 @@ + + + + + + + + + @lin3s_pattern_library_builder/pages/architecture.html.twig + + + + + @lin3s_pattern_library_builder/pages/architecture.html.twig +