Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 027a81c170 | |||
| c9ef6f1e72 | |||
| 3b24c5d9f4 | |||
| 49b5bcf9cd | |||
| 87b7835b56 | |||
| 8779cdaafa | |||
| e9d20bee4f | |||
| 665e9eedc3 | |||
| a565438c8f | |||
| efbf7e569a | |||
| 713e413c55 | |||
| 9de8dd6af0 | |||
| 10ecb065a8 | |||
| 69eb48d986 | |||
| 9e7874e81a | |||
| d4f326e7ce |
@@ -11,7 +11,6 @@ Dossier requires PHP 7.2+ and the following extensions enabled:
|
||||
|
||||
* Phar
|
||||
* SPL
|
||||
* Date
|
||||
* fileinfo
|
||||
* mbstring
|
||||
* Bz2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
### Settings file for magdev/dossier
|
||||
charset: utf-8
|
||||
docname: dossier
|
||||
|
||||
# Date formats
|
||||
date:
|
||||
|
||||
@@ -19,6 +19,10 @@ services:
|
||||
class: '\Magdev\Dossier\Service\MinifierService'
|
||||
arguments: ['@monolog']
|
||||
|
||||
git:
|
||||
class: '\Magdev\Dossier\Service\GitService'
|
||||
arguments: ['@config', '@monolog']
|
||||
|
||||
translator:
|
||||
class: '\Magdev\Dossier\Service\TranslatorService'
|
||||
arguments: ['@config', '@monolog']
|
||||
|
||||
@@ -502,19 +502,6 @@ dl.horizontal {
|
||||
font-weight: bold;
|
||||
font-size: (@base-font-size + .5pt);
|
||||
}
|
||||
dl.horizontal {
|
||||
display: none;
|
||||
dt {
|
||||
text-align: left;
|
||||
width: 1cm;
|
||||
}
|
||||
dd {
|
||||
padding-right: 1cm;
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
p, li {
|
||||
line-height: @intro-paragraph-line-height;
|
||||
font-size: @intro-paragraph-size;
|
||||
|
||||
@@ -19,6 +19,14 @@
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro list_projects(projects, tag) %}
|
||||
{% set tag = tag|default('li') %}
|
||||
{% for project in projects %}
|
||||
<{{ tag }}><em>{{ project.name }}:</em>
|
||||
{{ project.shortDescription }}</{{ tag }}>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro list_link_array(entries, tag) %}
|
||||
{% set tag = tag|default('li') %}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{% import "macros.html.twig" as macros %}
|
||||
|
||||
{% if projects|length > 0 %}
|
||||
<section class="projects">
|
||||
<h2>{{ 'projects.header'|trans }}</h2>
|
||||
@@ -6,18 +8,13 @@
|
||||
{% for project in projects %}
|
||||
<article class="project">
|
||||
<h3>{{ project.name }} {% if project.stack %}<small>({{ project.stack }})</small>{% endif %}</h3>
|
||||
<dl class="horizontal">
|
||||
<dt>{{ 'projects.fields.status'|trans }}</dt>
|
||||
<dd>
|
||||
<p class="badge badge-{{ project.status }}">{{ ('projects.status.' ~ project.status)|trans }}</p>
|
||||
</dd>
|
||||
{% if project.role %}
|
||||
<dt>{{ 'projects.fields.role'|trans }}</dt>
|
||||
<dd>{{ project.role }}</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
<p class="short-description">{{ project.shortDescription }}</p>
|
||||
{{ project.content|raw }}
|
||||
{% if project.hasUrls() %}
|
||||
<ul>
|
||||
{{ macros.list_link_array(project.urls) }}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</article>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@@ -115,11 +115,11 @@
|
||||
{{ macros.list_references(person.references) }}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
{% if person.projects|length > 0 %}
|
||||
|
||||
{% if projects|length > 0 %}
|
||||
<h3>{{ 'resume.headers.current_projects'|trans }}</h3>
|
||||
<ul>
|
||||
{{ macros.list_simple_array(person.projects) }}
|
||||
{{ macros.list_projects(projects) }}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
|
||||
1
bin/.gitignore
vendored
1
bin/.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
lessc
|
||||
pscss
|
||||
.directory
|
||||
/phpca
|
||||
|
||||
@@ -32,12 +32,12 @@
|
||||
"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",
|
||||
"monolog/monolog" : "^1.23",
|
||||
"pdfshift/pdfshift-php" : "~1.0.2"
|
||||
"pdfshift/pdfshift-php" : "~1.0.2",
|
||||
"raivisdejus/html-minifier" : "~0.5"
|
||||
},
|
||||
"config" : {
|
||||
"bin-dir" : "bin"
|
||||
@@ -64,5 +64,8 @@
|
||||
"url" : "git@github.com:magdev/console-form.git",
|
||||
"name" : "magdev/console-form"
|
||||
}
|
||||
]
|
||||
],
|
||||
"require-dev" : {
|
||||
"wapmorgan/php-code-analyzer" : "^1.0"
|
||||
}
|
||||
}
|
||||
726
composer.lock
generated
726
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -62,7 +62,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('docname', 'd', InputOption::VALUE_OPTIONAL, 'Set the name for the output document (w/o extension)', 'dossier')
|
||||
->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 +97,12 @@ final class DossierBuildCommand extends BaseCommand
|
||||
$cssproc = $this->getService('cssproc');
|
||||
/* @var $cssroc \Magdev\Dossier\Service\StylesheetProcessorService */
|
||||
|
||||
$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(),
|
||||
|
||||
@@ -198,7 +198,7 @@ class CurriculumVitae extends BaseCollection
|
||||
|
||||
$formatter = $this->formatter;
|
||||
array_walk($result, function(int &$seconds, string $key) use ($formatter) {
|
||||
$seconds = $formatter->formatExperience($seconds);
|
||||
$seconds = $formatter->formatYearMonthDuration($seconds);
|
||||
});
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Magdev\Dossier\Model\CurriculumVitae;
|
||||
|
||||
use Magdev\Dossier\Model\AbstractModel;
|
||||
use Magdev\Dossier\Model\Traits\PhotoTrait;
|
||||
use Magdev\Dossier\Model\Traits\ToggableTrait;
|
||||
use Mni\FrontYAML\Document;
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Analyzer\Base\AnalyzableInterface;
|
||||
@@ -46,6 +47,7 @@ use Magdev\Dossier\Model\Base\PhotoInterface;
|
||||
final class Entry extends BaseModel implements PhotoInterface, AnalyzableInterface
|
||||
{
|
||||
use PhotoTrait;
|
||||
use ToggableTrait;
|
||||
|
||||
/**
|
||||
* Start date
|
||||
|
||||
@@ -69,16 +69,6 @@ class Intro extends BaseModel implements PhotoInterface, AnalyzableInterface
|
||||
protected $showQuotes = self::SHOW_TOP;
|
||||
|
||||
|
||||
/**
|
||||
* Get the headline
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeadline(): string
|
||||
{
|
||||
return $this->headline;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -93,6 +83,17 @@ class Intro extends BaseModel implements PhotoInterface, AnalyzableInterface
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the headline
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHeadline(): string
|
||||
{
|
||||
return $this->headline;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the quotes
|
||||
*
|
||||
|
||||
@@ -132,12 +132,6 @@ final class Person extends BaseModel implements PhotoInterface, AnalyzableInterf
|
||||
*/
|
||||
protected $interests = array();
|
||||
|
||||
/**
|
||||
* Current Projects
|
||||
* @var array
|
||||
*/
|
||||
protected $projects = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -312,17 +306,6 @@ final class Person extends BaseModel implements PhotoInterface, AnalyzableInterf
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get current projects
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getProjects(): array
|
||||
{
|
||||
return $this->projects;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the work license
|
||||
*
|
||||
@@ -388,7 +371,10 @@ final class Person extends BaseModel implements PhotoInterface, AnalyzableInterf
|
||||
foreach ($value as $type => $address) {
|
||||
if ($type == 'accounts' && is_array($address)) {
|
||||
foreach ($address as $a) {
|
||||
$this->contacts->append(new Contact($a['address'], $a['type']));
|
||||
$contact = new Contact($a['address'], $a['type'], $a['active']);
|
||||
if ($contact->isActive()) {
|
||||
$this->contacts->append($contact);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->contacts->append(new Contact($address, $type));
|
||||
@@ -396,7 +382,10 @@ final class Person extends BaseModel implements PhotoInterface, AnalyzableInterf
|
||||
}
|
||||
} else if ($key == 'references') {
|
||||
foreach ($value as $reference) {
|
||||
$this->references->append(new Reference($reference));
|
||||
$ref = new Reference($reference);
|
||||
if ($ref->isActive()) {
|
||||
$this->references->append($ref);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->setProperty($key, $value);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
namespace Magdev\Dossier\Model\Person;
|
||||
|
||||
use Magdev\Dossier\Model\Traits\ToggableTrait;
|
||||
|
||||
/**
|
||||
* Contact model
|
||||
*
|
||||
@@ -37,6 +39,8 @@ namespace Magdev\Dossier\Model\Person;
|
||||
*/
|
||||
class Contact
|
||||
{
|
||||
use ToggableTrait;
|
||||
|
||||
/**
|
||||
* Contact address
|
||||
* @var string
|
||||
@@ -55,11 +59,13 @@ class Contact
|
||||
*
|
||||
* @param string $address
|
||||
* @param string $type
|
||||
* @param bool $active
|
||||
*/
|
||||
public function __construct(string $address, string $type)
|
||||
public function __construct(string $address, string $type, ?bool $active = true)
|
||||
{
|
||||
$this->address = $address;
|
||||
$this->type = $type;
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
namespace Magdev\Dossier\Model\Person;
|
||||
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Model\Traits\ToggableTrait;
|
||||
|
||||
/**
|
||||
* Model for job references
|
||||
@@ -39,6 +40,8 @@ use Magdev\Dossier\Model\Base\BaseModel;
|
||||
*/
|
||||
class Reference extends BaseModel
|
||||
{
|
||||
use ToggableTrait;
|
||||
|
||||
/**
|
||||
* Reference description
|
||||
* @var string
|
||||
|
||||
@@ -30,26 +30,43 @@
|
||||
|
||||
namespace Magdev\Dossier\Model;
|
||||
|
||||
|
||||
use Magdev\Dossier\Model\Base\BaseModel;
|
||||
use Magdev\Dossier\Model\Traits\ToggableTrait;
|
||||
use Mni\FrontYAML\Document;
|
||||
|
||||
/**
|
||||
* Model for projects page
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
class Project extends BaseModel
|
||||
{
|
||||
use ToggableTrait;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getStack(): string
|
||||
{
|
||||
@@ -57,35 +74,26 @@ class Project extends BaseModel
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getStatus(): string
|
||||
|
||||
public function hasUrls(): bool
|
||||
{
|
||||
return $this->status;
|
||||
return sizeof($this->urls) > 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getUrl(): string
|
||||
public function getUrls(): array
|
||||
{
|
||||
return $this->url;
|
||||
return $this->urls;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getShortDescription(): string
|
||||
{
|
||||
return $this->shortDescription;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
91
src/Model/Traits/ToggableTrait.php
Normal file
91
src/Model/Traits/ToggableTrait.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?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\Model\Traits;
|
||||
|
||||
/**
|
||||
* Trait for objects which can be de-/activated
|
||||
*
|
||||
* @author magdev
|
||||
*/
|
||||
trait ToggableTrait
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $active = true;
|
||||
|
||||
|
||||
/**
|
||||
* Activate object
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function activate(): self
|
||||
{
|
||||
$this->active = true;
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deactivate object
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function deactivate(): self
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
115
src/Service/GitService.php
Normal file
115
src/Service/GitService.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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;
|
||||
|
||||
// git branch | grep \* | cut -d ' ' -f2
|
||||
|
||||
class GitService
|
||||
{
|
||||
/**
|
||||
* Configuration service
|
||||
* @var \Magdev\Dossier\Service\ConfigService
|
||||
*/
|
||||
protected $config = null;
|
||||
|
||||
/**
|
||||
* Monolog service
|
||||
* @var \Magdev\Dossier\Service\MonologService
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \Magdev\Dossier\Service\ConfigService $config
|
||||
* @param \Magdev\Dossier\Service\MonologService $logger
|
||||
*/
|
||||
public function __construct(ConfigService $config, MonologService $logger)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a new repository
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function init(): bool
|
||||
{
|
||||
if (!$this->isGitRepository()) {
|
||||
$this->exec('git init');
|
||||
}
|
||||
return $this->isGitRepository();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current branch name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentBranchName(): string
|
||||
{
|
||||
if (!$this->isGitRepository()) {
|
||||
return $this->config->get('docname');
|
||||
}
|
||||
$output = $this->exec('git branch | grep \\\* | cut -d \' \' -f2');
|
||||
return $output[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if repository is initialized
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,10 @@ class MarkdownService
|
||||
foreach ($files as $file) {
|
||||
/* @var $file \SplFileInfo */
|
||||
$document = $this->getDocument($file->getPathname());
|
||||
$cv->append(new CurriculumVitae\Entry($document));
|
||||
$entry = new CurriculumVitae\Entry($document);
|
||||
if ($entry->isActive()) {
|
||||
$cv->append($entry);
|
||||
}
|
||||
}
|
||||
$cv->setSortDirection($sort)->sort();
|
||||
|
||||
@@ -117,7 +120,10 @@ class MarkdownService
|
||||
foreach ($files as $file) {
|
||||
/* @var $file \SplFileInfo */
|
||||
$document = $this->getDocument($file->getPathname());
|
||||
$projects->append(new Project($document));
|
||||
$project = new Project($document);
|
||||
if ($project->isActive()) {
|
||||
$projects->append($project);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -130,7 +130,10 @@ class PharHelperService
|
||||
*/
|
||||
public function copy(string $source, string $target): bool
|
||||
{
|
||||
return copy($this->getPharUrl($source), $target);
|
||||
if ($this->isInPhar() && substr($source, 0, 4) !== 'phar') {
|
||||
$source = $this->getPharUrl($source);
|
||||
}
|
||||
return copy($source, $target);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -120,13 +120,15 @@ class TemplateService
|
||||
{
|
||||
$theme = !$theme ? $this->theme : $theme;
|
||||
|
||||
if (getenv('DOSSIER_THEME_DIR')) {
|
||||
if (is_dir(getenv('DOSSIER_THEME_DIR').'/'.$theme) && file_exists(getenv('DOSSIER_THEME_DIR').'/'.$theme.'/'.$file)) {
|
||||
return getenv('DOSSIER_THEME_DIR').'/'.$theme.'/'.$file;
|
||||
if (getenv('APP_ENV') == 'prod') {
|
||||
if (getenv('DOSSIER_THEME_DIR')) {
|
||||
if (is_dir(getenv('DOSSIER_THEME_DIR').'/'.$theme) && file_exists(getenv('DOSSIER_THEME_DIR').'/'.$theme.'/'.$file)) {
|
||||
return getenv('DOSSIER_THEME_DIR').'/'.$theme.'/'.$file;
|
||||
}
|
||||
}
|
||||
if (is_dir(getenv('HOME').'/.dossier/tpl/'.$theme) && file_exists(getenv('HOME').'/.dossier/tpl/'.$theme.'/'.$file)) {
|
||||
return getenv('HOME').'/.dossier/tpl/'.$theme.'/'.$file;
|
||||
}
|
||||
}
|
||||
if (is_dir(getenv('HOME').'/.dossier/tpl/'.$theme) && file_exists(getenv('HOME').'/.dossier/tpl/'.$theme.'/'.$file)) {
|
||||
return getenv('HOME').'/.dossier/tpl/'.$theme.'/'.$file;
|
||||
}
|
||||
return DOSSIER_ROOT.'/app/tpl/'.$theme.'/'.$file;
|
||||
}
|
||||
@@ -143,16 +145,23 @@ class TemplateService
|
||||
$this->theme = $theme;
|
||||
|
||||
$loaders = array();
|
||||
if (getenv('DOSSIER_THEME_DIR') && is_dir(getenv('DOSSIER_THEME_DIR').'/'.$theme)) {
|
||||
$loaders[] = new \Twig_Loader_Filesystem(getenv('DOSSIER_THEME_DIR').'/'.$theme);
|
||||
}
|
||||
if (is_dir(getenv('HOME').'/.dossier/tpl/'.$theme)) {
|
||||
$loaders[] = new \Twig_Loader_Filesystem(getenv('HOME').'/.dossier/tpl/'.$theme);
|
||||
if (getenv('APP_ENV') == 'prod') {
|
||||
if (getenv('DOSSIER_THEME_DIR') && is_dir(getenv('DOSSIER_THEME_DIR').'/'.$theme)) {
|
||||
$loaders[] = new \Twig_Loader_Filesystem(getenv('DOSSIER_THEME_DIR').'/'.$theme);
|
||||
}
|
||||
if (is_dir(getenv('HOME').'/.dossier/tpl/'.$theme)) {
|
||||
$loaders[] = new \Twig_Loader_Filesystem(getenv('HOME').'/.dossier/tpl/'.$theme);
|
||||
}
|
||||
}
|
||||
$loaders[] = new \Twig_Loader_Filesystem(DOSSIER_ROOT.'/app/tpl/'.$theme);
|
||||
|
||||
$cache = false;
|
||||
if (getenv('APP_ENV') == 'prod') {
|
||||
$cache = new \Twig_Cache_Filesystem(DOSSIER_CACHE, \Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION);
|
||||
}
|
||||
|
||||
$this->twig = new \Twig_Environment(new \Twig_Loader_Chain($loaders), array(
|
||||
'cache' => new \Twig_Cache_Filesystem(DOSSIER_CACHE, \Twig_Cache_Filesystem::FORCE_BYTECODE_INVALIDATION),
|
||||
'cache' => $cache,
|
||||
'debug' => getenv('APP_DEBUG'),
|
||||
));
|
||||
$this->addTwigExtensions($this->translator->getTranslator(), $this->config);
|
||||
@@ -205,9 +214,6 @@ class TemplateService
|
||||
*/
|
||||
public function render(string $template, DataCollectorInterface $data, string $destDir): string
|
||||
{
|
||||
if (!is_dir($destDir)) {
|
||||
mkdir($destDir, 0755, true);
|
||||
}
|
||||
$vars = $data->getData();
|
||||
$name = isset($vars['name']) ? $vars['name'] : $this->docname;
|
||||
$name .= isset($vars['theme']) ? '.'.$vars['theme'] : '';
|
||||
@@ -215,6 +221,10 @@ class TemplateService
|
||||
|
||||
$html = $this->twig->render($template, $vars);
|
||||
$html = $this->minifier->minify($html);
|
||||
|
||||
if (!is_dir(dirname($path))) {
|
||||
mkdir(dirname($path), 0755, true);
|
||||
}
|
||||
if (!file_put_contents($path, $html)) {
|
||||
throw new \RuntimeException('Error writing output file: '.$path);
|
||||
}
|
||||
@@ -290,7 +300,7 @@ class TemplateService
|
||||
}, array('is_safe' => array('html'))));
|
||||
|
||||
$this->twig->addFilter(new \Twig_Filter('debug', function ($var) {
|
||||
return getenv('APP_DEBUG') == true ? '<code>'.print_r($var, true).'</code>' : '';
|
||||
return getenv('APP_DEBUG') == true || getenv('APP_ENV') == 'dev' ? '<code>'.print_r($var, true).'</code>' : '';
|
||||
}, array('is_safe' => array('html'))));
|
||||
|
||||
$this->twig->addFunction(new \Twig_Function('is_today', function (\DateTime $checkDate) {
|
||||
|
||||
Reference in New Issue
Block a user