From 526dd973489aa7a373623da3ab8430ca1aa92f9d Mon Sep 17 00:00:00 2001 From: magdev Date: Tue, 4 Jun 2019 20:47:26 +0200 Subject: [PATCH] made start-template and output-dir/-filename configurable --- app/conf/dossier.yaml | 10 +++++++++- src/Command/Dossier/DossierBuildCommand.php | 5 ++++- src/Service/GitService.php | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/conf/dossier.yaml b/app/conf/dossier.yaml index f01bf21..0e7d051 100644 --- a/app/conf/dossier.yaml +++ b/app/conf/dossier.yaml @@ -1,6 +1,14 @@ ### Settings file for magdev/dossier charset: utf-8 -docname: dossier + +# Output settings +output: + path: _output + docname: dossier + +# Theme settings +theme: + start_template: document.html.twig # Date formats date: diff --git a/src/Command/Dossier/DossierBuildCommand.php b/src/Command/Dossier/DossierBuildCommand.php index d860be8..817afe3 100644 --- a/src/Command/Dossier/DossierBuildCommand.php +++ b/src/Command/Dossier/DossierBuildCommand.php @@ -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); } diff --git a/src/Service/GitService.php b/src/Service/GitService.php index ba86392..d16c856 100644 --- a/src/Service/GitService.php +++ b/src/Service/GitService.php @@ -82,7 +82,7 @@ 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];