54 Commits

Author SHA1 Message Date
13c4e1baf8 don't use phing 2019-06-05 11:11:18 +02:00
ac8c31e525 added comments 2019-06-05 10:15:11 +02:00
b934c4b5db Added Test for DataCollector 2019-06-05 10:14:50 +02:00
6f86885c4f Set test environment 2019-06-05 10:14:31 +02:00
f1de0abfda typo 2019-06-05 10:14:16 +02:00
5359a608c1 don't use default command 2019-06-05 09:46:32 +02:00
d69799f5de fixed renaming bugs 2019-06-05 09:46:21 +02:00
fcc9a80d50 set dossier:build as default command 2019-06-05 09:43:57 +02:00
582a82f3fc Its not working yet 2019-06-05 09:37:02 +02:00
c4f2bae3c2 changed commands to match new order 2019-06-05 09:36:30 +02:00
0aa71f31b1 Added Project form 2019-06-05 09:35:46 +02:00
9f0b05cbe9 Added PhotoTrait 2019-06-05 09:35:35 +02:00
482beb7010 Reorganized commands, removed theme-commands and edit-commands 2019-06-05 09:35:13 +02:00
3ab5a91d64 Ignore test-config 2019-06-05 08:59:34 +02:00
8d456c8e18 setting directories 2019-06-05 08:59:19 +02:00
e9922e2016 adding some tasks to get started 2019-06-05 00:31:34 +02:00
3271cb65ba Merge branch 'master' into dev
Conflicts:
	composer.json
	composer.lock
2019-06-05 00:13:09 +02:00
7cbbf2cd88 Using Phing as build-tool 2019-06-05 00:10:35 +02:00
d329257704 use dev-master version 2019-06-04 23:32:43 +02:00
1d990608f0 load magdev/console-form via packagist 2019-06-04 23:30:51 +02:00
77158e334e still trying to make installation work 2019-06-04 23:29:29 +02:00
9fee520d5d still trying to make installation work 2019-06-04 23:25:46 +02:00
ca08a12386 set minimu stability to dev 2019-06-04 23:12:26 +02:00
8f5b174ea2 use master branch 2019-06-04 23:10:15 +02:00
e1ade971c7 use github https 2019-06-04 23:07:29 +02:00
58410759b5 override stability for console-form 2019-06-04 23:01:21 +02:00
faceddec16 use http-path for repository 2019-06-04 22:55:20 +02:00
5a0e15d907 use local fork of console-form 2019-06-04 22:49:49 +02:00
a5329afd63 Merge branch 'dev' 2019-06-04 22:32:58 +02:00
668bf757a4 start using PHPUnit and test all this 2019-06-04 22:17:41 +02:00
8f01bf32a2 don't do this string hacking, we have a model 2019-06-04 21:34:09 +02:00
bedfc8c559 typo 2019-06-04 21:31:43 +02:00
4d91bd6bf5 Sort status output by start_date 2019-06-04 21:26:58 +02:00
fa86042253 skip dot-directories 2019-06-04 21:15:32 +02:00
1159d0b62f Introduced SystemService 2019-06-04 21:06:59 +02:00
fa253e60d8 made exec method more flexible 2019-06-04 21:01:19 +02:00
526dd97348 made start-template and output-dir/-filename configurable 2019-06-04 20:47:26 +02:00
fc96ef2f9a made start-template and output-dir/-filename configurable
Also added config-sections for theme and output.
2019-06-04 20:44:56 +02:00
027a81c170 Introduced toggable objects 2019-06-01 12:31:10 +02:00
c9ef6f1e72 Changed deprecated method call 2019-06-01 12:30:15 +02:00
3b24c5d9f4 Use git branch-name as document-name, use default if no git 2019-06-01 12:29:00 +02:00
49b5bcf9cd Introduced GitService 2019-06-01 12:27:27 +02:00
87b7835b56 make sure target directory exists 2019-06-01 12:22:47 +02:00
8779cdaafa update to symfony 4.2.8 et al. 2019-05-25 16:50:26 +02:00
e9d20bee4f unified project handling 2019-05-25 16:48:31 +02:00
665e9eedc3 template caching disabled in debug mode, cleanup projects page 2018-12-16 13:38:46 +01:00
a565438c8f fixed missing end-tag 2018-12-15 12:12:10 +01:00
efbf7e569a added repository link 2018-12-15 12:08:49 +01:00
713e413c55 ignore phpca binary 2018-12-15 11:51:54 +01:00
9de8dd6af0 added Date dependency as reported by phpca 2018-12-15 11:50:44 +01:00
10ecb065a8 moved to raivisdejus/html-minifier to fix rendering bug, added phpca 2018-12-15 11:50:11 +01:00
69eb48d986 re-enabled html minification, moved to raivisdejus/html-minifier 2018-12-15 11:45:21 +01:00
9e7874e81a commented html-minification out, causes word-spacing errors 2018-12-15 11:36:31 +01:00
d4f326e7ce Fixed bug in copy from phar file method 2018-09-03 22:24:44 +02:00
39 changed files with 2668 additions and 765 deletions

2
.gitignore vendored
View File

@@ -12,3 +12,5 @@ Thumbs.db
example/
vendor/
.env
/.phpunit.result.cache
/build/

View File

@@ -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
View File

@@ -1,2 +1,3 @@
/dossier_dev.yaml
/dossier_prod.yaml
/dossier_test.yaml

View File

@@ -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:

View File

@@ -7,6 +7,9 @@ services:
config:
class: '\Magdev\Dossier\Service\ConfigService'
system:
class: '\Magdev\Dossier\Service\SystemService'
monolog:
class: '\Magdev\Dossier\Service\MonologService'
arguments: ['@config']
@@ -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']

View File

@@ -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;

View File

@@ -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') %}

View File

@@ -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>

View File

@@ -116,10 +116,10 @@
</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
View File

@@ -2,3 +2,6 @@
lessc
pscss
.directory
/phpca
/phpunit
/phing

View File

@@ -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();

View File

@@ -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

File diff suppressed because it is too large Load Diff

21
phpunit.xml Normal file
View 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>

View File

@@ -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');
@@ -73,6 +73,11 @@ final class CvAddCommand extends BaseCommand
*/
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);

View File

@@ -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);

View File

@@ -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);

View 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);
}
}
}
}

View File

@@ -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);
}

View File

@@ -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)

View File

@@ -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();
}
}

View 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;
}
}

View File

@@ -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;
}

View File

@@ -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
*/

View File

@@ -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
*

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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

View File

@@ -30,25 +30,50 @@
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
@@ -56,6 +81,10 @@ class Project extends BaseModel
return $this->stack;
}
public function getStatus(): string
{
return $this->status;
}
public function getName(): string
@@ -64,28 +93,20 @@ class Project extends BaseModel
}
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;
}
}

View File

@@ -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()
{
$this->setName('theme:list')
->setDescription('List available themes')
->addOption('all', 'a', InputOption::VALUE_NONE, 'List all themes, icluding the overridden ones');
protected $active = true;
parent::configure();
/**
* Activate object
*
* @return self
*/
public function activate(): self
{
$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
View 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');
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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');
}
$this->getService('uri_helper')->openFileInEditor($file);
$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;
}
}
}

View File

@@ -120,6 +120,7 @@ class TemplateService
{
$theme = !$theme ? $this->theme : $theme;
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;
@@ -128,6 +129,7 @@ class TemplateService
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('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) {

View File

@@ -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
View 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';

View File

@@ -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()
{
$this->setName('intro:edit')
->setDescription('Edit the intro in your default editor');
private $app = null;
parent::configure();
/**
* Setup TestCase
*/
public function setup(): void
{
$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->assertInstanceOf(ContainerBuilder::class, $this->app->getContainer());
}
$this->getService('uri_helper')->openFileInEditor($file);
}
}
/**
* @group core
*/
public function testGetValidService()
{
$this->assertInstanceOf(GitService::class, $this->app->getService('git'));
}
}

View File

@@ -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()
{
$this->setName('person:edit')
->setDescription('Edit personal data in your default editor');
private $initData = ['foo'];
parent::configure();
/**
* @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()
{
$data = new DataCollector($this->initData);
$this->assertEquals(true, $data->hasData());
$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());
}
}