From 2314516ce9396bd0eb3b0535c393d4c9d4fa999c Mon Sep 17 00:00:00 2001 From: onigoetz Date: Wed, 27 Jul 2016 15:32:51 -0400 Subject: [PATCH] Applied fixes from StyleCI --- daux/Processor.php | 4 +- index.php | 6 +- libs/Compiler.php | 2 +- libs/Console/RunAction.php | 6 +- libs/ContentTypes/ContentTypeHandler.php | 2 +- .../Markdown/CommonMarkConverter.php | 5 +- libs/ContentTypes/Markdown/ContentType.php | 1 + libs/ContentTypes/Markdown/LinkRenderer.php | 6 +- .../ContentTypes/Markdown/TableOfContents.php | 1 - .../Markdown/TableOfContentsParser.php | 1 - libs/Daux.php | 8 +- libs/DauxHelper.php | 226 +++++++++--------- libs/Format/Base/EmbedImages.php | 5 +- libs/Format/Base/Generator.php | 2 +- libs/Format/Base/RawPage.php | 4 +- libs/Format/Confluence/Api.php | 47 ++-- libs/Format/Confluence/ContentPage.php | 2 +- .../Markdown/FencedCodeRenderer.php | 3 +- .../ContentTypes/Markdown/LinkRenderer.php | 10 +- .../Confluence/DuplicateTitleException.php | 1 - libs/Format/Confluence/Generator.php | 10 +- libs/Format/Confluence/Publisher.php | 59 +++-- libs/Format/HTML/ComputedRawPage.php | 1 - libs/Format/HTML/ContentPage.php | 8 +- .../HTML/ContentTypes/Markdown/TOC/Entry.php | 2 +- .../ContentTypes/Markdown/TOC/Processor.php | 5 +- .../ContentTypes/Markdown/TOC/RootEntry.php | 2 +- libs/Format/HTML/Generator.php | 34 +-- libs/Format/HTML/RawPage.php | 1 - libs/Format/HTML/Template.php | 14 +- libs/Format/HTMLFile/Book.php | 20 +- libs/Format/HTMLFile/ContentPage.php | 3 +- libs/Format/HTMLFile/Generator.php | 8 +- libs/Processor.php | 4 +- libs/Server/ErrorPage.php | 1 + libs/Server/MimeType.php | 6 +- libs/Server/Server.php | 15 +- libs/Tree/Builder.php | 14 +- libs/Tree/Content.php | 16 +- libs/Tree/Directory.php | 27 ++- libs/Tree/Entry.php | 3 +- templates/content.php | 28 ++- templates/home.php | 42 ++-- templates/layout/00_layout.php | 24 +- templates/layout/05_page.php | 52 ++-- templates/partials/navbar_content.php | 6 +- .../Markdown/LinkRendererTest.php | 18 +- tests/DauxHelperTest.php | 20 +- tests/Format/Confluence/ApiTest.php | 16 +- tests/Tree/BuilderTest.php | 47 ++-- tests/Tree/ContentTest.php | 19 +- tests/Tree/DirectoryTest.php | 34 ++- 52 files changed, 477 insertions(+), 424 deletions(-) diff --git a/daux/Processor.php b/daux/Processor.php index 1175951..fd0f7af 100644 --- a/daux/Processor.php +++ b/daux/Processor.php @@ -2,8 +2,8 @@ use Todaymade\Daux\Tree\Root; -class Processor extends \Todaymade\Daux\Processor { - +class Processor extends \Todaymade\Daux\Processor +{ public function manipulateTree(Root $root) { print_r($root->dump()); diff --git a/index.php b/index.php index cbdbef6..5a84eae 100644 --- a/index.php +++ b/index.php @@ -76,12 +76,12 @@ if (php_sapi_name() === 'cli-server') { } if (file_exists('vendor/autoload.php')) { - require_once('vendor/autoload.php'); + require_once 'vendor/autoload.php'; } elseif (file_exists('daux.phar')) { define('PHAR_DIR', __DIR__); - require_once("phar://" . __DIR__ . "/daux.phar/vendor/autoload.php"); + require_once 'phar://' . __DIR__ . '/daux.phar/vendor/autoload.php'; } else { - throw new Exception("Impossible to load Daux, missing vendor/ or daux.phar"); + throw new Exception('Impossible to load Daux, missing vendor/ or daux.phar'); } \Todaymade\Daux\Server\Server::serve($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $_REQUEST); diff --git a/libs/Compiler.php b/libs/Compiler.php index f00e1d1..e76bc7b 100644 --- a/libs/Compiler.php +++ b/libs/Compiler.php @@ -141,7 +141,7 @@ class Compiler foreach (token_get_all($source) as $token) { if (is_string($token)) { $output .= $token; - } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { + } elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) { $output .= str_repeat("\n", substr_count($token[1], "\n")); } elseif (T_WHITESPACE === $token[0]) { // reduce wide spaces diff --git a/libs/Console/RunAction.php b/libs/Console/RunAction.php index e137829..531e09e 100644 --- a/libs/Console/RunAction.php +++ b/libs/Console/RunAction.php @@ -8,17 +8,17 @@ trait RunAction { $output->write($title); - $length = function_exists("mb_strlen")? mb_strlen($title) : strlen($title); + $length = function_exists('mb_strlen') ? mb_strlen($title) : strlen($title); // 8 is the length of the label + 2 let it breathe $padding = $width - $length - 10; try { $response = $closure(); } catch (\Exception $e) { - $output->writeln(str_pad(" ", $padding) . "[ FAIL ]"); + $output->writeln(str_pad(' ', $padding) . '[ FAIL ]'); throw $e; } - $output->writeln(str_pad(" ", $padding) . "[ OK ]"); + $output->writeln(str_pad(' ', $padding) . '[ OK ]'); return $response; } diff --git a/libs/ContentTypes/ContentTypeHandler.php b/libs/ContentTypes/ContentTypeHandler.php index 639d740..3234afc 100644 --- a/libs/ContentTypes/ContentTypeHandler.php +++ b/libs/ContentTypes/ContentTypeHandler.php @@ -5,7 +5,7 @@ use Todaymade\Daux\Tree\Content; class ContentTypeHandler { /** - * @var ContentType[] $types + * @var ContentType[] */ protected $types; diff --git a/libs/ContentTypes/Markdown/CommonMarkConverter.php b/libs/ContentTypes/Markdown/CommonMarkConverter.php index 7cd7b54..4c1a479 100644 --- a/libs/ContentTypes/Markdown/CommonMarkConverter.php +++ b/libs/ContentTypes/Markdown/CommonMarkConverter.php @@ -4,9 +4,6 @@ use League\CommonMark\DocParser; use League\CommonMark\Environment; use League\CommonMark\HtmlRenderer; use Todaymade\Daux\Config; -use Todaymade\Daux\ContentTypes\Markdown\TOC\Parser; -use Todaymade\Daux\ContentTypes\Markdown\TOC\Renderer; -use Todaymade\Daux\ContentTypes\Markdown\TOC\TOCProcessor; use Webuni\CommonMark\TableExtension\TableExtension; class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter @@ -16,7 +13,7 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter * * @param array $config */ - public function __construct(array $config = array()) + public function __construct(array $config = []) { $environment = Environment::createCommonMarkEnvironment(); $environment->mergeConfig($config); diff --git a/libs/ContentTypes/Markdown/ContentType.php b/libs/ContentTypes/Markdown/ContentType.php index 7f6c536..f13ce88 100644 --- a/libs/ContentTypes/Markdown/ContentType.php +++ b/libs/ContentTypes/Markdown/ContentType.php @@ -28,6 +28,7 @@ class ContentType implements \Todaymade\Daux\ContentTypes\ContentType public function convert($raw, Content $node) { $this->config->setCurrentPage($node); + return $this->converter->convertToHtml($raw); } } diff --git a/libs/ContentTypes/Markdown/LinkRenderer.php b/libs/ContentTypes/Markdown/LinkRenderer.php index 435f7fd..bdd3b34 100644 --- a/libs/ContentTypes/Markdown/LinkRenderer.php +++ b/libs/ContentTypes/Markdown/LinkRenderer.php @@ -34,7 +34,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer // "!" In this case we will try to find // the file starting at the root if ($url[0] == '!' || $url[0] == '/') { - $url = ltrim($url, "!/"); + $url = ltrim($url, '!/'); if ($file = DauxHelper::getFile($this->daux['tree'], $url)) { return $file; @@ -71,7 +71,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer // have the same interface if (!$inline instanceof Link) { throw new \RuntimeException( - "Wrong type passed to " . __CLASS__ . "::" . __METHOD__ . + 'Wrong type passed to ' . __CLASS__ . '::' . __METHOD__ . " the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" . get_class($inline) . "' was provided" ); @@ -83,7 +83,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer // Absolute urls, empty urls and anchors // should not go through the url resolver - if (empty($url) || $url[0] == "#" || preg_match("|^(?:[a-z]+:)?//|", $url)) { + if (empty($url) || $url[0] == '#' || preg_match('|^(?:[a-z]+:)?//|', $url)) { return $element; } diff --git a/libs/ContentTypes/Markdown/TableOfContents.php b/libs/ContentTypes/Markdown/TableOfContents.php index c8dd5b3..81384e4 100644 --- a/libs/ContentTypes/Markdown/TableOfContents.php +++ b/libs/ContentTypes/Markdown/TableOfContents.php @@ -5,7 +5,6 @@ use League\CommonMark\Cursor; class TableOfContents extends AbstractBlock { - /** * Returns true if this block can contain the given block as a child node * diff --git a/libs/ContentTypes/Markdown/TableOfContentsParser.php b/libs/ContentTypes/Markdown/TableOfContentsParser.php index 3481e39..f2a842e 100644 --- a/libs/ContentTypes/Markdown/TableOfContentsParser.php +++ b/libs/ContentTypes/Markdown/TableOfContentsParser.php @@ -6,7 +6,6 @@ use League\CommonMark\Cursor; class TableOfContentsParser extends AbstractBlockParser { - /** * @param ContextInterface $context * @param Cursor $cursor diff --git a/libs/Daux.php b/libs/Daux.php index 11a0c19..f4b3d9a 100644 --- a/libs/Daux.php +++ b/libs/Daux.php @@ -131,7 +131,7 @@ class Daux // Set the default configuration $this->options->merge([ 'docs_directory' => 'docs', - 'valid_content_extensions' => ['md', 'markdown'] + 'valid_content_extensions' => ['md', 'markdown'], ]); // Load the global configuration @@ -228,7 +228,7 @@ class Daux 'local_base' => $this->local_base, 'docs_path' => $this->docs_path, 'themes_path' => $this->themes_path, - 'templates' => 'templates' + 'templates' => 'templates', ]; $this->options->conservativeMerge($default); @@ -301,12 +301,12 @@ class Daux return null; } - $class = "\\Todaymade\\Daux\\Extension\\" . $processor; + $class = '\\Todaymade\\Daux\\Extension\\' . $processor; if (!class_exists($class)) { throw new \RuntimeException("Class '$class' not found. We cannot use it as a Processor"); } - if (!array_key_exists("Todaymade\\Daux\\Processor", class_parents($class))) { + if (!array_key_exists('Todaymade\\Daux\\Processor', class_parents($class))) { throw new \RuntimeException("Class '$class' invalid, should extend '\\Todaymade\\Daux\\Processor'"); } diff --git a/libs/DauxHelper.php b/libs/DauxHelper.php index be3aa0e..303b19e 100644 --- a/libs/DauxHelper.php +++ b/libs/DauxHelper.php @@ -60,11 +60,11 @@ class DauxHelper $theme_folder = $params['themes_path'] . DIRECTORY_SEPARATOR . $params['html']['theme']; $theme_url = $params['base_url'] . $params['themes_directory'] . '/' . $params['html']['theme'] . '/'; - $theme = array(); - if (is_file($theme_folder . DIRECTORY_SEPARATOR . "config.json")) { - $theme = json_decode(file_get_contents($theme_folder . DIRECTORY_SEPARATOR . "config.json"), true); + $theme = []; + if (is_file($theme_folder . DIRECTORY_SEPARATOR . 'config.json')) { + $theme = json_decode(file_get_contents($theme_folder . DIRECTORY_SEPARATOR . 'config.json'), true); if (!$theme) { - $theme = array(); + $theme = []; } } @@ -103,7 +103,7 @@ class DauxHelper $substitutions = [ '' => $params['local_base'], '' => $current_url, - '' => $theme_url + '' => $theme_url, ]; // Substitute some placeholders @@ -125,9 +125,9 @@ class DauxHelper */ public static function getCleanPath($path) { - $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); + $path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); - $absolutes = array(); + $absolutes = []; foreach ($parts as $part) { if ('.' == $part) { continue; @@ -138,14 +138,15 @@ class DauxHelper $absolutes[] = $part; } } + return implode(DIRECTORY_SEPARATOR, $absolutes); } public static function getFilenames(Config $config, $part) { - $extensions = implode("|", array_map("preg_quote", $config["valid_content_extensions"])) . "|html"; + $extensions = implode('|', array_map('preg_quote', $config['valid_content_extensions'])) . '|html'; - $raw = preg_replace("/(.*)?\\.(" . $extensions . ")$/", "$1", $part); + $raw = preg_replace('/(.*)?\\.(' . $extensions . ')$/', '$1', $part); $raw = Builder::removeSortingInformations($raw); return ["$raw.html", $raw]; @@ -238,7 +239,7 @@ class DauxHelper $separator = '_'; // Convert all dashes into underscores - $title = preg_replace('![' . preg_quote("-") . ']+!u', $separator, $title); + $title = preg_replace('![' . preg_quote('-') . ']+!u', $separator, $title); // Remove all characters that are not the separator, letters, numbers, or whitespace. $title = preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', $title); @@ -264,129 +265,129 @@ class DauxHelper return $charsArray; } - return $charsArray = array( - 'a' => array( + return $charsArray = [ + 'a' => [ 'à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ä', 'ā', 'ą', 'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', - 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ'), - 'b' => array('б', 'β', 'Ъ', 'Ь', 'ب'), - 'c' => array('ç', 'ć', 'č', 'ĉ', 'ċ'), - 'd' => array('ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', - 'д', 'δ', 'د', 'ض'), - 'e' => array('é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', + 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', ], + 'b' => ['б', 'β', 'Ъ', 'Ь', 'ب'], + 'c' => ['ç', 'ć', 'č', 'ĉ', 'ċ'], + 'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', + 'д', 'δ', 'د', 'ض', ], + 'e' => ['é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', 'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', - 'є', 'ə'), - 'f' => array('ф', 'φ', 'ف'), - 'g' => array('ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ج'), - 'h' => array('ĥ', 'ħ', 'η', 'ή', 'ح', 'ه'), - 'i' => array('í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', + 'є', 'ə', ], + 'f' => ['ф', 'φ', 'ف'], + 'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ج'], + 'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه'], + 'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', - 'ῗ', 'і', 'ї', 'и'), - 'j' => array('ĵ', 'ј', 'Ј'), - 'k' => array('ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك'), - 'l' => array('ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل'), - 'm' => array('м', 'μ', 'م'), - 'n' => array('ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن'), - 'o' => array('ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', + 'ῗ', 'і', 'ї', 'и', ], + 'j' => ['ĵ', 'ј', 'Ј'], + 'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك'], + 'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل'], + 'm' => ['м', 'μ', 'م'], + 'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن'], + 'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', - 'ö', 'о', 'و', 'θ'), - 'p' => array('п', 'π'), - 'r' => array('ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر'), - 's' => array('ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص'), - 't' => array('ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط'), - 'u' => array('ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', - 'ự', 'ü', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у'), - 'v' => array('в'), - 'w' => array('ŵ', 'ω', 'ώ'), - 'x' => array('χ'), - 'y' => array('ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', - 'ϋ', 'ύ', 'ΰ', 'ي'), - 'z' => array('ź', 'ž', 'ż', 'з', 'ζ', 'ز'), - 'aa' => array('ع'), - 'ae' => array('æ'), - 'ch' => array('ч'), - 'dj' => array('ђ', 'đ'), - 'dz' => array('џ'), - 'gh' => array('غ'), - 'kh' => array('х', 'خ'), - 'lj' => array('љ'), - 'nj' => array('њ'), - 'oe' => array('œ'), - 'ps' => array('ψ'), - 'sh' => array('ш'), - 'shch' => array('щ'), - 'ss' => array('ß'), - 'th' => array('þ', 'ث', 'ذ', 'ظ'), - 'ts' => array('ц'), - 'ya' => array('я'), - 'yu' => array('ю'), - 'zh' => array('ж'), - '(c)' => array('©'), - 'A' => array('Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ', + 'ö', 'о', 'و', 'θ', ], + 'p' => ['п', 'π'], + 'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر'], + 's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص'], + 't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط'], + 'u' => ['ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', + 'ự', 'ü', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', ], + 'v' => ['в'], + 'w' => ['ŵ', 'ω', 'ώ'], + 'x' => ['χ'], + 'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', + 'ϋ', 'ύ', 'ΰ', 'ي', ], + 'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز'], + 'aa' => ['ع'], + 'ae' => ['æ'], + 'ch' => ['ч'], + 'dj' => ['ђ', 'đ'], + 'dz' => ['џ'], + 'gh' => ['غ'], + 'kh' => ['х', 'خ'], + 'lj' => ['љ'], + 'nj' => ['њ'], + 'oe' => ['œ'], + 'ps' => ['ψ'], + 'sh' => ['ш'], + 'shch' => ['щ'], + 'ss' => ['ß'], + 'th' => ['þ', 'ث', 'ذ', 'ظ'], + 'ts' => ['ц'], + 'ya' => ['я'], + 'yu' => ['ю'], + 'zh' => ['ж'], + '(c)' => ['©'], + 'A' => ['Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ', 'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Ä', 'Å', 'Ā', 'Ą', 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', - 'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А'), - 'B' => array('Б', 'Β'), - 'C' => array('Ç', 'Ć', 'Č', 'Ĉ', 'Ċ'), - 'D' => array('Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ'), - 'E' => array('É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ', + 'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А', ], + 'B' => ['Б', 'Β'], + 'C' => ['Ç', 'Ć', 'Č', 'Ĉ', 'Ċ'], + 'D' => ['Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ'], + 'E' => ['É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ', 'Ệ', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ', 'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э', - 'Є', 'Ə'), - 'F' => array('Ф', 'Φ'), - 'G' => array('Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ'), - 'H' => array('Η', 'Ή'), - 'I' => array('Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į', + 'Є', 'Ə', ], + 'F' => ['Ф', 'Φ'], + 'G' => ['Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ'], + 'H' => ['Η', 'Ή'], + 'I' => ['Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į', 'İ', 'Ι', 'Ί', 'Ϊ', 'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', - 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї'), - 'K' => array('К', 'Κ'), - 'L' => array('Ĺ', 'Ł', 'Л', 'Λ', 'Ļ'), - 'M' => array('М', 'Μ'), - 'N' => array('Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν'), - 'O' => array('Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', + 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї', ], + 'K' => ['К', 'Κ'], + 'L' => ['Ĺ', 'Ł', 'Л', 'Λ', 'Ļ'], + 'M' => ['М', 'Μ'], + 'N' => ['Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν'], + 'O' => ['Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ö', 'Ø', 'Ō', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', - 'Ὸ', 'Ό', 'О', 'Θ', 'Ө'), - 'P' => array('П', 'Π'), - 'R' => array('Ř', 'Ŕ', 'Р', 'Ρ'), - 'S' => array('Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ'), - 'T' => array('Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ'), - 'U' => array('Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ', - 'Ự', 'Û', 'Ü', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У'), - 'V' => array('В'), - 'W' => array('Ω', 'Ώ'), - 'X' => array('Χ'), - 'Y' => array('Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', - 'Ы', 'Й', 'Υ', 'Ϋ'), - 'Z' => array('Ź', 'Ž', 'Ż', 'З', 'Ζ'), - 'AE' => array('Æ'), - 'CH' => array('Ч'), - 'DJ' => array('Ђ'), - 'DZ' => array('Џ'), - 'KH' => array('Х'), - 'LJ' => array('Љ'), - 'NJ' => array('Њ'), - 'PS' => array('Ψ'), - 'SH' => array('Ш'), - 'SHCH' => array('Щ'), - 'SS' => array('ẞ'), - 'TH' => array('Þ'), - 'TS' => array('Ц'), - 'YA' => array('Я'), - 'YU' => array('Ю'), - 'ZH' => array('Ж'), - ' ' => array("\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81", + 'Ὸ', 'Ό', 'О', 'Θ', 'Ө', ], + 'P' => ['П', 'Π'], + 'R' => ['Ř', 'Ŕ', 'Р', 'Ρ'], + 'S' => ['Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ'], + 'T' => ['Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ'], + 'U' => ['Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ', + 'Ự', 'Û', 'Ü', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У', ], + 'V' => ['В'], + 'W' => ['Ω', 'Ώ'], + 'X' => ['Χ'], + 'Y' => ['Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', + 'Ы', 'Й', 'Υ', 'Ϋ', ], + 'Z' => ['Ź', 'Ž', 'Ż', 'З', 'Ζ'], + 'AE' => ['Æ'], + 'CH' => ['Ч'], + 'DJ' => ['Ђ'], + 'DZ' => ['Џ'], + 'KH' => ['Х'], + 'LJ' => ['Љ'], + 'NJ' => ['Њ'], + 'PS' => ['Ψ'], + 'SH' => ['Ш'], + 'SHCH' => ['Щ'], + 'SS' => ['ẞ'], + 'TH' => ['Þ'], + 'TS' => ['Ц'], + 'YA' => ['Я'], + 'YU' => ['Ю'], + 'ZH' => ['Ж'], + ' ' => ["\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81", "\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84", "\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87", "\xE2\x80\x88", "\xE2\x80\x89", "\xE2\x80\x8A", - "\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80"), - ); + "\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80", ], + ]; } public static function getRelativePath($from, $to) @@ -419,6 +420,7 @@ class DauxHelper } } } + return implode('/', $relPath); } } diff --git a/libs/Format/Base/EmbedImages.php b/libs/Format/Base/EmbedImages.php index ab5c083..8cc440d 100644 --- a/libs/Format/Base/EmbedImages.php +++ b/libs/Format/Base/EmbedImages.php @@ -5,7 +5,6 @@ * Date: 06/11/15 * Time: 20:27 */ - namespace Todaymade\Daux\Format\Base; use DOMDocument; @@ -15,7 +14,6 @@ use Todaymade\Daux\Tree\Root; class EmbedImages { - protected $tree; public function __construct(Root $tree) @@ -28,7 +26,6 @@ class EmbedImages return preg_replace_callback( "/]*src=['\"]([^\"]*)['\"][^>]*>/", function ($matches) use ($file, $callback) { - if ($result = $this->findImage($matches[1], $matches[0], $file, $callback)) { return $result; } @@ -60,7 +57,7 @@ class EmbedImages private function findImage($src, $tag, Content $file, $callback) { //for protocol relative or http requests : keep the original one - if (substr($src, 0, strlen("http")) === "http" || substr($src, 0, strlen("//")) === "//") { + if (substr($src, 0, strlen('http')) === 'http' || substr($src, 0, strlen('//')) === '//') { return $src; } diff --git a/libs/Format/Base/Generator.php b/libs/Format/Base/Generator.php index 28383e9..e499309 100644 --- a/libs/Format/Base/Generator.php +++ b/libs/Format/Base/Generator.php @@ -14,7 +14,7 @@ interface Generator /** * @param InputInterface $input * @param OutputInterface $output - * @param integer $width + * @param int $width * @return mixed */ public function generateAll(InputInterface $input, OutputInterface $output, $width); diff --git a/libs/Format/Base/RawPage.php b/libs/Format/Base/RawPage.php index bb0009e..f6300a3 100644 --- a/libs/Format/Base/RawPage.php +++ b/libs/Format/Base/RawPage.php @@ -18,11 +18,11 @@ abstract class RawPage implements Page public function getPureContent() { - throw new Exception("you should not use this method to show a raw content"); + throw new Exception('you should not use this method to show a raw content'); } public function getContent() { - throw new Exception("you should not use this method to show a raw content"); + throw new Exception('you should not use this method to show a raw content'); } } diff --git a/libs/Format/Confluence/Api.php b/libs/Format/Confluence/Api.php index 7281a5a..70574bf 100644 --- a/libs/Format/Confluence/Api.php +++ b/libs/Format/Confluence/Api.php @@ -31,7 +31,7 @@ class Api { $options = [ 'base_uri' => $this->base_url . 'rest/api/', - 'auth' => [$this->user, $this->pass] + 'auth' => [$this->user, $this->pass], ]; return new Client($options); @@ -68,7 +68,7 @@ class Api $json = json_decode($body, true); $message .= ($json != null && array_key_exists('message', $json)) ? $json['message'] : $body; - if ($level == '4' && strpos($message, "page with this title already exists") !== false) { + if ($level == '4' && strpos($message, 'page with this title already exists') !== false) { return new DuplicateTitleException($message, 0, $e->getPrevious()); } @@ -77,7 +77,7 @@ class Api public function getPage($id) { - $url = "content/$id?expand=ancestors,version,body.storage"; + $url = "content/$id?expand=ancestors,version,body.storage"; try { $result = json_decode($this->getClient()->get($url)->getBody(), true); @@ -92,18 +92,18 @@ class Api } return [ - "id" => $result['id'], - "ancestor_id" => $ancestor_id, - "title" => $result['title'], - "version" => $result['version']['number'], - "content" => $result['body']['storage']['value'], + 'id' => $result['id'], + 'ancestor_id' => $ancestor_id, + 'title' => $result['title'], + 'version' => $result['version']['number'], + 'content' => $result['body']['storage']['value'], ]; } /** * Get a list of pages * - * @param integer $rootPage + * @param int $rootPage * @param bool $recursive * @return array */ @@ -128,10 +128,10 @@ class Api foreach ($hierarchy['results'] as $result) { $pages[$result['title']] = [ - "id" => $result['id'], - "title" => $result['title'], - "version" => $result['version']['number'], - "content" => $result['body']['storage']['value'], + 'id' => $result['id'], + 'title' => $result['title'], + 'version' => $result['version']['number'], + 'content' => $result['body']['storage']['value'], ]; if ($recursive) { @@ -144,17 +144,16 @@ class Api // to be a bug in Confluence $start += $increment; $url = "$base_url&start=$start"; - } while (!empty($hierarchy['results'])); return $pages; } /** - * @param integer $parent_id + * @param int $parent_id * @param string $title * @param string $content - * @return integer + * @return int */ public function createPage($parent_id, $title, $content) { @@ -162,7 +161,7 @@ class Api 'type' => 'page', 'space' => ['key' => $this->space], 'title' => $title, - 'body' => ['storage' => ['value' => $content, 'representation' => 'storage']] + 'body' => ['storage' => ['value' => $content, 'representation' => 'storage']], ]; if ($parent_id) { @@ -179,9 +178,9 @@ class Api } /** - * @param integer $parent_id - * @param integer $page_id - * @param integer $newVersion + * @param int $parent_id + * @param int $page_id + * @param int $newVersion * @param string $title * @param string $content */ @@ -190,9 +189,9 @@ class Api $body = [ 'type' => 'page', 'space' => ['key' => $this->space], - 'version' => ['number' => $newVersion, "minorEdit" => true], + 'version' => ['number' => $newVersion, 'minorEdit' => true], 'title' => $title, - 'body' => ['storage' => ['value' => $content, 'representation' => 'storage']] + 'body' => ['storage' => ['value' => $content, 'representation' => 'storage']], ]; if ($parent_id) { @@ -209,7 +208,7 @@ class Api /** * Delete a page * - * @param integer $page_id + * @param int $page_id * @return mixed */ public function deletePage($page_id) @@ -222,7 +221,7 @@ class Api } /** - * @param integer $id + * @param int $id * @param array $attachment */ public function uploadAttachment($id, $attachment) diff --git a/libs/Format/Confluence/ContentPage.php b/libs/Format/Confluence/ContentPage.php index ed620f6..be492e3 100644 --- a/libs/Format/Confluence/ContentPage.php +++ b/libs/Format/Confluence/ContentPage.php @@ -38,7 +38,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage private function createImageTag($filename, $attributes) { - $img = " $value) { $img .= ' ac:' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"'; diff --git a/libs/Format/Confluence/ContentTypes/Markdown/FencedCodeRenderer.php b/libs/Format/Confluence/ContentTypes/Markdown/FencedCodeRenderer.php index c7d07c2..4dfcdea 100644 --- a/libs/Format/Confluence/ContentTypes/Markdown/FencedCodeRenderer.php +++ b/libs/Format/Confluence/ContentTypes/Markdown/FencedCodeRenderer.php @@ -8,7 +8,6 @@ use League\CommonMark\HtmlElement; class FencedCodeRenderer implements BlockRendererInterface { - protected $supported_languages = [ 'actionscript3', 'bash', @@ -32,7 +31,7 @@ class FencedCodeRenderer implements BlockRendererInterface 'ruby', 'scala', 'sql', - 'vb' + 'vb', ]; protected $known_conversions = ['html' => 'html/xml', 'xml' => 'html/xml', 'js' => 'javascript']; diff --git a/libs/Format/Confluence/ContentTypes/Markdown/LinkRenderer.php b/libs/Format/Confluence/ContentTypes/Markdown/LinkRenderer.php index 2d9e707..e8896ef 100644 --- a/libs/Format/Confluence/ContentTypes/Markdown/LinkRenderer.php +++ b/libs/Format/Confluence/ContentTypes/Markdown/LinkRenderer.php @@ -20,7 +20,7 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer // have the same interface if (!$inline instanceof Link) { throw new \RuntimeException( - "Wrong type passed to " . __CLASS__ . "::" . __METHOD__ . + 'Wrong type passed to ' . __CLASS__ . '::' . __METHOD__ . " the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" . get_class($inline) . "' was provided" ); @@ -34,16 +34,16 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer } //Internal links - $file = $this->resolveInternalFile(ltrim($url, "!")); + $file = $this->resolveInternalFile(ltrim($url, '!')); $link_props = [ - 'ri:content-title' => trim($this->daux['confluence']['prefix']) . " " . $file->getTitle(), - 'ri:space-key' => $this->daux['confluence']['space_id'] + 'ri:content-title' => trim($this->daux['confluence']['prefix']) . ' ' . $file->getTitle(), + 'ri:space-key' => $this->daux['confluence']['space_id'], ]; $page = strval(new HtmlElement('ri:page', $link_props, '', true)); $children = $htmlRenderer->renderInlines($inline->children()); - if (strpos($children, "<") !== false) { + if (strpos($children, '<') !== false) { $children = '' . $children . ''; } else { $children = ''; diff --git a/libs/Format/Confluence/DuplicateTitleException.php b/libs/Format/Confluence/DuplicateTitleException.php index 79cc7ee..3b4f6b7 100644 --- a/libs/Format/Confluence/DuplicateTitleException.php +++ b/libs/Format/Confluence/DuplicateTitleException.php @@ -2,5 +2,4 @@ class DuplicateTitleException extends \RuntimeException { - } diff --git a/libs/Format/Confluence/Generator.php b/libs/Format/Confluence/Generator.php index ddfb155..8e216a3 100644 --- a/libs/Format/Confluence/Generator.php +++ b/libs/Format/Confluence/Generator.php @@ -32,7 +32,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator public function getContentTypes() { return [ - new ContentTypes\Markdown\ContentType($this->daux->getParams()) + new ContentTypes\Markdown\ContentType($this->daux->getParams()), ]; } @@ -44,13 +44,13 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator $params = $this->daux->getParams(); $confluence = $params['confluence']; - $this->prefix = trim($confluence['prefix']) . " "; + $this->prefix = trim($confluence['prefix']) . ' '; $tree = $this->runAction( - "Generating Tree ...", + 'Generating Tree ...', $output, $width, - function() use ($params) { + function () use ($params) { $tree = $this->generateRecursive($this->daux->tree, $params); $tree['title'] = $this->prefix . $params['title']; @@ -58,7 +58,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator } ); - $output->writeln("Start Publishing..."); + $output->writeln('Start Publishing...'); $publisher = new Publisher($confluence); $publisher->output = $output; diff --git a/libs/Format/Confluence/Publisher.php b/libs/Format/Confluence/Publisher.php index d05d1bd..09b0087 100644 --- a/libs/Format/Confluence/Publisher.php +++ b/libs/Format/Confluence/Publisher.php @@ -23,7 +23,7 @@ class Publisher protected $previous_title; /** - * @var integer terminal width + * @var int terminal width */ public $width; @@ -48,13 +48,12 @@ class Publisher try { return $this->runAction($title, $this->output, $this->width, $closure); } catch (BadResponseException $e) { - $this->output->writeLn(" " . $e->getMessage() . ""); + $this->output->writeLn(' ' . $e->getMessage() . ''); } } public function publish(array $tree) { - echo "Finding Root Page...\n"; if (array_key_exists('ancestor_id', $this->confluence)) { $pages = $this->client->getList($this->confluence['ancestor_id']); @@ -69,14 +68,14 @@ class Publisher $published = $this->client->getPage($this->confluence['root_id']); $this->confluence['ancestor_id'] = $published['ancestor_id']; } else { - throw new \RuntimeException("You must at least specify a `root_id` or `ancestor_id` in your confluence configuration."); + throw new \RuntimeException('You must at least specify a `root_id` or `ancestor_id` in your confluence configuration.'); } $this->run( - "Getting already published pages...", - function() use (&$published) { + 'Getting already published pages...', + function () use (&$published) { if ($published != null) { $published['children'] = $this->client->getList($published['id'], true); } @@ -85,19 +84,19 @@ class Publisher $published = $this->run( "Create placeholder pages...\n", - function() use ($tree, $published) { + function () use ($tree, $published) { return $this->createRecursive($this->confluence['ancestor_id'], $tree, $published); } ); - $this->output->writeLn("Publishing updates..."); + $this->output->writeLn('Publishing updates...'); $published = $this->updateRecursive($this->confluence['ancestor_id'], $tree, $published); if ($this->shouldDelete()) { - $this->output->writeLn("Deleting obsolete pages..."); + $this->output->writeLn('Deleting obsolete pages...'); } else { - $this->output->writeLn("Listing obsolete pages..."); + $this->output->writeLn('Listing obsolete pages...'); echo "> The following pages will not be deleted, but just listed for information.\n"; echo "> If you want to delete these pages, you need to set the --delete flag on the command.\n"; } @@ -106,29 +105,29 @@ class Publisher protected function niceTitle($title) { - if ($title == "index.html") { - return "Homepage"; + if ($title == 'index.html') { + return 'Homepage'; } - return rtrim(strtr($title, ['index.html' => '', '.html' => '']), "/"); + return rtrim(strtr($title, ['index.html' => '', '.html' => '']), '/'); } protected function createPage($parent_id, $entry, $published) { - echo "- " . $this->niceTitle($entry['file']->getUrl()) . "\n"; + echo '- ' . $this->niceTitle($entry['file']->getUrl()) . "\n"; $published['version'] = 1; $published['title'] = $entry['title']; - $published['id'] = $this->client->createPage($parent_id, $entry['title'], "The content will come very soon !"); + $published['id'] = $this->client->createPage($parent_id, $entry['title'], 'The content will come very soon !'); return $published; } protected function createPlaceholderPage($parent_id, $entry, $published) { - echo "- " . $entry['title'] . "\n"; + echo '- ' . $entry['title'] . "\n"; $published['version'] = 1; $published['title'] = $entry['title']; - $published['id'] = $this->client->createPage($parent_id, $entry['title'], ""); + $published['id'] = $this->client->createPage($parent_id, $entry['title'], ''); return $published; } @@ -160,7 +159,7 @@ class Publisher protected function createRecursive($parent_id, $entry, $published) { - $callback = function($parent_id, $entry, $published) { + $callback = function ($parent_id, $entry, $published) { // nothing to do if the ID already exists if (array_key_exists('id', $published)) { return $published; @@ -181,7 +180,7 @@ class Publisher protected function updateRecursive($parent_id, $entry, $published) { - $callback = function($parent_id, $entry, $published) { + $callback = function ($parent_id, $entry, $published) { if (array_key_exists('id', $published) && array_key_exists('page', $entry)) { $this->updatePage($parent_id, $entry, $published); } @@ -200,23 +199,21 @@ class Publisher protected function deleteRecursive($published, $prefix = '') { - foreach($published['children'] as $child) { + foreach ($published['children'] as $child) { if (array_key_exists('children', $child) && count($child['children'])) { $this->deleteRecursive($child, $child['title'] . '/'); } if (!array_key_exists('needed', $child)) { - if ($this->shouldDelete()) { $this->run( - "- " . $prefix . $child['title'], - function() use ($child) { + '- ' . $prefix . $child['title'], + function () use ($child) { $this->client->deletePage($child['id']); } ); - } else { - echo "- " . $prefix . $child['title'] . "\n"; + echo '- ' . $prefix . $child['title'] . "\n"; } } } @@ -252,7 +249,7 @@ class Publisher } //DEBUG - if (getenv("DEBUG") && strtolower(getenv("DEBUG")) != "false") { + if (getenv('DEBUG') && strtolower(getenv('DEBUG')) != 'false') { $prefix = 'static/export/'; if (!is_dir($prefix)) { mkdir($prefix, 0777, true); @@ -267,14 +264,14 @@ class Publisher protected function updatePage($parent_id, $entry, $published) { - if ($this->previous_title != "Updating") { - $this->previous_title = "Updating"; + if ($this->previous_title != 'Updating') { + $this->previous_title = 'Updating'; echo "Updating Pages...\n"; } $this->run( - "- " . $this->niceTitle($entry['file']->getUrl()), - function() use ($entry, $published, $parent_id) { + '- ' . $this->niceTitle($entry['file']->getUrl()), + function () use ($entry, $published, $parent_id) { if ($this->shouldUpdate($entry['page'], $published)) { $this->client->updatePage( $parent_id, @@ -291,7 +288,7 @@ class Publisher foreach ($entry['page']->attachments as $attachment) { $this->run( " With attachment: $attachment[filename]", - function() use ($published, $attachment) { + function () use ($published, $attachment) { $this->client->uploadAttachment($published['id'], $attachment); } ); diff --git a/libs/Format/HTML/ComputedRawPage.php b/libs/Format/HTML/ComputedRawPage.php index 72ddfc4..c6e8690 100644 --- a/libs/Format/HTML/ComputedRawPage.php +++ b/libs/Format/HTML/ComputedRawPage.php @@ -2,5 +2,4 @@ class ComputedRawPage extends \Todaymade\Daux\Format\Base\ComputedRawPage { - } diff --git a/libs/Format/HTML/ContentPage.php b/libs/Format/HTML/ContentPage.php index 596c66c..bf9e5c1 100644 --- a/libs/Format/HTML/ContentPage.php +++ b/libs/Format/HTML/ContentPage.php @@ -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); } } diff --git a/libs/Format/HTML/ContentTypes/Markdown/TOC/Entry.php b/libs/Format/HTML/ContentTypes/Markdown/TOC/Entry.php index 561ee29..ca2bbf4 100644 --- a/libs/Format/HTML/ContentTypes/Markdown/TOC/Entry.php +++ b/libs/Format/HTML/ContentTypes/Markdown/TOC/Entry.php @@ -78,6 +78,6 @@ class Entry public function toString() { - return $this->getLevel() . " - " . $this->getId(); + return $this->getLevel() . ' - ' . $this->getId(); } } diff --git a/libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php b/libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php index bfe6a75..70d8f82 100644 --- a/libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php +++ b/libs/Format/HTML/ContentTypes/Markdown/TOC/Processor.php @@ -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(); } } diff --git a/libs/Format/HTML/ContentTypes/Markdown/TOC/RootEntry.php b/libs/Format/HTML/ContentTypes/Markdown/TOC/RootEntry.php index c942ca2..2b942b5 100644 --- a/libs/Format/HTML/ContentTypes/Markdown/TOC/RootEntry.php +++ b/libs/Format/HTML/ContentTypes/Markdown/TOC/RootEntry.php @@ -13,6 +13,6 @@ class RootEntry extends Entry */ public function getParent() { - throw new \RuntimeException("No Parent Exception"); + throw new \RuntimeException('No Parent Exception'); } } diff --git a/libs/Format/HTML/Generator.php b/libs/Format/HTML/Generator.php index e68ba6a..49d23cc 100755 --- a/libs/Format/HTML/Generator.php +++ b/libs/Format/HTML/Generator.php @@ -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 '@]*?>.*?@siu', '@]*?>.*?@siu', @@ -109,14 +108,15 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator '@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)); } } diff --git a/libs/Format/HTML/RawPage.php b/libs/Format/HTML/RawPage.php index fcff274..9cf5f59 100644 --- a/libs/Format/HTML/RawPage.php +++ b/libs/Format/HTML/RawPage.php @@ -2,5 +2,4 @@ class RawPage extends \Todaymade\Daux\Format\Base\RawPage { - } diff --git a/libs/Format/HTML/Template.php b/libs/Format/HTML/Template.php index 55bdbdd..eb1de68 100644 --- a/libs/Format/HTML/Template.php +++ b/libs/Format/HTML/Template.php @@ -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 .= '' . $page['title'] . ''; } + return $title; }); } private function renderNavigation($entries) { - $nav = ""; + $nav = ''; foreach ($entries as $entry) { if (array_key_exists('children', $entry)) { - $icon = ' '; 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; } diff --git a/libs/Format/HTMLFile/Book.php b/libs/Format/HTMLFile/Book.php index 4a05d8a..96842a7 100644 --- a/libs/Format/HTMLFile/Book.php +++ b/libs/Format/HTMLFile/Book.php @@ -30,7 +30,7 @@ class Book } } - throw new RuntimeException("Could not find the content page"); + throw new RuntimeException('Could not find the content page'); } protected function buildNavigation(Directory $tree) @@ -51,21 +51,22 @@ class Book continue; } - $page_index = ($index = $node->getIndexPage())? $index : $node->getFirstPage(); + $page_index = ($index = $node->getIndexPage()) ? $index : $node->getFirstPage(); $nav[] = [ 'title' => $node->getTitle(), - 'href' => "#section_" . $this->getSectionId($page_index), - 'children' => $this->buildNavigation($node) + 'href' => '#section_' . $this->getSectionId($page_index), + 'children' => $this->buildNavigation($node), ]; } } + return $nav; } private function renderNavigation($entries) { - $nav = ""; + $nav = ''; foreach ($entries as $entry) { if (array_key_exists('children', $entry)) { if (array_key_exists('href', $entry)) { @@ -87,9 +88,9 @@ class Book protected function generateTOC() { - return "

Table of Contents

" . + return '

Table of Contents

' . $this->renderNavigation($this->buildNavigation($this->tree)) . - "
 
"; + '
 
'; } protected function generateCover() @@ -97,7 +98,7 @@ class Book return "
" . "

{$this->cover['title']}

" . "

{$this->cover['subject']} by {$this->cover['author']}

" . - "
 
"; + '
 
'; } protected function generatePages() @@ -109,6 +110,7 @@ class Book $content .= '
' . $page['content'] . '
'; $content .= '
 
'; } + return $content; } @@ -137,6 +139,6 @@ class Book public function generate() { - return "" . $this->generateHead() . $this->generateBody() . ""; + return '' . $this->generateHead() . $this->generateBody() . ''; } } diff --git a/libs/Format/HTMLFile/ContentPage.php b/libs/Format/HTMLFile/ContentPage.php index 289e460..0587204 100644 --- a/libs/Format/HTMLFile/ContentPage.php +++ b/libs/Format/HTMLFile/ContentPage.php @@ -18,11 +18,10 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage $content, $this->file, function ($src, array $attributes, Raw $file) { - $content = base64_encode(file_get_contents($file->getPath())); $attr = ''; foreach ($attributes as $name => $value) { - $attr .= ' ' .$name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"'; + $attr .= ' ' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"'; } return ""; diff --git a/libs/Format/HTMLFile/Generator.php b/libs/Format/HTMLFile/Generator.php index 6250e2f..35f4a26 100644 --- a/libs/Format/HTMLFile/Generator.php +++ b/libs/Format/HTMLFile/Generator.php @@ -27,7 +27,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator public function getContentTypes() { return [ - 'markdown' => new ContentType($this->daux->getParams()) + 'markdown' => new ContentType($this->daux->getParams()), ]; } @@ -46,8 +46,8 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator $pdf->SetHeaderData('', 0, $params['title'], $params['tagline']); // set header and footer fonts - $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); - $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); + $pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]); + $pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); @@ -84,7 +84,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator $current = $this->daux->tree->getIndexPage(); while ($current) { $this->runAction( - "Generating " . $current->getTitle(), + 'Generating ' . $current->getTitle(), $output, $width, function () use ($book, $current, $params) { diff --git a/libs/Processor.php b/libs/Processor.php index 11fe5ab..4bb43f8 100644 --- a/libs/Processor.php +++ b/libs/Processor.php @@ -17,14 +17,14 @@ class Processor protected $output; /** - * @var integer + * @var int */ protected $width; /** * @param Daux $daux * @param OutputInterface $output - * @param integer $width + * @param int $width */ public function __construct(Daux $daux, OutputInterface $output, $width) { diff --git a/libs/Server/ErrorPage.php b/libs/Server/ErrorPage.php index 1d034a3..2c03cb8 100644 --- a/libs/Server/ErrorPage.php +++ b/libs/Server/ErrorPage.php @@ -38,6 +38,7 @@ class ErrorPage extends SimplePage ]; $template = new Template($params['templates'], $params['theme']['templates']); + return $template->render('error', ['page' => $page, 'params' => $params]); } } diff --git a/libs/Server/MimeType.php b/libs/Server/MimeType.php index 3e02512..be71729 100644 --- a/libs/Server/MimeType.php +++ b/libs/Server/MimeType.php @@ -2,7 +2,6 @@ /** * Class MimeType - * @package Defr * @author Dennis Fridrich * @see http://www.php.net/mime_content_type */ @@ -11,7 +10,7 @@ class MimeType /** * @var array */ - protected static $mimeTypes = array( + protected static $mimeTypes = [ 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', @@ -58,7 +57,7 @@ class MimeType // Open Office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', - ); + ]; /** * @param $filename * @return string @@ -73,6 +72,7 @@ class MimeType $finfo = finfo_open(FILEINFO_MIME); $mimetype = finfo_file($finfo, $filename); finfo_close($finfo); + return $mimetype; } else { return 'application/octet-stream'; diff --git a/libs/Server/Server.php b/libs/Server/Server.php index 1d305b8..5ae3b93 100755 --- a/libs/Server/Server.php +++ b/libs/Server/Server.php @@ -44,7 +44,7 @@ class Server $page = $server->handle($_REQUEST); } catch (NotFoundException $e) { http_response_code(404); - $page = new ErrorPage("An error occured", $e->getMessage(), $daux->getParams()); + $page = new ErrorPage('An error occured', $e->getMessage(), $daux->getParams()); } if ($page instanceof RawPage) { @@ -53,7 +53,7 @@ class Server // Transfer file in 1024 byte chunks to save memory usage. if ($fd = fopen($page->getFile(), 'rb')) { while (!feof($fd)) { - print fread($fd, 1024); + echo fread($fd, 1024); } fclose($fd); } @@ -73,7 +73,7 @@ class Server // The path has a special treatment on windows, revert the slashes $dir = dirname($_SERVER['PHP_SELF']); - $this->base_url = $_SERVER['HTTP_HOST'] . (DIRECTORY_SEPARATOR == "\\"? str_replace("\\", "/", $dir) : $dir); + $this->base_url = $_SERVER['HTTP_HOST'] . (DIRECTORY_SEPARATOR == '\\' ? str_replace('\\', '/', $dir) : $dir); $t = strrpos($this->base_url, '/index.php'); if ($t != false) { @@ -171,16 +171,17 @@ class Server parse_str($_SERVER['QUERY_STRING'], $_GET); } else { $_SERVER['QUERY_STRING'] = ''; - $_GET = array(); + $_GET = []; } $uri = parse_url($uri, PHP_URL_PATH); } else { return false; } - $uri = str_replace(array('//', '../'), '/', trim($uri, '/')); - if ($uri == "") { - $uri = "index_page"; + $uri = str_replace(['//', '../'], '/', trim($uri, '/')); + if ($uri == '') { + $uri = 'index_page'; } + return $uri; } } diff --git a/libs/Tree/Builder.php b/libs/Tree/Builder.php index e357cf2..e8f5633 100644 --- a/libs/Tree/Builder.php +++ b/libs/Tree/Builder.php @@ -46,7 +46,7 @@ class Builder preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $m); if (!isset($m[3])) { - throw new RuntimeException("Name not found"); + throw new RuntimeException('Name not found'); } return $m[3]; @@ -137,17 +137,17 @@ class Builder */ public static function removeSortingInformations($filename) { - preg_match("/^-?[0-9]*_?(.*)/", $filename, $matches); + preg_match('/^-?[0-9]*_?(.*)/', $filename, $matches); // Remove the numeric part // of the filename, only if // there is something after - return empty($matches[1])? $matches[0] : $matches[1]; + return empty($matches[1]) ? $matches[0] : $matches[1]; } /** * @param Directory $parent - * @param String $title + * @param string $title * @return Directory */ public static function getOrCreateDir(Directory $parent, $title) @@ -185,7 +185,7 @@ class Builder $title = static::getName($path); $uri = DauxHelper::slug($title); if ($parent->getConfig()['mode'] === Daux::STATIC_MODE) { - $uri .= ".html"; + $uri .= '.html'; } } @@ -193,8 +193,8 @@ class Builder return $parent->getEntries()[$uri]; } - $page = $raw? new ComputedRaw($parent, $uri) : new Content($parent, $uri); - $page->setContent("-"); //set an almost empty content to avoid problems + $page = $raw ? new ComputedRaw($parent, $uri) : new Content($parent, $uri); + $page->setContent('-'); //set an almost empty content to avoid problems $page->setName($path); $page->setTitle($title); diff --git a/libs/Tree/Content.php b/libs/Tree/Content.php index 6121141..c81a85c 100644 --- a/libs/Tree/Content.php +++ b/libs/Tree/Content.php @@ -111,11 +111,17 @@ class Content extends Entry $lines = preg_split('/\n/', $sections[0]); foreach ($lines as $line) { $trimmed = trim($line); - if ($trimmed == '') continue; // skip empty lines - if ($trimmed[0] == '#') continue; // can be taken as comments - - $re = "/^([-\\w]*)\\s*?:(.*)/"; - if (!preg_match($re, $trimmed, $parts)) break; //Break as soon as we have a line that doesn't match + if ($trimmed == '') { + continue; + } // skip empty lines + if ($trimmed[0] == '#') { + continue; + } // can be taken as comments + + $re = '/^([-\\w]*)\\s*?:(.*)/'; + if (!preg_match($re, $trimmed, $parts)) { + break; + } //Break as soon as we have a line that doesn't match $key = strtolower(trim($parts[1])); $value = trim($parts[2]); diff --git a/libs/Tree/Directory.php b/libs/Tree/Directory.php index 20631b9..88b987d 100644 --- a/libs/Tree/Directory.php +++ b/libs/Tree/Directory.php @@ -31,9 +31,9 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate continue; } - if ($name[0] == "-") { + if ($name[0] == '-') { if (is_numeric($name[1])) { - $exploded = explode("_", $name); + $exploded = explode('_', $name); $buckets['down_numeric'][abs(substr($exploded[0], 1))][$key] = $entry; continue; } @@ -43,7 +43,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate } if (is_numeric($name[0])) { - $exploded = explode("_", $name); + $exploded = explode('_', $name); $buckets['numeric'][abs($exploded[0])][$key] = $entry; continue; } @@ -68,7 +68,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate private function sortBucket($bucket, $final) { - uasort($bucket, function(Entry $a, Entry $b) { + uasort($bucket, function (Entry $a, Entry $b) { return strcasecmp($a->getName(), $b->getName()); }); @@ -103,7 +103,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate public function getConfig() { if (!$this->parent) { - throw new \RuntimeException("Could not retrieve configuration. Are you sure that your tree has a Root ?"); + throw new \RuntimeException('Could not retrieve configuration. Are you sure that your tree has a Root ?'); } return $this->parent->getConfig(); @@ -139,7 +139,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate */ public function seekFirstPage() { - if ($this instanceof Directory) { + if ($this instanceof self) { $index_key = $this->getConfig()['index_key']; if (isset($this->children[$index_key])) { return $this->children[$index_key]; @@ -148,13 +148,14 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate if ($node instanceof Content) { return $node; } - if ($node instanceof Directory + if ($node instanceof self && strpos($node->getUri(), '.') !== 0 - && $childNode = $node->seekFirstPage() ) { + && $childNode = $node->seekFirstPage()) { return $childNode; } } } + return null; } @@ -176,14 +177,16 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate } $this->setFirstPage($node); + return $node; } } // If we can't find one we check in the sub-directories foreach ($this->getEntries() as $node) { - if ($node instanceof Directory && $page = $node->getFirstPage()) { + if ($node instanceof self && $page = $node->getFirstPage()) { $this->setFirstPage($page); + return $page; } } @@ -210,7 +213,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate foreach ($this->getEntries() as $node) { if ($node instanceof Content) { return true; - } elseif ($node instanceof Directory) { + } elseif ($node instanceof self) { if ($node->hasContent()) { return true; } @@ -237,7 +240,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate /** * Whether a offset exists * @param mixed $offset An offset to check for. - * @return boolean true on success or false on failure. + * @return bool true on success or false on failure. */ public function offsetExists($offset) { @@ -263,7 +266,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate public function offsetSet($offset, $value) { if (!$value instanceof Entry) { - throw new RuntimeException("The value is not of type Entry"); + throw new RuntimeException('The value is not of type Entry'); } $this->addChild($value); diff --git a/libs/Tree/Entry.php b/libs/Tree/Entry.php index 07dffc0..e948e70 100644 --- a/libs/Tree/Entry.php +++ b/libs/Tree/Entry.php @@ -159,6 +159,7 @@ abstract class Entry } $url .= $this->getUri(); + return $url; } @@ -170,7 +171,7 @@ abstract class Entry 'name' => $this->getName(), 'uri' => $this->getUri(), 'url' => $this->getUrl(), - 'path' => $this->path + 'path' => $this->path, ]; } } diff --git a/templates/content.php b/templates/content.php index c1ca09c..c149d86 100644 --- a/templates/content.php +++ b/templates/content.php @@ -1,26 +1,36 @@ layout('theme::layout/05_page') ?>
- + - + - +
- + - +
diff --git a/templates/home.php b/templates/home.php index 5793808..2560787 100755 --- a/templates/home.php +++ b/templates/home.php @@ -5,21 +5,23 @@ - + Fork me on GitHub - +
' . $params['tagline'] . ''; - } ?> + echo '

' . $params['tagline'] . '

'; +} ?>
'; - } ?> + echo '' . $params['title'] . ''; +} ?>
@@ -40,9 +42,11 @@
- + - +
@@ -54,23 +58,29 @@
- + - + - + - +
diff --git a/templates/layout/00_layout.php b/templates/layout/00_layout.php index 868dd05..0f35c5b 100755 --- a/templates/layout/00_layout.php +++ b/templates/layout/00_layout.php @@ -4,7 +4,9 @@ - <?= $page['title']; ?> <?php if ($page['title'] != $params['title']) { echo "- " . $params['title']; } ?> + <?= $page['title']; ?> <?php if ($page['title'] != $params['title']) { + echo '- ' . $params['title']; +} ?> @@ -15,18 +17,20 @@ "; - } ?> + echo ""; +} ?> "; - } ?> + echo ""; +} ?> - + - + @@ -73,7 +78,8 @@ }); }); - + diff --git a/templates/layout/05_page.php b/templates/layout/05_page.php index 42778bd..e307618 100755 --- a/templates/layout/05_page.php +++ b/templates/layout/05_page.php @@ -1,8 +1,10 @@ layout('theme::layout/00_layout') ?> - + Fork me on GitHub - + @@ -76,9 +92,11 @@
- + - +
section('content'); ?> diff --git a/templates/partials/navbar_content.php b/templates/partials/navbar_content.php index 775c6ca..8d4e9e0 100755 --- a/templates/partials/navbar_content.php +++ b/templates/partials/navbar_content.php @@ -1,8 +1,10 @@ - + - + diff --git a/tests/ContentTypes/Markdown/LinkRendererTest.php b/tests/ContentTypes/Markdown/LinkRendererTest.php index 40667b5..bf0cbf0 100644 --- a/tests/ContentTypes/Markdown/LinkRendererTest.php +++ b/tests/ContentTypes/Markdown/LinkRendererTest.php @@ -36,17 +36,17 @@ class LinkRendererTest extends \PHPUnit_Framework_TestCase { return [ // /Widgets/Page - ['Link', "[Link](http://google.ch)", "Widgets/Page.html"], - ['Link', "[Link](#features)", "Widgets/Page.html"], - ['Link', "[Link](Button.md)", "Widgets/Page.html"], - ['Link', "[Link](./Button.md)", "Widgets/Page.html"], - ['Link', "[Link](Button)", "Widgets/Page.html"], - ['Link', "[Link](./Button)", "Widgets/Page.html"], - ['Link', "[Link](!Widgets/Button)", "Widgets/Page.html"], + ['Link', '[Link](http://google.ch)', 'Widgets/Page.html'], + ['Link', '[Link](#features)', 'Widgets/Page.html'], + ['Link', '[Link](Button.md)', 'Widgets/Page.html'], + ['Link', '[Link](./Button.md)', 'Widgets/Page.html'], + ['Link', '[Link](Button)', 'Widgets/Page.html'], + ['Link', '[Link](./Button)', 'Widgets/Page.html'], + ['Link', '[Link](!Widgets/Button)', 'Widgets/Page.html'], // /Content/Page - ['Link', "[Link](../Widgets/Button.md)", "Content/Page.html"], - ['Link', "[Link](!Widgets/Button)", "Content/Page.html"], + ['Link', '[Link](../Widgets/Button.md)', 'Content/Page.html'], + ['Link', '[Link](!Widgets/Button)', 'Content/Page.html'], ]; } diff --git a/tests/DauxHelperTest.php b/tests/DauxHelperTest.php index b642ef1..191f3b1 100644 --- a/tests/DauxHelperTest.php +++ b/tests/DauxHelperTest.php @@ -1,25 +1,25 @@ assertEquals($expected, DauxHelper::getFilenames($config, $node)); } - } diff --git a/tests/Format/Confluence/ApiTest.php b/tests/Format/Confluence/ApiTest.php index 694066b..0df637b 100644 --- a/tests/Format/Confluence/ApiTest.php +++ b/tests/Format/Confluence/ApiTest.php @@ -1,12 +1,12 @@ assertEquals("test.com", $api->getClient()->getConfig()['base_uri']->getHost()); - } -} \ No newline at end of file + // this test supports upgrade Guzzle to version 6 + public function testClientOptions() + { + $api = new Api('http://test.com/', 'user', 'pass'); + $this->assertEquals('test.com', $api->getClient()->getConfig()['base_uri']->getHost()); + } +} diff --git a/tests/Tree/BuilderTest.php b/tests/Tree/BuilderTest.php index c2599a2..5c29bf5 100644 --- a/tests/Tree/BuilderTest.php +++ b/tests/Tree/BuilderTest.php @@ -1,6 +1,5 @@ assertEquals($expected, Builder::removeSortingInformations($value)); } - public function testGetOrCreateDirNew() { + public function testGetOrCreateDirNew() + { $root = new Root(new Config(), ''); @@ -47,10 +47,10 @@ class BuilderTest extends \PHPUnit_Framework_TestCase $this->assertSame($root, $dir->getParent()); $this->assertEquals('directory', $dir->getTitle()); $this->assertEquals('directory', $dir->getUri()); - } - public function testGetOrCreateDirExisting() { + public function testGetOrCreateDirExisting() + { $root = new Root(new Config(), ''); $directory = new Directory($root, 'directory'); $directory->setTitle('directory'); @@ -63,7 +63,8 @@ class BuilderTest extends \PHPUnit_Framework_TestCase $this->assertSame($directory, $dir); } - public function getStaticRoot() { + public function getStaticRoot() + { $config = new Config(); $config['mode'] = Daux::STATIC_MODE; $config['index_key'] = 'index.html'; diff --git a/tests/Tree/ContentTest.php b/tests/Tree/ContentTest.php index a39cb95..765f780 100644 --- a/tests/Tree/ContentTest.php +++ b/tests/Tree/ContentTest.php @@ -4,7 +4,8 @@ use Todaymade\Daux\Config; class ContentTest extends \PHPUnit_Framework_TestCase { - protected function createContent($content) { + protected function createContent($content) + { $dir = new Directory(new Root(new Config, ''), ''); $obj = new Content($dir, ''); $obj->setContent($content); @@ -14,15 +15,15 @@ class ContentTest extends \PHPUnit_Framework_TestCase public function providerTestAttributes() { - return array( - ['This is content', [], "This is content"], - ["title: This is a simple title\n---\nThis is content\n", ['title' => 'This is a simple title'], "This is content"], - ["title: This is a simple title\ntitle :This is another title\n---\nThis is content\n", ['title' => 'This is another title'], "This is content"], - ["title: This is a simple title\nthis is not metadata\n---\nThis is content\n", ['title' => 'This is a simple title'], "This is content"], - ["title: This is only metatada, no content", [], "title: This is only metatada, no content"], - ["title: This is almost only metadata\n---\n", ["title" => "This is almost only metadata"], ""], + return [ + ['This is content', [], 'This is content'], + ["title: This is a simple title\n---\nThis is content\n", ['title' => 'This is a simple title'], 'This is content'], + ["title: This is a simple title\ntitle :This is another title\n---\nThis is content\n", ['title' => 'This is another title'], 'This is content'], + ["title: This is a simple title\nthis is not metadata\n---\nThis is content\n", ['title' => 'This is a simple title'], 'This is content'], + ['title: This is only metatada, no content', [], 'title: This is only metatada, no content'], + ["title: This is almost only metadata\n---\n", ['title' => 'This is almost only metadata'], ''], ["# Some content\n\nhi\n```yml\nvalue: true\n```\n----\n Follow up", [], "# Some content\n\nhi\n```yml\nvalue: true\n```\n----\n Follow up"], - ); + ]; } /** diff --git a/tests/Tree/DirectoryTest.php b/tests/Tree/DirectoryTest.php index f78610c..a836276 100644 --- a/tests/Tree/DirectoryTest.php +++ b/tests/Tree/DirectoryTest.php @@ -2,24 +2,24 @@ use Todaymade\Daux\Config; -class DirectoryTest extends \PHPUnit_Framework_TestCase { - +class DirectoryTest extends \PHPUnit_Framework_TestCase +{ public function providerSort() { - return array( - array(["005_Fifth", "01_First"], ["01_First", "005_Fifth"]), - array(["005_Fifth", "Another", "01_First"], ["01_First", "005_Fifth", "Another"]), - array(["005_Fifth", "Another", "-Sticky", "01_First"], ["01_First", "005_Fifth", "Another", "-Sticky"]), - array(['01_before', '-Down'], ['01_before', '-Down']), - array(['01_before', '-Down-after', '-Down'], ['01_before', '-Down', '-Down-after']), - array(["01_numeric", "01_before"], ["01_before", "01_numeric"]), - array(["A_File", "01_A_File"], ["01_A_File", "A_File"]), - array(["A_File", "01_Continuing", "-01_Coming", "-02_Soon"], ["01_Continuing", "A_File", "-01_Coming", "-02_Soon"]), - array(["01_Getting_Started", "API_Calls", "200_Something_Else-Cool", "_5_Ways_to_Be_Happy"], ["01_Getting_Started", "200_Something_Else-Cool", "_5_Ways_to_Be_Happy", "API_Calls"]), - array(["01_Getting_Started", "API_Calls", "index", "200_Something_Else-Cool", "_5_Ways_to_Be_Happy"], ["index", "01_Getting_Started", "200_Something_Else-Cool", "_5_Ways_to_Be_Happy", "API_Calls"]), - array(["Before_but_after", "A_File", "Continuing"], ["A_File", "Before_but_after", "Continuing"]), - array(["01_GitHub_Flavored_Markdown", "Code_Test", "05_Code_Highlighting"], ["01_GitHub_Flavored_Markdown", "05_Code_Highlighting", "Code_Test"]), - ); + return [ + [['005_Fifth', '01_First'], ['01_First', '005_Fifth']], + [['005_Fifth', 'Another', '01_First'], ['01_First', '005_Fifth', 'Another']], + [['005_Fifth', 'Another', '-Sticky', '01_First'], ['01_First', '005_Fifth', 'Another', '-Sticky']], + [['01_before', '-Down'], ['01_before', '-Down']], + [['01_before', '-Down-after', '-Down'], ['01_before', '-Down', '-Down-after']], + [['01_numeric', '01_before'], ['01_before', '01_numeric']], + [['A_File', '01_A_File'], ['01_A_File', 'A_File']], + [['A_File', '01_Continuing', '-01_Coming', '-02_Soon'], ['01_Continuing', 'A_File', '-01_Coming', '-02_Soon']], + [['01_Getting_Started', 'API_Calls', '200_Something_Else-Cool', '_5_Ways_to_Be_Happy'], ['01_Getting_Started', '200_Something_Else-Cool', '_5_Ways_to_Be_Happy', 'API_Calls']], + [['01_Getting_Started', 'API_Calls', 'index', '200_Something_Else-Cool', '_5_Ways_to_Be_Happy'], ['index', '01_Getting_Started', '200_Something_Else-Cool', '_5_Ways_to_Be_Happy', 'API_Calls']], + [['Before_but_after', 'A_File', 'Continuing'], ['A_File', 'Before_but_after', 'Continuing']], + [['01_GitHub_Flavored_Markdown', 'Code_Test', '05_Code_Highlighting'], ['01_GitHub_Flavored_Markdown', '05_Code_Highlighting', 'Code_Test']], + ]; } /** @@ -44,6 +44,4 @@ class DirectoryTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($expected, $final); } - - }