Compare commits
54 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13c4e1baf8 | |||
| ac8c31e525 | |||
| b934c4b5db | |||
| 6f86885c4f | |||
| f1de0abfda | |||
| 5359a608c1 | |||
| d69799f5de | |||
| fcc9a80d50 | |||
| 582a82f3fc | |||
| c4f2bae3c2 | |||
| 0aa71f31b1 | |||
| 9f0b05cbe9 | |||
| 482beb7010 | |||
| 3ab5a91d64 | |||
| 8d456c8e18 | |||
| e9922e2016 | |||
| 3271cb65ba | |||
| 7cbbf2cd88 | |||
| d329257704 | |||
| 1d990608f0 | |||
| 77158e334e | |||
| 9fee520d5d | |||
| ca08a12386 | |||
| 8f5b174ea2 | |||
| e1ade971c7 | |||
| 58410759b5 | |||
| faceddec16 | |||
| 5a0e15d907 | |||
| a5329afd63 | |||
| 668bf757a4 | |||
| 8f01bf32a2 | |||
| bedfc8c559 | |||
| 4d91bd6bf5 | |||
| fa86042253 | |||
| 1159d0b62f | |||
| fa253e60d8 | |||
| 526dd97348 | |||
| fc96ef2f9a | |||
| 027a81c170 | |||
| c9ef6f1e72 | |||
| 3b24c5d9f4 | |||
| 49b5bcf9cd | |||
| 87b7835b56 | |||
| 8779cdaafa | |||
| e9d20bee4f | |||
| 665e9eedc3 | |||
| a565438c8f | |||
| efbf7e569a | |||
| 713e413c55 | |||
| 9de8dd6af0 | |||
| 10ecb065a8 | |||
| 69eb48d986 | |||
| 9e7874e81a | |||
| d4f326e7ce |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -12,3 +12,5 @@ Thumbs.db
|
||||
example/
|
||||
vendor/
|
||||
.env
|
||||
/.phpunit.result.cache
|
||||
/build/
|
||||
|
||||
@@ -11,7 +11,6 @@ Dossier requires PHP 7.2+ and the following extensions enabled:
|
||||
|
||||
* Phar
|
||||
* SPL
|
||||
* Date
|
||||
* fileinfo
|
||||
* mbstring
|
||||
* Bz2
|
||||
|
||||
1
app/conf/.gitignore
vendored
1
app/conf/.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
/dossier_dev.yaml
|
||||
/dossier_prod.yaml
|
||||
/dossier_test.yaml
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
### Settings file for magdev/dossier
|
||||
charset: utf-8
|
||||
|
||||
# Output settings
|
||||
output:
|
||||
path: _output
|
||||
docname: dossier
|
||||
|
||||
# Theme settings
|
||||
theme:
|
||||
start_template: document.html.twig
|
||||
|
||||
# Date formats
|
||||
date:
|
||||
format:
|
||||
|
||||
@@ -6,6 +6,9 @@ services:
|
||||
|
||||
config:
|
||||
class: '\Magdev\Dossier\Service\ConfigService'
|
||||
|
||||
system:
|
||||
class: '\Magdev\Dossier\Service\SystemService'
|
||||
|
||||
monolog:
|
||||
class: '\Magdev\Dossier\Service\MonologService'
|
||||
@@ -19,6 +22,10 @@ services:
|
||||
class: '\Magdev\Dossier\Service\MinifierService'
|
||||
arguments: ['@monolog']
|
||||
|
||||
git:
|
||||
class: '\Magdev\Dossier\Service\GitService'
|
||||
arguments: ['@config', '@monolog', '@system']
|
||||
|
||||
translator:
|
||||
class: '\Magdev\Dossier\Service\TranslatorService'
|
||||
arguments: ['@config', '@monolog']
|
||||
|
||||
@@ -502,19 +502,6 @@ dl.horizontal {
|
||||
font-weight: bold;
|
||||
font-size: (@base-font-size + .5pt);
|
||||
}
|
||||
dl.horizontal {
|
||||
display: none;
|
||||
dt {
|
||||
text-align: left;
|
||||
width: 1cm;
|
||||
}
|
||||
dd {
|
||||
padding-right: 1cm;
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
p, li {
|
||||
line-height: @intro-paragraph-line-height;
|
||||
font-size: @intro-paragraph-size;
|
||||
|
||||
@@ -19,6 +19,14 @@
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro list_projects(projects, tag) %}
|
||||
{% set tag = tag|default('li') %}
|
||||
{% for project in projects %}
|
||||
<{{ tag }}><em>{{ project.name }}:</em>
|
||||
{{ project.shortDescription }}</{{ tag }}>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro list_link_array(entries, tag) %}
|
||||
{% set tag = tag|default('li') %}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{% import "macros.html.twig" as macros %}
|
||||
|
||||
{% if projects|length > 0 %}
|
||||
<section class="projects">
|
||||
<h2>{{ 'projects.header'|trans }}</h2>
|
||||
@@ -6,18 +8,13 @@
|
||||
{% for project in projects %}
|
||||
<article class="project">
|
||||
<h3>{{ project.name }} {% if project.stack %}<small>({{ project.stack }})</small>{% endif %}</h3>
|
||||
<dl class="horizontal">
|
||||
<dt>{{ 'projects.fields.status'|trans }}</dt>
|
||||
<dd>
|
||||
<p class="badge badge-{{ project.status }}">{{ ('projects.status.' ~ project.status)|trans }}</p>
|
||||
</dd>
|
||||
{% if project.role %}
|
||||
<dt>{{ 'projects.fields.role'|trans }}</dt>
|
||||
<dd>{{ project.role }}</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
<p class="short-description">{{ project.shortDescription }}</p>
|
||||
{{ project.content|raw }}
|
||||
{% if project.hasUrls() %}
|
||||
<ul>
|
||||
{{ macros.list_link_array(project.urls) }}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@@ -115,11 +115,11 @@
|
||||
{{ macros.list_references(person.references) }}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if person.projects|length > 0 %}
|
||||
|
||||
{% if projects|length > 0 %}
|
||||
<h3>{{ 'resume.headers.current_projects'|trans }}</h3>
|
||||
<ul>
|
||||
{{ macros.list_simple_array(person.projects) }}
|
||||
{{ macros.list_projects(projects) }}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
|
||||
3
bin/.gitignore
vendored
3
bin/.gitignore
vendored
@@ -2,3 +2,6 @@
|
||||
lessc
|
||||
pscss
|
||||
.directory
|
||||
/phpca
|
||||
/phpunit
|
||||
/phing
|
||||
|
||||
@@ -27,19 +27,10 @@
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
define('DOSSIER_ROOT', dirname(__DIR__));
|
||||
define('DOSSIER_CACHE', getenv('HOME').'/.dossier/cache');
|
||||
define('PROJECT_ROOT', getcwd());
|
||||
require(dirname(__DIR__).'/src/bootstrap.php');
|
||||
define('DOSSIER_LOGO', 'DQogX19fX19fX18gICAgICAgICAgICAgICAgICAgICAgLl9fICAgICAgICAgICAgICANCiBcX19fX19fIFwgICBfX19fICBfX19fX18gX19fX198X198IF9fX19fX19fX19fIA0KICB8ICAgIHwgIFwgLyAgXyBcLyAgX19fLy8gIF9fXy8gIHwvIF9fIFxfICBfXyBcDQogIHwgICAgYCAgICggIDxfPiApX19fIFwgXF9fXyBcfCAgXCAgX19fL3wgIHwgXC8NCiAvX19fX19fXyAgL1xfX19fL19fX18gID5fX19fICA+X198XF9fXyAgPl9ffCAgIA0KICAgICAgICAgXC8gICAgICAgICAgIFwvICAgICBcLyAgICAgICAgXC8gICAgICAgDQo=');
|
||||
|
||||
if (!is_dir(DOSSIER_CACHE)) {
|
||||
mkdir(DOSSIER_CACHE, 0700, true);
|
||||
}
|
||||
|
||||
require DOSSIER_ROOT.'/vendor/autoload.php';
|
||||
|
||||
use Magdev\Dossier\Application;
|
||||
use Magdev\Dossier\Command;
|
||||
|
||||
@@ -47,21 +38,21 @@ $app = new Application('dossier.phar', '1.0.0');
|
||||
$app->add(new Command\Dossier\DossierBuildCommand());
|
||||
$app->add(new Command\Dossier\DossierInitCommand());
|
||||
$app->add(new Command\Dossier\DossierStatusCommand());
|
||||
$app->add(new Command\Intro\IntroAddCommand());
|
||||
$app->add(new Command\Intro\IntroEditCommand());
|
||||
$app->add(new Command\Person\PersonAddCommand());
|
||||
$app->add(new Command\Person\PersonEditCommand());
|
||||
$app->add(new Command\Cv\CvAddCommand());
|
||||
$app->add(new Command\Cv\CvEditCommand());
|
||||
|
||||
$app->add(new Command\Create\CreateIntroCommand());
|
||||
$app->add(new Command\Create\CreatePersonCommand());
|
||||
$app->add(new Command\Create\CreateCvCommand());
|
||||
$app->add(new Command\Create\CreateProjectCommand());
|
||||
|
||||
$app->add(new Command\Config\ConfigShowCommand());
|
||||
$app->add(new Command\Config\ConfigGetCommand());
|
||||
$app->add(new Command\Config\ConfigSetCommand());
|
||||
$app->add(new Command\Config\ConfigUnsetCommand());
|
||||
$app->add(new Command\Theme\ThemeListCommand());
|
||||
$app->add(new Command\Theme\ThemeDumpCommand());
|
||||
|
||||
$app->add(new Command\Cache\CacheClearCommand());
|
||||
$app->add(new Command\Server\ServerStartCommand());
|
||||
$app->add(new Command\Dev\PharExtractCommand());
|
||||
|
||||
$app->run();
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name" : "magdev/dossier",
|
||||
"type" : "project",
|
||||
"description" : "Create your dossier from Markdown files",
|
||||
"description" : "Create a personal dossier from Markdown files",
|
||||
"license" : "MIT",
|
||||
"authors" : [{
|
||||
"name" : "Marco Grätsch",
|
||||
@@ -13,6 +13,12 @@
|
||||
"Magdev\\Dossier\\" : "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev" : {
|
||||
"psr-4" : {
|
||||
"Magdev\\DossierTests\\" : "tests"
|
||||
}
|
||||
},
|
||||
"minimum-stability" : "stable",
|
||||
"require" : {
|
||||
"php" : "~7.2",
|
||||
"ext-phar" : "*",
|
||||
@@ -32,12 +38,16 @@
|
||||
"mnapoli/front-yaml" : "^1.6",
|
||||
"oyejorge/less.php" : "v1.7.0.14",
|
||||
"erusev/parsedown-extra" : "^0.7.1",
|
||||
"zaininnari/html-minifier" : "*",
|
||||
"leafo/scssphp" : "^0.7.6",
|
||||
"adbario/php-dot-notation" : "^2.0",
|
||||
"magdev/console-form" : "^0.0.7",
|
||||
"magdev/console-form" : "dev-master",
|
||||
"monolog/monolog" : "^1.23",
|
||||
"pdfshift/pdfshift-php" : "~1.0.2"
|
||||
"pdfshift/pdfshift-php" : "~1.0.2",
|
||||
"raivisdejus/html-minifier" : "~0.5"
|
||||
},
|
||||
"require-dev" : {
|
||||
"wapmorgan/php-code-analyzer" : "^1.0",
|
||||
"phpunit/phpunit" : "~8.1"
|
||||
},
|
||||
"config" : {
|
||||
"bin-dir" : "bin"
|
||||
@@ -58,11 +68,5 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"repositories" : [{
|
||||
"type" : "git",
|
||||
"url" : "git@github.com:magdev/console-form.git",
|
||||
"name" : "magdev/console-form"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
2341
composer.lock
generated
2341
composer.lock
generated
File diff suppressed because it is too large
Load Diff
21
phpunit.xml
Normal file
21
phpunit.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<phpunit
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="src/bootstrap.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="dossier">
|
||||
<directory>tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<php>
|
||||
<env name="APP_ENV" value="test"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
@@ -28,7 +28,7 @@
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Cv;
|
||||
namespace Magdev\Dossier\Command\Create;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@@ -43,7 +43,7 @@ use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class CvAddCommand extends BaseCommand
|
||||
final class CreateCvCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* TheCV Form
|
||||
@@ -58,7 +58,7 @@ final class CvAddCommand extends BaseCommand
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('cv:add')
|
||||
$this->setName('create:cv')
|
||||
->setDescription('Write a new CV entry')
|
||||
->addArgument('name', InputArgument::REQUIRED, 'Choose the name of the entry')
|
||||
->addOption('review', 'r', InputOption::VALUE_NONE, 'Review file in editor');
|
||||
@@ -72,7 +72,12 @@ final class CvAddCommand extends BaseCommand
|
||||
* @see \Magdev\Dossier\Command\BaseCommand::initialize()
|
||||
*/
|
||||
protected function initialize(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
{
|
||||
$name = $input->getArgument('name');
|
||||
if (file_exists(PROJECT_ROOT.'/cv/'.$name.'.md')) {
|
||||
throw new \RuntimeException('File cv/'.$name.'.md already exists');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->form = $this->getHelper('form')->getFormByName('form.cv', $input, $output);
|
||||
parent::initialize($input, $output);
|
||||
@@ -28,7 +28,7 @@
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Intro;
|
||||
namespace Magdev\Dossier\Command\Create;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@@ -37,7 +37,7 @@ use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Droath\ConsoleForm\Exception\FormException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
final class IntroAddCommand extends BaseCommand
|
||||
final class CreateIntroCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The IntroForm
|
||||
@@ -52,7 +52,7 @@ final class IntroAddCommand extends BaseCommand
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('intro:add')
|
||||
$this->setName('create:intro')
|
||||
->setDescription('Write the Intro page')
|
||||
->addOption('review', 'r', InputOption::VALUE_NONE, 'Review file in editor');
|
||||
|
||||
@@ -68,6 +68,10 @@ final class IntroAddCommand extends BaseCommand
|
||||
{
|
||||
parent::initialize($input, $output);
|
||||
|
||||
if (file_exists(PROJECT_ROOT.'/intro.md')) {
|
||||
throw new \RuntimeException('File intro.md already exists');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->form = $this->getHelper('form')
|
||||
->getFormByName('form.intro', $input, $output);
|
||||
@@ -28,7 +28,7 @@
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Person;
|
||||
namespace Magdev\Dossier\Command\Create;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@@ -37,7 +37,7 @@ use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Droath\ConsoleForm\Exception\FormException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
final class PersonAddCommand extends BaseCommand
|
||||
final class CreatePersonCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* The IntroForm
|
||||
@@ -52,7 +52,7 @@ final class PersonAddCommand extends BaseCommand
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('person:add')
|
||||
$this->setName('create:person')
|
||||
->setDescription('Write the Person page')
|
||||
->addOption('review', 'r', InputOption::VALUE_NONE, 'Review file in editor');
|
||||
|
||||
@@ -68,6 +68,10 @@ final class PersonAddCommand extends BaseCommand
|
||||
{
|
||||
parent::initialize($input, $output);
|
||||
|
||||
if (file_exists(PROJECT_ROOT.'/person.md')) {
|
||||
throw new \RuntimeException('File person.md already exists');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->form = $this->getHelper('form')
|
||||
->getFormByName('form.person', $input, $output);
|
||||
129
src/Command/Create/CreateProjectCommand.php
Normal file
129
src/Command/Create/CreateProjectCommand.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Create;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Droath\ConsoleForm\Exception\FormException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
/**
|
||||
* Write a new project
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class CreateProjectCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* TheCV Form
|
||||
* @var \Magdev\Dossier\Form\Extension\Form
|
||||
*/
|
||||
protected $form = null;
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('create:project')
|
||||
->setDescription('Write a new project file')
|
||||
->addArgument('name', InputArgument::REQUIRED, 'Choose the name of the entry')
|
||||
->addOption('review', 'r', InputOption::VALUE_NONE, 'Review file in editor');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Magdev\Dossier\Command\BaseCommand::initialize()
|
||||
*/
|
||||
protected function initialize(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$name = $input->getArgument('name');
|
||||
if (file_exists(PROJECT_ROOT.'/projects/'.$name.'.md')) {
|
||||
throw new \RuntimeException('File projects/'.$name.'.md already exists');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->form = $this->getHelper('form')->getFormByName('form.project', $input, $output);
|
||||
parent::initialize($input, $output);
|
||||
} catch (FormException $fe) {
|
||||
throw new RuntimeException(get_class($fe).': '.$fe->getMessage(), $fe->getCode(), $fe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::interact()
|
||||
*/
|
||||
protected function interact(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->io->title($this->translator->trans('form.project.header.add'));
|
||||
$this->io->newLine();
|
||||
$this->form->process();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if ($this->form->isProcessed()) {
|
||||
$markdown = $this->getService('markdown');
|
||||
/* @var $markdown \Magdev\Dossier\Service\MarkdownService */
|
||||
|
||||
try {
|
||||
$text = $this->form->stripData('text', '');
|
||||
$name = $input->getArgument('name');
|
||||
|
||||
$markdown->save(PROJECT_ROOT.'/projects/'.$name.'.md', $this->form->getResults(), $text, false);
|
||||
$this->io->success($this->translator->trans('message.write.success', array(
|
||||
'%name%' => 'Project/'.ucfirst($name)
|
||||
)));
|
||||
|
||||
if ($input->getOption('review') != false) {
|
||||
$this->getService('uri_helper')->openFileInEditor(PROJECT_ROOT.'/projects/'.$name.'.md');
|
||||
}
|
||||
} catch (FormException $fe) {
|
||||
throw new RuntimeException(get_class($fe).': '.$fe->getMessage(), $fe->getCode(), $fe);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ use Magdev\Dossier\Model\Intro;
|
||||
use Magdev\Dossier\Model\Letter;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
use Magdev\Dossier\Util\DataCollector;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
|
||||
/**
|
||||
* Generate your dossier
|
||||
@@ -62,7 +63,8 @@ final class DossierBuildCommand extends BaseCommand
|
||||
->addOption('locale', 'l', InputOption::VALUE_OPTIONAL, 'Set the locale', 'de')
|
||||
->addOption('sort', 's', InputOption::VALUE_OPTIONAL, 'Set the sort direction for the CV', CurriculumVitae::SORT_DESC)
|
||||
->addOption('theme', 't', InputOption::VALUE_OPTIONAL, 'Select the theme', 'print')
|
||||
->addOption('docname', 'd', InputOption::VALUE_OPTIONAL, 'Set the name for the output document (w/o extension)', 'dossier')
|
||||
->addOption('start-template', 'i', InputOption::VALUE_OPTIONAL, 'The name of the start-template', '')
|
||||
->addOption('docname', 'd', InputOption::VALUE_OPTIONAL, 'Set the name for the output document (w/o extension)', '')
|
||||
|
||||
->addOption('no-cover', null, InputOption::VALUE_NONE, 'Suppress the cover')
|
||||
->addOption('no-intro', null, InputOption::VALUE_NONE, 'Suppress the introduction')
|
||||
@@ -97,11 +99,13 @@ final class DossierBuildCommand extends BaseCommand
|
||||
$cssproc = $this->getService('cssproc');
|
||||
/* @var $cssroc \Magdev\Dossier\Service\StylesheetProcessorService */
|
||||
|
||||
$startTemplate = $input->getOption('start-template') ?: $this->config->get('theme.start_template');
|
||||
$name = $input->getOption('docname') ?: $this->getService('git')->getCurrentBranchName();
|
||||
try {
|
||||
$data = new DataCollector(array(
|
||||
'disabled' => $this->getHelper('section_manager')->getDisabledSections($input),
|
||||
'theme' => $input->getOption('theme'),
|
||||
'name' => $input->getOption('docname'),
|
||||
'name' => ($name ?: 'dossier'),
|
||||
'tags' => $this->config->get('cv.tags'),
|
||||
'locale' => $this->translator->getTranslator()->getLocale(),
|
||||
'stylesheet' => $cssproc->parseThemeStyles(),
|
||||
@@ -112,7 +116,7 @@ final class DossierBuildCommand extends BaseCommand
|
||||
$models = $this->getService('markdown')->getFileSet($input->getOption('sort'));
|
||||
$data->merge($models);
|
||||
|
||||
$outputFile = $tpl->render('document.html.twig', $data, PROJECT_ROOT.'/_output');
|
||||
$outputFile = $tpl->render($startTemplate, $data, PROJECT_ROOT.'/'.$this->config->get('output.path'));
|
||||
if ($input->getOption('pdf')) {
|
||||
$outputFile = $this->getService('pdf')->createPdf($outputFile);
|
||||
}
|
||||
|
||||
@@ -102,17 +102,17 @@ class DossierStatusCommand extends BaseCommand
|
||||
);
|
||||
$status[] = new TableSeparator();
|
||||
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv');
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv', \FilesystemIterator::SKIP_DOTS);
|
||||
foreach ($files as $file) {
|
||||
/* @var $file \SplFileInfo */
|
||||
$document = $markdown->getDocument($file->getPathname());
|
||||
$entry = new Entry($document);
|
||||
$status[] = array(get_class($entry), 'cv/'.$file->getFilename(),
|
||||
$status[$entry->getStartDate()->format('Ymd')] = array(get_class($entry), 'cv/'.$file->getFilename(),
|
||||
$this->io->align($this->io->bool($entry->useInResume()), 9, DossierStyle::ALIGN_CENTER),
|
||||
$this->io->align($this->io->percent($analyzer->analyze($entry), $thresholds), 6, DossierStyle::ALIGN_RIGHT)
|
||||
);
|
||||
}
|
||||
|
||||
ksort($status);
|
||||
$this->io->table(array('Model', 'File',
|
||||
$this->io->align('In Resume', 9),
|
||||
$this->io->align('Status', 6, DossierStyle::ALIGN_RIGHT)
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Theme;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
/**
|
||||
* Create a local copy of a template
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class ThemeDumpCommand extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* Phar helper service
|
||||
* @var \Magdev\Dossier\Service\PharHelperService
|
||||
*/
|
||||
private $pharHelper = null;
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('theme:dump')
|
||||
->setDescription('Create a local copy of a theme')
|
||||
|
||||
->addArgument('theme', InputArgument::REQUIRED, 'The name of the theme')
|
||||
->addOption('locale', 'l', InputOption::VALUE_OPTIONAL, 'Set the locale', 'de')
|
||||
->addOption('rename', 'r', InputOption::VALUE_OPTIONAL, 'Rename the theme', '')
|
||||
->addOption('output', 'o', InputOption::VALUE_OPTIONAL, 'Output folder', getenv('HOME').'/.dossier/tpl');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::initialize()
|
||||
*/
|
||||
protected function initialize(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->pharHelper = $this->getService('phar_helper');
|
||||
|
||||
parent::initialize($input, $output);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$theme = $input->getArgument('theme');
|
||||
$outDir = $input->getOption('output');
|
||||
$newName = $input->getOption('rename');
|
||||
|
||||
$themeDir = 'app/tpl/'.$theme;
|
||||
$targetDir = !$newName ? $outDir.'/'.$theme : $outDir.'/'.$newName;
|
||||
$this->pharHelper->copyDir($themeDir, $targetDir);
|
||||
|
||||
$this->io->success($this->translator->trans('message.dump.success', array('%theme%' => $theme)));
|
||||
/*
|
||||
if ($outDir != getenv('HOME').'/.dossier/tpl') {
|
||||
$output->writeln('<fg=cyan> '.$this->translator->trans('message.export.template_dir').'</>');
|
||||
$output->writeln('<fg=blue> '.$this->translator->trans('message.export.code.template_environment', array('%path%' => $outDir)).'</>');
|
||||
} else {
|
||||
$output->writeln('<fg=cyan> '.$this->translator->trans('message.export.template_homedir').'</>');
|
||||
}*/
|
||||
$this->io->newLine();
|
||||
}
|
||||
}
|
||||
|
||||
77
src/Form/ProjectFormBuilder.php
Normal file
77
src/Form/ProjectFormBuilder.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Form;
|
||||
|
||||
use Magdev\Dossier\Form\Extension\Form;
|
||||
use Magdev\Dossier\Form\Field\SelectField;
|
||||
use Magdev\Dossier\Form\Field\TextField;
|
||||
use Magdev\Dossier\Form\Field\BooleanField;
|
||||
|
||||
/**
|
||||
* EntryFormBuilder
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
class ProjectFormBuilder extends Base\BaseFormBuilder implements Base\FormBuilderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Droath\ConsoleForm\FormInterface::getName()
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'form.project';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Droath\ConsoleForm\FormInterface::buildForm()
|
||||
*/
|
||||
public function buildForm()
|
||||
{
|
||||
$form = new Form();
|
||||
$form->setLabelPrefix($this->config->get('form.label.prefix'))
|
||||
->setLabelLength($this->config->get('form.label.length'))
|
||||
->addFormLoadCallback($this->getUnflattenCallback())
|
||||
->addFormResultsCallback($this->getFlattenCallback());
|
||||
|
||||
$form->addField(new TextField('name', $this->translator->trans('form.project.name')));
|
||||
$form->addField(new TextField('shortDescription', $this->translator->trans('form.project.short_description')));
|
||||
$form->addField(new TextField('stack', $this->translator->trans('form.project.stack')));
|
||||
$form->addField(new TextField('status', $this->translator->trans('form.project.status')));
|
||||
$form->addField(new BooleanField('active', $this->translator->trans('form.project.active')));
|
||||
$this->addFlatGroupField($form, 'urls', false, 'project');
|
||||
$form->addField(new TextField('text', $this->translator->trans('form.project.text'), false));
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ class CurriculumVitae extends BaseCollection
|
||||
|
||||
$formatter = $this->formatter;
|
||||
array_walk($result, function(int &$seconds, string $key) use ($formatter) {
|
||||
$seconds = $formatter->formatExperience($seconds);
|
||||
$seconds = $formatter->formatYearMonthDuration($seconds);
|
||||
});
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Magdev\Dossier\Model\CurriculumVitae;
|
||||
|
||||
use Magdev\Dossier\Model\AbstractModel;
|
||||
use Magdev\Dossier\Model\Traits\PhotoTrait;
|
||||
use Magdev\Dossier\Model\Traits\ToggableTrait;
|
||||
use Mni\FrontYAML\Document;
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Analyzer\Base\AnalyzableInterface;
|
||||
@@ -46,6 +47,7 @@ use Magdev\Dossier\Model\Base\PhotoInterface;
|
||||
final class Entry extends BaseModel implements PhotoInterface, AnalyzableInterface
|
||||
{
|
||||
use PhotoTrait;
|
||||
use ToggableTrait;
|
||||
|
||||
/**
|
||||
* Start date
|
||||
@@ -127,7 +129,7 @@ final class Entry extends BaseModel implements PhotoInterface, AnalyzableInterfa
|
||||
|
||||
|
||||
/**
|
||||
* Constrctor
|
||||
* Constructor
|
||||
*
|
||||
* @param \Mni\FrontYAML\Document $document
|
||||
*/
|
||||
|
||||
@@ -69,16 +69,6 @@ class Intro extends BaseModel implements PhotoInterface, AnalyzableInterface
|
||||
protected $showQuotes = self::SHOW_TOP;
|
||||
|
||||
|
||||
/**
|
||||
* Get the headline
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeadline(): string
|
||||
{
|
||||
return $this->headline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -93,6 +83,17 @@ class Intro extends BaseModel implements PhotoInterface, AnalyzableInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the headline
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeadline(): string
|
||||
{
|
||||
return $this->headline;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the quotes
|
||||
*
|
||||
|
||||
@@ -132,12 +132,6 @@ final class Person extends BaseModel implements PhotoInterface, AnalyzableInterf
|
||||
*/
|
||||
protected $interests = array();
|
||||
|
||||
/**
|
||||
* Current Projects
|
||||
* @var array
|
||||
*/
|
||||
protected $projects = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -312,17 +306,6 @@ final class Person extends BaseModel implements PhotoInterface, AnalyzableInterf
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get current projects
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getProjects(): array
|
||||
{
|
||||
return $this->projects;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the work license
|
||||
*
|
||||
@@ -388,7 +371,10 @@ final class Person extends BaseModel implements PhotoInterface, AnalyzableInterf
|
||||
foreach ($value as $type => $address) {
|
||||
if ($type == 'accounts' && is_array($address)) {
|
||||
foreach ($address as $a) {
|
||||
$this->contacts->append(new Contact($a['address'], $a['type']));
|
||||
$contact = new Contact($a['address'], $a['type'], $a['active']);
|
||||
if ($contact->isActive()) {
|
||||
$this->contacts->append($contact);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->contacts->append(new Contact($address, $type));
|
||||
@@ -396,7 +382,10 @@ final class Person extends BaseModel implements PhotoInterface, AnalyzableInterf
|
||||
}
|
||||
} else if ($key == 'references') {
|
||||
foreach ($value as $reference) {
|
||||
$this->references->append(new Reference($reference));
|
||||
$ref = new Reference($reference);
|
||||
if ($ref->isActive()) {
|
||||
$this->references->append($ref);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->setProperty($key, $value);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
namespace Magdev\Dossier\Model\Person;
|
||||
|
||||
use Magdev\Dossier\Model\Traits\ToggableTrait;
|
||||
|
||||
/**
|
||||
* Contact model
|
||||
*
|
||||
@@ -37,6 +39,8 @@ namespace Magdev\Dossier\Model\Person;
|
||||
*/
|
||||
class Contact
|
||||
{
|
||||
use ToggableTrait;
|
||||
|
||||
/**
|
||||
* Contact address
|
||||
* @var string
|
||||
@@ -55,11 +59,13 @@ class Contact
|
||||
*
|
||||
* @param string $address
|
||||
* @param string $type
|
||||
* @param bool $active
|
||||
*/
|
||||
public function __construct(string $address, string $type)
|
||||
public function __construct(string $address, string $type, ?bool $active = true)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->type = $type;
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
namespace Magdev\Dossier\Model\Person;
|
||||
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Model\Traits\ToggableTrait;
|
||||
|
||||
/**
|
||||
* Model for job references
|
||||
@@ -39,6 +40,8 @@ use Magdev\Dossier\Model\Base\BaseModel;
|
||||
*/
|
||||
class Reference extends BaseModel
|
||||
{
|
||||
use ToggableTrait;
|
||||
|
||||
/**
|
||||
* Reference description
|
||||
* @var string
|
||||
|
||||
@@ -30,32 +30,61 @@
|
||||
|
||||
namespace Magdev\Dossier\Model;
|
||||
|
||||
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Model\Traits\ToggableTrait;
|
||||
use Mni\FrontYAML\Document;
|
||||
use Magdev\Dossier\Model\Traits\PhotoTrait;
|
||||
|
||||
/**
|
||||
* Model for projects page
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
class Project extends BaseModel
|
||||
{
|
||||
use ToggableTrait;
|
||||
use PhotoTrait;
|
||||
|
||||
/**
|
||||
* Project name
|
||||
* @var string
|
||||
*/
|
||||
protected $name = '';
|
||||
protected $status = '';
|
||||
protected $url = '';
|
||||
|
||||
/**
|
||||
* Public URLs
|
||||
* @var array
|
||||
*/
|
||||
protected $urls = array();
|
||||
|
||||
/**
|
||||
* Short Description
|
||||
* @var string
|
||||
*/
|
||||
protected $shortDescription = '';
|
||||
|
||||
/**
|
||||
* Project stack
|
||||
* @var string
|
||||
*/
|
||||
protected $stack = '';
|
||||
protected $role = '';
|
||||
|
||||
|
||||
|
||||
public function getRole(): string
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Project status
|
||||
* @var string
|
||||
*/
|
||||
protected $status = '';
|
||||
|
||||
|
||||
public function getStack(): string
|
||||
{
|
||||
return $this->stack;
|
||||
}
|
||||
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
|
||||
public function getName(): string
|
||||
@@ -63,29 +92,21 @@ class Project extends BaseModel
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getStatus(): string
|
||||
|
||||
public function hasUrls(): bool
|
||||
{
|
||||
return $this->status;
|
||||
return sizeof($this->urls) > 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getUrl(): string
|
||||
public function getUrls(): array
|
||||
{
|
||||
return $this->url;
|
||||
return $this->urls;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getShortDescription(): string
|
||||
{
|
||||
return $this->shortDescription;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,50 +23,69 @@
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Theme;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
namespace Magdev\Dossier\Model\Traits;
|
||||
|
||||
/**
|
||||
* Create a local copy of a template
|
||||
*
|
||||
* Trait for objects which can be de-/activated
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
final class ThemeListCommand extends BaseCommand
|
||||
{
|
||||
trait ToggableTrait
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* @var bool
|
||||
*/
|
||||
protected function configure()
|
||||
protected $active = true;
|
||||
|
||||
|
||||
/**
|
||||
* Activate object
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function activate(): self
|
||||
{
|
||||
$this->setName('theme:list')
|
||||
->setDescription('List available themes')
|
||||
->addOption('all', 'a', InputOption::VALUE_NONE, 'List all themes, icluding the overridden ones');
|
||||
|
||||
parent::configure();
|
||||
$this->active = true;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::execute()
|
||||
* Deactivate object
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
public function deactivate(): self
|
||||
{
|
||||
$all = (bool) $input->getOption('all');
|
||||
$helper = $this->getHelper('export');
|
||||
/* @var $helper \Magdev\Dossier\Helper\ExportHelper */
|
||||
|
||||
$themes = $this->config->findThemes($all);
|
||||
$this->active = false;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Toggle current activation status
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function toggle(): self
|
||||
{
|
||||
$this->active = !$this->active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if object is activated
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
}
|
||||
|
||||
106
src/Service/GitService.php
Normal file
106
src/Service/GitService.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Service;
|
||||
|
||||
class GitService
|
||||
{
|
||||
/**
|
||||
* Configuration service
|
||||
* @var \Magdev\Dossier\Service\ConfigService
|
||||
*/
|
||||
protected $config = null;
|
||||
|
||||
/**
|
||||
* Monolog service
|
||||
* @var \Magdev\Dossier\Service\MonologService
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
/**
|
||||
* System service
|
||||
* @var \Magdev\Dossier\Service\SystemService
|
||||
*/
|
||||
protected $system = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Magdev\Dossier\Service\ConfigService $config
|
||||
* @param \Magdev\Dossier\Service\MonologService $logger
|
||||
* @param \Magdev\Dossier\Service\SystemService $system
|
||||
*/
|
||||
public function __construct(ConfigService $config, MonologService $logger, SystemService $system)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->logger = $logger;
|
||||
$this->system = $system;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a new repository
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function init(): bool
|
||||
{
|
||||
if (!$this->isGitRepository()) {
|
||||
$this->system->exec('git init');
|
||||
}
|
||||
return $this->isGitRepository();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current branch name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentBranchName(): string
|
||||
{
|
||||
if (!$this->isGitRepository()) {
|
||||
return $this->config->get('output.docname');
|
||||
}
|
||||
return $this->system->exec('git branch | grep \\\* | cut -d \' \' -f2', SystemService::MODE_LASTLINE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if repository is initialized
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isGitRepository(): bool
|
||||
{
|
||||
return is_dir(PROJECT_ROOT.'/.git') && file_exists(PROJECT_ROOT.'/.git/HEAD');
|
||||
}
|
||||
}
|
||||
@@ -104,11 +104,14 @@ class MarkdownService
|
||||
$intro = new Intro($this->getDocument(PROJECT_ROOT.'/intro.md'));
|
||||
|
||||
$cv = new CurriculumVitae($this->formatter);
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv');
|
||||
$files = new \FilesystemIterator(PROJECT_ROOT.'/cv', \FilesystemIterator::SKIP_DOTS);
|
||||
foreach ($files as $file) {
|
||||
/* @var $file \SplFileInfo */
|
||||
$document = $this->getDocument($file->getPathname());
|
||||
$cv->append(new CurriculumVitae\Entry($document));
|
||||
$entry = new CurriculumVitae\Entry($document);
|
||||
if ($entry->isActive()) {
|
||||
$cv->append($entry);
|
||||
}
|
||||
}
|
||||
$cv->setSortDirection($sort)->sort();
|
||||
|
||||
@@ -117,7 +120,10 @@ class MarkdownService
|
||||
foreach ($files as $file) {
|
||||
/* @var $file \SplFileInfo */
|
||||
$document = $this->getDocument($file->getPathname());
|
||||
$projects->append(new Project($document));
|
||||
$project = new Project($document);
|
||||
if ($project->isActive()) {
|
||||
$projects->append($project);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -130,7 +130,10 @@ class PharHelperService
|
||||
*/
|
||||
public function copy(string $source, string $target): bool
|
||||
{
|
||||
return copy($this->getPharUrl($source), $target);
|
||||
if ($this->isInPhar() && substr($source, 0, 4) !== 'phar') {
|
||||
$source = $this->getPharUrl($source);
|
||||
}
|
||||
return copy($source, $target);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,48 +23,37 @@
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Cv;
|
||||
namespace Magdev\Dossier\Service;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
|
||||
class CvEditCommand extends BaseCommand
|
||||
class SystemService
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('cv:edit')
|
||||
->setDescription('Edit a CV entry in your default editor')
|
||||
->addArgument('file', InputArgument::REQUIRED, 'Filename of the entry w/o extension');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
const MODE_OUTPUT = 1;
|
||||
const MODE_RETURN = 2;
|
||||
const MODE_LASTLINE = 3;
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* Execute a system command
|
||||
*
|
||||
* @param string $cmd
|
||||
* @param int $mode
|
||||
* @param array $output
|
||||
* @param int $return
|
||||
* @return string|int|array
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
public function exec(string $cmd, int $mode = self::MODE_OUTPUT, &$output = array(), int &$return = 0)
|
||||
{
|
||||
$file = PROJECT_ROOT.'/cv/'.$input->getArgument('file').'.md';
|
||||
|
||||
if (!file_exists($file)) {
|
||||
throw new RuntimeException('File '.$file.' not found');
|
||||
$lastline = exec($cmd, $output, $return);
|
||||
switch ($mode) {
|
||||
case self::MODE_LASTLINE: return $lastline;
|
||||
case self::MODE_RETURN: return $return;
|
||||
default:
|
||||
case self::MODE_OUTPUT: return $output;
|
||||
}
|
||||
|
||||
$this->getService('uri_helper')->openFileInEditor($file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,13 +120,15 @@ class TemplateService
|
||||
{
|
||||
$theme = !$theme ? $this->theme : $theme;
|
||||
|
||||
if (getenv('DOSSIER_THEME_DIR')) {
|
||||
if (is_dir(getenv('DOSSIER_THEME_DIR').'/'.$theme) && file_exists(getenv('DOSSIER_THEME_DIR').'/'.$theme.'/'.$file)) {
|
||||
return getenv('DOSSIER_THEME_DIR').'/'.$theme.'/'.$file;
|
||||
if (getenv('APP_ENV') == 'prod') {
|
||||
if (getenv('DOSSIER_THEME_DIR')) {
|
||||
if (is_dir(getenv('DOSSIER_THEME_DIR').'/'.$theme) && file_exists(getenv('DOSSIER_THEME_DIR').'/'.$theme.'/'.$file)) {
|
||||
return getenv('DOSSIER_THEME_DIR').'/'.$theme.'/'.$file;
|
||||
}
|
||||
}
|
||||
if (is_dir(getenv('HOME').'/.dossier/tpl/'.$theme) && file_exists(getenv('HOME').'/.dossier/tpl/'.$theme.'/'.$file)) {
|
||||
return getenv('HOME').'/.dossier/tpl/'.$theme.'/'.$file;
|
||||
}
|
||||
}
|
||||
if (is_dir(getenv('HOME').'/.dossier/tpl/'.$theme) && file_exists(getenv('HOME').'/.dossier/tpl/'.$theme.'/'.$file)) {
|
||||
return getenv('HOME').'/.dossier/tpl/'.$theme.'/'.$file;
|
||||
}
|
||||
return DOSSIER_ROOT.'/app/tpl/'.$theme.'/'.$file;
|
||||
}
|
||||
@@ -143,16 +145,23 @@ class TemplateService
|
||||
$this->theme = $theme;
|
||||
|
||||
$loaders = array();
|
||||
if (getenv('DOSSIER_THEME_DIR') && is_dir(getenv('DOSSIER_THEME_DIR').'/'.$theme)) {
|
||||
$loaders[] = new \Twig_Loader_Filesystem(getenv('DOSSIER_THEME_DIR').'/'.$theme);
|
||||
}
|
||||
if (is_dir(getenv('HOME').'/.dossier/tpl/'.$theme)) {
|
||||
$loaders[] = new \Twig_Loader_Filesystem(getenv('HOME').'/.dossier/tpl/'.$theme);
|
||||
if (getenv('APP_ENV') == 'prod') {
|
||||
if (getenv('DOSSIER_THEME_DIR') && is_dir(getenv('DOSSIER_THEME_DIR').'/'.$theme)) {
|
||||
$loaders[] = new \Twig_Loader_Filesystem(getenv('DOSSIER_THEME_DIR').'/'.$theme);
|
||||
}
|
||||
if (is_dir(getenv('HOME').'/.dossier/tpl/'.$theme)) {
|
||||
$loaders[] = new \Twig_Loader_Filesystem(getenv('HOME').'/.dossier/tpl/'.$theme);
|
||||
}
|
||||
}
|
||||
$loaders[] = new \Twig_Loader_Filesystem(DOSSIER_ROOT.'/app/tpl/'.$theme);
|
||||
|
||||
$cache = false;
|
||||
if (getenv('APP_ENV') == 'prod') {
|
||||
$cache = new \Twig_Cache_Filesystem(DOSSIER_CACHE, \Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION);
|
||||
}
|
||||
|
||||
$this->twig = new \Twig_Environment(new \Twig_Loader_Chain($loaders), array(
|
||||
'cache' => new \Twig_Cache_Filesystem(DOSSIER_CACHE, \Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION),
|
||||
'cache' => $cache,
|
||||
'debug' => getenv('APP_DEBUG'),
|
||||
));
|
||||
$this->addTwigExtensions($this->translator->getTranslator(), $this->config);
|
||||
@@ -205,9 +214,6 @@ class TemplateService
|
||||
*/
|
||||
public function render(string $template, DataCollectorInterface $data, string $destDir): string
|
||||
{
|
||||
if (!is_dir($destDir)) {
|
||||
mkdir($destDir, 0755, true);
|
||||
}
|
||||
$vars = $data->getData();
|
||||
$name = isset($vars['name']) ? $vars['name'] : $this->docname;
|
||||
$name .= isset($vars['theme']) ? '.'.$vars['theme'] : '';
|
||||
@@ -215,6 +221,10 @@ class TemplateService
|
||||
|
||||
$html = $this->twig->render($template, $vars);
|
||||
$html = $this->minifier->minify($html);
|
||||
|
||||
if (!is_dir(dirname($path))) {
|
||||
mkdir(dirname($path), 0755, true);
|
||||
}
|
||||
if (!file_put_contents($path, $html)) {
|
||||
throw new \RuntimeException('Error writing output file: '.$path);
|
||||
}
|
||||
@@ -290,7 +300,7 @@ class TemplateService
|
||||
}, array('is_safe' => array('html'))));
|
||||
|
||||
$this->twig->addFilter(new \Twig_Filter('debug', function ($var) {
|
||||
return getenv('APP_DEBUG') == true ? '<code>'.print_r($var, true).'</code>' : '';
|
||||
return getenv('APP_DEBUG') == true || getenv('APP_ENV') == 'dev' ? '<code>'.print_r($var, true).'</code>' : '';
|
||||
}, array('is_safe' => array('html'))));
|
||||
|
||||
$this->twig->addFunction(new \Twig_Function('is_today', function (\DateTime $checkDate) {
|
||||
|
||||
@@ -97,7 +97,7 @@ class DataCollector implements DataCollectorInterface
|
||||
*/
|
||||
public function hasData(): bool
|
||||
{
|
||||
return sizeof($this->data) > o ? true : false;
|
||||
return sizeof($this->data) > 0 ? true : false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
41
src/bootstrap.php
Normal file
41
src/bootstrap.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
define('DOSSIER_ROOT', dirname(__DIR__));
|
||||
define('DOSSIER_CACHE', getenv('HOME').'/.dossier/cache');
|
||||
define('PROJECT_ROOT', getcwd());
|
||||
|
||||
if (!is_dir(DOSSIER_CACHE)) {
|
||||
mkdir(DOSSIER_CACHE, 0700, true);
|
||||
}
|
||||
|
||||
require DOSSIER_ROOT.'/vendor/autoload.php';
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,47 +23,49 @@
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Intro;
|
||||
namespace Magdev\DossierTests;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Magdev\Dossier\Application;
|
||||
use Magdev\Dossier\Service\GitService;
|
||||
|
||||
class IntroEditCommand extends BaseCommand
|
||||
class ApplicationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* @var \Magdev\Dossier\Application
|
||||
*/
|
||||
protected function configure()
|
||||
private $app = null;
|
||||
|
||||
|
||||
/**
|
||||
* Setup TestCase
|
||||
*/
|
||||
public function setup(): void
|
||||
{
|
||||
$this->setName('intro:edit')
|
||||
->setDescription('Edit the intro in your default editor');
|
||||
|
||||
parent::configure();
|
||||
$this->app = new Application();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* @group core
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
public function testGetContainer()
|
||||
{
|
||||
$file = PROJECT_ROOT.'/intro.md';
|
||||
|
||||
if (!file_exists($file)) {
|
||||
throw new RuntimeException('File '.$file.' not found');
|
||||
}
|
||||
|
||||
$this->getService('uri_helper')->openFileInEditor($file);
|
||||
$this->assertInstanceOf(ContainerBuilder::class, $this->app->getContainer());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @group core
|
||||
*/
|
||||
public function testGetValidService()
|
||||
{
|
||||
$this->assertInstanceOf(GitService::class, $this->app->getService('git'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2018 magdev
|
||||
* Copyright (c) 2019 magdev
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,47 +23,51 @@
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author magdev
|
||||
* @copyright 2018 Marco Grätsch
|
||||
* @copyright 2019 Marco Grätsch
|
||||
* @package magdev/dossier
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
*/
|
||||
|
||||
namespace Magdev\Dossier\Command\Person;
|
||||
namespace Magdev\DossierTests\Util;
|
||||
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Exception\RuntimeException;
|
||||
use Magdev\Dossier\Command\Base\BaseCommand;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Magdev\Dossier\Util\DataCollector;
|
||||
|
||||
class PersonEditCommand extends BaseCommand
|
||||
class DataCollectorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* @var array
|
||||
*/
|
||||
protected function configure()
|
||||
private $initData = ['foo'];
|
||||
|
||||
|
||||
/**
|
||||
* @group core
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::addData()
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::hasData()
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::setData()
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::getData()
|
||||
*/
|
||||
public function testSetGetData()
|
||||
{
|
||||
$this->setName('person:edit')
|
||||
->setDescription('Edit personal data in your default editor');
|
||||
$data = new DataCollector($this->initData);
|
||||
$this->assertEquals(true, $data->hasData());
|
||||
|
||||
parent::configure();
|
||||
$data->setData(1, 'bar');
|
||||
$this->assertEquals(['foo', 'bar'], $data->getData());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @see \Symfony\Component\Console\Command\Command::configure()
|
||||
* @group core
|
||||
* @covers \Magdev\Dossier\Util\DataCollector::merge()
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
public function testMergeData()
|
||||
{
|
||||
$file = PROJECT_ROOT.'/person.md';
|
||||
$data = new DataCollector($this->initData);
|
||||
$data2 = new DataCollector(['bar']);
|
||||
|
||||
if (!file_exists($file)) {
|
||||
throw new RuntimeException('File '.$file.' not found');
|
||||
}
|
||||
|
||||
$this->getService('uri_helper')->openFileInEditor($file);
|
||||
$data->merge($data2);
|
||||
$this->assertEquals(['foo', 'bar'], $data->getData());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user