8
0
Fork 0

Applied fixes from StyleCI

Dieser Commit ist enthalten in:
onigoetz 2016-07-27 15:32:51 -04:00 committet von Stéphane Goetz
Ursprung cfc8d30ba2
Commit 2314516ce9
52 geänderte Dateien mit 477 neuen und 424 gelöschten Zeilen

Datei anzeigen

@ -2,8 +2,8 @@
use Todaymade\Daux\Tree\Root; use Todaymade\Daux\Tree\Root;
class Processor extends \Todaymade\Daux\Processor { class Processor extends \Todaymade\Daux\Processor
{
public function manipulateTree(Root $root) public function manipulateTree(Root $root)
{ {
print_r($root->dump()); print_r($root->dump());

Datei anzeigen

@ -76,12 +76,12 @@ if (php_sapi_name() === 'cli-server') {
} }
if (file_exists('vendor/autoload.php')) { if (file_exists('vendor/autoload.php')) {
require_once('vendor/autoload.php'); require_once 'vendor/autoload.php';
} elseif (file_exists('daux.phar')) { } elseif (file_exists('daux.phar')) {
define('PHAR_DIR', __DIR__); define('PHAR_DIR', __DIR__);
require_once("phar://" . __DIR__ . "/daux.phar/vendor/autoload.php"); require_once 'phar://' . __DIR__ . '/daux.phar/vendor/autoload.php';
} else { } 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); \Todaymade\Daux\Server\Server::serve($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $_REQUEST);

Datei anzeigen

@ -141,7 +141,7 @@ class Compiler
foreach (token_get_all($source) as $token) { foreach (token_get_all($source) as $token) {
if (is_string($token)) { if (is_string($token)) {
$output .= $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")); $output .= str_repeat("\n", substr_count($token[1], "\n"));
} elseif (T_WHITESPACE === $token[0]) { } elseif (T_WHITESPACE === $token[0]) {
// reduce wide spaces // reduce wide spaces

Datei anzeigen

@ -8,17 +8,17 @@ trait RunAction
{ {
$output->write($title); $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 // 8 is the length of the label + 2 let it breathe
$padding = $width - $length - 10; $padding = $width - $length - 10;
try { try {
$response = $closure(); $response = $closure();
} catch (\Exception $e) { } catch (\Exception $e) {
$output->writeln(str_pad(" ", $padding) . "[ <fg=red>FAIL</fg=red> ]"); $output->writeln(str_pad(' ', $padding) . '[ <fg=red>FAIL</fg=red> ]');
throw $e; throw $e;
} }
$output->writeln(str_pad(" ", $padding) . "[ <fg=green>OK</fg=green> ]"); $output->writeln(str_pad(' ', $padding) . '[ <fg=green>OK</fg=green> ]');
return $response; return $response;
} }

Datei anzeigen

@ -5,7 +5,7 @@ use Todaymade\Daux\Tree\Content;
class ContentTypeHandler class ContentTypeHandler
{ {
/** /**
* @var ContentType[] $types * @var ContentType[]
*/ */
protected $types; protected $types;

Datei anzeigen

@ -4,9 +4,6 @@ use League\CommonMark\DocParser;
use League\CommonMark\Environment; use League\CommonMark\Environment;
use League\CommonMark\HtmlRenderer; use League\CommonMark\HtmlRenderer;
use Todaymade\Daux\Config; 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; use Webuni\CommonMark\TableExtension\TableExtension;
class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
@ -16,7 +13,7 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
* *
* @param array $config * @param array $config
*/ */
public function __construct(array $config = array()) public function __construct(array $config = [])
{ {
$environment = Environment::createCommonMarkEnvironment(); $environment = Environment::createCommonMarkEnvironment();
$environment->mergeConfig($config); $environment->mergeConfig($config);

Datei anzeigen

@ -28,6 +28,7 @@ class ContentType implements \Todaymade\Daux\ContentTypes\ContentType
public function convert($raw, Content $node) public function convert($raw, Content $node)
{ {
$this->config->setCurrentPage($node); $this->config->setCurrentPage($node);
return $this->converter->convertToHtml($raw); return $this->converter->convertToHtml($raw);
} }
} }

Datei anzeigen

@ -34,7 +34,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
// "!" In this case we will try to find // "!" In this case we will try to find
// the file starting at the root // the file starting at the root
if ($url[0] == '!' || $url[0] == '/') { if ($url[0] == '!' || $url[0] == '/') {
$url = ltrim($url, "!/"); $url = ltrim($url, '!/');
if ($file = DauxHelper::getFile($this->daux['tree'], $url)) { if ($file = DauxHelper::getFile($this->daux['tree'], $url)) {
return $file; return $file;
@ -71,7 +71,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
// have the same interface // have the same interface
if (!$inline instanceof Link) { if (!$inline instanceof Link) {
throw new \RuntimeException( 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 '" . " the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" .
get_class($inline) . "' was provided" get_class($inline) . "' was provided"
); );
@ -83,7 +83,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
// Absolute urls, empty urls and anchors // Absolute urls, empty urls and anchors
// should not go through the url resolver // 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; return $element;
} }

Datei anzeigen

@ -5,7 +5,6 @@ use League\CommonMark\Cursor;
class TableOfContents extends AbstractBlock class TableOfContents extends AbstractBlock
{ {
/** /**
* Returns true if this block can contain the given block as a child node * Returns true if this block can contain the given block as a child node
* *

Datei anzeigen

@ -6,7 +6,6 @@ use League\CommonMark\Cursor;
class TableOfContentsParser extends AbstractBlockParser class TableOfContentsParser extends AbstractBlockParser
{ {
/** /**
* @param ContextInterface $context * @param ContextInterface $context
* @param Cursor $cursor * @param Cursor $cursor

Datei anzeigen

@ -131,7 +131,7 @@ class Daux
// Set the default configuration // Set the default configuration
$this->options->merge([ $this->options->merge([
'docs_directory' => 'docs', 'docs_directory' => 'docs',
'valid_content_extensions' => ['md', 'markdown'] 'valid_content_extensions' => ['md', 'markdown'],
]); ]);
// Load the global configuration // Load the global configuration
@ -228,7 +228,7 @@ class Daux
'local_base' => $this->local_base, 'local_base' => $this->local_base,
'docs_path' => $this->docs_path, 'docs_path' => $this->docs_path,
'themes_path' => $this->themes_path, 'themes_path' => $this->themes_path,
'templates' => 'templates' 'templates' => 'templates',
]; ];
$this->options->conservativeMerge($default); $this->options->conservativeMerge($default);
@ -301,12 +301,12 @@ class Daux
return null; return null;
} }
$class = "\\Todaymade\\Daux\\Extension\\" . $processor; $class = '\\Todaymade\\Daux\\Extension\\' . $processor;
if (!class_exists($class)) { if (!class_exists($class)) {
throw new \RuntimeException("Class '$class' not found. We cannot use it as a Processor"); 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'"); throw new \RuntimeException("Class '$class' invalid, should extend '\\Todaymade\\Daux\\Processor'");
} }

Datei anzeigen

@ -60,11 +60,11 @@ class DauxHelper
$theme_folder = $params['themes_path'] . DIRECTORY_SEPARATOR . $params['html']['theme']; $theme_folder = $params['themes_path'] . DIRECTORY_SEPARATOR . $params['html']['theme'];
$theme_url = $params['base_url'] . $params['themes_directory'] . '/' . $params['html']['theme'] . '/'; $theme_url = $params['base_url'] . $params['themes_directory'] . '/' . $params['html']['theme'] . '/';
$theme = array(); $theme = [];
if (is_file($theme_folder . DIRECTORY_SEPARATOR . "config.json")) { if (is_file($theme_folder . DIRECTORY_SEPARATOR . 'config.json')) {
$theme = json_decode(file_get_contents($theme_folder . DIRECTORY_SEPARATOR . "config.json"), true); $theme = json_decode(file_get_contents($theme_folder . DIRECTORY_SEPARATOR . 'config.json'), true);
if (!$theme) { if (!$theme) {
$theme = array(); $theme = [];
} }
} }
@ -103,7 +103,7 @@ class DauxHelper
$substitutions = [ $substitutions = [
'<local_base>' => $params['local_base'], '<local_base>' => $params['local_base'],
'<base_url>' => $current_url, '<base_url>' => $current_url,
'<theme_url>' => $theme_url '<theme_url>' => $theme_url,
]; ];
// Substitute some placeholders // Substitute some placeholders
@ -125,9 +125,9 @@ class DauxHelper
*/ */
public static function getCleanPath($path) 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'); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
$absolutes = array(); $absolutes = [];
foreach ($parts as $part) { foreach ($parts as $part) {
if ('.' == $part) { if ('.' == $part) {
continue; continue;
@ -138,14 +138,15 @@ class DauxHelper
$absolutes[] = $part; $absolutes[] = $part;
} }
} }
return implode(DIRECTORY_SEPARATOR, $absolutes); return implode(DIRECTORY_SEPARATOR, $absolutes);
} }
public static function getFilenames(Config $config, $part) 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); $raw = Builder::removeSortingInformations($raw);
return ["$raw.html", $raw]; return ["$raw.html", $raw];
@ -238,7 +239,7 @@ class DauxHelper
$separator = '_'; $separator = '_';
// Convert all dashes into underscores // 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. // Remove all characters that are not the separator, letters, numbers, or whitespace.
$title = preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', $title); $title = preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', $title);
@ -264,129 +265,129 @@ class DauxHelper
return $charsArray; return $charsArray;
} }
return $charsArray = array( return $charsArray = [
'a' => array( 'a' => [
'à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', 'à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ',
'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ä', 'ā', 'ą', 'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ä', 'ā', 'ą',
'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ',
'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', 'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ',
'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ'), 'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', ],
'b' => array('б', 'β', 'Ъ', 'Ь', 'ب'), 'b' => ['б', 'β', 'Ъ', 'Ь', 'ب'],
'c' => array('ç', 'ć', 'č', 'ĉ', 'ċ'), 'c' => ['ç', 'ć', 'č', 'ĉ', 'ċ'],
'd' => array('ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ', 'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ',
'д', 'δ', 'د', 'ض'), 'д', 'δ', 'د', 'ض', ],
'e' => array('é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ', 'e' => ['é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ',
'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ', 'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ',
'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э',
'є', 'ə'), 'є', 'ə', ],
'f' => array('ф', 'φ', 'ف'), 'f' => ['ф', 'φ', 'ف'],
'g' => array('ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ج'), 'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ج'],
'h' => array('ĥ', 'ħ', 'η', 'ή', 'ح', 'ه'), 'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه'],
'i' => array('í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į', 'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į',
'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ',
'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ',
'ῗ', 'і', 'ї', 'и'), 'ῗ', 'і', 'ї', 'и', ],
'j' => array('ĵ', 'ј', 'Ј'), 'j' => ['ĵ', 'ј', 'Ј'],
'k' => array('ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك'), 'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك'],
'l' => array('ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل'), 'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل'],
'm' => array('м', 'μ', 'م'), 'm' => ['м', 'μ', 'م'],
'n' => array('ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن'), 'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن'],
'o' => array('ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ', 'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ',
'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő', 'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő',
'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό',
'ö', 'о', 'و', 'θ'), 'ö', 'о', 'و', 'θ', ],
'p' => array('п', 'π'), 'p' => ['п', 'π'],
'r' => array('ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر'), 'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر'],
's' => array('ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص'), 's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص'],
't' => array('ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط'), 't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط'],
'u' => array('ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ', 'u' => ['ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ',
'ự', 'ü', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у'), 'ự', 'ü', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', ],
'v' => array('в'), 'v' => ['в'],
'w' => array('ŵ', 'ω', 'ώ'), 'w' => ['ŵ', 'ω', 'ώ'],
'x' => array('χ'), 'x' => ['χ'],
'y' => array('ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ', 'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ',
'ϋ', 'ύ', 'ΰ', 'ي'), 'ϋ', 'ύ', 'ΰ', 'ي', ],
'z' => array('ź', 'ž', 'ż', 'з', 'ζ', 'ز'), 'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز'],
'aa' => array('ع'), 'aa' => ['ع'],
'ae' => array('æ'), 'ae' => ['æ'],
'ch' => array('ч'), 'ch' => ['ч'],
'dj' => array('ђ', 'đ'), 'dj' => ['ђ', 'đ'],
'dz' => array('џ'), 'dz' => ['џ'],
'gh' => array('غ'), 'gh' => ['غ'],
'kh' => array('х', 'خ'), 'kh' => ['х', 'خ'],
'lj' => array('љ'), 'lj' => ['љ'],
'nj' => array('њ'), 'nj' => ['њ'],
'oe' => array('œ'), 'oe' => ['œ'],
'ps' => array('ψ'), 'ps' => ['ψ'],
'sh' => array('ш'), 'sh' => ['ш'],
'shch' => array('щ'), 'shch' => ['щ'],
'ss' => array('ß'), 'ss' => ['ß'],
'th' => array('þ', 'ث', 'ذ', 'ظ'), 'th' => ['þ', 'ث', 'ذ', 'ظ'],
'ts' => array('ц'), 'ts' => ['ц'],
'ya' => array('я'), 'ya' => ['я'],
'yu' => array('ю'), 'yu' => ['ю'],
'zh' => array('ж'), 'zh' => ['ж'],
'(c)' => array('©'), '(c)' => ['©'],
'A' => array('Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ', 'A' => ['Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ',
'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Ä', 'Å', 'Ā', 'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Ä', 'Å', 'Ā',
'Ą', 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ą', 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ',
'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ',
'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А'), 'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А', ],
'B' => array('Б', 'Β'), 'B' => ['Б', 'Β'],
'C' => array('Ç', 'Ć', 'Č', 'Ĉ', 'Ċ'), 'C' => ['Ç', 'Ć', 'Č', 'Ĉ', 'Ċ'],
'D' => array('Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ'), 'D' => ['Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ'],
'E' => array('É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ', 'E' => ['É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ',
'Ệ', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ', 'Ệ', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ',
'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э', 'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э',
'Є', 'Ə'), 'Є', 'Ə', ],
'F' => array('Ф', 'Φ'), 'F' => ['Ф', 'Φ'],
'G' => array('Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ'), 'G' => ['Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ'],
'H' => array('Η', 'Ή'), 'H' => ['Η', 'Ή'],
'I' => array('Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į', 'I' => ['Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į',
'İ', 'Ι', 'Ί', 'Ϊ', 'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', 'İ', 'Ι', 'Ί', 'Ϊ', 'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ',
'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї'), 'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї', ],
'K' => array('К', 'Κ'), 'K' => ['К', 'Κ'],
'L' => array('Ĺ', 'Ł', 'Л', 'Λ', 'Ļ'), 'L' => ['Ĺ', 'Ł', 'Л', 'Λ', 'Ļ'],
'M' => array('М', 'Μ'), 'M' => ['М', 'Μ'],
'N' => array('Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν'), 'N' => ['Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν'],
'O' => array('Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ', 'O' => ['Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ',
'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ö', 'Ø', 'Ō', 'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ö', 'Ø', 'Ō',
'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ',
'Ὸ', 'Ό', 'О', 'Θ', 'Ө'), 'Ὸ', 'Ό', 'О', 'Θ', 'Ө', ],
'P' => array('П', 'Π'), 'P' => ['П', 'Π'],
'R' => array('Ř', 'Ŕ', 'Р', 'Ρ'), 'R' => ['Ř', 'Ŕ', 'Р', 'Ρ'],
'S' => array('Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ'), 'S' => ['Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ'],
'T' => array('Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ'), 'T' => ['Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ'],
'U' => array('Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ', 'U' => ['Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ',
'Ự', 'Û', 'Ü', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У'), 'Ự', 'Û', 'Ü', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У', ],
'V' => array('В'), 'V' => ['В'],
'W' => array('Ω', 'Ώ'), 'W' => ['Ω', 'Ώ'],
'X' => array('Χ'), 'X' => ['Χ'],
'Y' => array('Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ', 'Y' => ['Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ',
'Ы', 'Й', 'Υ', 'Ϋ'), 'Ы', 'Й', 'Υ', 'Ϋ', ],
'Z' => array('Ź', 'Ž', 'Ż', 'З', 'Ζ'), 'Z' => ['Ź', 'Ž', 'Ż', 'З', 'Ζ'],
'AE' => array('Æ'), 'AE' => ['Æ'],
'CH' => array('Ч'), 'CH' => ['Ч'],
'DJ' => array('Ђ'), 'DJ' => ['Ђ'],
'DZ' => array('Џ'), 'DZ' => ['Џ'],
'KH' => array('Х'), 'KH' => ['Х'],
'LJ' => array('Љ'), 'LJ' => ['Љ'],
'NJ' => array('Њ'), 'NJ' => ['Њ'],
'PS' => array('Ψ'), 'PS' => ['Ψ'],
'SH' => array('Ш'), 'SH' => ['Ш'],
'SHCH' => array('Щ'), 'SHCH' => ['Щ'],
'SS' => array('ẞ'), 'SS' => ['ẞ'],
'TH' => array('Þ'), 'TH' => ['Þ'],
'TS' => array('Ц'), 'TS' => ['Ц'],
'YA' => array('Я'), 'YA' => ['Я'],
'YU' => array('Ю'), 'YU' => ['Ю'],
'ZH' => array('Ж'), 'ZH' => ['Ж'],
' ' => array("\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81", ' ' => ["\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81",
"\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84", "\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84",
"\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87", "\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87",
"\xE2\x80\x88", "\xE2\x80\x89", "\xE2\x80\x8A", "\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) public static function getRelativePath($from, $to)
@ -419,6 +420,7 @@ class DauxHelper
} }
} }
} }
return implode('/', $relPath); return implode('/', $relPath);
} }
} }

Datei anzeigen

@ -5,7 +5,6 @@
* Date: 06/11/15 * Date: 06/11/15
* Time: 20:27 * Time: 20:27
*/ */
namespace Todaymade\Daux\Format\Base; namespace Todaymade\Daux\Format\Base;
use DOMDocument; use DOMDocument;
@ -15,7 +14,6 @@ use Todaymade\Daux\Tree\Root;
class EmbedImages class EmbedImages
{ {
protected $tree; protected $tree;
public function __construct(Root $tree) public function __construct(Root $tree)
@ -28,7 +26,6 @@ class EmbedImages
return preg_replace_callback( return preg_replace_callback(
"/<img\\s+[^>]*src=['\"]([^\"]*)['\"][^>]*>/", "/<img\\s+[^>]*src=['\"]([^\"]*)['\"][^>]*>/",
function ($matches) use ($file, $callback) { function ($matches) use ($file, $callback) {
if ($result = $this->findImage($matches[1], $matches[0], $file, $callback)) { if ($result = $this->findImage($matches[1], $matches[0], $file, $callback)) {
return $result; return $result;
} }
@ -60,7 +57,7 @@ class EmbedImages
private function findImage($src, $tag, Content $file, $callback) private function findImage($src, $tag, Content $file, $callback)
{ {
//for protocol relative or http requests : keep the original one //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; return $src;
} }

Datei anzeigen

@ -14,7 +14,7 @@ interface Generator
/** /**
* @param InputInterface $input * @param InputInterface $input
* @param OutputInterface $output * @param OutputInterface $output
* @param integer $width * @param int $width
* @return mixed * @return mixed
*/ */
public function generateAll(InputInterface $input, OutputInterface $output, $width); public function generateAll(InputInterface $input, OutputInterface $output, $width);

Datei anzeigen

@ -18,11 +18,11 @@ abstract class RawPage implements Page
public function getPureContent() 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() 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');
} }
} }

Datei anzeigen

@ -31,7 +31,7 @@ class Api
{ {
$options = [ $options = [
'base_uri' => $this->base_url . 'rest/api/', 'base_uri' => $this->base_url . 'rest/api/',
'auth' => [$this->user, $this->pass] 'auth' => [$this->user, $this->pass],
]; ];
return new Client($options); return new Client($options);
@ -68,7 +68,7 @@ class Api
$json = json_decode($body, true); $json = json_decode($body, true);
$message .= ($json != null && array_key_exists('message', $json)) ? $json['message'] : $body; $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()); return new DuplicateTitleException($message, 0, $e->getPrevious());
} }
@ -77,7 +77,7 @@ class Api
public function getPage($id) public function getPage($id)
{ {
$url = "content/$id?expand=ancestors,version,body.storage"; $url = "content/$id?expand=ancestors,version,body.storage";
try { try {
$result = json_decode($this->getClient()->get($url)->getBody(), true); $result = json_decode($this->getClient()->get($url)->getBody(), true);
@ -92,18 +92,18 @@ class Api
} }
return [ return [
"id" => $result['id'], 'id' => $result['id'],
"ancestor_id" => $ancestor_id, 'ancestor_id' => $ancestor_id,
"title" => $result['title'], 'title' => $result['title'],
"version" => $result['version']['number'], 'version' => $result['version']['number'],
"content" => $result['body']['storage']['value'], 'content' => $result['body']['storage']['value'],
]; ];
} }
/** /**
* Get a list of pages * Get a list of pages
* *
* @param integer $rootPage * @param int $rootPage
* @param bool $recursive * @param bool $recursive
* @return array * @return array
*/ */
@ -128,10 +128,10 @@ class Api
foreach ($hierarchy['results'] as $result) { foreach ($hierarchy['results'] as $result) {
$pages[$result['title']] = [ $pages[$result['title']] = [
"id" => $result['id'], 'id' => $result['id'],
"title" => $result['title'], 'title' => $result['title'],
"version" => $result['version']['number'], 'version' => $result['version']['number'],
"content" => $result['body']['storage']['value'], 'content' => $result['body']['storage']['value'],
]; ];
if ($recursive) { if ($recursive) {
@ -144,17 +144,16 @@ class Api
// to be a bug in Confluence // to be a bug in Confluence
$start += $increment; $start += $increment;
$url = "$base_url&start=$start"; $url = "$base_url&start=$start";
} while (!empty($hierarchy['results'])); } while (!empty($hierarchy['results']));
return $pages; return $pages;
} }
/** /**
* @param integer $parent_id * @param int $parent_id
* @param string $title * @param string $title
* @param string $content * @param string $content
* @return integer * @return int
*/ */
public function createPage($parent_id, $title, $content) public function createPage($parent_id, $title, $content)
{ {
@ -162,7 +161,7 @@ class Api
'type' => 'page', 'type' => 'page',
'space' => ['key' => $this->space], 'space' => ['key' => $this->space],
'title' => $title, 'title' => $title,
'body' => ['storage' => ['value' => $content, 'representation' => 'storage']] 'body' => ['storage' => ['value' => $content, 'representation' => 'storage']],
]; ];
if ($parent_id) { if ($parent_id) {
@ -179,9 +178,9 @@ class Api
} }
/** /**
* @param integer $parent_id * @param int $parent_id
* @param integer $page_id * @param int $page_id
* @param integer $newVersion * @param int $newVersion
* @param string $title * @param string $title
* @param string $content * @param string $content
*/ */
@ -190,9 +189,9 @@ class Api
$body = [ $body = [
'type' => 'page', 'type' => 'page',
'space' => ['key' => $this->space], 'space' => ['key' => $this->space],
'version' => ['number' => $newVersion, "minorEdit" => true], 'version' => ['number' => $newVersion, 'minorEdit' => true],
'title' => $title, 'title' => $title,
'body' => ['storage' => ['value' => $content, 'representation' => 'storage']] 'body' => ['storage' => ['value' => $content, 'representation' => 'storage']],
]; ];
if ($parent_id) { if ($parent_id) {
@ -209,7 +208,7 @@ class Api
/** /**
* Delete a page * Delete a page
* *
* @param integer $page_id * @param int $page_id
* @return mixed * @return mixed
*/ */
public function deletePage($page_id) public function deletePage($page_id)
@ -222,7 +221,7 @@ class Api
} }
/** /**
* @param integer $id * @param int $id
* @param array $attachment * @param array $attachment
*/ */
public function uploadAttachment($id, $attachment) public function uploadAttachment($id, $attachment)

Datei anzeigen

@ -38,7 +38,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
private function createImageTag($filename, $attributes) private function createImageTag($filename, $attributes)
{ {
$img = "<ac:image"; $img = '<ac:image';
foreach ($attributes as $name => $value) { foreach ($attributes as $name => $value) {
$img .= ' ac:' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"'; $img .= ' ac:' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';

Datei anzeigen

@ -8,7 +8,6 @@ use League\CommonMark\HtmlElement;
class FencedCodeRenderer implements BlockRendererInterface class FencedCodeRenderer implements BlockRendererInterface
{ {
protected $supported_languages = [ protected $supported_languages = [
'actionscript3', 'actionscript3',
'bash', 'bash',
@ -32,7 +31,7 @@ class FencedCodeRenderer implements BlockRendererInterface
'ruby', 'ruby',
'scala', 'scala',
'sql', 'sql',
'vb' 'vb',
]; ];
protected $known_conversions = ['html' => 'html/xml', 'xml' => 'html/xml', 'js' => 'javascript']; protected $known_conversions = ['html' => 'html/xml', 'xml' => 'html/xml', 'js' => 'javascript'];

Datei anzeigen

@ -20,7 +20,7 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
// have the same interface // have the same interface
if (!$inline instanceof Link) { if (!$inline instanceof Link) {
throw new \RuntimeException( 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 '" . " the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" .
get_class($inline) . "' was provided" get_class($inline) . "' was provided"
); );
@ -34,16 +34,16 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
} }
//Internal links //Internal links
$file = $this->resolveInternalFile(ltrim($url, "!")); $file = $this->resolveInternalFile(ltrim($url, '!'));
$link_props = [ $link_props = [
'ri:content-title' => trim($this->daux['confluence']['prefix']) . " " . $file->getTitle(), 'ri:content-title' => trim($this->daux['confluence']['prefix']) . ' ' . $file->getTitle(),
'ri:space-key' => $this->daux['confluence']['space_id'] 'ri:space-key' => $this->daux['confluence']['space_id'],
]; ];
$page = strval(new HtmlElement('ri:page', $link_props, '', true)); $page = strval(new HtmlElement('ri:page', $link_props, '', true));
$children = $htmlRenderer->renderInlines($inline->children()); $children = $htmlRenderer->renderInlines($inline->children());
if (strpos($children, "<") !== false) { if (strpos($children, '<') !== false) {
$children = '<ac:link-body>' . $children . '</ac:link-body>'; $children = '<ac:link-body>' . $children . '</ac:link-body>';
} else { } else {
$children = '<ac:plain-text-link-body><![CDATA[' . $children . ']]></ac:plain-text-link-body>'; $children = '<ac:plain-text-link-body><![CDATA[' . $children . ']]></ac:plain-text-link-body>';

Datei anzeigen

@ -2,5 +2,4 @@
class DuplicateTitleException extends \RuntimeException class DuplicateTitleException extends \RuntimeException
{ {
} }

Datei anzeigen

@ -32,7 +32,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
public function getContentTypes() public function getContentTypes()
{ {
return [ 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(); $params = $this->daux->getParams();
$confluence = $params['confluence']; $confluence = $params['confluence'];
$this->prefix = trim($confluence['prefix']) . " "; $this->prefix = trim($confluence['prefix']) . ' ';
$tree = $this->runAction( $tree = $this->runAction(
"Generating Tree ...", 'Generating Tree ...',
$output, $output,
$width, $width,
function() use ($params) { function () use ($params) {
$tree = $this->generateRecursive($this->daux->tree, $params); $tree = $this->generateRecursive($this->daux->tree, $params);
$tree['title'] = $this->prefix . $params['title']; $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 = new Publisher($confluence);
$publisher->output = $output; $publisher->output = $output;

Datei anzeigen

@ -23,7 +23,7 @@ class Publisher
protected $previous_title; protected $previous_title;
/** /**
* @var integer terminal width * @var int terminal width
*/ */
public $width; public $width;
@ -48,13 +48,12 @@ class Publisher
try { try {
return $this->runAction($title, $this->output, $this->width, $closure); return $this->runAction($title, $this->output, $this->width, $closure);
} catch (BadResponseException $e) { } catch (BadResponseException $e) {
$this->output->writeLn(" <error>" . $e->getMessage() . "</error>"); $this->output->writeLn(' <error>' . $e->getMessage() . '</error>');
} }
} }
public function publish(array $tree) public function publish(array $tree)
{ {
echo "Finding Root Page...\n"; echo "Finding Root Page...\n";
if (array_key_exists('ancestor_id', $this->confluence)) { if (array_key_exists('ancestor_id', $this->confluence)) {
$pages = $this->client->getList($this->confluence['ancestor_id']); $pages = $this->client->getList($this->confluence['ancestor_id']);
@ -69,14 +68,14 @@ class Publisher
$published = $this->client->getPage($this->confluence['root_id']); $published = $this->client->getPage($this->confluence['root_id']);
$this->confluence['ancestor_id'] = $published['ancestor_id']; $this->confluence['ancestor_id'] = $published['ancestor_id'];
} else { } 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( $this->run(
"Getting already published pages...", 'Getting already published pages...',
function() use (&$published) { function () use (&$published) {
if ($published != null) { if ($published != null) {
$published['children'] = $this->client->getList($published['id'], true); $published['children'] = $this->client->getList($published['id'], true);
} }
@ -85,19 +84,19 @@ class Publisher
$published = $this->run( $published = $this->run(
"Create placeholder pages...\n", "Create placeholder pages...\n",
function() use ($tree, $published) { function () use ($tree, $published) {
return $this->createRecursive($this->confluence['ancestor_id'], $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); $published = $this->updateRecursive($this->confluence['ancestor_id'], $tree, $published);
if ($this->shouldDelete()) { if ($this->shouldDelete()) {
$this->output->writeLn("Deleting obsolete pages..."); $this->output->writeLn('Deleting obsolete pages...');
} else { } 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 "> 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"; 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) protected function niceTitle($title)
{ {
if ($title == "index.html") { if ($title == 'index.html') {
return "Homepage"; return 'Homepage';
} }
return rtrim(strtr($title, ['index.html' => '', '.html' => '']), "/"); return rtrim(strtr($title, ['index.html' => '', '.html' => '']), '/');
} }
protected function createPage($parent_id, $entry, $published) 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['version'] = 1;
$published['title'] = $entry['title']; $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; return $published;
} }
protected function createPlaceholderPage($parent_id, $entry, $published) protected function createPlaceholderPage($parent_id, $entry, $published)
{ {
echo "- " . $entry['title'] . "\n"; echo '- ' . $entry['title'] . "\n";
$published['version'] = 1; $published['version'] = 1;
$published['title'] = $entry['title']; $published['title'] = $entry['title'];
$published['id'] = $this->client->createPage($parent_id, $entry['title'], ""); $published['id'] = $this->client->createPage($parent_id, $entry['title'], '');
return $published; return $published;
} }
@ -160,7 +159,7 @@ class Publisher
protected function createRecursive($parent_id, $entry, $published) 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 // nothing to do if the ID already exists
if (array_key_exists('id', $published)) { if (array_key_exists('id', $published)) {
return $published; return $published;
@ -181,7 +180,7 @@ class Publisher
protected function updateRecursive($parent_id, $entry, $published) 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)) { if (array_key_exists('id', $published) && array_key_exists('page', $entry)) {
$this->updatePage($parent_id, $entry, $published); $this->updatePage($parent_id, $entry, $published);
} }
@ -200,23 +199,21 @@ class Publisher
protected function deleteRecursive($published, $prefix = '') protected function deleteRecursive($published, $prefix = '')
{ {
foreach($published['children'] as $child) { foreach ($published['children'] as $child) {
if (array_key_exists('children', $child) && count($child['children'])) { if (array_key_exists('children', $child) && count($child['children'])) {
$this->deleteRecursive($child, $child['title'] . '/'); $this->deleteRecursive($child, $child['title'] . '/');
} }
if (!array_key_exists('needed', $child)) { if (!array_key_exists('needed', $child)) {
if ($this->shouldDelete()) { if ($this->shouldDelete()) {
$this->run( $this->run(
"- " . $prefix . $child['title'], '- ' . $prefix . $child['title'],
function() use ($child) { function () use ($child) {
$this->client->deletePage($child['id']); $this->client->deletePage($child['id']);
} }
); );
} else { } else {
echo "- " . $prefix . $child['title'] . "\n"; echo '- ' . $prefix . $child['title'] . "\n";
} }
} }
} }
@ -252,7 +249,7 @@ class Publisher
} }
//DEBUG //DEBUG
if (getenv("DEBUG") && strtolower(getenv("DEBUG")) != "false") { if (getenv('DEBUG') && strtolower(getenv('DEBUG')) != 'false') {
$prefix = 'static/export/'; $prefix = 'static/export/';
if (!is_dir($prefix)) { if (!is_dir($prefix)) {
mkdir($prefix, 0777, true); mkdir($prefix, 0777, true);
@ -267,14 +264,14 @@ class Publisher
protected function updatePage($parent_id, $entry, $published) protected function updatePage($parent_id, $entry, $published)
{ {
if ($this->previous_title != "Updating") { if ($this->previous_title != 'Updating') {
$this->previous_title = "Updating"; $this->previous_title = 'Updating';
echo "Updating Pages...\n"; echo "Updating Pages...\n";
} }
$this->run( $this->run(
"- " . $this->niceTitle($entry['file']->getUrl()), '- ' . $this->niceTitle($entry['file']->getUrl()),
function() use ($entry, $published, $parent_id) { function () use ($entry, $published, $parent_id) {
if ($this->shouldUpdate($entry['page'], $published)) { if ($this->shouldUpdate($entry['page'], $published)) {
$this->client->updatePage( $this->client->updatePage(
$parent_id, $parent_id,
@ -291,7 +288,7 @@ class Publisher
foreach ($entry['page']->attachments as $attachment) { foreach ($entry['page']->attachments as $attachment) {
$this->run( $this->run(
" With attachment: $attachment[filename]", " With attachment: $attachment[filename]",
function() use ($published, $attachment) { function () use ($published, $attachment) {
$this->client->uploadAttachment($published['id'], $attachment); $this->client->uploadAttachment($published['id'], $attachment);
} }
); );

Datei anzeigen

@ -2,5 +2,4 @@
class ComputedRawPage extends \Todaymade\Daux\Format\Base\ComputedRawPage class ComputedRawPage extends \Todaymade\Daux\Format\Base\ComputedRawPage
{ {
} }

Datei anzeigen

@ -18,10 +18,10 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
} }
if ($this->params['multilanguage']) { 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() private function initialize()
@ -45,13 +45,14 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
if ($multilanguage && !empty($parents)) { if ($multilanguage && !empty($parents)) {
$parents = array_splice($parents, 1); $parents = array_splice($parents, 1);
} }
$breadcrumb_trail = array(); $breadcrumb_trail = [];
if (!empty($parents)) { if (!empty($parents)) {
foreach ($parents as $node) { foreach ($parents as $node) {
$page = $node->getIndexPage() ?: $node->getFirstPage(); $page = $node->getIndexPage() ?: $node->getFirstPage();
$breadcrumb_trail[$node->getTitle()] = $page ? $page->getUrl() : ''; $breadcrumb_trail[$node->getTitle()] = $page ? $page->getUrl() : '';
} }
} }
return $breadcrumb_trail; return $breadcrumb_trail;
} }
@ -95,6 +96,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
$context = ['page' => $page, 'params' => $params]; $context = ['page' => $page, 'params' => $params];
$template = new Template($params['templates'], $params['theme']['templates']); $template = new Template($params['templates'], $params['theme']['templates']);
return $template->render($this->homepage ? 'theme::home' : 'theme::content', $context); return $template->render($this->homepage ? 'theme::home' : 'theme::content', $context);
} }
} }

Datei anzeigen

@ -78,6 +78,6 @@ class Entry
public function toString() public function toString()
{ {
return $this->getLevel() . " - " . $this->getId(); return $this->getLevel() . ' - ' . $this->getId();
} }
} }

Datei anzeigen

@ -70,7 +70,6 @@ class Processor implements DocumentProcessorInterface
} else { } else {
$document->prependChild($this->render($generated->getChildren())); $document->prependChild($this->render($generated->getChildren()));
} }
} }
} }
@ -184,7 +183,8 @@ class Processor implements DocumentProcessorInterface
return $list; return $list;
} }
protected function setNull($object, $property) { protected function setNull($object, $property)
{
$prop = new \ReflectionProperty(get_class($object), $property); $prop = new \ReflectionProperty(get_class($object), $property);
$prop->setAccessible(true); $prop->setAccessible(true);
$prop->setValue($object, null); $prop->setValue($object, null);
@ -212,6 +212,7 @@ class Processor implements DocumentProcessorInterface
} }
$deepCopy = new DeepCopy(); $deepCopy = new DeepCopy();
return $deepCopy->copy($firstClone)->children(); return $deepCopy->copy($firstClone)->children();
} }
} }

Datei anzeigen

@ -13,6 +13,6 @@ class RootEntry extends Entry
*/ */
public function getParent() public function getParent()
{ {
throw new \RuntimeException("No Parent Exception"); throw new \RuntimeException('No Parent Exception');
} }
} }

Datei anzeigen

@ -37,7 +37,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
public function getContentTypes() public function getContentTypes()
{ {
return [ 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( $this->runAction(
"Copying Static assets ...", 'Copying Static assets ...',
$output, $output,
$width, $width,
function() use ($destination) { function () use ($destination) {
GeneratorHelper::copyAssets($destination, $this->daux->local_base); GeneratorHelper::copyAssets($destination, $this->daux->local_base);
} }
); );
$output->writeLn("Generating ..."); $output->writeLn('Generating ...');
if (!array_key_exists('search', $params['html']) || !$params['html']['search']) { if (!array_key_exists('search', $params['html']) || !$params['html']['search']) {
$params['html']['search'] = $input->getOption('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]) 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) private function strip_html_tags($text)
{ {
$text = preg_replace( $text = preg_replace(
array( [
// Remove invisible content // Remove invisible content
'@<head[^>]*?>.*?</head>@siu', '@<head[^>]*?>.*?</head>@siu',
'@<style[^>]*?>.*?</style>@siu', '@<style[^>]*?>.*?</style>@siu',
@ -109,14 +108,15 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
'@</?((form)|(button)|(fieldset)|(legend)|(input))@iu', '@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
'@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu', '@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
'@</?((frameset)|(frame)|(iframe))@iu', '@</?((frameset)|(frame)|(iframe))@iu',
), ],
array( [
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
"\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",
"\n\$0", "\n\$0", "\n\$0", "\n\$0",
), ],
$text $text
); );
return trim(preg_replace('/\s+/', ' ', strip_tags($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 string $output_dir
* @param \Todaymade\Daux\Config $params * @param \Todaymade\Daux\Config $params
* @param OutputInterface $output * @param OutputInterface $output
* @param integer $width * @param int $width
* @param boolean $index_pages * @param bool $index_pages
* @param string $base_url * @param string $base_url
* @throws \Exception * @throws \Exception
*/ */
@ -150,23 +150,24 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
DauxHelper::rebaseConfiguration($params, $base_url); DauxHelper::rebaseConfiguration($params, $base_url);
} else { } else {
$this->runAction( $this->runAction(
"- " . $node->getUrl(), '- ' . $node->getUrl(),
$output, $output,
$width, $width,
function() use ($node, $output_dir, $key, $params, $index_pages) { function () use ($node, $output_dir, $key, $params, $index_pages) {
if ($node instanceof Raw) { if ($node instanceof Raw) {
copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key); copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
return; return;
} }
$generated = $this->generateOne($node, $params); $generated = $this->generateOne($node, $params);
file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent()); file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent());
if ($index_pages) { if ($index_pages) {
$this->indexed_pages[] =[ $this->indexed_pages[] = [
'title' => $node->getTitle(), 'title' => $node->getTitle(),
'text' => utf8_encode($this->strip_html_tags($generated->getPureContent())), 'text' => utf8_encode($this->strip_html_tags($generated->getPureContent())),
'tags' => "", 'tags' => '',
'url' => $node->getUrl() 'url' => $node->getUrl(),
]; ];
} }
} }
@ -191,6 +192,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
} }
$params['request'] = $node->getUrl(); $params['request'] = $node->getUrl();
return ContentPage::fromFile($node, $params, $this->daux->getContentTypeHandler()->getType($node)); return ContentPage::fromFile($node, $params, $this->daux->getContentTypeHandler()->getType($node));
} }
} }

Datei anzeigen

@ -2,5 +2,4 @@
class RawPage extends \Todaymade\Daux\Format\Base\RawPage class RawPage extends \Todaymade\Daux\Format\Base\RawPage
{ {
} }

Datei anzeigen

@ -35,7 +35,7 @@ class Template
* @param array $data * @param array $data
* @return string * @return string
*/ */
public function render($name, array $data = array()) public function render($name, array $data = [])
{ {
$this->engine->addData([ $this->engine->addData([
'base_url' => $data['params']['base_url'], 'base_url' => $data['params']['base_url'],
@ -50,12 +50,13 @@ class Template
protected function registerFunctions() 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); $nav = $this->buildNavigation($tree, $path, $current_url, $base_page, $mode);
return $this->renderNavigation($nav); 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 = ''; $title = '';
$breadcrumb_trail = $page['breadcrumb_trail']; $breadcrumb_trail = $page['breadcrumb_trail'];
$separator = $this->getSeparator($page['breadcrumb_separator']); $separator = $this->getSeparator($page['breadcrumb_separator']);
@ -69,16 +70,16 @@ class Template
} else { } else {
$title .= '<a href="' . $base_page . $page['request'] . '">' . $page['title'] . '</a>'; $title .= '<a href="' . $base_page . $page['request'] . '">' . $page['title'] . '</a>';
} }
return $title; return $title;
}); });
} }
private function renderNavigation($entries) private function renderNavigation($entries)
{ {
$nav = ""; $nav = '';
foreach ($entries as $entry) { foreach ($entries as $entry) {
if (array_key_exists('children', $entry)) { if (array_key_exists('children', $entry)) {
$icon = '<i class="Nav__arrow">&nbsp;</i>'; $icon = '<i class="Nav__arrow">&nbsp;</i>';
if (array_key_exists('href', $entry)) { if (array_key_exists('href', $entry)) {
@ -128,7 +129,7 @@ class Template
]; ];
if ($mode === Daux::STATIC_MODE) { if ($mode === Daux::STATIC_MODE) {
$link .= "/index.html"; $link .= '/index.html';
} }
if ($node->getIndexPage()) { if ($node->getIndexPage()) {
@ -146,6 +147,7 @@ class Template
$nav[] = $folder; $nav[] = $folder;
} }
} }
return $nav; return $nav;
} }

Datei anzeigen

@ -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) protected function buildNavigation(Directory $tree)
@ -51,21 +51,22 @@ class Book
continue; continue;
} }
$page_index = ($index = $node->getIndexPage())? $index : $node->getFirstPage(); $page_index = ($index = $node->getIndexPage()) ? $index : $node->getFirstPage();
$nav[] = [ $nav[] = [
'title' => $node->getTitle(), 'title' => $node->getTitle(),
'href' => "#section_" . $this->getSectionId($page_index), 'href' => '#section_' . $this->getSectionId($page_index),
'children' => $this->buildNavigation($node) 'children' => $this->buildNavigation($node),
]; ];
} }
} }
return $nav; return $nav;
} }
private function renderNavigation($entries) private function renderNavigation($entries)
{ {
$nav = ""; $nav = '';
foreach ($entries as $entry) { foreach ($entries as $entry) {
if (array_key_exists('children', $entry)) { if (array_key_exists('children', $entry)) {
if (array_key_exists('href', $entry)) { if (array_key_exists('href', $entry)) {
@ -87,9 +88,9 @@ class Book
protected function generateTOC() protected function generateTOC()
{ {
return "<h1>Table of Contents</h1>" . return '<h1>Table of Contents</h1>' .
$this->renderNavigation($this->buildNavigation($this->tree)) . $this->renderNavigation($this->buildNavigation($this->tree)) .
"</div><div class=\"page-break\">&nbsp;</div>"; '</div><div class="page-break">&nbsp;</div>';
} }
protected function generateCover() protected function generateCover()
@ -97,7 +98,7 @@ class Book
return "<div style='margin:4em 30% 4em 0;'>" . return "<div style='margin:4em 30% 4em 0;'>" .
"<h1 style='font-size:40pt; margin-bottom:0;'>{$this->cover['title']}</h1>" . "<h1 style='font-size:40pt; margin-bottom:0;'>{$this->cover['title']}</h1>" .
"<p><strong>{$this->cover['subject']}</strong> by {$this->cover['author']}</p>" . "<p><strong>{$this->cover['subject']}</strong> by {$this->cover['author']}</p>" .
"</div><div class=\"page-break\">&nbsp;</div>"; '</div><div class="page-break">&nbsp;</div>';
} }
protected function generatePages() protected function generatePages()
@ -109,6 +110,7 @@ class Book
$content .= '<section class="content">' . $page['content'] . '</section>'; $content .= '<section class="content">' . $page['content'] . '</section>';
$content .= '<div class="page-break">&nbsp;</div>'; $content .= '<div class="page-break">&nbsp;</div>';
} }
return $content; return $content;
} }
@ -137,6 +139,6 @@ class Book
public function generate() public function generate()
{ {
return "<!DOCTYPE html><html>" . $this->generateHead() . $this->generateBody() . "</html>"; return '<!DOCTYPE html><html>' . $this->generateHead() . $this->generateBody() . '</html>';
} }
} }

Datei anzeigen

@ -18,11 +18,10 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
$content, $content,
$this->file, $this->file,
function ($src, array $attributes, Raw $file) { function ($src, array $attributes, Raw $file) {
$content = base64_encode(file_get_contents($file->getPath())); $content = base64_encode(file_get_contents($file->getPath()));
$attr = ''; $attr = '';
foreach ($attributes as $name => $value) { foreach ($attributes as $name => $value) {
$attr .= ' ' .$name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"'; $attr .= ' ' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
} }
return "<img $attr src=\"data:image/png;base64,$content\"/>"; return "<img $attr src=\"data:image/png;base64,$content\"/>";

Datei anzeigen

@ -27,7 +27,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
public function getContentTypes() public function getContentTypes()
{ {
return [ 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']); $pdf->SetHeaderData('', 0, $params['title'], $params['tagline']);
// set header and footer fonts // set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]);
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]);
// set default monospaced font // set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
@ -84,7 +84,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
$current = $this->daux->tree->getIndexPage(); $current = $this->daux->tree->getIndexPage();
while ($current) { while ($current) {
$this->runAction( $this->runAction(
"Generating " . $current->getTitle(), 'Generating ' . $current->getTitle(),
$output, $output,
$width, $width,
function () use ($book, $current, $params) { function () use ($book, $current, $params) {

Datei anzeigen

@ -17,14 +17,14 @@ class Processor
protected $output; protected $output;
/** /**
* @var integer * @var int
*/ */
protected $width; protected $width;
/** /**
* @param Daux $daux * @param Daux $daux
* @param OutputInterface $output * @param OutputInterface $output
* @param integer $width * @param int $width
*/ */
public function __construct(Daux $daux, OutputInterface $output, $width) public function __construct(Daux $daux, OutputInterface $output, $width)
{ {

Datei anzeigen

@ -38,6 +38,7 @@ class ErrorPage extends SimplePage
]; ];
$template = new Template($params['templates'], $params['theme']['templates']); $template = new Template($params['templates'], $params['theme']['templates']);
return $template->render('error', ['page' => $page, 'params' => $params]); return $template->render('error', ['page' => $page, 'params' => $params]);
} }
} }

Datei anzeigen

@ -2,7 +2,6 @@
/** /**
* Class MimeType * Class MimeType
* @package Defr
* @author Dennis Fridrich <fridrich.dennis@gmail.com> * @author Dennis Fridrich <fridrich.dennis@gmail.com>
* @see http://www.php.net/mime_content_type * @see http://www.php.net/mime_content_type
*/ */
@ -11,7 +10,7 @@ class MimeType
/** /**
* @var array * @var array
*/ */
protected static $mimeTypes = array( protected static $mimeTypes = [
'txt' => 'text/plain', 'txt' => 'text/plain',
'htm' => 'text/html', 'htm' => 'text/html',
'html' => 'text/html', 'html' => 'text/html',
@ -58,7 +57,7 @@ class MimeType
// Open Office // Open Office
'odt' => 'application/vnd.oasis.opendocument.text', 'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
); ];
/** /**
* @param $filename * @param $filename
* @return string * @return string
@ -73,6 +72,7 @@ class MimeType
$finfo = finfo_open(FILEINFO_MIME); $finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename); $mimetype = finfo_file($finfo, $filename);
finfo_close($finfo); finfo_close($finfo);
return $mimetype; return $mimetype;
} else { } else {
return 'application/octet-stream'; return 'application/octet-stream';

Datei anzeigen

@ -44,7 +44,7 @@ class Server
$page = $server->handle($_REQUEST); $page = $server->handle($_REQUEST);
} catch (NotFoundException $e) { } catch (NotFoundException $e) {
http_response_code(404); 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) { if ($page instanceof RawPage) {
@ -53,7 +53,7 @@ class Server
// Transfer file in 1024 byte chunks to save memory usage. // Transfer file in 1024 byte chunks to save memory usage.
if ($fd = fopen($page->getFile(), 'rb')) { if ($fd = fopen($page->getFile(), 'rb')) {
while (!feof($fd)) { while (!feof($fd)) {
print fread($fd, 1024); echo fread($fd, 1024);
} }
fclose($fd); fclose($fd);
} }
@ -73,7 +73,7 @@ class Server
// The path has a special treatment on windows, revert the slashes // The path has a special treatment on windows, revert the slashes
$dir = dirname($_SERVER['PHP_SELF']); $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'); $t = strrpos($this->base_url, '/index.php');
if ($t != false) { if ($t != false) {
@ -171,16 +171,17 @@ class Server
parse_str($_SERVER['QUERY_STRING'], $_GET); parse_str($_SERVER['QUERY_STRING'], $_GET);
} else { } else {
$_SERVER['QUERY_STRING'] = ''; $_SERVER['QUERY_STRING'] = '';
$_GET = array(); $_GET = [];
} }
$uri = parse_url($uri, PHP_URL_PATH); $uri = parse_url($uri, PHP_URL_PATH);
} else { } else {
return false; return false;
} }
$uri = str_replace(array('//', '../'), '/', trim($uri, '/')); $uri = str_replace(['//', '../'], '/', trim($uri, '/'));
if ($uri == "") { if ($uri == '') {
$uri = "index_page"; $uri = 'index_page';
} }
return $uri; return $uri;
} }
} }

Datei anzeigen

@ -46,7 +46,7 @@ class Builder
preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $m); preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $m);
if (!isset($m[3])) { if (!isset($m[3])) {
throw new RuntimeException("Name not found"); throw new RuntimeException('Name not found');
} }
return $m[3]; return $m[3];
@ -137,17 +137,17 @@ class Builder
*/ */
public static function removeSortingInformations($filename) public static function removeSortingInformations($filename)
{ {
preg_match("/^-?[0-9]*_?(.*)/", $filename, $matches); preg_match('/^-?[0-9]*_?(.*)/', $filename, $matches);
// Remove the numeric part // Remove the numeric part
// of the filename, only if // of the filename, only if
// there is something after // there is something after
return empty($matches[1])? $matches[0] : $matches[1]; return empty($matches[1]) ? $matches[0] : $matches[1];
} }
/** /**
* @param Directory $parent * @param Directory $parent
* @param String $title * @param string $title
* @return Directory * @return Directory
*/ */
public static function getOrCreateDir(Directory $parent, $title) public static function getOrCreateDir(Directory $parent, $title)
@ -185,7 +185,7 @@ class Builder
$title = static::getName($path); $title = static::getName($path);
$uri = DauxHelper::slug($title); $uri = DauxHelper::slug($title);
if ($parent->getConfig()['mode'] === Daux::STATIC_MODE) { if ($parent->getConfig()['mode'] === Daux::STATIC_MODE) {
$uri .= ".html"; $uri .= '.html';
} }
} }
@ -193,8 +193,8 @@ class Builder
return $parent->getEntries()[$uri]; return $parent->getEntries()[$uri];
} }
$page = $raw? new ComputedRaw($parent, $uri) : new Content($parent, $uri); $page = $raw ? new ComputedRaw($parent, $uri) : new Content($parent, $uri);
$page->setContent("-"); //set an almost empty content to avoid problems $page->setContent('-'); //set an almost empty content to avoid problems
$page->setName($path); $page->setName($path);
$page->setTitle($title); $page->setTitle($title);

Datei anzeigen

@ -111,11 +111,17 @@ class Content extends Entry
$lines = preg_split('/\n/', $sections[0]); $lines = preg_split('/\n/', $sections[0]);
foreach ($lines as $line) { foreach ($lines as $line) {
$trimmed = trim($line); $trimmed = trim($line);
if ($trimmed == '') continue; // skip empty lines if ($trimmed == '') {
if ($trimmed[0] == '#') continue; // can be taken as comments continue;
} // skip empty lines
$re = "/^([-\\w]*)\\s*?:(.*)/"; if ($trimmed[0] == '#') {
if (!preg_match($re, $trimmed, $parts)) break; //Break as soon as we have a line that doesn't match 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])); $key = strtolower(trim($parts[1]));
$value = trim($parts[2]); $value = trim($parts[2]);

Datei anzeigen

@ -31,9 +31,9 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
continue; continue;
} }
if ($name[0] == "-") { if ($name[0] == '-') {
if (is_numeric($name[1])) { if (is_numeric($name[1])) {
$exploded = explode("_", $name); $exploded = explode('_', $name);
$buckets['down_numeric'][abs(substr($exploded[0], 1))][$key] = $entry; $buckets['down_numeric'][abs(substr($exploded[0], 1))][$key] = $entry;
continue; continue;
} }
@ -43,7 +43,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
} }
if (is_numeric($name[0])) { if (is_numeric($name[0])) {
$exploded = explode("_", $name); $exploded = explode('_', $name);
$buckets['numeric'][abs($exploded[0])][$key] = $entry; $buckets['numeric'][abs($exploded[0])][$key] = $entry;
continue; continue;
} }
@ -68,7 +68,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
private function sortBucket($bucket, $final) 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()); return strcasecmp($a->getName(), $b->getName());
}); });
@ -103,7 +103,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
public function getConfig() public function getConfig()
{ {
if (!$this->parent) { 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(); return $this->parent->getConfig();
@ -139,7 +139,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
*/ */
public function seekFirstPage() public function seekFirstPage()
{ {
if ($this instanceof Directory) { if ($this instanceof self) {
$index_key = $this->getConfig()['index_key']; $index_key = $this->getConfig()['index_key'];
if (isset($this->children[$index_key])) { if (isset($this->children[$index_key])) {
return $this->children[$index_key]; return $this->children[$index_key];
@ -148,13 +148,14 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
if ($node instanceof Content) { if ($node instanceof Content) {
return $node; return $node;
} }
if ($node instanceof Directory if ($node instanceof self
&& strpos($node->getUri(), '.') !== 0 && strpos($node->getUri(), '.') !== 0
&& $childNode = $node->seekFirstPage() ) { && $childNode = $node->seekFirstPage()) {
return $childNode; return $childNode;
} }
} }
} }
return null; return null;
} }
@ -176,14 +177,16 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
} }
$this->setFirstPage($node); $this->setFirstPage($node);
return $node; return $node;
} }
} }
// If we can't find one we check in the sub-directories // If we can't find one we check in the sub-directories
foreach ($this->getEntries() as $node) { foreach ($this->getEntries() as $node) {
if ($node instanceof Directory && $page = $node->getFirstPage()) { if ($node instanceof self && $page = $node->getFirstPage()) {
$this->setFirstPage($page); $this->setFirstPage($page);
return $page; return $page;
} }
} }
@ -210,7 +213,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
foreach ($this->getEntries() as $node) { foreach ($this->getEntries() as $node) {
if ($node instanceof Content) { if ($node instanceof Content) {
return true; return true;
} elseif ($node instanceof Directory) { } elseif ($node instanceof self) {
if ($node->hasContent()) { if ($node->hasContent()) {
return true; return true;
} }
@ -237,7 +240,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
/** /**
* Whether a offset exists * Whether a offset exists
* @param mixed $offset An offset to check for. * @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) public function offsetExists($offset)
{ {
@ -263,7 +266,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
public function offsetSet($offset, $value) public function offsetSet($offset, $value)
{ {
if (!$value instanceof Entry) { 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); $this->addChild($value);

Datei anzeigen

@ -159,6 +159,7 @@ abstract class Entry
} }
$url .= $this->getUri(); $url .= $this->getUri();
return $url; return $url;
} }
@ -170,7 +171,7 @@ abstract class Entry
'name' => $this->getName(), 'name' => $this->getName(),
'uri' => $this->getUri(), 'uri' => $this->getUri(),
'url' => $this->getUrl(), 'url' => $this->getUrl(),
'path' => $this->path 'path' => $this->path,
]; ];
} }
} }

Datei anzeigen

@ -1,26 +1,36 @@
<?php $this->layout('theme::layout/05_page') ?> <?php $this->layout('theme::layout/05_page') ?>
<article class="Page"> <article class="Page">
<?php if ($params['html']['date_modified']) { ?> <?php if ($params['html']['date_modified']) {
?>
<div class="Page__header"> <div class="Page__header">
<h1><?= $page['breadcrumbs']? $this->get_breadcrumb_title($page, $base_page) : $page['title'] ?></h1> <h1><?= $page['breadcrumbs'] ? $this->get_breadcrumb_title($page, $base_page) : $page['title'] ?></h1>
</div> </div>
<?php } else { ?> <?php
} else {
?>
<div class="Page__header"> <div class="Page__header">
<h1><?= $page['breadcrumbs']? $this->get_breadcrumb_title($page, $base_page) : $page['title'] ?></h1> <h1><?= $page['breadcrumbs'] ? $this->get_breadcrumb_title($page, $base_page) : $page['title'] ?></h1>
</div> </div>
<?php } ?> <?php
} ?>
<div class="s-content"> <div class="s-content">
<?= $page['content']; ?> <?= $page['content']; ?>
</div> </div>
<?php if(!empty($page['prev']) || !empty($page['next'])) { ?> <?php if (!empty($page['prev']) || !empty($page['next'])) {
?>
<nav> <nav>
<ul class="Pager"> <ul class="Pager">
<?php if(!empty($page['prev'])) { ?><li class=Pager--prev><a href="<?= $base_url . $page['prev']->getUrl() ?>">Previous</a></li><?php } ?> <?php if (!empty($page['prev'])) {
<?php if(!empty($page['next'])) { ?><li class=Pager--next><a href="<?= $base_url . $page['next']->getUrl() ?>">Next</a></li><?php } ?> ?><li class=Pager--prev><a href="<?= $base_url . $page['prev']->getUrl() ?>">Previous</a></li><?php
} ?>
<?php if (!empty($page['next'])) {
?><li class=Pager--next><a href="<?= $base_url . $page['next']->getUrl() ?>">Next</a></li><?php
} ?>
</ul> </ul>
</nav> </nav>
<?php } ?> <?php
} ?>
</article> </article>

Datei anzeigen

@ -5,21 +5,23 @@
</div> </div>
</div> </div>
<?php if ($params['html']['repo']) { ?> <?php if ($params['html']['repo']) {
?>
<a href="https://github.com/<?= $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="Github hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> <a href="https://github.com/<?= $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="Github hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<?php } ?> <?php
} ?>
<div class="Homepage"> <div class="Homepage">
<div class="HomepageTitle container"> <div class="HomepageTitle container">
<?php if ($params['tagline']) { <?php if ($params['tagline']) {
echo '<h2>' . $params['tagline'] . '</h2>'; echo '<h2>' . $params['tagline'] . '</h2>';
} ?> } ?>
</div> </div>
<div class="HomepageImage container"> <div class="HomepageImage container">
<?php if ($params['image']) { <?php if ($params['image']) {
echo '<img class="homepage-image img-responsive" src="' . $params['image'] . '" alt="' . $params['title'] . '">'; echo '<img class="homepage-image img-responsive" src="' . $params['image'] . '" alt="' . $params['title'] . '">';
} ?> } ?>
</div> </div>
<div class="HomepageButtons"> <div class="HomepageButtons">
@ -40,9 +42,11 @@
<div class="HomepageContent"> <div class="HomepageContent">
<div class="container"> <div class="container">
<div class="container--inner"> <div class="container--inner">
<?php if ($params['html']['search']) { ?> <?php if ($params['html']['search']) {
?>
<div id="tipue_search_content" style="display:none"></div> <div id="tipue_search_content" style="display:none"></div>
<?php } ?> <?php
} ?>
<div class="doc_content s-content"> <div class="doc_content s-content">
<?= $page['content']; ?> <?= $page['content']; ?>
@ -54,23 +58,29 @@
<div class="HomepageFooter"> <div class="HomepageFooter">
<div class="container"> <div class="container">
<div class="container--inner"> <div class="container--inner">
<?php if (!empty($params['html']['links'])) { ?> <?php if (!empty($params['html']['links'])) {
?>
<ul class="HomepageFooter__links"> <ul class="HomepageFooter__links">
<?php foreach ($params['html']['links'] as $name => $url) { <?php foreach ($params['html']['links'] as $name => $url) {
echo '<li><a href="' . $url . '" target="_blank">' . $name . '</a></li>'; echo '<li><a href="' . $url . '" target="_blank">' . $name . '</a></li>';
} ?> } ?>
</ul> </ul>
<?php } ?> <?php
} ?>
<?php if (!empty($params['html']['twitter'])) { ?> <?php if (!empty($params['html']['twitter'])) {
?>
<div class="HomepageFooter__twitter"> <div class="HomepageFooter__twitter">
<?php foreach ($params['html']['twitter'] as $handle) { ?> <?php foreach ($params['html']['twitter'] as $handle) {
?>
<div class="Twitter"> <div class="Twitter">
<iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=<?= $handle; ?>&amp;show_count=false"></iframe> <iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=<?= $handle; ?>&amp;show_count=false"></iframe>
</div> </div>
<?php } ?> <?php
} ?>
</div> </div>
<?php } ?> <?php
} ?>
</div> </div>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>

Datei anzeigen

@ -4,7 +4,9 @@
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head> <head>
<title><?= $page['title']; ?> <?php if ($page['title'] != $params['title']) { echo "- " . $params['title']; } ?></title> <title><?= $page['title']; ?> <?php if ($page['title'] != $params['title']) {
echo '- ' . $params['title'];
} ?></title>
<meta name="description" content="<?= $params['tagline']; ?>" /> <meta name="description" content="<?= $params['tagline']; ?>" />
<meta name="author" content="<?= $params['author']; ?>"> <meta name="author" content="<?= $params['author']; ?>">
<meta charset="UTF-8"> <meta charset="UTF-8">
@ -15,18 +17,20 @@
<!-- Font --> <!-- Font -->
<?php foreach ($params['theme']['fonts'] as $font) { <?php foreach ($params['theme']['fonts'] as $font) {
echo "<link href='$font' rel='stylesheet' type='text/css'>"; echo "<link href='$font' rel='stylesheet' type='text/css'>";
} ?> } ?>
<!-- CSS --> <!-- CSS -->
<?php foreach ($params['theme']['css'] as $css) { <?php foreach ($params['theme']['css'] as $css) {
echo "<link href='$css' rel='stylesheet' type='text/css'>"; echo "<link href='$css' rel='stylesheet' type='text/css'>";
} ?> } ?>
<?php if ($params['html']['search']) { ?> <?php if ($params['html']['search']) {
?>
<!-- Tipue Search --> <!-- Tipue Search -->
<link href="<?= $base_url; ?>tipuesearch/tipuesearch.css" rel="stylesheet"> <link href="<?= $base_url; ?>tipuesearch/tipuesearch.css" rel="stylesheet">
<?php } ?> <?php
} ?>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
@ -58,7 +62,8 @@
<script src="<?= $base_url; ?>themes/daux/js/daux.js"></script> <script src="<?= $base_url; ?>themes/daux/js/daux.js"></script>
<?php if ($params['html']['search']) { ?> <?php if ($params['html']['search']) {
?>
<!-- Tipue Search --> <!-- Tipue Search -->
<script type="text/javascript" src="<?php echo $base_url; ?>tipuesearch/tipuesearch_set.js"></script> <script type="text/javascript" src="<?php echo $base_url; ?>tipuesearch/tipuesearch_set.js"></script>
<script type="text/javascript" src="<?php echo $base_url; ?>tipuesearch/tipuesearch.min.js"></script> <script type="text/javascript" src="<?php echo $base_url; ?>tipuesearch/tipuesearch.min.js"></script>
@ -73,7 +78,8 @@
}); });
}); });
</script> </script>
<?php } ?> <?php
} ?>
</body> </body>
</html> </html>

Datei anzeigen

@ -1,8 +1,10 @@
<?php $this->layout('theme::layout/00_layout') ?> <?php $this->layout('theme::layout/00_layout') ?>
<?php if ($params['html']['repo']) { ?> <?php if ($params['html']['repo']) {
?>
<a href="https://github.com/<?= $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="Github hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a> <a href="https://github.com/<?= $params['html']['repo']; ?>" target="_blank" id="github-ribbon" class="Github hidden-print"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<?php } ?> <?php
} ?>
<div class="Navbar hidden-print"> <div class="Navbar hidden-print">
<?php $this->insert('theme::partials/navbar_content', ['params' => $params]); ?> <?php $this->insert('theme::partials/navbar_content', ['params' => $params]); ?>
@ -33,40 +35,54 @@
<div class="Links"> <div class="Links">
<?php if (!empty($params['html']['links'])) { ?> <?php if (!empty($params['html']['links'])) {
?>
<hr/> <hr/>
<?php foreach ($params['html']['links'] as $name => $url) { ?> <?php foreach ($params['html']['links'] as $name => $url) {
?>
<a href="<?= $url ?>" target="_blank"><?= $name ?></a> <a href="<?= $url ?>" target="_blank"><?= $name ?></a>
<br /> <br />
<?php } ?> <?php
<?php } ?> } ?>
<?php
} ?>
<?php if ($params['html']['toggle_code']) { ?> <?php if ($params['html']['toggle_code']) {
?>
<div class="CodeToggler"> <div class="CodeToggler">
<hr/> <hr/>
<?php if ($params['html']['float']) { ?> <?php if ($params['html']['float']) {
?>
<span class="CodeToggler__text">Code blocks</span> <span class="CodeToggler__text">Code blocks</span>
<div class="ButtonGroup" role="group"> <div class="ButtonGroup" role="group">
<button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--hide">No</button> <button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--hide">No</button>
<button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--below">Below</button> <button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--below">Below</button>
<button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--float">Inline</button> <button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--float">Inline</button>
</div> </div>
<?php } else { ?> <?php
} else {
?>
<a class="CodeToggler__button CodeToggler__button--main" href="#">Show Code Blocks Inline</a><br> <a class="CodeToggler__button CodeToggler__button--main" href="#">Show Code Blocks Inline</a><br>
<?php } ?> <?php
} ?>
</div> </div>
<?php } ?> <?php
} ?>
<?php if (!empty($params['html']['twitter'])) { ?> <?php if (!empty($params['html']['twitter'])) {
?>
<hr/> <hr/>
<div class="Twitter"> <div class="Twitter">
<?php foreach ($params['html']['twitter'] as $handle) { ?> <?php foreach ($params['html']['twitter'] as $handle) {
?>
<iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=<?= $handle; ?>&amp;show_count=false"></iframe> <iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=<?= $handle; ?>&amp;show_count=false"></iframe>
<br /> <br />
<br /> <br />
<?php } ?> <?php
} ?>
</div> </div>
<?php } ?> <?php
} ?>
</div> </div>
</div> </div>
<!-- For Mobile --> <!-- For Mobile -->
@ -76,9 +92,11 @@
<div class="Columns__right <?= $params['html']['float'] ? 'Columns__right--float' : ''; ?>"> <div class="Columns__right <?= $params['html']['float'] ? 'Columns__right--float' : ''; ?>">
<div class="Columns__right__content"> <div class="Columns__right__content">
<?php if ($params['html']['search']) { ?> <?php if ($params['html']['search']) {
?>
<div id="tipue_search_content" style="display:none"></div> <div id="tipue_search_content" style="display:none"></div>
<?php } ?> <?php
} ?>
<div class="doc_content"> <div class="doc_content">
<?= $this->section('content'); ?> <?= $this->section('content'); ?>

Datei anzeigen

@ -1,8 +1,10 @@
<a class="Navbar__brand" href="<?= $params['base_page'] . $params['index']->getUri(); ?>"><?= $params['title']; ?></a> <a class="Navbar__brand" href="<?= $params['base_page'] . $params['index']->getUri(); ?>"><?= $params['title']; ?></a>
<?php if ($params['html']['search']) { ?> <?php if ($params['html']['search']) {
?>
<div class="Search"> <div class="Search">
<svg class="Search__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 451 451"><path d="M447.05 428l-109.6-109.6c29.4-33.8 47.2-77.9 47.2-126.1C384.65 86.2 298.35 0 192.35 0 86.25 0 .05 86.3.05 192.3s86.3 192.3 192.3 192.3c48.2 0 92.3-17.8 126.1-47.2L428.05 447c2.6 2.6 6.1 4 9.5 4s6.9-1.3 9.5-4c5.2-5.2 5.2-13.8 0-19zM26.95 192.3c0-91.2 74.2-165.3 165.3-165.3 91.2 0 165.3 74.2 165.3 165.3s-74.1 165.4-165.3 165.4c-91.1 0-165.3-74.2-165.3-165.4z"/></svg> <svg class="Search__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 451 451"><path d="M447.05 428l-109.6-109.6c29.4-33.8 47.2-77.9 47.2-126.1C384.65 86.2 298.35 0 192.35 0 86.25 0 .05 86.3.05 192.3s86.3 192.3 192.3 192.3c48.2 0 92.3-17.8 126.1-47.2L428.05 447c2.6 2.6 6.1 4 9.5 4s6.9-1.3 9.5-4c5.2-5.2 5.2-13.8 0-19zM26.95 192.3c0-91.2 74.2-165.3 165.3-165.3 91.2 0 165.3 74.2 165.3 165.3s-74.1 165.4-165.3 165.4c-91.1 0-165.3-74.2-165.3-165.4z"/></svg>
<input type="search" id="tipue_search_input" class="Search__field" placeholder="Search..." autocomplete="on" results=25 autosave=text_search> <input type="search" id="tipue_search_input" class="Search__field" placeholder="Search..." autocomplete="on" results=25 autosave=text_search>
</div> </div>
<?php } ?> <?php
} ?>

Datei anzeigen

@ -36,17 +36,17 @@ class LinkRendererTest extends \PHPUnit_Framework_TestCase
{ {
return [ return [
// /Widgets/Page // /Widgets/Page
['<a href="http://google.ch">Link</a>', "[Link](http://google.ch)", "Widgets/Page.html"], ['<a href="http://google.ch">Link</a>', '[Link](http://google.ch)', 'Widgets/Page.html'],
['<a href="#features">Link</a>', "[Link](#features)", "Widgets/Page.html"], ['<a href="#features">Link</a>', '[Link](#features)', 'Widgets/Page.html'],
['<a href="Button.html">Link</a>', "[Link](Button.md)", "Widgets/Page.html"], ['<a href="Button.html">Link</a>', '[Link](Button.md)', 'Widgets/Page.html'],
['<a href="Button.html">Link</a>', "[Link](./Button.md)", "Widgets/Page.html"], ['<a href="Button.html">Link</a>', '[Link](./Button.md)', 'Widgets/Page.html'],
['<a href="Button.html">Link</a>', "[Link](Button)", "Widgets/Page.html"], ['<a href="Button.html">Link</a>', '[Link](Button)', 'Widgets/Page.html'],
['<a href="Button.html">Link</a>', "[Link](./Button)", "Widgets/Page.html"], ['<a href="Button.html">Link</a>', '[Link](./Button)', 'Widgets/Page.html'],
['<a href="Button.html">Link</a>', "[Link](!Widgets/Button)", "Widgets/Page.html"], ['<a href="Button.html">Link</a>', '[Link](!Widgets/Button)', 'Widgets/Page.html'],
// /Content/Page // /Content/Page
['<a href="../Widgets/Button.html">Link</a>', "[Link](../Widgets/Button.md)", "Content/Page.html"], ['<a href="../Widgets/Button.html">Link</a>', '[Link](../Widgets/Button.md)', 'Content/Page.html'],
['<a href="../Widgets/Button.html">Link</a>', "[Link](!Widgets/Button)", "Content/Page.html"], ['<a href="../Widgets/Button.html">Link</a>', '[Link](!Widgets/Button)', 'Content/Page.html'],
]; ];
} }

Datei anzeigen

@ -1,25 +1,25 @@
<?php namespace Todaymade\Daux; <?php namespace Todaymade\Daux;
class DauxHelperTest extends \PHPUnit_Framework_TestCase { class DauxHelperTest extends \PHPUnit_Framework_TestCase
{
public function providerGetFilenames() { public function providerGetFilenames()
{
return [ return [
[["Page.html", "Page"], "Page.html"], [['Page.html', 'Page'], 'Page.html'],
[["Page.html", "Page"], "Page.md"], [['Page.html', 'Page'], 'Page.md'],
[["Page.html", "Page"], "Page"], [['Page.html', 'Page'], 'Page'],
[["Code_Highlighting.html", "Code_Highlighting"], "05_Code_Highlighting.md"], [['Code_Highlighting.html', 'Code_Highlighting'], '05_Code_Highlighting.md'],
]; ];
} }
/** /**
* @dataProvider providerGetFilenames * @dataProvider providerGetFilenames
*/ */
public function testGetFilenames($expected, $node) { public function testGetFilenames($expected, $node)
{
$config = new Config(); $config = new Config();
$config['valid_content_extensions'] = ['md']; $config['valid_content_extensions'] = ['md'];
$this->assertEquals($expected, DauxHelper::getFilenames($config, $node)); $this->assertEquals($expected, DauxHelper::getFilenames($config, $node));
} }
} }

Datei anzeigen

@ -1,12 +1,12 @@
<?php <?php
namespace Todaymade\Daux\Format\Confluence; namespace Todaymade\Daux\Format\Confluence;
class BuilderTest extends \PHPUnit_Framework_TestCase class ApiTest extends \PHPUnit_Framework_TestCase
{ {
// this test supports upgrade Guzzle to version 6 // this test supports upgrade Guzzle to version 6
public function testClientOptions() public function testClientOptions()
{ {
$api = new Api("http://test.com/", "user", "pass"); $api = new Api('http://test.com/', 'user', 'pass');
$this->assertEquals("test.com", $api->getClient()->getConfig()['base_uri']->getHost()); $this->assertEquals('test.com', $api->getClient()->getConfig()['base_uri']->getHost());
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
<?php namespace Todaymade\Daux\Tree; <?php namespace Todaymade\Daux\Tree;
use Todaymade\Daux\Config; use Todaymade\Daux\Config;
use Todaymade\Daux\Daux; use Todaymade\Daux\Daux;
@ -8,26 +7,26 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
{ {
public function providerRemoveSorting() public function providerRemoveSorting()
{ {
return array( return [
['01_before', 'before'], ['01_before', 'before'],
['-Down', 'Down'], ['-Down', 'Down'],
["01_numeric", 'numeric'], ['01_numeric', 'numeric'],
["01_A_File", "A_File"], ['01_A_File', 'A_File'],
["A_File", "A_File"], ['A_File', 'A_File'],
["01_Continuing", "Continuing"], ['01_Continuing', 'Continuing'],
["-01_Coming", "Coming"], ['-01_Coming', 'Coming'],
["-02_Soon", "Soon"], ['-02_Soon', 'Soon'],
["01_Getting_Started", "Getting_Started"], ['01_Getting_Started', 'Getting_Started'],
["API_Calls", "API_Calls"], ['API_Calls', 'API_Calls'],
["200_Something_Else-Cool", "Something_Else-Cool"], ['200_Something_Else-Cool', 'Something_Else-Cool'],
["_5_Ways_to_Be_Happy", "5_Ways_to_Be_Happy"], ['_5_Ways_to_Be_Happy', '5_Ways_to_Be_Happy'],
["Before_but_after", "Before_but_after"], ['Before_but_after', 'Before_but_after'],
["Continuing", "Continuing"], ['Continuing', 'Continuing'],
["01_GitHub_Flavored_Markdown", "GitHub_Flavored_Markdown"], ['01_GitHub_Flavored_Markdown', 'GitHub_Flavored_Markdown'],
["Code_Test", "Code_Test"], ['Code_Test', 'Code_Test'],
["05_Code_Highlighting", "Code_Highlighting"], ['05_Code_Highlighting', 'Code_Highlighting'],
["1", "1"], ['1', '1'],
); ];
} }
/** /**
@ -38,7 +37,8 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, Builder::removeSortingInformations($value)); $this->assertEquals($expected, Builder::removeSortingInformations($value));
} }
public function testGetOrCreateDirNew() { public function testGetOrCreateDirNew()
{
$root = new Root(new Config(), ''); $root = new Root(new Config(), '');
@ -47,10 +47,10 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
$this->assertSame($root, $dir->getParent()); $this->assertSame($root, $dir->getParent());
$this->assertEquals('directory', $dir->getTitle()); $this->assertEquals('directory', $dir->getTitle());
$this->assertEquals('directory', $dir->getUri()); $this->assertEquals('directory', $dir->getUri());
} }
public function testGetOrCreateDirExisting() { public function testGetOrCreateDirExisting()
{
$root = new Root(new Config(), ''); $root = new Root(new Config(), '');
$directory = new Directory($root, 'directory'); $directory = new Directory($root, 'directory');
$directory->setTitle('directory'); $directory->setTitle('directory');
@ -63,7 +63,8 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
$this->assertSame($directory, $dir); $this->assertSame($directory, $dir);
} }
public function getStaticRoot() { public function getStaticRoot()
{
$config = new Config(); $config = new Config();
$config['mode'] = Daux::STATIC_MODE; $config['mode'] = Daux::STATIC_MODE;
$config['index_key'] = 'index.html'; $config['index_key'] = 'index.html';

Datei anzeigen

@ -4,7 +4,8 @@ use Todaymade\Daux\Config;
class ContentTest extends \PHPUnit_Framework_TestCase class ContentTest extends \PHPUnit_Framework_TestCase
{ {
protected function createContent($content) { protected function createContent($content)
{
$dir = new Directory(new Root(new Config, ''), ''); $dir = new Directory(new Root(new Config, ''), '');
$obj = new Content($dir, ''); $obj = new Content($dir, '');
$obj->setContent($content); $obj->setContent($content);
@ -14,15 +15,15 @@ class ContentTest extends \PHPUnit_Framework_TestCase
public function providerTestAttributes() public function providerTestAttributes()
{ {
return array( return [
['This is content', [], "This is content"], ['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\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\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 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 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"], ""], ["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"], ["# 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"],
); ];
} }
/** /**

Datei anzeigen

@ -2,24 +2,24 @@
use Todaymade\Daux\Config; use Todaymade\Daux\Config;
class DirectoryTest extends \PHPUnit_Framework_TestCase { class DirectoryTest extends \PHPUnit_Framework_TestCase
{
public function providerSort() public function providerSort()
{ {
return array( return [
array(["005_Fifth", "01_First"], ["01_First", "005_Fifth"]), [['005_Fifth', '01_First'], ['01_First', '005_Fifth']],
array(["005_Fifth", "Another", "01_First"], ["01_First", "005_Fifth", "Another"]), [['005_Fifth', 'Another', '01_First'], ['01_First', '005_Fifth', 'Another']],
array(["005_Fifth", "Another", "-Sticky", "01_First"], ["01_First", "005_Fifth", "Another", "-Sticky"]), [['005_Fifth', 'Another', '-Sticky', '01_First'], ['01_First', '005_Fifth', 'Another', '-Sticky']],
array(['01_before', '-Down'], ['01_before', '-Down']), [['01_before', '-Down'], ['01_before', '-Down']],
array(['01_before', '-Down-after', '-Down'], ['01_before', '-Down', '-Down-after']), [['01_before', '-Down-after', '-Down'], ['01_before', '-Down', '-Down-after']],
array(["01_numeric", "01_before"], ["01_before", "01_numeric"]), [['01_numeric', '01_before'], ['01_before', '01_numeric']],
array(["A_File", "01_A_File"], ["01_A_File", "A_File"]), [['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"]), [['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"]), [['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"]), [['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"]), [['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"]), [['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); $this->assertEquals($expected, $final);
} }
} }