Applied fixes from StyleCI
This commit is contained in:
committed by
Stéphane Goetz
parent
cfc8d30ba2
commit
2314516ce9
@ -2,5 +2,4 @@
|
||||
|
||||
class ComputedRawPage extends \Todaymade\Daux\Format\Base\ComputedRawPage
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
}
|
||||
|
||||
if ($this->params['multilanguage']) {
|
||||
return ($this->file->getParent()->getParent() instanceof Root);
|
||||
return $this->file->getParent()->getParent() instanceof Root;
|
||||
}
|
||||
|
||||
return ($this->file->getParent() instanceof Root);
|
||||
return $this->file->getParent() instanceof Root;
|
||||
}
|
||||
|
||||
private function initialize()
|
||||
@ -45,13 +45,14 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
if ($multilanguage && !empty($parents)) {
|
||||
$parents = array_splice($parents, 1);
|
||||
}
|
||||
$breadcrumb_trail = array();
|
||||
$breadcrumb_trail = [];
|
||||
if (!empty($parents)) {
|
||||
foreach ($parents as $node) {
|
||||
$page = $node->getIndexPage() ?: $node->getFirstPage();
|
||||
$breadcrumb_trail[$node->getTitle()] = $page ? $page->getUrl() : '';
|
||||
}
|
||||
}
|
||||
|
||||
return $breadcrumb_trail;
|
||||
}
|
||||
|
||||
@ -95,6 +96,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
$context = ['page' => $page, 'params' => $params];
|
||||
|
||||
$template = new Template($params['templates'], $params['theme']['templates']);
|
||||
|
||||
return $template->render($this->homepage ? 'theme::home' : 'theme::content', $context);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,6 @@ class Entry
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return $this->getLevel() . " - " . $this->getId();
|
||||
return $this->getLevel() . ' - ' . $this->getId();
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,6 @@ class Processor implements DocumentProcessorInterface
|
||||
} else {
|
||||
$document->prependChild($this->render($generated->getChildren()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +183,8 @@ class Processor implements DocumentProcessorInterface
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function setNull($object, $property) {
|
||||
protected function setNull($object, $property)
|
||||
{
|
||||
$prop = new \ReflectionProperty(get_class($object), $property);
|
||||
$prop->setAccessible(true);
|
||||
$prop->setValue($object, null);
|
||||
@ -212,6 +212,7 @@ class Processor implements DocumentProcessorInterface
|
||||
}
|
||||
|
||||
$deepCopy = new DeepCopy();
|
||||
|
||||
return $deepCopy->copy($firstClone)->children();
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,6 @@ class RootEntry extends Entry
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
throw new \RuntimeException("No Parent Exception");
|
||||
throw new \RuntimeException('No Parent Exception');
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
public function getContentTypes()
|
||||
{
|
||||
return [
|
||||
'markdown' => new ContentType($this->daux->getParams())
|
||||
'markdown' => new ContentType($this->daux->getParams()),
|
||||
];
|
||||
}
|
||||
|
||||
@ -51,15 +51,15 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
}
|
||||
|
||||
$this->runAction(
|
||||
"Copying Static assets ...",
|
||||
'Copying Static assets ...',
|
||||
$output,
|
||||
$width,
|
||||
function() use ($destination) {
|
||||
function () use ($destination) {
|
||||
GeneratorHelper::copyAssets($destination, $this->daux->local_base);
|
||||
}
|
||||
);
|
||||
|
||||
$output->writeLn("Generating ...");
|
||||
$output->writeLn('Generating ...');
|
||||
|
||||
if (!array_key_exists('search', $params['html']) || !$params['html']['search']) {
|
||||
$params['html']['search'] = $input->getOption('search');
|
||||
@ -77,7 +77,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
json_encode(['pages' => $this->indexed_pages])
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +89,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
private function strip_html_tags($text)
|
||||
{
|
||||
$text = preg_replace(
|
||||
array(
|
||||
[
|
||||
// Remove invisible content
|
||||
'@<head[^>]*?>.*?</head>@siu',
|
||||
'@<style[^>]*?>.*?</style>@siu',
|
||||
@ -109,14 +108,15 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
'@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
|
||||
'@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
|
||||
'@</?((frameset)|(frame)|(iframe))@iu',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
||||
"\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",
|
||||
"\n\$0", "\n\$0",
|
||||
),
|
||||
],
|
||||
$text
|
||||
);
|
||||
|
||||
return trim(preg_replace('/\s+/', ' ', strip_tags($text)));
|
||||
}
|
||||
|
||||
@ -127,8 +127,8 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
* @param string $output_dir
|
||||
* @param \Todaymade\Daux\Config $params
|
||||
* @param OutputInterface $output
|
||||
* @param integer $width
|
||||
* @param boolean $index_pages
|
||||
* @param int $width
|
||||
* @param bool $index_pages
|
||||
* @param string $base_url
|
||||
* @throws \Exception
|
||||
*/
|
||||
@ -150,23 +150,24 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
DauxHelper::rebaseConfiguration($params, $base_url);
|
||||
} else {
|
||||
$this->runAction(
|
||||
"- " . $node->getUrl(),
|
||||
'- ' . $node->getUrl(),
|
||||
$output,
|
||||
$width,
|
||||
function() use ($node, $output_dir, $key, $params, $index_pages) {
|
||||
function () use ($node, $output_dir, $key, $params, $index_pages) {
|
||||
if ($node instanceof Raw) {
|
||||
copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$generated = $this->generateOne($node, $params);
|
||||
file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent());
|
||||
if ($index_pages) {
|
||||
$this->indexed_pages[] =[
|
||||
$this->indexed_pages[] = [
|
||||
'title' => $node->getTitle(),
|
||||
'text' => utf8_encode($this->strip_html_tags($generated->getPureContent())),
|
||||
'tags' => "",
|
||||
'url' => $node->getUrl()
|
||||
'tags' => '',
|
||||
'url' => $node->getUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -191,6 +192,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
}
|
||||
|
||||
$params['request'] = $node->getUrl();
|
||||
|
||||
return ContentPage::fromFile($node, $params, $this->daux->getContentTypeHandler()->getType($node));
|
||||
}
|
||||
}
|
||||
|
@ -2,5 +2,4 @@
|
||||
|
||||
class RawPage extends \Todaymade\Daux\Format\Base\RawPage
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class Template
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function render($name, array $data = array())
|
||||
public function render($name, array $data = [])
|
||||
{
|
||||
$this->engine->addData([
|
||||
'base_url' => $data['params']['base_url'],
|
||||
@ -50,12 +50,13 @@ class Template
|
||||
|
||||
protected function registerFunctions()
|
||||
{
|
||||
$this->engine->registerFunction('get_navigation', function($tree, $path, $current_url, $base_page, $mode) {
|
||||
$this->engine->registerFunction('get_navigation', function ($tree, $path, $current_url, $base_page, $mode) {
|
||||
$nav = $this->buildNavigation($tree, $path, $current_url, $base_page, $mode);
|
||||
|
||||
return $this->renderNavigation($nav);
|
||||
});
|
||||
|
||||
$this->engine->registerFunction('get_breadcrumb_title', function($page, $base_page) {
|
||||
$this->engine->registerFunction('get_breadcrumb_title', function ($page, $base_page) {
|
||||
$title = '';
|
||||
$breadcrumb_trail = $page['breadcrumb_trail'];
|
||||
$separator = $this->getSeparator($page['breadcrumb_separator']);
|
||||
@ -69,16 +70,16 @@ class Template
|
||||
} else {
|
||||
$title .= '<a href="' . $base_page . $page['request'] . '">' . $page['title'] . '</a>';
|
||||
}
|
||||
|
||||
return $title;
|
||||
});
|
||||
}
|
||||
|
||||
private function renderNavigation($entries)
|
||||
{
|
||||
$nav = "";
|
||||
$nav = '';
|
||||
foreach ($entries as $entry) {
|
||||
if (array_key_exists('children', $entry)) {
|
||||
|
||||
$icon = '<i class="Nav__arrow"> </i>';
|
||||
|
||||
if (array_key_exists('href', $entry)) {
|
||||
@ -128,7 +129,7 @@ class Template
|
||||
];
|
||||
|
||||
if ($mode === Daux::STATIC_MODE) {
|
||||
$link .= "/index.html";
|
||||
$link .= '/index.html';
|
||||
}
|
||||
|
||||
if ($node->getIndexPage()) {
|
||||
@ -146,6 +147,7 @@ class Template
|
||||
$nav[] = $folder;
|
||||
}
|
||||
}
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user