38 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
27 changed files with 2211 additions and 501 deletions

2
.gitignore vendored
View File

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

1
app/conf/.gitignore vendored
View File

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

View File

@@ -1,7 +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']
@@ -21,7 +24,7 @@ services:
git:
class: '\Magdev\Dossier\Service\GitService'
arguments: ['@config', '@monolog']
arguments: ['@config', '@monolog', '@system']
translator:
class: '\Magdev\Dossier\Service\TranslatorService'

2
bin/.gitignore vendored
View File

@@ -3,3 +3,5 @@ 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" : "*",
@@ -34,11 +40,15 @@
"erusev/parsedown-extra" : "^0.7.1",
"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",
"raivisdejus/html-minifier" : "~0.5"
},
"require-dev" : {
"wapmorgan/php-code-analyzer" : "^1.0",
"phpunit/phpunit" : "~8.1"
},
"config" : {
"bin-dir" : "bin"
},
@@ -58,14 +68,5 @@
]
}
}
},
"repositories" : [{
"type" : "git",
"url" : "git@github.com:magdev/console-form.git",
"name" : "magdev/console-form"
}
],
"require-dev" : {
"wapmorgan/php-code-analyzer" : "^1.0"
}
}

1929
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

@@ -1,70 +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\Cv;
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
{
/**
* {@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();
}
/**
* {@inheritDoc}
* @see \Symfony\Component\Console\Command\Command::configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$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);
}
}

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,6 +63,7 @@ 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('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')
@@ -97,6 +99,7 @@ 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(
@@ -113,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

@@ -129,7 +129,7 @@ final class Entry extends BaseModel implements PhotoInterface, AnalyzableInterfa
/**
* Constrctor
* Constructor
*
* @param \Mni\FrontYAML\Document $document
*/

View File

@@ -33,6 +33,7 @@ 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
@@ -42,6 +43,7 @@ use Mni\FrontYAML\Document;
class Project extends BaseModel
{
use ToggableTrait;
use PhotoTrait;
/**
* Project name
@@ -67,12 +69,23 @@ class Project extends BaseModel
*/
protected $stack = '';
/**
* Project status
* @var string
*/
protected $status = '';
public function getStack(): string
{
return $this->stack;
}
public function getStatus(): string
{
return $this->status;
}
public function getName(): string
{

View File

@@ -30,8 +30,6 @@
namespace Magdev\Dossier\Service;
// git branch | grep \* | cut -d ' ' -f2
class GitService
{
/**
@@ -46,17 +44,25 @@ class GitService
*/
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)
public function __construct(ConfigService $config, MonologService $logger, SystemService $system)
{
$this->config = $config;
$this->logger = $logger;
$this->system = $system;
}
@@ -68,7 +74,7 @@ class GitService
public function init(): bool
{
if (!$this->isGitRepository()) {
$this->exec('git init');
$this->system->exec('git init');
}
return $this->isGitRepository();
}
@@ -82,10 +88,9 @@ class GitService
public function getCurrentBranchName(): string
{
if (!$this->isGitRepository()) {
return $this->config->get('docname');
return $this->config->get('output.docname');
}
$output = $this->exec('git branch | grep \\\* | cut -d \' \' -f2');
return $output[0];
return $this->system->exec('git branch | grep \\\* | cut -d \' \' -f2', SystemService::MODE_LASTLINE);
}
@@ -96,20 +101,6 @@ class GitService
*/
public function isGitRepository(): bool
{
return is_dir(PROJECT_ROOT.'/.git') && file_exists(PROJECT_ROOT.'/.git/config');
}
/**
* Execute a system command
*
* @param string $cmd
* @return array
*/
protected function exec(string $cmd): array
{
$output = array();
exec($cmd, $output);
return $output;
return is_dir(PROJECT_ROOT.'/.git') && file_exists(PROJECT_ROOT.'/.git/HEAD');
}
}

View File

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

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,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\Theme;
namespace Magdev\Dossier\Service;
class SystemService
{
const MODE_OUTPUT = 1;
const MODE_RETURN = 2;
const MODE_LASTLINE = 3;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Magdev\Dossier\Command\Base\BaseCommand;
/**
* Create a local copy of a template
* Execute a system command
*
* @author magdev
* @param string $cmd
* @param int $mode
* @param array $output
* @param int $return
* @return string|int|array
*/
final class ThemeListCommand extends BaseCommand
public function exec(string $cmd, int $mode = self::MODE_OUTPUT, &$output = array(), int &$return = 0)
{
/**
* {@inheritDoc}
* @see \Symfony\Component\Console\Command\Command::configure()
*/
protected function configure()
{
$this->setName('theme:list')
->setDescription('List available themes')
->addOption('all', 'a', InputOption::VALUE_NONE, 'List all themes, icluding the overridden ones');
parent::configure();
}
/**
* {@inheritDoc}
* @see \Symfony\Component\Console\Command\Command::execute()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$all = (bool) $input->getOption('all');
$helper = $this->getHelper('export');
/* @var $helper \Magdev\Dossier\Helper\ExportHelper */
$themes = $this->config->findThemes($all);
$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

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