Applied fixes from StyleCI
This commit is contained in:
bovenliggende
cfc8d30ba2
commit
2314516ce9
@ -2,8 +2,8 @@
|
||||
|
||||
use Todaymade\Daux\Tree\Root;
|
||||
|
||||
class Processor extends \Todaymade\Daux\Processor {
|
||||
|
||||
class Processor extends \Todaymade\Daux\Processor
|
||||
{
|
||||
public function manipulateTree(Root $root)
|
||||
{
|
||||
print_r($root->dump());
|
||||
|
@ -76,12 +76,12 @@ if (php_sapi_name() === 'cli-server') {
|
||||
}
|
||||
|
||||
if (file_exists('vendor/autoload.php')) {
|
||||
require_once('vendor/autoload.php');
|
||||
require_once 'vendor/autoload.php';
|
||||
} elseif (file_exists('daux.phar')) {
|
||||
define('PHAR_DIR', __DIR__);
|
||||
require_once("phar://" . __DIR__ . "/daux.phar/vendor/autoload.php");
|
||||
require_once 'phar://' . __DIR__ . '/daux.phar/vendor/autoload.php';
|
||||
} else {
|
||||
throw new Exception("Impossible to load Daux, missing vendor/ or daux.phar");
|
||||
throw new Exception('Impossible to load Daux, missing vendor/ or daux.phar');
|
||||
}
|
||||
|
||||
\Todaymade\Daux\Server\Server::serve($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $_REQUEST);
|
||||
|
@ -141,7 +141,7 @@ class Compiler
|
||||
foreach (token_get_all($source) as $token) {
|
||||
if (is_string($token)) {
|
||||
$output .= $token;
|
||||
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
|
||||
} elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
|
||||
$output .= str_repeat("\n", substr_count($token[1], "\n"));
|
||||
} elseif (T_WHITESPACE === $token[0]) {
|
||||
// reduce wide spaces
|
||||
|
@ -8,17 +8,17 @@ trait RunAction
|
||||
{
|
||||
$output->write($title);
|
||||
|
||||
$length = function_exists("mb_strlen")? mb_strlen($title) : strlen($title);
|
||||
$length = function_exists('mb_strlen') ? mb_strlen($title) : strlen($title);
|
||||
|
||||
// 8 is the length of the label + 2 let it breathe
|
||||
$padding = $width - $length - 10;
|
||||
try {
|
||||
$response = $closure();
|
||||
} catch (\Exception $e) {
|
||||
$output->writeln(str_pad(" ", $padding) . "[ <fg=red>FAIL</fg=red> ]");
|
||||
$output->writeln(str_pad(' ', $padding) . '[ <fg=red>FAIL</fg=red> ]');
|
||||
throw $e;
|
||||
}
|
||||
$output->writeln(str_pad(" ", $padding) . "[ <fg=green>OK</fg=green> ]");
|
||||
$output->writeln(str_pad(' ', $padding) . '[ <fg=green>OK</fg=green> ]');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use Todaymade\Daux\Tree\Content;
|
||||
class ContentTypeHandler
|
||||
{
|
||||
/**
|
||||
* @var ContentType[] $types
|
||||
* @var ContentType[]
|
||||
*/
|
||||
protected $types;
|
||||
|
||||
|
@ -4,9 +4,6 @@ use League\CommonMark\DocParser;
|
||||
use League\CommonMark\Environment;
|
||||
use League\CommonMark\HtmlRenderer;
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\ContentTypes\Markdown\TOC\Parser;
|
||||
use Todaymade\Daux\ContentTypes\Markdown\TOC\Renderer;
|
||||
use Todaymade\Daux\ContentTypes\Markdown\TOC\TOCProcessor;
|
||||
use Webuni\CommonMark\TableExtension\TableExtension;
|
||||
|
||||
class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
||||
@ -16,7 +13,7 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
||||
*
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(array $config = array())
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
$environment = Environment::createCommonMarkEnvironment();
|
||||
$environment->mergeConfig($config);
|
||||
|
@ -28,6 +28,7 @@ class ContentType implements \Todaymade\Daux\ContentTypes\ContentType
|
||||
public function convert($raw, Content $node)
|
||||
{
|
||||
$this->config->setCurrentPage($node);
|
||||
|
||||
return $this->converter->convertToHtml($raw);
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
||||
// "!" In this case we will try to find
|
||||
// the file starting at the root
|
||||
if ($url[0] == '!' || $url[0] == '/') {
|
||||
$url = ltrim($url, "!/");
|
||||
$url = ltrim($url, '!/');
|
||||
|
||||
if ($file = DauxHelper::getFile($this->daux['tree'], $url)) {
|
||||
return $file;
|
||||
@ -71,7 +71,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
||||
// have the same interface
|
||||
if (!$inline instanceof Link) {
|
||||
throw new \RuntimeException(
|
||||
"Wrong type passed to " . __CLASS__ . "::" . __METHOD__ .
|
||||
'Wrong type passed to ' . __CLASS__ . '::' . __METHOD__ .
|
||||
" the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" .
|
||||
get_class($inline) . "' was provided"
|
||||
);
|
||||
@ -83,7 +83,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
||||
|
||||
// Absolute urls, empty urls and anchors
|
||||
// should not go through the url resolver
|
||||
if (empty($url) || $url[0] == "#" || preg_match("|^(?:[a-z]+:)?//|", $url)) {
|
||||
if (empty($url) || $url[0] == '#' || preg_match('|^(?:[a-z]+:)?//|', $url)) {
|
||||
return $element;
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ use League\CommonMark\Cursor;
|
||||
|
||||
class TableOfContents extends AbstractBlock
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns true if this block can contain the given block as a child node
|
||||
*
|
||||
|
@ -6,7 +6,6 @@ use League\CommonMark\Cursor;
|
||||
|
||||
class TableOfContentsParser extends AbstractBlockParser
|
||||
{
|
||||
|
||||
/**
|
||||
* @param ContextInterface $context
|
||||
* @param Cursor $cursor
|
||||
|
@ -131,7 +131,7 @@ class Daux
|
||||
// Set the default configuration
|
||||
$this->options->merge([
|
||||
'docs_directory' => 'docs',
|
||||
'valid_content_extensions' => ['md', 'markdown']
|
||||
'valid_content_extensions' => ['md', 'markdown'],
|
||||
]);
|
||||
|
||||
// Load the global configuration
|
||||
@ -228,7 +228,7 @@ class Daux
|
||||
'local_base' => $this->local_base,
|
||||
'docs_path' => $this->docs_path,
|
||||
'themes_path' => $this->themes_path,
|
||||
'templates' => 'templates'
|
||||
'templates' => 'templates',
|
||||
];
|
||||
$this->options->conservativeMerge($default);
|
||||
|
||||
@ -301,12 +301,12 @@ class Daux
|
||||
return null;
|
||||
}
|
||||
|
||||
$class = "\\Todaymade\\Daux\\Extension\\" . $processor;
|
||||
$class = '\\Todaymade\\Daux\\Extension\\' . $processor;
|
||||
if (!class_exists($class)) {
|
||||
throw new \RuntimeException("Class '$class' not found. We cannot use it as a Processor");
|
||||
}
|
||||
|
||||
if (!array_key_exists("Todaymade\\Daux\\Processor", class_parents($class))) {
|
||||
if (!array_key_exists('Todaymade\\Daux\\Processor', class_parents($class))) {
|
||||
throw new \RuntimeException("Class '$class' invalid, should extend '\\Todaymade\\Daux\\Processor'");
|
||||
}
|
||||
|
||||
|
@ -60,11 +60,11 @@ class DauxHelper
|
||||
$theme_folder = $params['themes_path'] . DIRECTORY_SEPARATOR . $params['html']['theme'];
|
||||
$theme_url = $params['base_url'] . $params['themes_directory'] . '/' . $params['html']['theme'] . '/';
|
||||
|
||||
$theme = array();
|
||||
if (is_file($theme_folder . DIRECTORY_SEPARATOR . "config.json")) {
|
||||
$theme = json_decode(file_get_contents($theme_folder . DIRECTORY_SEPARATOR . "config.json"), true);
|
||||
$theme = [];
|
||||
if (is_file($theme_folder . DIRECTORY_SEPARATOR . 'config.json')) {
|
||||
$theme = json_decode(file_get_contents($theme_folder . DIRECTORY_SEPARATOR . 'config.json'), true);
|
||||
if (!$theme) {
|
||||
$theme = array();
|
||||
$theme = [];
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ class DauxHelper
|
||||
$substitutions = [
|
||||
'<local_base>' => $params['local_base'],
|
||||
'<base_url>' => $current_url,
|
||||
'<theme_url>' => $theme_url
|
||||
'<theme_url>' => $theme_url,
|
||||
];
|
||||
|
||||
// Substitute some placeholders
|
||||
@ -125,9 +125,9 @@ class DauxHelper
|
||||
*/
|
||||
public static function getCleanPath($path)
|
||||
{
|
||||
$path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
|
||||
$path = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path);
|
||||
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
|
||||
$absolutes = array();
|
||||
$absolutes = [];
|
||||
foreach ($parts as $part) {
|
||||
if ('.' == $part) {
|
||||
continue;
|
||||
@ -138,14 +138,15 @@ class DauxHelper
|
||||
$absolutes[] = $part;
|
||||
}
|
||||
}
|
||||
|
||||
return implode(DIRECTORY_SEPARATOR, $absolutes);
|
||||
}
|
||||
|
||||
public static function getFilenames(Config $config, $part)
|
||||
{
|
||||
$extensions = implode("|", array_map("preg_quote", $config["valid_content_extensions"])) . "|html";
|
||||
$extensions = implode('|', array_map('preg_quote', $config['valid_content_extensions'])) . '|html';
|
||||
|
||||
$raw = preg_replace("/(.*)?\\.(" . $extensions . ")$/", "$1", $part);
|
||||
$raw = preg_replace('/(.*)?\\.(' . $extensions . ')$/', '$1', $part);
|
||||
$raw = Builder::removeSortingInformations($raw);
|
||||
|
||||
return ["$raw.html", $raw];
|
||||
@ -238,7 +239,7 @@ class DauxHelper
|
||||
|
||||
$separator = '_';
|
||||
// Convert all dashes into underscores
|
||||
$title = preg_replace('![' . preg_quote("-") . ']+!u', $separator, $title);
|
||||
$title = preg_replace('![' . preg_quote('-') . ']+!u', $separator, $title);
|
||||
|
||||
// Remove all characters that are not the separator, letters, numbers, or whitespace.
|
||||
$title = preg_replace('![^' . preg_quote($separator) . '\pL\pN\s]+!u', '', $title);
|
||||
@ -264,129 +265,129 @@ class DauxHelper
|
||||
return $charsArray;
|
||||
}
|
||||
|
||||
return $charsArray = array(
|
||||
'a' => array(
|
||||
return $charsArray = [
|
||||
'a' => [
|
||||
'à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ',
|
||||
'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ä', 'ā', 'ą',
|
||||
'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ',
|
||||
'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ',
|
||||
'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ'),
|
||||
'b' => array('б', 'β', 'Ъ', 'Ь', 'ب'),
|
||||
'c' => array('ç', 'ć', 'č', 'ĉ', 'ċ'),
|
||||
'd' => array('ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ',
|
||||
'д', 'δ', 'د', 'ض'),
|
||||
'e' => array('é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ',
|
||||
'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ', ],
|
||||
'b' => ['б', 'β', 'Ъ', 'Ь', 'ب'],
|
||||
'c' => ['ç', 'ć', 'č', 'ĉ', 'ċ'],
|
||||
'd' => ['ď', 'ð', 'đ', 'ƌ', 'ȡ', 'ɖ', 'ɗ', 'ᵭ', 'ᶁ', 'ᶑ',
|
||||
'д', 'δ', 'د', 'ض', ],
|
||||
'e' => ['é', 'è', 'ẻ', 'ẽ', 'ẹ', 'ê', 'ế', 'ề', 'ể', 'ễ',
|
||||
'ệ', 'ë', 'ē', 'ę', 'ě', 'ĕ', 'ė', 'ε', 'έ', 'ἐ',
|
||||
'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'е', 'ё', 'э',
|
||||
'є', 'ə'),
|
||||
'f' => array('ф', 'φ', 'ف'),
|
||||
'g' => array('ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ج'),
|
||||
'h' => array('ĥ', 'ħ', 'η', 'ή', 'ح', 'ه'),
|
||||
'i' => array('í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į',
|
||||
'є', 'ə', ],
|
||||
'f' => ['ф', 'φ', 'ف'],
|
||||
'g' => ['ĝ', 'ğ', 'ġ', 'ģ', 'г', 'ґ', 'γ', 'ج'],
|
||||
'h' => ['ĥ', 'ħ', 'η', 'ή', 'ح', 'ه'],
|
||||
'i' => ['í', 'ì', 'ỉ', 'ĩ', 'ị', 'î', 'ï', 'ī', 'ĭ', 'į',
|
||||
'ı', 'ι', 'ί', 'ϊ', 'ΐ', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ',
|
||||
'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ',
|
||||
'ῗ', 'і', 'ї', 'и'),
|
||||
'j' => array('ĵ', 'ј', 'Ј'),
|
||||
'k' => array('ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك'),
|
||||
'l' => array('ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل'),
|
||||
'm' => array('м', 'μ', 'م'),
|
||||
'n' => array('ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن'),
|
||||
'o' => array('ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ',
|
||||
'ῗ', 'і', 'ї', 'и', ],
|
||||
'j' => ['ĵ', 'ј', 'Ј'],
|
||||
'k' => ['ķ', 'ĸ', 'к', 'κ', 'Ķ', 'ق', 'ك'],
|
||||
'l' => ['ł', 'ľ', 'ĺ', 'ļ', 'ŀ', 'л', 'λ', 'ل'],
|
||||
'm' => ['м', 'μ', 'م'],
|
||||
'n' => ['ñ', 'ń', 'ň', 'ņ', 'ʼn', 'ŋ', 'ν', 'н', 'ن'],
|
||||
'o' => ['ó', 'ò', 'ỏ', 'õ', 'ọ', 'ô', 'ố', 'ồ', 'ổ', 'ỗ',
|
||||
'ộ', 'ơ', 'ớ', 'ờ', 'ở', 'ỡ', 'ợ', 'ø', 'ō', 'ő',
|
||||
'ŏ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό',
|
||||
'ö', 'о', 'و', 'θ'),
|
||||
'p' => array('п', 'π'),
|
||||
'r' => array('ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر'),
|
||||
's' => array('ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص'),
|
||||
't' => array('ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط'),
|
||||
'u' => array('ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ',
|
||||
'ự', 'ü', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у'),
|
||||
'v' => array('в'),
|
||||
'w' => array('ŵ', 'ω', 'ώ'),
|
||||
'x' => array('χ'),
|
||||
'y' => array('ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ',
|
||||
'ϋ', 'ύ', 'ΰ', 'ي'),
|
||||
'z' => array('ź', 'ž', 'ż', 'з', 'ζ', 'ز'),
|
||||
'aa' => array('ع'),
|
||||
'ae' => array('æ'),
|
||||
'ch' => array('ч'),
|
||||
'dj' => array('ђ', 'đ'),
|
||||
'dz' => array('џ'),
|
||||
'gh' => array('غ'),
|
||||
'kh' => array('х', 'خ'),
|
||||
'lj' => array('љ'),
|
||||
'nj' => array('њ'),
|
||||
'oe' => array('œ'),
|
||||
'ps' => array('ψ'),
|
||||
'sh' => array('ш'),
|
||||
'shch' => array('щ'),
|
||||
'ss' => array('ß'),
|
||||
'th' => array('þ', 'ث', 'ذ', 'ظ'),
|
||||
'ts' => array('ц'),
|
||||
'ya' => array('я'),
|
||||
'yu' => array('ю'),
|
||||
'zh' => array('ж'),
|
||||
'(c)' => array('©'),
|
||||
'A' => array('Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ',
|
||||
'ö', 'о', 'و', 'θ', ],
|
||||
'p' => ['п', 'π'],
|
||||
'r' => ['ŕ', 'ř', 'ŗ', 'р', 'ρ', 'ر'],
|
||||
's' => ['ś', 'š', 'ş', 'с', 'σ', 'ș', 'ς', 'س', 'ص'],
|
||||
't' => ['ť', 'ţ', 'т', 'τ', 'ț', 'ت', 'ط'],
|
||||
'u' => ['ú', 'ù', 'ủ', 'ũ', 'ụ', 'ư', 'ứ', 'ừ', 'ử', 'ữ',
|
||||
'ự', 'ü', 'û', 'ū', 'ů', 'ű', 'ŭ', 'ų', 'µ', 'у', ],
|
||||
'v' => ['в'],
|
||||
'w' => ['ŵ', 'ω', 'ώ'],
|
||||
'x' => ['χ'],
|
||||
'y' => ['ý', 'ỳ', 'ỷ', 'ỹ', 'ỵ', 'ÿ', 'ŷ', 'й', 'ы', 'υ',
|
||||
'ϋ', 'ύ', 'ΰ', 'ي', ],
|
||||
'z' => ['ź', 'ž', 'ż', 'з', 'ζ', 'ز'],
|
||||
'aa' => ['ع'],
|
||||
'ae' => ['æ'],
|
||||
'ch' => ['ч'],
|
||||
'dj' => ['ђ', 'đ'],
|
||||
'dz' => ['џ'],
|
||||
'gh' => ['غ'],
|
||||
'kh' => ['х', 'خ'],
|
||||
'lj' => ['љ'],
|
||||
'nj' => ['њ'],
|
||||
'oe' => ['œ'],
|
||||
'ps' => ['ψ'],
|
||||
'sh' => ['ш'],
|
||||
'shch' => ['щ'],
|
||||
'ss' => ['ß'],
|
||||
'th' => ['þ', 'ث', 'ذ', 'ظ'],
|
||||
'ts' => ['ц'],
|
||||
'ya' => ['я'],
|
||||
'yu' => ['ю'],
|
||||
'zh' => ['ж'],
|
||||
'(c)' => ['©'],
|
||||
'A' => ['Á', 'À', 'Ả', 'Ã', 'Ạ', 'Ă', 'Ắ', 'Ằ', 'Ẳ', 'Ẵ',
|
||||
'Ặ', 'Â', 'Ấ', 'Ầ', 'Ẩ', 'Ẫ', 'Ậ', 'Ä', 'Å', 'Ā',
|
||||
'Ą', 'Α', 'Ά', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ',
|
||||
'Ἇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ',
|
||||
'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А'),
|
||||
'B' => array('Б', 'Β'),
|
||||
'C' => array('Ç', 'Ć', 'Č', 'Ĉ', 'Ċ'),
|
||||
'D' => array('Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ'),
|
||||
'E' => array('É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ',
|
||||
'Ᾱ', 'Ὰ', 'Ά', 'ᾼ', 'А', ],
|
||||
'B' => ['Б', 'Β'],
|
||||
'C' => ['Ç', 'Ć', 'Č', 'Ĉ', 'Ċ'],
|
||||
'D' => ['Ď', 'Ð', 'Đ', 'Ɖ', 'Ɗ', 'Ƌ', 'ᴅ', 'ᴆ', 'Д', 'Δ'],
|
||||
'E' => ['É', 'È', 'Ẻ', 'Ẽ', 'Ẹ', 'Ê', 'Ế', 'Ề', 'Ể', 'Ễ',
|
||||
'Ệ', 'Ë', 'Ē', 'Ę', 'Ě', 'Ĕ', 'Ė', 'Ε', 'Έ', 'Ἐ',
|
||||
'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Έ', 'Ὲ', 'Е', 'Ё', 'Э',
|
||||
'Є', 'Ə'),
|
||||
'F' => array('Ф', 'Φ'),
|
||||
'G' => array('Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ'),
|
||||
'H' => array('Η', 'Ή'),
|
||||
'I' => array('Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į',
|
||||
'Є', 'Ə', ],
|
||||
'F' => ['Ф', 'Φ'],
|
||||
'G' => ['Ğ', 'Ġ', 'Ģ', 'Г', 'Ґ', 'Γ'],
|
||||
'H' => ['Η', 'Ή'],
|
||||
'I' => ['Í', 'Ì', 'Ỉ', 'Ĩ', 'Ị', 'Î', 'Ï', 'Ī', 'Ĭ', 'Į',
|
||||
'İ', 'Ι', 'Ί', 'Ϊ', 'Ἰ', 'Ἱ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ',
|
||||
'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї'),
|
||||
'K' => array('К', 'Κ'),
|
||||
'L' => array('Ĺ', 'Ł', 'Л', 'Λ', 'Ļ'),
|
||||
'M' => array('М', 'Μ'),
|
||||
'N' => array('Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν'),
|
||||
'O' => array('Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ',
|
||||
'Ἷ', 'Ῐ', 'Ῑ', 'Ὶ', 'Ί', 'И', 'І', 'Ї', ],
|
||||
'K' => ['К', 'Κ'],
|
||||
'L' => ['Ĺ', 'Ł', 'Л', 'Λ', 'Ļ'],
|
||||
'M' => ['М', 'Μ'],
|
||||
'N' => ['Ń', 'Ñ', 'Ň', 'Ņ', 'Ŋ', 'Н', 'Ν'],
|
||||
'O' => ['Ó', 'Ò', 'Ỏ', 'Õ', 'Ọ', 'Ô', 'Ố', 'Ồ', 'Ổ', 'Ỗ',
|
||||
'Ộ', 'Ơ', 'Ớ', 'Ờ', 'Ở', 'Ỡ', 'Ợ', 'Ö', 'Ø', 'Ō',
|
||||
'Ő', 'Ŏ', 'Ο', 'Ό', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ',
|
||||
'Ὸ', 'Ό', 'О', 'Θ', 'Ө'),
|
||||
'P' => array('П', 'Π'),
|
||||
'R' => array('Ř', 'Ŕ', 'Р', 'Ρ'),
|
||||
'S' => array('Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ'),
|
||||
'T' => array('Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ'),
|
||||
'U' => array('Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ',
|
||||
'Ự', 'Û', 'Ü', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У'),
|
||||
'V' => array('В'),
|
||||
'W' => array('Ω', 'Ώ'),
|
||||
'X' => array('Χ'),
|
||||
'Y' => array('Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ',
|
||||
'Ы', 'Й', 'Υ', 'Ϋ'),
|
||||
'Z' => array('Ź', 'Ž', 'Ż', 'З', 'Ζ'),
|
||||
'AE' => array('Æ'),
|
||||
'CH' => array('Ч'),
|
||||
'DJ' => array('Ђ'),
|
||||
'DZ' => array('Џ'),
|
||||
'KH' => array('Х'),
|
||||
'LJ' => array('Љ'),
|
||||
'NJ' => array('Њ'),
|
||||
'PS' => array('Ψ'),
|
||||
'SH' => array('Ш'),
|
||||
'SHCH' => array('Щ'),
|
||||
'SS' => array('ẞ'),
|
||||
'TH' => array('Þ'),
|
||||
'TS' => array('Ц'),
|
||||
'YA' => array('Я'),
|
||||
'YU' => array('Ю'),
|
||||
'ZH' => array('Ж'),
|
||||
' ' => array("\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81",
|
||||
'Ὸ', 'Ό', 'О', 'Θ', 'Ө', ],
|
||||
'P' => ['П', 'Π'],
|
||||
'R' => ['Ř', 'Ŕ', 'Р', 'Ρ'],
|
||||
'S' => ['Ş', 'Ŝ', 'Ș', 'Š', 'Ś', 'С', 'Σ'],
|
||||
'T' => ['Ť', 'Ţ', 'Ŧ', 'Ț', 'Т', 'Τ'],
|
||||
'U' => ['Ú', 'Ù', 'Ủ', 'Ũ', 'Ụ', 'Ư', 'Ứ', 'Ừ', 'Ử', 'Ữ',
|
||||
'Ự', 'Û', 'Ü', 'Ū', 'Ů', 'Ű', 'Ŭ', 'Ų', 'У', ],
|
||||
'V' => ['В'],
|
||||
'W' => ['Ω', 'Ώ'],
|
||||
'X' => ['Χ'],
|
||||
'Y' => ['Ý', 'Ỳ', 'Ỷ', 'Ỹ', 'Ỵ', 'Ÿ', 'Ῠ', 'Ῡ', 'Ὺ', 'Ύ',
|
||||
'Ы', 'Й', 'Υ', 'Ϋ', ],
|
||||
'Z' => ['Ź', 'Ž', 'Ż', 'З', 'Ζ'],
|
||||
'AE' => ['Æ'],
|
||||
'CH' => ['Ч'],
|
||||
'DJ' => ['Ђ'],
|
||||
'DZ' => ['Џ'],
|
||||
'KH' => ['Х'],
|
||||
'LJ' => ['Љ'],
|
||||
'NJ' => ['Њ'],
|
||||
'PS' => ['Ψ'],
|
||||
'SH' => ['Ш'],
|
||||
'SHCH' => ['Щ'],
|
||||
'SS' => ['ẞ'],
|
||||
'TH' => ['Þ'],
|
||||
'TS' => ['Ц'],
|
||||
'YA' => ['Я'],
|
||||
'YU' => ['Ю'],
|
||||
'ZH' => ['Ж'],
|
||||
' ' => ["\xC2\xA0", "\xE2\x80\x80", "\xE2\x80\x81",
|
||||
"\xE2\x80\x82", "\xE2\x80\x83", "\xE2\x80\x84",
|
||||
"\xE2\x80\x85", "\xE2\x80\x86", "\xE2\x80\x87",
|
||||
"\xE2\x80\x88", "\xE2\x80\x89", "\xE2\x80\x8A",
|
||||
"\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80"),
|
||||
);
|
||||
"\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80", ],
|
||||
];
|
||||
}
|
||||
|
||||
public static function getRelativePath($from, $to)
|
||||
@ -419,6 +420,7 @@ class DauxHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode('/', $relPath);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
* Date: 06/11/15
|
||||
* Time: 20:27
|
||||
*/
|
||||
|
||||
namespace Todaymade\Daux\Format\Base;
|
||||
|
||||
use DOMDocument;
|
||||
@ -15,7 +14,6 @@ use Todaymade\Daux\Tree\Root;
|
||||
|
||||
class EmbedImages
|
||||
{
|
||||
|
||||
protected $tree;
|
||||
|
||||
public function __construct(Root $tree)
|
||||
@ -28,7 +26,6 @@ class EmbedImages
|
||||
return preg_replace_callback(
|
||||
"/<img\\s+[^>]*src=['\"]([^\"]*)['\"][^>]*>/",
|
||||
function ($matches) use ($file, $callback) {
|
||||
|
||||
if ($result = $this->findImage($matches[1], $matches[0], $file, $callback)) {
|
||||
return $result;
|
||||
}
|
||||
@ -60,7 +57,7 @@ class EmbedImages
|
||||
private function findImage($src, $tag, Content $file, $callback)
|
||||
{
|
||||
//for protocol relative or http requests : keep the original one
|
||||
if (substr($src, 0, strlen("http")) === "http" || substr($src, 0, strlen("//")) === "//") {
|
||||
if (substr($src, 0, strlen('http')) === 'http' || substr($src, 0, strlen('//')) === '//') {
|
||||
return $src;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ interface Generator
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
* @param integer $width
|
||||
* @param int $width
|
||||
* @return mixed
|
||||
*/
|
||||
public function generateAll(InputInterface $input, OutputInterface $output, $width);
|
||||
|
@ -18,11 +18,11 @@ abstract class RawPage implements Page
|
||||
|
||||
public function getPureContent()
|
||||
{
|
||||
throw new Exception("you should not use this method to show a raw content");
|
||||
throw new Exception('you should not use this method to show a raw content');
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
throw new Exception("you should not use this method to show a raw content");
|
||||
throw new Exception('you should not use this method to show a raw content');
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class Api
|
||||
{
|
||||
$options = [
|
||||
'base_uri' => $this->base_url . 'rest/api/',
|
||||
'auth' => [$this->user, $this->pass]
|
||||
'auth' => [$this->user, $this->pass],
|
||||
];
|
||||
|
||||
return new Client($options);
|
||||
@ -68,7 +68,7 @@ class Api
|
||||
$json = json_decode($body, true);
|
||||
$message .= ($json != null && array_key_exists('message', $json)) ? $json['message'] : $body;
|
||||
|
||||
if ($level == '4' && strpos($message, "page with this title already exists") !== false) {
|
||||
if ($level == '4' && strpos($message, 'page with this title already exists') !== false) {
|
||||
return new DuplicateTitleException($message, 0, $e->getPrevious());
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ class Api
|
||||
|
||||
public function getPage($id)
|
||||
{
|
||||
$url = "content/$id?expand=ancestors,version,body.storage";
|
||||
$url = "content/$id?expand=ancestors,version,body.storage";
|
||||
|
||||
try {
|
||||
$result = json_decode($this->getClient()->get($url)->getBody(), true);
|
||||
@ -92,18 +92,18 @@ class Api
|
||||
}
|
||||
|
||||
return [
|
||||
"id" => $result['id'],
|
||||
"ancestor_id" => $ancestor_id,
|
||||
"title" => $result['title'],
|
||||
"version" => $result['version']['number'],
|
||||
"content" => $result['body']['storage']['value'],
|
||||
'id' => $result['id'],
|
||||
'ancestor_id' => $ancestor_id,
|
||||
'title' => $result['title'],
|
||||
'version' => $result['version']['number'],
|
||||
'content' => $result['body']['storage']['value'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of pages
|
||||
*
|
||||
* @param integer $rootPage
|
||||
* @param int $rootPage
|
||||
* @param bool $recursive
|
||||
* @return array
|
||||
*/
|
||||
@ -128,10 +128,10 @@ class Api
|
||||
|
||||
foreach ($hierarchy['results'] as $result) {
|
||||
$pages[$result['title']] = [
|
||||
"id" => $result['id'],
|
||||
"title" => $result['title'],
|
||||
"version" => $result['version']['number'],
|
||||
"content" => $result['body']['storage']['value'],
|
||||
'id' => $result['id'],
|
||||
'title' => $result['title'],
|
||||
'version' => $result['version']['number'],
|
||||
'content' => $result['body']['storage']['value'],
|
||||
];
|
||||
|
||||
if ($recursive) {
|
||||
@ -144,17 +144,16 @@ class Api
|
||||
// to be a bug in Confluence
|
||||
$start += $increment;
|
||||
$url = "$base_url&start=$start";
|
||||
|
||||
} while (!empty($hierarchy['results']));
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $parent_id
|
||||
* @param int $parent_id
|
||||
* @param string $title
|
||||
* @param string $content
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
public function createPage($parent_id, $title, $content)
|
||||
{
|
||||
@ -162,7 +161,7 @@ class Api
|
||||
'type' => 'page',
|
||||
'space' => ['key' => $this->space],
|
||||
'title' => $title,
|
||||
'body' => ['storage' => ['value' => $content, 'representation' => 'storage']]
|
||||
'body' => ['storage' => ['value' => $content, 'representation' => 'storage']],
|
||||
];
|
||||
|
||||
if ($parent_id) {
|
||||
@ -179,9 +178,9 @@ class Api
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $parent_id
|
||||
* @param integer $page_id
|
||||
* @param integer $newVersion
|
||||
* @param int $parent_id
|
||||
* @param int $page_id
|
||||
* @param int $newVersion
|
||||
* @param string $title
|
||||
* @param string $content
|
||||
*/
|
||||
@ -190,9 +189,9 @@ class Api
|
||||
$body = [
|
||||
'type' => 'page',
|
||||
'space' => ['key' => $this->space],
|
||||
'version' => ['number' => $newVersion, "minorEdit" => true],
|
||||
'version' => ['number' => $newVersion, 'minorEdit' => true],
|
||||
'title' => $title,
|
||||
'body' => ['storage' => ['value' => $content, 'representation' => 'storage']]
|
||||
'body' => ['storage' => ['value' => $content, 'representation' => 'storage']],
|
||||
];
|
||||
|
||||
if ($parent_id) {
|
||||
@ -209,7 +208,7 @@ class Api
|
||||
/**
|
||||
* Delete a page
|
||||
*
|
||||
* @param integer $page_id
|
||||
* @param int $page_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function deletePage($page_id)
|
||||
@ -222,7 +221,7 @@ class Api
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $id
|
||||
* @param int $id
|
||||
* @param array $attachment
|
||||
*/
|
||||
public function uploadAttachment($id, $attachment)
|
||||
|
@ -38,7 +38,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
|
||||
private function createImageTag($filename, $attributes)
|
||||
{
|
||||
$img = "<ac:image";
|
||||
$img = '<ac:image';
|
||||
|
||||
foreach ($attributes as $name => $value) {
|
||||
$img .= ' ac:' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
|
||||
|
@ -8,7 +8,6 @@ use League\CommonMark\HtmlElement;
|
||||
|
||||
class FencedCodeRenderer implements BlockRendererInterface
|
||||
{
|
||||
|
||||
protected $supported_languages = [
|
||||
'actionscript3',
|
||||
'bash',
|
||||
@ -32,7 +31,7 @@ class FencedCodeRenderer implements BlockRendererInterface
|
||||
'ruby',
|
||||
'scala',
|
||||
'sql',
|
||||
'vb'
|
||||
'vb',
|
||||
];
|
||||
protected $known_conversions = ['html' => 'html/xml', 'xml' => 'html/xml', 'js' => 'javascript'];
|
||||
|
||||
|
@ -20,7 +20,7 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
|
||||
// have the same interface
|
||||
if (!$inline instanceof Link) {
|
||||
throw new \RuntimeException(
|
||||
"Wrong type passed to " . __CLASS__ . "::" . __METHOD__ .
|
||||
'Wrong type passed to ' . __CLASS__ . '::' . __METHOD__ .
|
||||
" the expected type was 'League\\CommonMark\\Inline\\Element\\Link' but '" .
|
||||
get_class($inline) . "' was provided"
|
||||
);
|
||||
@ -34,16 +34,16 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
|
||||
}
|
||||
|
||||
//Internal links
|
||||
$file = $this->resolveInternalFile(ltrim($url, "!"));
|
||||
$file = $this->resolveInternalFile(ltrim($url, '!'));
|
||||
|
||||
$link_props = [
|
||||
'ri:content-title' => trim($this->daux['confluence']['prefix']) . " " . $file->getTitle(),
|
||||
'ri:space-key' => $this->daux['confluence']['space_id']
|
||||
'ri:content-title' => trim($this->daux['confluence']['prefix']) . ' ' . $file->getTitle(),
|
||||
'ri:space-key' => $this->daux['confluence']['space_id'],
|
||||
];
|
||||
|
||||
$page = strval(new HtmlElement('ri:page', $link_props, '', true));
|
||||
$children = $htmlRenderer->renderInlines($inline->children());
|
||||
if (strpos($children, "<") !== false) {
|
||||
if (strpos($children, '<') !== false) {
|
||||
$children = '<ac:link-body>' . $children . '</ac:link-body>';
|
||||
} else {
|
||||
$children = '<ac:plain-text-link-body><![CDATA[' . $children . ']]></ac:plain-text-link-body>';
|
||||
|
@ -2,5 +2,4 @@
|
||||
|
||||
class DuplicateTitleException extends \RuntimeException
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
public function getContentTypes()
|
||||
{
|
||||
return [
|
||||
new ContentTypes\Markdown\ContentType($this->daux->getParams())
|
||||
new ContentTypes\Markdown\ContentType($this->daux->getParams()),
|
||||
];
|
||||
}
|
||||
|
||||
@ -44,13 +44,13 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
$params = $this->daux->getParams();
|
||||
|
||||
$confluence = $params['confluence'];
|
||||
$this->prefix = trim($confluence['prefix']) . " ";
|
||||
$this->prefix = trim($confluence['prefix']) . ' ';
|
||||
|
||||
$tree = $this->runAction(
|
||||
"Generating Tree ...",
|
||||
'Generating Tree ...',
|
||||
$output,
|
||||
$width,
|
||||
function() use ($params) {
|
||||
function () use ($params) {
|
||||
$tree = $this->generateRecursive($this->daux->tree, $params);
|
||||
$tree['title'] = $this->prefix . $params['title'];
|
||||
|
||||
@ -58,7 +58,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
}
|
||||
);
|
||||
|
||||
$output->writeln("Start Publishing...");
|
||||
$output->writeln('Start Publishing...');
|
||||
|
||||
$publisher = new Publisher($confluence);
|
||||
$publisher->output = $output;
|
||||
|
@ -23,7 +23,7 @@ class Publisher
|
||||
protected $previous_title;
|
||||
|
||||
/**
|
||||
* @var integer terminal width
|
||||
* @var int terminal width
|
||||
*/
|
||||
public $width;
|
||||
|
||||
@ -48,13 +48,12 @@ class Publisher
|
||||
try {
|
||||
return $this->runAction($title, $this->output, $this->width, $closure);
|
||||
} catch (BadResponseException $e) {
|
||||
$this->output->writeLn(" <error>" . $e->getMessage() . "</error>");
|
||||
$this->output->writeLn(' <error>' . $e->getMessage() . '</error>');
|
||||
}
|
||||
}
|
||||
|
||||
public function publish(array $tree)
|
||||
{
|
||||
|
||||
echo "Finding Root Page...\n";
|
||||
if (array_key_exists('ancestor_id', $this->confluence)) {
|
||||
$pages = $this->client->getList($this->confluence['ancestor_id']);
|
||||
@ -69,14 +68,14 @@ class Publisher
|
||||
$published = $this->client->getPage($this->confluence['root_id']);
|
||||
$this->confluence['ancestor_id'] = $published['ancestor_id'];
|
||||
} else {
|
||||
throw new \RuntimeException("You must at least specify a `root_id` or `ancestor_id` in your confluence configuration.");
|
||||
throw new \RuntimeException('You must at least specify a `root_id` or `ancestor_id` in your confluence configuration.');
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->run(
|
||||
"Getting already published pages...",
|
||||
function() use (&$published) {
|
||||
'Getting already published pages...',
|
||||
function () use (&$published) {
|
||||
if ($published != null) {
|
||||
$published['children'] = $this->client->getList($published['id'], true);
|
||||
}
|
||||
@ -85,19 +84,19 @@ class Publisher
|
||||
|
||||
$published = $this->run(
|
||||
"Create placeholder pages...\n",
|
||||
function() use ($tree, $published) {
|
||||
function () use ($tree, $published) {
|
||||
return $this->createRecursive($this->confluence['ancestor_id'], $tree, $published);
|
||||
}
|
||||
);
|
||||
|
||||
$this->output->writeLn("Publishing updates...");
|
||||
$this->output->writeLn('Publishing updates...');
|
||||
$published = $this->updateRecursive($this->confluence['ancestor_id'], $tree, $published);
|
||||
|
||||
|
||||
if ($this->shouldDelete()) {
|
||||
$this->output->writeLn("Deleting obsolete pages...");
|
||||
$this->output->writeLn('Deleting obsolete pages...');
|
||||
} else {
|
||||
$this->output->writeLn("Listing obsolete pages...");
|
||||
$this->output->writeLn('Listing obsolete pages...');
|
||||
echo "> The following pages will not be deleted, but just listed for information.\n";
|
||||
echo "> If you want to delete these pages, you need to set the --delete flag on the command.\n";
|
||||
}
|
||||
@ -106,29 +105,29 @@ class Publisher
|
||||
|
||||
protected function niceTitle($title)
|
||||
{
|
||||
if ($title == "index.html") {
|
||||
return "Homepage";
|
||||
if ($title == 'index.html') {
|
||||
return 'Homepage';
|
||||
}
|
||||
|
||||
return rtrim(strtr($title, ['index.html' => '', '.html' => '']), "/");
|
||||
return rtrim(strtr($title, ['index.html' => '', '.html' => '']), '/');
|
||||
}
|
||||
|
||||
protected function createPage($parent_id, $entry, $published)
|
||||
{
|
||||
echo "- " . $this->niceTitle($entry['file']->getUrl()) . "\n";
|
||||
echo '- ' . $this->niceTitle($entry['file']->getUrl()) . "\n";
|
||||
$published['version'] = 1;
|
||||
$published['title'] = $entry['title'];
|
||||
$published['id'] = $this->client->createPage($parent_id, $entry['title'], "The content will come very soon !");
|
||||
$published['id'] = $this->client->createPage($parent_id, $entry['title'], 'The content will come very soon !');
|
||||
|
||||
return $published;
|
||||
}
|
||||
|
||||
protected function createPlaceholderPage($parent_id, $entry, $published)
|
||||
{
|
||||
echo "- " . $entry['title'] . "\n";
|
||||
echo '- ' . $entry['title'] . "\n";
|
||||
$published['version'] = 1;
|
||||
$published['title'] = $entry['title'];
|
||||
$published['id'] = $this->client->createPage($parent_id, $entry['title'], "");
|
||||
$published['id'] = $this->client->createPage($parent_id, $entry['title'], '');
|
||||
|
||||
return $published;
|
||||
}
|
||||
@ -160,7 +159,7 @@ class Publisher
|
||||
|
||||
protected function createRecursive($parent_id, $entry, $published)
|
||||
{
|
||||
$callback = function($parent_id, $entry, $published) {
|
||||
$callback = function ($parent_id, $entry, $published) {
|
||||
// nothing to do if the ID already exists
|
||||
if (array_key_exists('id', $published)) {
|
||||
return $published;
|
||||
@ -181,7 +180,7 @@ class Publisher
|
||||
|
||||
protected function updateRecursive($parent_id, $entry, $published)
|
||||
{
|
||||
$callback = function($parent_id, $entry, $published) {
|
||||
$callback = function ($parent_id, $entry, $published) {
|
||||
if (array_key_exists('id', $published) && array_key_exists('page', $entry)) {
|
||||
$this->updatePage($parent_id, $entry, $published);
|
||||
}
|
||||
@ -200,23 +199,21 @@ class Publisher
|
||||
|
||||
protected function deleteRecursive($published, $prefix = '')
|
||||
{
|
||||
foreach($published['children'] as $child) {
|
||||
foreach ($published['children'] as $child) {
|
||||
if (array_key_exists('children', $child) && count($child['children'])) {
|
||||
$this->deleteRecursive($child, $child['title'] . '/');
|
||||
}
|
||||
|
||||
if (!array_key_exists('needed', $child)) {
|
||||
|
||||
if ($this->shouldDelete()) {
|
||||
$this->run(
|
||||
"- " . $prefix . $child['title'],
|
||||
function() use ($child) {
|
||||
'- ' . $prefix . $child['title'],
|
||||
function () use ($child) {
|
||||
$this->client->deletePage($child['id']);
|
||||
}
|
||||
);
|
||||
|
||||
} else {
|
||||
echo "- " . $prefix . $child['title'] . "\n";
|
||||
echo '- ' . $prefix . $child['title'] . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -252,7 +249,7 @@ class Publisher
|
||||
}
|
||||
|
||||
//DEBUG
|
||||
if (getenv("DEBUG") && strtolower(getenv("DEBUG")) != "false") {
|
||||
if (getenv('DEBUG') && strtolower(getenv('DEBUG')) != 'false') {
|
||||
$prefix = 'static/export/';
|
||||
if (!is_dir($prefix)) {
|
||||
mkdir($prefix, 0777, true);
|
||||
@ -267,14 +264,14 @@ class Publisher
|
||||
|
||||
protected function updatePage($parent_id, $entry, $published)
|
||||
{
|
||||
if ($this->previous_title != "Updating") {
|
||||
$this->previous_title = "Updating";
|
||||
if ($this->previous_title != 'Updating') {
|
||||
$this->previous_title = 'Updating';
|
||||
echo "Updating Pages...\n";
|
||||
}
|
||||
|
||||
$this->run(
|
||||
"- " . $this->niceTitle($entry['file']->getUrl()),
|
||||
function() use ($entry, $published, $parent_id) {
|
||||
'- ' . $this->niceTitle($entry['file']->getUrl()),
|
||||
function () use ($entry, $published, $parent_id) {
|
||||
if ($this->shouldUpdate($entry['page'], $published)) {
|
||||
$this->client->updatePage(
|
||||
$parent_id,
|
||||
@ -291,7 +288,7 @@ class Publisher
|
||||
foreach ($entry['page']->attachments as $attachment) {
|
||||
$this->run(
|
||||
" With attachment: $attachment[filename]",
|
||||
function() use ($published, $attachment) {
|
||||
function () use ($published, $attachment) {
|
||||
$this->client->uploadAttachment($published['id'], $attachment);
|
||||
}
|
||||
);
|
||||
|
@ -2,5 +2,4 @@
|
||||
|
||||
class ComputedRawPage extends \Todaymade\Daux\Format\Base\ComputedRawPage
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
}
|
||||
|
||||
if ($this->params['multilanguage']) {
|
||||
return ($this->file->getParent()->getParent() instanceof Root);
|
||||
return $this->file->getParent()->getParent() instanceof Root;
|
||||
}
|
||||
|
||||
return ($this->file->getParent() instanceof Root);
|
||||
return $this->file->getParent() instanceof Root;
|
||||
}
|
||||
|
||||
private function initialize()
|
||||
@ -45,13 +45,14 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
if ($multilanguage && !empty($parents)) {
|
||||
$parents = array_splice($parents, 1);
|
||||
}
|
||||
$breadcrumb_trail = array();
|
||||
$breadcrumb_trail = [];
|
||||
if (!empty($parents)) {
|
||||
foreach ($parents as $node) {
|
||||
$page = $node->getIndexPage() ?: $node->getFirstPage();
|
||||
$breadcrumb_trail[$node->getTitle()] = $page ? $page->getUrl() : '';
|
||||
}
|
||||
}
|
||||
|
||||
return $breadcrumb_trail;
|
||||
}
|
||||
|
||||
@ -95,6 +96,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
$context = ['page' => $page, 'params' => $params];
|
||||
|
||||
$template = new Template($params['templates'], $params['theme']['templates']);
|
||||
|
||||
return $template->render($this->homepage ? 'theme::home' : 'theme::content', $context);
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,6 @@ class Entry
|
||||
|
||||
public function toString()
|
||||
{
|
||||
return $this->getLevel() . " - " . $this->getId();
|
||||
return $this->getLevel() . ' - ' . $this->getId();
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,6 @@ class Processor implements DocumentProcessorInterface
|
||||
} else {
|
||||
$document->prependChild($this->render($generated->getChildren()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -184,7 +183,8 @@ class Processor implements DocumentProcessorInterface
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function setNull($object, $property) {
|
||||
protected function setNull($object, $property)
|
||||
{
|
||||
$prop = new \ReflectionProperty(get_class($object), $property);
|
||||
$prop->setAccessible(true);
|
||||
$prop->setValue($object, null);
|
||||
@ -212,6 +212,7 @@ class Processor implements DocumentProcessorInterface
|
||||
}
|
||||
|
||||
$deepCopy = new DeepCopy();
|
||||
|
||||
return $deepCopy->copy($firstClone)->children();
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,6 @@ class RootEntry extends Entry
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
throw new \RuntimeException("No Parent Exception");
|
||||
throw new \RuntimeException('No Parent Exception');
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
public function getContentTypes()
|
||||
{
|
||||
return [
|
||||
'markdown' => new ContentType($this->daux->getParams())
|
||||
'markdown' => new ContentType($this->daux->getParams()),
|
||||
];
|
||||
}
|
||||
|
||||
@ -51,15 +51,15 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
}
|
||||
|
||||
$this->runAction(
|
||||
"Copying Static assets ...",
|
||||
'Copying Static assets ...',
|
||||
$output,
|
||||
$width,
|
||||
function() use ($destination) {
|
||||
function () use ($destination) {
|
||||
GeneratorHelper::copyAssets($destination, $this->daux->local_base);
|
||||
}
|
||||
);
|
||||
|
||||
$output->writeLn("Generating ...");
|
||||
$output->writeLn('Generating ...');
|
||||
|
||||
if (!array_key_exists('search', $params['html']) || !$params['html']['search']) {
|
||||
$params['html']['search'] = $input->getOption('search');
|
||||
@ -77,7 +77,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
json_encode(['pages' => $this->indexed_pages])
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +89,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
private function strip_html_tags($text)
|
||||
{
|
||||
$text = preg_replace(
|
||||
array(
|
||||
[
|
||||
// Remove invisible content
|
||||
'@<head[^>]*?>.*?</head>@siu',
|
||||
'@<style[^>]*?>.*?</style>@siu',
|
||||
@ -109,14 +108,15 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
'@</?((form)|(button)|(fieldset)|(legend)|(input))@iu',
|
||||
'@</?((label)|(select)|(optgroup)|(option)|(textarea))@iu',
|
||||
'@</?((frameset)|(frame)|(iframe))@iu',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
|
||||
"\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0", "\n\$0",
|
||||
"\n\$0", "\n\$0",
|
||||
),
|
||||
],
|
||||
$text
|
||||
);
|
||||
|
||||
return trim(preg_replace('/\s+/', ' ', strip_tags($text)));
|
||||
}
|
||||
|
||||
@ -127,8 +127,8 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
* @param string $output_dir
|
||||
* @param \Todaymade\Daux\Config $params
|
||||
* @param OutputInterface $output
|
||||
* @param integer $width
|
||||
* @param boolean $index_pages
|
||||
* @param int $width
|
||||
* @param bool $index_pages
|
||||
* @param string $base_url
|
||||
* @throws \Exception
|
||||
*/
|
||||
@ -150,23 +150,24 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
DauxHelper::rebaseConfiguration($params, $base_url);
|
||||
} else {
|
||||
$this->runAction(
|
||||
"- " . $node->getUrl(),
|
||||
'- ' . $node->getUrl(),
|
||||
$output,
|
||||
$width,
|
||||
function() use ($node, $output_dir, $key, $params, $index_pages) {
|
||||
function () use ($node, $output_dir, $key, $params, $index_pages) {
|
||||
if ($node instanceof Raw) {
|
||||
copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$generated = $this->generateOne($node, $params);
|
||||
file_put_contents($output_dir . DIRECTORY_SEPARATOR . $key, $generated->getContent());
|
||||
if ($index_pages) {
|
||||
$this->indexed_pages[] =[
|
||||
$this->indexed_pages[] = [
|
||||
'title' => $node->getTitle(),
|
||||
'text' => utf8_encode($this->strip_html_tags($generated->getPureContent())),
|
||||
'tags' => "",
|
||||
'url' => $node->getUrl()
|
||||
'tags' => '',
|
||||
'url' => $node->getUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -191,6 +192,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
}
|
||||
|
||||
$params['request'] = $node->getUrl();
|
||||
|
||||
return ContentPage::fromFile($node, $params, $this->daux->getContentTypeHandler()->getType($node));
|
||||
}
|
||||
}
|
||||
|
@ -2,5 +2,4 @@
|
||||
|
||||
class RawPage extends \Todaymade\Daux\Format\Base\RawPage
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class Template
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function render($name, array $data = array())
|
||||
public function render($name, array $data = [])
|
||||
{
|
||||
$this->engine->addData([
|
||||
'base_url' => $data['params']['base_url'],
|
||||
@ -50,12 +50,13 @@ class Template
|
||||
|
||||
protected function registerFunctions()
|
||||
{
|
||||
$this->engine->registerFunction('get_navigation', function($tree, $path, $current_url, $base_page, $mode) {
|
||||
$this->engine->registerFunction('get_navigation', function ($tree, $path, $current_url, $base_page, $mode) {
|
||||
$nav = $this->buildNavigation($tree, $path, $current_url, $base_page, $mode);
|
||||
|
||||
return $this->renderNavigation($nav);
|
||||
});
|
||||
|
||||
$this->engine->registerFunction('get_breadcrumb_title', function($page, $base_page) {
|
||||
$this->engine->registerFunction('get_breadcrumb_title', function ($page, $base_page) {
|
||||
$title = '';
|
||||
$breadcrumb_trail = $page['breadcrumb_trail'];
|
||||
$separator = $this->getSeparator($page['breadcrumb_separator']);
|
||||
@ -69,16 +70,16 @@ class Template
|
||||
} else {
|
||||
$title .= '<a href="' . $base_page . $page['request'] . '">' . $page['title'] . '</a>';
|
||||
}
|
||||
|
||||
return $title;
|
||||
});
|
||||
}
|
||||
|
||||
private function renderNavigation($entries)
|
||||
{
|
||||
$nav = "";
|
||||
$nav = '';
|
||||
foreach ($entries as $entry) {
|
||||
if (array_key_exists('children', $entry)) {
|
||||
|
||||
$icon = '<i class="Nav__arrow"> </i>';
|
||||
|
||||
if (array_key_exists('href', $entry)) {
|
||||
@ -128,7 +129,7 @@ class Template
|
||||
];
|
||||
|
||||
if ($mode === Daux::STATIC_MODE) {
|
||||
$link .= "/index.html";
|
||||
$link .= '/index.html';
|
||||
}
|
||||
|
||||
if ($node->getIndexPage()) {
|
||||
@ -146,6 +147,7 @@ class Template
|
||||
$nav[] = $folder;
|
||||
}
|
||||
}
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ class Book
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException("Could not find the content page");
|
||||
throw new RuntimeException('Could not find the content page');
|
||||
}
|
||||
|
||||
protected function buildNavigation(Directory $tree)
|
||||
@ -51,21 +51,22 @@ class Book
|
||||
continue;
|
||||
}
|
||||
|
||||
$page_index = ($index = $node->getIndexPage())? $index : $node->getFirstPage();
|
||||
$page_index = ($index = $node->getIndexPage()) ? $index : $node->getFirstPage();
|
||||
|
||||
$nav[] = [
|
||||
'title' => $node->getTitle(),
|
||||
'href' => "#section_" . $this->getSectionId($page_index),
|
||||
'children' => $this->buildNavigation($node)
|
||||
'href' => '#section_' . $this->getSectionId($page_index),
|
||||
'children' => $this->buildNavigation($node),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
private function renderNavigation($entries)
|
||||
{
|
||||
$nav = "";
|
||||
$nav = '';
|
||||
foreach ($entries as $entry) {
|
||||
if (array_key_exists('children', $entry)) {
|
||||
if (array_key_exists('href', $entry)) {
|
||||
@ -87,9 +88,9 @@ class Book
|
||||
|
||||
protected function generateTOC()
|
||||
{
|
||||
return "<h1>Table of Contents</h1>" .
|
||||
return '<h1>Table of Contents</h1>' .
|
||||
$this->renderNavigation($this->buildNavigation($this->tree)) .
|
||||
"</div><div class=\"page-break\"> </div>";
|
||||
'</div><div class="page-break"> </div>';
|
||||
}
|
||||
|
||||
protected function generateCover()
|
||||
@ -97,7 +98,7 @@ class Book
|
||||
return "<div style='margin:4em 30% 4em 0;'>" .
|
||||
"<h1 style='font-size:40pt; margin-bottom:0;'>{$this->cover['title']}</h1>" .
|
||||
"<p><strong>{$this->cover['subject']}</strong> by {$this->cover['author']}</p>" .
|
||||
"</div><div class=\"page-break\"> </div>";
|
||||
'</div><div class="page-break"> </div>';
|
||||
}
|
||||
|
||||
protected function generatePages()
|
||||
@ -109,6 +110,7 @@ class Book
|
||||
$content .= '<section class="content">' . $page['content'] . '</section>';
|
||||
$content .= '<div class="page-break"> </div>';
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
@ -137,6 +139,6 @@ class Book
|
||||
|
||||
public function generate()
|
||||
{
|
||||
return "<!DOCTYPE html><html>" . $this->generateHead() . $this->generateBody() . "</html>";
|
||||
return '<!DOCTYPE html><html>' . $this->generateHead() . $this->generateBody() . '</html>';
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,10 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
$content,
|
||||
$this->file,
|
||||
function ($src, array $attributes, Raw $file) {
|
||||
|
||||
$content = base64_encode(file_get_contents($file->getPath()));
|
||||
$attr = '';
|
||||
foreach ($attributes as $name => $value) {
|
||||
$attr .= ' ' .$name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
|
||||
$attr .= ' ' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
|
||||
}
|
||||
|
||||
return "<img $attr src=\"data:image/png;base64,$content\"/>";
|
||||
|
@ -27,7 +27,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
public function getContentTypes()
|
||||
{
|
||||
return [
|
||||
'markdown' => new ContentType($this->daux->getParams())
|
||||
'markdown' => new ContentType($this->daux->getParams()),
|
||||
];
|
||||
}
|
||||
|
||||
@ -46,8 +46,8 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
$pdf->SetHeaderData('', 0, $params['title'], $params['tagline']);
|
||||
|
||||
// set header and footer fonts
|
||||
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
||||
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
|
||||
$pdf->setHeaderFont([PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN]);
|
||||
$pdf->setFooterFont([PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA]);
|
||||
|
||||
// set default monospaced font
|
||||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||||
@ -84,7 +84,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
$current = $this->daux->tree->getIndexPage();
|
||||
while ($current) {
|
||||
$this->runAction(
|
||||
"Generating " . $current->getTitle(),
|
||||
'Generating ' . $current->getTitle(),
|
||||
$output,
|
||||
$width,
|
||||
function () use ($book, $current, $params) {
|
||||
|
@ -17,14 +17,14 @@ class Processor
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $width;
|
||||
|
||||
/**
|
||||
* @param Daux $daux
|
||||
* @param OutputInterface $output
|
||||
* @param integer $width
|
||||
* @param int $width
|
||||
*/
|
||||
public function __construct(Daux $daux, OutputInterface $output, $width)
|
||||
{
|
||||
|
@ -38,6 +38,7 @@ class ErrorPage extends SimplePage
|
||||
];
|
||||
|
||||
$template = new Template($params['templates'], $params['theme']['templates']);
|
||||
|
||||
return $template->render('error', ['page' => $page, 'params' => $params]);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
/**
|
||||
* Class MimeType
|
||||
* @package Defr
|
||||
* @author Dennis Fridrich <fridrich.dennis@gmail.com>
|
||||
* @see http://www.php.net/mime_content_type
|
||||
*/
|
||||
@ -11,7 +10,7 @@ class MimeType
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $mimeTypes = array(
|
||||
protected static $mimeTypes = [
|
||||
'txt' => 'text/plain',
|
||||
'htm' => 'text/html',
|
||||
'html' => 'text/html',
|
||||
@ -58,7 +57,7 @@ class MimeType
|
||||
// Open Office
|
||||
'odt' => 'application/vnd.oasis.opendocument.text',
|
||||
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
|
||||
);
|
||||
];
|
||||
/**
|
||||
* @param $filename
|
||||
* @return string
|
||||
@ -73,6 +72,7 @@ class MimeType
|
||||
$finfo = finfo_open(FILEINFO_MIME);
|
||||
$mimetype = finfo_file($finfo, $filename);
|
||||
finfo_close($finfo);
|
||||
|
||||
return $mimetype;
|
||||
} else {
|
||||
return 'application/octet-stream';
|
||||
|
@ -44,7 +44,7 @@ class Server
|
||||
$page = $server->handle($_REQUEST);
|
||||
} catch (NotFoundException $e) {
|
||||
http_response_code(404);
|
||||
$page = new ErrorPage("An error occured", $e->getMessage(), $daux->getParams());
|
||||
$page = new ErrorPage('An error occured', $e->getMessage(), $daux->getParams());
|
||||
}
|
||||
|
||||
if ($page instanceof RawPage) {
|
||||
@ -53,7 +53,7 @@ class Server
|
||||
// Transfer file in 1024 byte chunks to save memory usage.
|
||||
if ($fd = fopen($page->getFile(), 'rb')) {
|
||||
while (!feof($fd)) {
|
||||
print fread($fd, 1024);
|
||||
echo fread($fd, 1024);
|
||||
}
|
||||
fclose($fd);
|
||||
}
|
||||
@ -73,7 +73,7 @@ class Server
|
||||
|
||||
// The path has a special treatment on windows, revert the slashes
|
||||
$dir = dirname($_SERVER['PHP_SELF']);
|
||||
$this->base_url = $_SERVER['HTTP_HOST'] . (DIRECTORY_SEPARATOR == "\\"? str_replace("\\", "/", $dir) : $dir);
|
||||
$this->base_url = $_SERVER['HTTP_HOST'] . (DIRECTORY_SEPARATOR == '\\' ? str_replace('\\', '/', $dir) : $dir);
|
||||
|
||||
$t = strrpos($this->base_url, '/index.php');
|
||||
if ($t != false) {
|
||||
@ -171,16 +171,17 @@ class Server
|
||||
parse_str($_SERVER['QUERY_STRING'], $_GET);
|
||||
} else {
|
||||
$_SERVER['QUERY_STRING'] = '';
|
||||
$_GET = array();
|
||||
$_GET = [];
|
||||
}
|
||||
$uri = parse_url($uri, PHP_URL_PATH);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
$uri = str_replace(array('//', '../'), '/', trim($uri, '/'));
|
||||
if ($uri == "") {
|
||||
$uri = "index_page";
|
||||
$uri = str_replace(['//', '../'], '/', trim($uri, '/'));
|
||||
if ($uri == '') {
|
||||
$uri = 'index_page';
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ class Builder
|
||||
preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $path, $m);
|
||||
|
||||
if (!isset($m[3])) {
|
||||
throw new RuntimeException("Name not found");
|
||||
throw new RuntimeException('Name not found');
|
||||
}
|
||||
|
||||
return $m[3];
|
||||
@ -137,17 +137,17 @@ class Builder
|
||||
*/
|
||||
public static function removeSortingInformations($filename)
|
||||
{
|
||||
preg_match("/^-?[0-9]*_?(.*)/", $filename, $matches);
|
||||
preg_match('/^-?[0-9]*_?(.*)/', $filename, $matches);
|
||||
|
||||
// Remove the numeric part
|
||||
// of the filename, only if
|
||||
// there is something after
|
||||
return empty($matches[1])? $matches[0] : $matches[1];
|
||||
return empty($matches[1]) ? $matches[0] : $matches[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Directory $parent
|
||||
* @param String $title
|
||||
* @param string $title
|
||||
* @return Directory
|
||||
*/
|
||||
public static function getOrCreateDir(Directory $parent, $title)
|
||||
@ -185,7 +185,7 @@ class Builder
|
||||
$title = static::getName($path);
|
||||
$uri = DauxHelper::slug($title);
|
||||
if ($parent->getConfig()['mode'] === Daux::STATIC_MODE) {
|
||||
$uri .= ".html";
|
||||
$uri .= '.html';
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,8 +193,8 @@ class Builder
|
||||
return $parent->getEntries()[$uri];
|
||||
}
|
||||
|
||||
$page = $raw? new ComputedRaw($parent, $uri) : new Content($parent, $uri);
|
||||
$page->setContent("-"); //set an almost empty content to avoid problems
|
||||
$page = $raw ? new ComputedRaw($parent, $uri) : new Content($parent, $uri);
|
||||
$page->setContent('-'); //set an almost empty content to avoid problems
|
||||
$page->setName($path);
|
||||
$page->setTitle($title);
|
||||
|
||||
|
@ -111,11 +111,17 @@ class Content extends Entry
|
||||
$lines = preg_split('/\n/', $sections[0]);
|
||||
foreach ($lines as $line) {
|
||||
$trimmed = trim($line);
|
||||
if ($trimmed == '') continue; // skip empty lines
|
||||
if ($trimmed[0] == '#') continue; // can be taken as comments
|
||||
|
||||
$re = "/^([-\\w]*)\\s*?:(.*)/";
|
||||
if (!preg_match($re, $trimmed, $parts)) break; //Break as soon as we have a line that doesn't match
|
||||
if ($trimmed == '') {
|
||||
continue;
|
||||
} // skip empty lines
|
||||
if ($trimmed[0] == '#') {
|
||||
continue;
|
||||
} // can be taken as comments
|
||||
|
||||
$re = '/^([-\\w]*)\\s*?:(.*)/';
|
||||
if (!preg_match($re, $trimmed, $parts)) {
|
||||
break;
|
||||
} //Break as soon as we have a line that doesn't match
|
||||
|
||||
$key = strtolower(trim($parts[1]));
|
||||
$value = trim($parts[2]);
|
||||
|
@ -31,9 +31,9 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($name[0] == "-") {
|
||||
if ($name[0] == '-') {
|
||||
if (is_numeric($name[1])) {
|
||||
$exploded = explode("_", $name);
|
||||
$exploded = explode('_', $name);
|
||||
$buckets['down_numeric'][abs(substr($exploded[0], 1))][$key] = $entry;
|
||||
continue;
|
||||
}
|
||||
@ -43,7 +43,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
}
|
||||
|
||||
if (is_numeric($name[0])) {
|
||||
$exploded = explode("_", $name);
|
||||
$exploded = explode('_', $name);
|
||||
$buckets['numeric'][abs($exploded[0])][$key] = $entry;
|
||||
continue;
|
||||
}
|
||||
@ -68,7 +68,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
|
||||
private function sortBucket($bucket, $final)
|
||||
{
|
||||
uasort($bucket, function(Entry $a, Entry $b) {
|
||||
uasort($bucket, function (Entry $a, Entry $b) {
|
||||
return strcasecmp($a->getName(), $b->getName());
|
||||
});
|
||||
|
||||
@ -103,7 +103,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
public function getConfig()
|
||||
{
|
||||
if (!$this->parent) {
|
||||
throw new \RuntimeException("Could not retrieve configuration. Are you sure that your tree has a Root ?");
|
||||
throw new \RuntimeException('Could not retrieve configuration. Are you sure that your tree has a Root ?');
|
||||
}
|
||||
|
||||
return $this->parent->getConfig();
|
||||
@ -139,7 +139,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
*/
|
||||
public function seekFirstPage()
|
||||
{
|
||||
if ($this instanceof Directory) {
|
||||
if ($this instanceof self) {
|
||||
$index_key = $this->getConfig()['index_key'];
|
||||
if (isset($this->children[$index_key])) {
|
||||
return $this->children[$index_key];
|
||||
@ -148,13 +148,14 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
if ($node instanceof Content) {
|
||||
return $node;
|
||||
}
|
||||
if ($node instanceof Directory
|
||||
if ($node instanceof self
|
||||
&& strpos($node->getUri(), '.') !== 0
|
||||
&& $childNode = $node->seekFirstPage() ) {
|
||||
&& $childNode = $node->seekFirstPage()) {
|
||||
return $childNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -176,14 +177,16 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
}
|
||||
|
||||
$this->setFirstPage($node);
|
||||
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
// If we can't find one we check in the sub-directories
|
||||
foreach ($this->getEntries() as $node) {
|
||||
if ($node instanceof Directory && $page = $node->getFirstPage()) {
|
||||
if ($node instanceof self && $page = $node->getFirstPage()) {
|
||||
$this->setFirstPage($page);
|
||||
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
@ -210,7 +213,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
foreach ($this->getEntries() as $node) {
|
||||
if ($node instanceof Content) {
|
||||
return true;
|
||||
} elseif ($node instanceof Directory) {
|
||||
} elseif ($node instanceof self) {
|
||||
if ($node->hasContent()) {
|
||||
return true;
|
||||
}
|
||||
@ -237,7 +240,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
/**
|
||||
* Whether a offset exists
|
||||
* @param mixed $offset An offset to check for.
|
||||
* @return boolean true on success or false on failure.
|
||||
* @return bool true on success or false on failure.
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
@ -263,7 +266,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
if (!$value instanceof Entry) {
|
||||
throw new RuntimeException("The value is not of type Entry");
|
||||
throw new RuntimeException('The value is not of type Entry');
|
||||
}
|
||||
|
||||
$this->addChild($value);
|
||||
|
@ -159,6 +159,7 @@ abstract class Entry
|
||||
}
|
||||
|
||||
$url .= $this->getUri();
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
@ -170,7 +171,7 @@ abstract class Entry
|
||||
'name' => $this->getName(),
|
||||
'uri' => $this->getUri(),
|
||||
'url' => $this->getUrl(),
|
||||
'path' => $this->path
|
||||
'path' => $this->path,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,36 @@
|
||||
<?php $this->layout('theme::layout/05_page') ?>
|
||||
<article class="Page">
|
||||
<?php if ($params['html']['date_modified']) { ?>
|
||||
<?php if ($params['html']['date_modified']) {
|
||||
?>
|
||||
<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>
|
||||
<?php } else { ?>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<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>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
<div class="s-content">
|
||||
<?= $page['content']; ?>
|
||||
</div>
|
||||
|
||||
<?php if(!empty($page['prev']) || !empty($page['next'])) { ?>
|
||||
<?php if (!empty($page['prev']) || !empty($page['next'])) {
|
||||
?>
|
||||
<nav>
|
||||
<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['next'])) { ?><li class=Pager--next><a href="<?= $base_url . $page['next']->getUrl() ?>">Next</a></li><?php } ?>
|
||||
<?php if (!empty($page['prev'])) {
|
||||
?><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>
|
||||
</nav>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
</article>
|
||||
|
||||
|
@ -5,21 +5,23 @@
|
||||
</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>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
<div class="Homepage">
|
||||
<div class="HomepageTitle container">
|
||||
<?php if ($params['tagline']) {
|
||||
echo '<h2>' . $params['tagline'] . '</h2>';
|
||||
} ?>
|
||||
echo '<h2>' . $params['tagline'] . '</h2>';
|
||||
} ?>
|
||||
</div>
|
||||
|
||||
<div class="HomepageImage container">
|
||||
<?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 class="HomepageButtons">
|
||||
@ -40,9 +42,11 @@
|
||||
<div class="HomepageContent">
|
||||
<div class="container">
|
||||
<div class="container--inner">
|
||||
<?php if ($params['html']['search']) { ?>
|
||||
<?php if ($params['html']['search']) {
|
||||
?>
|
||||
<div id="tipue_search_content" style="display:none"></div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
<div class="doc_content s-content">
|
||||
<?= $page['content']; ?>
|
||||
@ -54,23 +58,29 @@
|
||||
<div class="HomepageFooter">
|
||||
<div class="container">
|
||||
<div class="container--inner">
|
||||
<?php if (!empty($params['html']['links'])) { ?>
|
||||
<?php if (!empty($params['html']['links'])) {
|
||||
?>
|
||||
<ul class="HomepageFooter__links">
|
||||
<?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>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
<?php if (!empty($params['html']['twitter'])) { ?>
|
||||
<?php if (!empty($params['html']['twitter'])) {
|
||||
?>
|
||||
<div class="HomepageFooter__twitter">
|
||||
<?php foreach ($params['html']['twitter'] as $handle) { ?>
|
||||
<?php foreach ($params['html']['twitter'] as $handle) {
|
||||
?>
|
||||
<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; ?>&show_count=false"></iframe>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
@ -4,7 +4,9 @@
|
||||
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
|
||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
|
||||
<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="author" content="<?= $params['author']; ?>">
|
||||
<meta charset="UTF-8">
|
||||
@ -15,18 +17,20 @@
|
||||
|
||||
<!-- 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 -->
|
||||
<?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 -->
|
||||
<link href="<?= $base_url; ?>tipuesearch/tipuesearch.css" rel="stylesheet">
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<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>
|
||||
|
||||
<?php if ($params['html']['search']) { ?>
|
||||
<?php if ($params['html']['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.min.js"></script>
|
||||
@ -73,7 +78,8 @@
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?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>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
<div class="Navbar hidden-print">
|
||||
<?php $this->insert('theme::partials/navbar_content', ['params' => $params]); ?>
|
||||
@ -33,40 +35,54 @@
|
||||
|
||||
|
||||
<div class="Links">
|
||||
<?php if (!empty($params['html']['links'])) { ?>
|
||||
<?php if (!empty($params['html']['links'])) {
|
||||
?>
|
||||
<hr/>
|
||||
<?php foreach ($params['html']['links'] as $name => $url) { ?>
|
||||
<?php foreach ($params['html']['links'] as $name => $url) {
|
||||
?>
|
||||
<a href="<?= $url ?>" target="_blank"><?= $name ?></a>
|
||||
<br />
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
<?php if ($params['html']['toggle_code']) { ?>
|
||||
<?php if ($params['html']['toggle_code']) {
|
||||
?>
|
||||
<div class="CodeToggler">
|
||||
<hr/>
|
||||
<?php if ($params['html']['float']) { ?>
|
||||
<?php if ($params['html']['float']) {
|
||||
?>
|
||||
<span class="CodeToggler__text">Code blocks</span>
|
||||
<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--below">Below</button>
|
||||
<button class="Button Button--default Button--small CodeToggler__button CodeToggler__button--float">Inline</button>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<a class="CodeToggler__button CodeToggler__button--main" href="#">Show Code Blocks Inline</a><br>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
<?php if (!empty($params['html']['twitter'])) { ?>
|
||||
<?php if (!empty($params['html']['twitter'])) {
|
||||
?>
|
||||
<hr/>
|
||||
<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; ?>&show_count=false"></iframe>
|
||||
<br />
|
||||
<br />
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- For Mobile -->
|
||||
@ -76,9 +92,11 @@
|
||||
<div class="Columns__right <?= $params['html']['float'] ? 'Columns__right--float' : ''; ?>">
|
||||
|
||||
<div class="Columns__right__content">
|
||||
<?php if ($params['html']['search']) { ?>
|
||||
<?php if ($params['html']['search']) {
|
||||
?>
|
||||
<div id="tipue_search_content" style="display:none"></div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
||||
<div class="doc_content">
|
||||
<?= $this->section('content'); ?>
|
||||
|
@ -1,8 +1,10 @@
|
||||
<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">
|
||||
<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>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
} ?>
|
||||
|
@ -36,17 +36,17 @@ class LinkRendererTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
return [
|
||||
// /Widgets/Page
|
||||
['<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="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](!Widgets/Button)", "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="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](!Widgets/Button)', 'Widgets/Page.html'],
|
||||
|
||||
// /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)", "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'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,25 @@
|
||||
<?php namespace Todaymade\Daux;
|
||||
|
||||
class DauxHelperTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
public function providerGetFilenames() {
|
||||
class DauxHelperTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function providerGetFilenames()
|
||||
{
|
||||
return [
|
||||
[["Page.html", "Page"], "Page.html"],
|
||||
[["Page.html", "Page"], "Page.md"],
|
||||
[["Page.html", "Page"], "Page"],
|
||||
[["Code_Highlighting.html", "Code_Highlighting"], "05_Code_Highlighting.md"],
|
||||
[['Page.html', 'Page'], 'Page.html'],
|
||||
[['Page.html', 'Page'], 'Page.md'],
|
||||
[['Page.html', 'Page'], 'Page'],
|
||||
[['Code_Highlighting.html', 'Code_Highlighting'], '05_Code_Highlighting.md'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerGetFilenames
|
||||
*/
|
||||
public function testGetFilenames($expected, $node) {
|
||||
|
||||
public function testGetFilenames($expected, $node)
|
||||
{
|
||||
$config = new Config();
|
||||
$config['valid_content_extensions'] = ['md'];
|
||||
|
||||
$this->assertEquals($expected, DauxHelper::getFilenames($config, $node));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
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
|
||||
public function testClientOptions()
|
||||
{
|
||||
$api = new Api("http://test.com/", "user", "pass");
|
||||
$this->assertEquals("test.com", $api->getClient()->getConfig()['base_uri']->getHost());
|
||||
}
|
||||
}
|
||||
// this test supports upgrade Guzzle to version 6
|
||||
public function testClientOptions()
|
||||
{
|
||||
$api = new Api('http://test.com/', 'user', 'pass');
|
||||
$this->assertEquals('test.com', $api->getClient()->getConfig()['base_uri']->getHost());
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php namespace Todaymade\Daux\Tree;
|
||||
|
||||
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\Daux;
|
||||
|
||||
@ -8,26 +7,26 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function providerRemoveSorting()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
['01_before', 'before'],
|
||||
['-Down', 'Down'],
|
||||
["01_numeric", 'numeric'],
|
||||
["01_A_File", "A_File"],
|
||||
["A_File", "A_File"],
|
||||
["01_Continuing", "Continuing"],
|
||||
["-01_Coming", "Coming"],
|
||||
["-02_Soon", "Soon"],
|
||||
["01_Getting_Started", "Getting_Started"],
|
||||
["API_Calls", "API_Calls"],
|
||||
["200_Something_Else-Cool", "Something_Else-Cool"],
|
||||
["_5_Ways_to_Be_Happy", "5_Ways_to_Be_Happy"],
|
||||
["Before_but_after", "Before_but_after"],
|
||||
["Continuing", "Continuing"],
|
||||
["01_GitHub_Flavored_Markdown", "GitHub_Flavored_Markdown"],
|
||||
["Code_Test", "Code_Test"],
|
||||
["05_Code_Highlighting", "Code_Highlighting"],
|
||||
["1", "1"],
|
||||
);
|
||||
['01_numeric', 'numeric'],
|
||||
['01_A_File', 'A_File'],
|
||||
['A_File', 'A_File'],
|
||||
['01_Continuing', 'Continuing'],
|
||||
['-01_Coming', 'Coming'],
|
||||
['-02_Soon', 'Soon'],
|
||||
['01_Getting_Started', 'Getting_Started'],
|
||||
['API_Calls', 'API_Calls'],
|
||||
['200_Something_Else-Cool', 'Something_Else-Cool'],
|
||||
['_5_Ways_to_Be_Happy', '5_Ways_to_Be_Happy'],
|
||||
['Before_but_after', 'Before_but_after'],
|
||||
['Continuing', 'Continuing'],
|
||||
['01_GitHub_Flavored_Markdown', 'GitHub_Flavored_Markdown'],
|
||||
['Code_Test', 'Code_Test'],
|
||||
['05_Code_Highlighting', 'Code_Highlighting'],
|
||||
['1', '1'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,7 +37,8 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expected, Builder::removeSortingInformations($value));
|
||||
}
|
||||
|
||||
public function testGetOrCreateDirNew() {
|
||||
public function testGetOrCreateDirNew()
|
||||
{
|
||||
$root = new Root(new Config(), '');
|
||||
|
||||
|
||||
@ -47,10 +47,10 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($root, $dir->getParent());
|
||||
$this->assertEquals('directory', $dir->getTitle());
|
||||
$this->assertEquals('directory', $dir->getUri());
|
||||
|
||||
}
|
||||
|
||||
public function testGetOrCreateDirExisting() {
|
||||
public function testGetOrCreateDirExisting()
|
||||
{
|
||||
$root = new Root(new Config(), '');
|
||||
$directory = new Directory($root, 'directory');
|
||||
$directory->setTitle('directory');
|
||||
@ -63,7 +63,8 @@ class BuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($directory, $dir);
|
||||
}
|
||||
|
||||
public function getStaticRoot() {
|
||||
public function getStaticRoot()
|
||||
{
|
||||
$config = new Config();
|
||||
$config['mode'] = Daux::STATIC_MODE;
|
||||
$config['index_key'] = 'index.html';
|
||||
|
@ -4,7 +4,8 @@ use Todaymade\Daux\Config;
|
||||
|
||||
class ContentTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected function createContent($content) {
|
||||
protected function createContent($content)
|
||||
{
|
||||
$dir = new Directory(new Root(new Config, ''), '');
|
||||
$obj = new Content($dir, '');
|
||||
$obj->setContent($content);
|
||||
@ -14,15 +15,15 @@ class ContentTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public function providerTestAttributes()
|
||||
{
|
||||
return array(
|
||||
['This is content', [], "This is content"],
|
||||
["title: This is a simple title\n---\nThis is content\n", ['title' => 'This is a simple title'], "This is content"],
|
||||
["title: This is a simple title\ntitle :This is another title\n---\nThis is content\n", ['title' => 'This is another title'], "This is content"],
|
||||
["title: This is a simple title\nthis is not metadata\n---\nThis is content\n", ['title' => 'This is a simple title'], "This is content"],
|
||||
["title: This is only metatada, no content", [], "title: This is only metatada, no content"],
|
||||
["title: This is almost only metadata\n---\n", ["title" => "This is almost only metadata"], ""],
|
||||
return [
|
||||
['This is content', [], 'This is content'],
|
||||
["title: This is a simple title\n---\nThis is content\n", ['title' => 'This is a simple title'], 'This is content'],
|
||||
["title: This is a simple title\ntitle :This is another title\n---\nThis is content\n", ['title' => 'This is another title'], 'This is content'],
|
||||
["title: This is a simple title\nthis is not metadata\n---\nThis is content\n", ['title' => 'This is a simple title'], 'This is content'],
|
||||
['title: This is only metatada, no content', [], 'title: This is only metatada, no content'],
|
||||
["title: This is almost only metadata\n---\n", ['title' => 'This is almost only metadata'], ''],
|
||||
["# Some content\n\nhi\n```yml\nvalue: true\n```\n----\n Follow up", [], "# Some content\n\nhi\n```yml\nvalue: true\n```\n----\n Follow up"],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,24 +2,24 @@
|
||||
|
||||
use Todaymade\Daux\Config;
|
||||
|
||||
class DirectoryTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
class DirectoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function providerSort()
|
||||
{
|
||||
return array(
|
||||
array(["005_Fifth", "01_First"], ["01_First", "005_Fifth"]),
|
||||
array(["005_Fifth", "Another", "01_First"], ["01_First", "005_Fifth", "Another"]),
|
||||
array(["005_Fifth", "Another", "-Sticky", "01_First"], ["01_First", "005_Fifth", "Another", "-Sticky"]),
|
||||
array(['01_before', '-Down'], ['01_before', '-Down']),
|
||||
array(['01_before', '-Down-after', '-Down'], ['01_before', '-Down', '-Down-after']),
|
||||
array(["01_numeric", "01_before"], ["01_before", "01_numeric"]),
|
||||
array(["A_File", "01_A_File"], ["01_A_File", "A_File"]),
|
||||
array(["A_File", "01_Continuing", "-01_Coming", "-02_Soon"], ["01_Continuing", "A_File", "-01_Coming", "-02_Soon"]),
|
||||
array(["01_Getting_Started", "API_Calls", "200_Something_Else-Cool", "_5_Ways_to_Be_Happy"], ["01_Getting_Started", "200_Something_Else-Cool", "_5_Ways_to_Be_Happy", "API_Calls"]),
|
||||
array(["01_Getting_Started", "API_Calls", "index", "200_Something_Else-Cool", "_5_Ways_to_Be_Happy"], ["index", "01_Getting_Started", "200_Something_Else-Cool", "_5_Ways_to_Be_Happy", "API_Calls"]),
|
||||
array(["Before_but_after", "A_File", "Continuing"], ["A_File", "Before_but_after", "Continuing"]),
|
||||
array(["01_GitHub_Flavored_Markdown", "Code_Test", "05_Code_Highlighting"], ["01_GitHub_Flavored_Markdown", "05_Code_Highlighting", "Code_Test"]),
|
||||
);
|
||||
return [
|
||||
[['005_Fifth', '01_First'], ['01_First', '005_Fifth']],
|
||||
[['005_Fifth', 'Another', '01_First'], ['01_First', '005_Fifth', 'Another']],
|
||||
[['005_Fifth', 'Another', '-Sticky', '01_First'], ['01_First', '005_Fifth', 'Another', '-Sticky']],
|
||||
[['01_before', '-Down'], ['01_before', '-Down']],
|
||||
[['01_before', '-Down-after', '-Down'], ['01_before', '-Down', '-Down-after']],
|
||||
[['01_numeric', '01_before'], ['01_before', '01_numeric']],
|
||||
[['A_File', '01_A_File'], ['01_A_File', 'A_File']],
|
||||
[['A_File', '01_Continuing', '-01_Coming', '-02_Soon'], ['01_Continuing', 'A_File', '-01_Coming', '-02_Soon']],
|
||||
[['01_Getting_Started', 'API_Calls', '200_Something_Else-Cool', '_5_Ways_to_Be_Happy'], ['01_Getting_Started', '200_Something_Else-Cool', '_5_Ways_to_Be_Happy', 'API_Calls']],
|
||||
[['01_Getting_Started', 'API_Calls', 'index', '200_Something_Else-Cool', '_5_Ways_to_Be_Happy'], ['index', '01_Getting_Started', '200_Something_Else-Cool', '_5_Ways_to_Be_Happy', 'API_Calls']],
|
||||
[['Before_but_after', 'A_File', 'Continuing'], ['A_File', 'Before_but_after', 'Continuing']],
|
||||
[['01_GitHub_Flavored_Markdown', 'Code_Test', '05_Code_Highlighting'], ['01_GitHub_Flavored_Markdown', '05_Code_Highlighting', 'Code_Test']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,6 +44,4 @@ class DirectoryTest extends \PHPUnit_Framework_TestCase {
|
||||
|
||||
$this->assertEquals($expected, $final);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Laden…
Verwijs in nieuw issue
Block a user