made start-template and output-dir/-filename configurable

Also added config-sections for theme and output.
This commit is contained in:
2019-06-04 20:44:56 +02:00
parent 027a81c170
commit fc96ef2f9a
3 changed files with 14 additions and 3 deletions

View File

@@ -1,6 +1,14 @@
### Settings file for magdev/dossier ### Settings file for magdev/dossier
charset: utf-8 charset: utf-8
docname: dossier
# Output settings
output:
path: _output
docname: dossier
# Theme settings
theme:
start_template: document.html.twig
# Date formats # Date formats
date: date:

View File

@@ -40,6 +40,7 @@ use Magdev\Dossier\Model\Intro;
use Magdev\Dossier\Model\Letter; use Magdev\Dossier\Model\Letter;
use Magdev\Dossier\Command\Base\BaseCommand; use Magdev\Dossier\Command\Base\BaseCommand;
use Magdev\Dossier\Util\DataCollector; use Magdev\Dossier\Util\DataCollector;
use Symfony\Component\Console\Command\Command;
/** /**
* Generate your dossier * Generate your dossier
@@ -62,6 +63,7 @@ final class DossierBuildCommand extends BaseCommand
->addOption('locale', 'l', InputOption::VALUE_OPTIONAL, 'Set the locale', 'de') ->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('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('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('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-cover', null, InputOption::VALUE_NONE, 'Suppress the cover')
@@ -97,6 +99,7 @@ final class DossierBuildCommand extends BaseCommand
$cssproc = $this->getService('cssproc'); $cssproc = $this->getService('cssproc');
/* @var $cssroc \Magdev\Dossier\Service\StylesheetProcessorService */ /* @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(); $name = $input->getOption('docname') ?: $this->getService('git')->getCurrentBranchName();
try { try {
$data = new DataCollector(array( $data = new DataCollector(array(
@@ -113,7 +116,7 @@ final class DossierBuildCommand extends BaseCommand
$models = $this->getService('markdown')->getFileSet($input->getOption('sort')); $models = $this->getService('markdown')->getFileSet($input->getOption('sort'));
$data->merge($models); $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')) { if ($input->getOption('pdf')) {
$outputFile = $this->getService('pdf')->createPdf($outputFile); $outputFile = $this->getService('pdf')->createPdf($outputFile);
} }

View File

@@ -82,7 +82,7 @@ class GitService
public function getCurrentBranchName(): string public function getCurrentBranchName(): string
{ {
if (!$this->isGitRepository()) { if (!$this->isGitRepository()) {
return $this->config->get('docname'); return $this->config->get('output.docname');
} }
$output = $this->exec('git branch | grep \\\* | cut -d \' \' -f2'); $output = $this->exec('git branch | grep \\\* | cut -d \' \' -f2');
return $output[0]; return $output[0];