Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
<div class="js-bengor-cookies"></div> {#Prevent bengor-cookies console errors#}
<script src="{{ assets_path ~ '/patternlibrary.js' }}"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/*
* This file is part of the Pattern Library Builder project.
*
* Copyright (c) 2017-present LIN3S <info@lin3s.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove second license header

* This file is part of the Pattern Library Builder project.
*
* Copyright (c) 2017-present LIN3S <info@lin3s.com>
*
* 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 <gorka.lauzirika@gmail.com>
*/
class LoadThumbnailsCommand extends Command
{
private const CHROME_BIN = "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path is highly coupled with MacOS

private $configLoader;

public function __construct(StyleguideConfigLoader $configLoader)
{
parent::__construct();
$this->configLoader = $configLoader;
}

protected function configure()
{
$this->setName('lin3s:pattern-library-builder:load-thumbnails');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call setDescription method with proper explanation

}

protected function execute(InputInterface $input, OutputInterface $output)
{
$configs = $this->configLoader->allInPlain();

foreach ($configs as $config) {
$this->takeScreenshot($config);
}
}

private function takeScreenshot(array $config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add missing "void" return type

{
$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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can you Symfony Process to maintain better compatibility between different envs

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="lin3s.pattern_library_builder.command.load_thumbnails"
class="LIN3S\PatternLibraryBuilder\Symfony\Command\LoadThumbnailsCommand">
<argument type="service" id="lin3s.pattern_library_builder.loader.styleguide_config_loader"/>
<tag name="console.command"/>
</service>

<service id="lin3s.pattern_library_builder.controller.index_controller"
class="LIN3S\PatternLibraryBuilder\Controller\IndexController">
<argument type="service" id="lin3s.pattern_library_builder.loader.styleguide_config_loader"/>
<argument type="service" id="twig"/>
<argument>@lin3s_pattern_library_builder/pages/architecture.html.twig</argument>
</service>
<service id="lin3s.pattern_library_builder.controller.index_controller"
class="LIN3S\PatternLibraryBuilder\Controller\IndexController">
<argument type="service" id="lin3s.pattern_library_builder.loader.styleguide_config_loader"/>
<argument type="service" id="twig"/>
<argument>@lin3s_pattern_library_builder/pages/architecture.html.twig</argument>
</service>

<service id="lin3s.pattern_library_builder.controller.index_controller"
class="LIN3S\PatternLibraryBuilder\Controller\IndexController">
Expand Down