More reformatting
This commit is contained in:
parent
9c13185620
commit
8cf6a7667b
16
.php_cs
16
.php_cs
@ -2,13 +2,27 @@
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->exclude('vendor')
|
||||
->exclude('templates')
|
||||
->in(__DIR__)
|
||||
;
|
||||
|
||||
return PhpCsFixer\Config::create()
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'@PHP70Migration' => true,
|
||||
'@PHP71Migration' => true,
|
||||
'@PhpCsFixer' => true,
|
||||
'explicit_string_variable' => false,
|
||||
'single_blank_line_before_namespace' => false,
|
||||
'no_short_echo_tag' => false,
|
||||
'blank_line_after_opening_tag' => false,
|
||||
'yoda_style' => false,
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'php_unit_internal_class' => false,
|
||||
'php_unit_test_class_requires_covers' => false,
|
||||
'phpdoc_align' => false,
|
||||
'multiline_whitespace_before_semicolons' => false,
|
||||
'ordered_class_elements' => ['use_trait', 'constant_public', 'constant_protected', 'constant_private', 'property_public', 'property_protected', 'property_private', 'construct', 'method']
|
||||
])
|
||||
->setFinder($finder)
|
||||
;
|
||||
|
@ -5,7 +5,7 @@ use ArrayObject;
|
||||
class BaseConfig extends ArrayObject
|
||||
{
|
||||
/**
|
||||
* Merge an array into the object
|
||||
* Merge an array into the object.
|
||||
*
|
||||
* @param array $newValues
|
||||
* @param bool $override
|
||||
@ -17,6 +17,7 @@ class BaseConfig extends ArrayObject
|
||||
// we can simply set it.
|
||||
if (!array_key_exists($key, (array) $this)) {
|
||||
$this[$key] = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php namespace Todaymade\Daux;
|
||||
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Todaymade\Daux\Daux;
|
||||
|
||||
class Cache
|
||||
{
|
||||
@ -9,7 +8,7 @@ class Cache
|
||||
|
||||
public static function getDirectory(): string
|
||||
{
|
||||
$dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "dauxio" . DIRECTORY_SEPARATOR;
|
||||
$dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'dauxio' . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (!Cache::$printed) {
|
||||
Cache::$printed = true;
|
||||
@ -21,10 +20,6 @@ class Cache
|
||||
|
||||
/**
|
||||
* Store an item in the cache for a given number of minutes.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @return void
|
||||
*/
|
||||
public static function put(string $key, string $value): void
|
||||
{
|
||||
@ -34,9 +29,6 @@ class Cache
|
||||
|
||||
/**
|
||||
* Create the file cache directory if necessary.
|
||||
*
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
protected static function ensureCacheDirectoryExists(string $path): void
|
||||
{
|
||||
@ -49,9 +41,6 @@ class Cache
|
||||
|
||||
/**
|
||||
* Remove an item from the cache.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
*/
|
||||
public static function forget(string $key): bool
|
||||
{
|
||||
@ -67,7 +56,6 @@ class Cache
|
||||
/**
|
||||
* Retrieve an item from the cache by key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get(string $key): ?string
|
||||
@ -83,13 +71,11 @@ class Cache
|
||||
|
||||
/**
|
||||
* Get the full path for the given cache key.
|
||||
*
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
protected static function path(string $key): string
|
||||
{
|
||||
$parts = array_slice(str_split($hash = sha1($key), 2), 0, 2);
|
||||
|
||||
return Cache::getDirectory() . '/' . implode('/', $parts) . '/' . $hash;
|
||||
}
|
||||
|
||||
@ -103,11 +89,11 @@ class Cache
|
||||
if (is_dir($dir)) {
|
||||
$objects = scandir($dir);
|
||||
foreach ($objects as $object) {
|
||||
if ($object != "." && $object != "..") {
|
||||
if (is_dir($dir . "/" . $object)) {
|
||||
Cache::rrmdir($dir . "/" . $object);
|
||||
if ($object != '.' && $object != '..') {
|
||||
if (is_dir($dir . '/' . $object)) {
|
||||
Cache::rrmdir($dir . '/' . $object);
|
||||
} else {
|
||||
unlink($dir . "/" . $object);
|
||||
unlink($dir . '/' . $object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php namespace Todaymade\Daux;
|
||||
|
||||
use Todaymade\Daux\Tree\Content;
|
||||
use Todaymade\Daux\Tree\Entry;
|
||||
use Todaymade\Daux\Format\Confluence\Config as ConfluenceConfig;
|
||||
use Todaymade\Daux\Format\HTML\Config as HTMLConfig;
|
||||
use Todaymade\Daux\Format\HTML\Theme as Theme;
|
||||
use Todaymade\Daux\Format\Confluence\Config as ConfluenceConfig;
|
||||
use Todaymade\Daux\Tree\Content;
|
||||
use Todaymade\Daux\Tree\Entry;
|
||||
|
||||
class Config extends BaseConfig
|
||||
{
|
||||
@ -229,6 +229,7 @@ class Config extends BaseConfig
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
return $this->getBaseUrl();
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ class ConfigBuilder
|
||||
/** @var Config */
|
||||
private $config;
|
||||
|
||||
private $configuration_override_file = null;
|
||||
private $configuration_override_file;
|
||||
|
||||
private function __construct(string $mode)
|
||||
{
|
||||
@ -23,12 +23,14 @@ class ConfigBuilder
|
||||
{
|
||||
$builder = new ConfigBuilder($mode);
|
||||
$builder->loadBaseConfiguration();
|
||||
|
||||
return $builder;
|
||||
}
|
||||
|
||||
public function with(array $values): ConfigBuilder
|
||||
{
|
||||
$this->config->merge($values);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -46,6 +48,7 @@ class ConfigBuilder
|
||||
$array = &$array[$key];
|
||||
}
|
||||
$array[array_shift($keys)] = $value;
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
@ -54,60 +57,70 @@ class ConfigBuilder
|
||||
foreach ($values as $value) {
|
||||
$this->setValue($this->config, $value[0], $value[1]);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withDocumentationDirectory($dir): ConfigBuilder
|
||||
{
|
||||
$this->config['docs_directory'] = $dir;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withValidContentExtensions(array $value): ConfigBuilder
|
||||
{
|
||||
$this->config['valid_content_extensions'] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withThemesPath($themePath): ConfigBuilder
|
||||
{
|
||||
$this->config['themes_path'] = $themePath;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withThemesDirectory($directory): ConfigBuilder
|
||||
{
|
||||
$this->config['themes_directory'] = $directory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withCache(bool $value): ConfigBuilder
|
||||
{
|
||||
$this->config['cache'] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withFormat($format): ConfigBuilder
|
||||
{
|
||||
$this->config['format'] = $format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withConfigurationOverride($file): ConfigBuilder
|
||||
{
|
||||
$this->configuration_override_file = $file;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withProcessor($value): ConfigBuilder
|
||||
{
|
||||
$this->config['processor'] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withConfluenceDelete($value): ConfigBuilder
|
||||
{
|
||||
$this->config['confluence']['delete'] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@ -146,6 +159,7 @@ class ConfigBuilder
|
||||
|
||||
/**
|
||||
* @param string $override_file
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function initializeConfiguration()
|
||||
@ -207,7 +221,7 @@ class ConfigBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* Load and validate the global configuration
|
||||
* Load and validate the global configuration.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@ -231,6 +245,7 @@ class ConfigBuilder
|
||||
/**
|
||||
* @param string $config_file
|
||||
* @param bool $optional
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function loadConfiguration($config_file, $optional = true)
|
||||
@ -251,11 +266,13 @@ class ConfigBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file requested for configuration overrides
|
||||
* Get the file requested for configuration overrides.
|
||||
*
|
||||
* @param null|string $path
|
||||
*
|
||||
* @param string|null $path
|
||||
* @return string|null the path to a file to load for configuration overrides
|
||||
* @throws Exception
|
||||
*
|
||||
* @return null|string the path to a file to load for configuration overrides
|
||||
*/
|
||||
private function getConfigurationOverride($path)
|
||||
{
|
||||
@ -273,10 +290,11 @@ class ConfigBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $path
|
||||
* @param null|string $path
|
||||
* @param string $basedir
|
||||
* @param string $type
|
||||
* @return false|null|string
|
||||
*
|
||||
* @return null|false|string
|
||||
*/
|
||||
private function findLocation($path, $basedir, $type)
|
||||
{
|
||||
@ -286,11 +304,10 @@ class ConfigBuilder
|
||||
}
|
||||
|
||||
// VFS, used only in tests
|
||||
if (substr($path, 0, 6) == "vfs://") {
|
||||
if (substr($path, 0, 6) == 'vfs://') {
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
// Check if it's relative to the current directory or an absolute path
|
||||
if (DauxHelper::is($path, $type)) {
|
||||
return DauxHelper::getAbsolutePath($path);
|
||||
|
@ -12,11 +12,11 @@ class Application extends SymfonyApplication
|
||||
$this->add(new Serve());
|
||||
$this->add(new ClearCache());
|
||||
|
||||
$app_name = "daux/daux.io";
|
||||
$app_name = 'daux/daux.io';
|
||||
|
||||
$up = '..' . DIRECTORY_SEPARATOR;
|
||||
$composer = __DIR__ . DIRECTORY_SEPARATOR . $up . $up . $up . $up . $up . 'composer.lock';
|
||||
$version = "unknown";
|
||||
$version = 'unknown';
|
||||
|
||||
if (file_exists($composer)) {
|
||||
$app = json_decode(file_get_contents($composer));
|
||||
|
@ -18,7 +18,7 @@ class ClearCache extends SymfonyCommand
|
||||
{
|
||||
$output->writeln("Clearing cache at '" . Cache::getDirectory() . "'");
|
||||
Cache::clear();
|
||||
$output->writeln("<info>Cache cleared</info>");
|
||||
$output->writeln('<info>Cache cleared</info>');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class DauxCommand extends SymfonyCommand
|
||||
if ($input->hasOption('value')) {
|
||||
$values = array_map(
|
||||
function ($value) {
|
||||
return array_map("trim", explode('=', $value));
|
||||
return array_map('trim', explode('=', $value));
|
||||
},
|
||||
$input->getOption('value')
|
||||
);
|
||||
|
@ -6,8 +6,8 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Terminal;
|
||||
use Todaymade\Daux\Daux;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
use Todaymade\Daux\Daux;
|
||||
|
||||
class Generate extends DauxCommand
|
||||
{
|
||||
@ -61,7 +61,7 @@ class Generate extends DauxCommand
|
||||
$builder = $this->prepareConfig(Daux::STATIC_MODE, $input, $output);
|
||||
$daux = new Daux($builder->build(), $output);
|
||||
|
||||
$width = (new Terminal)->getWidth();
|
||||
$width = (new Terminal())->getWidth();
|
||||
|
||||
// Instiantiate the processor if one is defined
|
||||
$this->prepareProcessor($daux, $width);
|
||||
|
@ -26,6 +26,7 @@ trait RunAction
|
||||
});
|
||||
} catch (\Exception $e) {
|
||||
$this->status($padding, '[ <fg=red>FAIL</fg=red> ]');
|
||||
|
||||
throw $e;
|
||||
}
|
||||
$this->status($padding, '[ <fg=green>OK</fg=green> ]');
|
||||
|
@ -1,14 +1,11 @@
|
||||
<?php namespace Todaymade\Daux\Console;
|
||||
|
||||
use Exception;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
use Symfony\Component\Process\ProcessUtils;
|
||||
use Symfony\Component\Console\Terminal;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
use Todaymade\Daux\Daux;
|
||||
use Todaymade\Daux\Server\Server;
|
||||
|
||||
class Serve extends DauxCommand
|
||||
{
|
||||
@ -36,7 +33,7 @@ class Serve extends DauxCommand
|
||||
|
||||
$daux = new Daux($builder->build(), $output);
|
||||
|
||||
$width = (new Terminal)->getWidth();
|
||||
$width = (new Terminal())->getWidth();
|
||||
|
||||
// Instiantiate the processor if one is defined
|
||||
$this->prepareProcessor($daux, $width);
|
||||
@ -45,7 +42,8 @@ class Serve extends DauxCommand
|
||||
$file = tmpfile();
|
||||
|
||||
if ($file === false) {
|
||||
$output->writeln("<fg=red>Failed to create temporary file for configuration</fg=red>");
|
||||
$output->writeln('<fg=red>Failed to create temporary file for configuration</fg=red>');
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -59,7 +57,7 @@ class Serve extends DauxCommand
|
||||
putenv('DAUX_EXTENSION=' . DAUX_EXTENSION);
|
||||
|
||||
$base = escapeshellarg(__DIR__ . '/../../');
|
||||
$binary = escapeshellarg((new PhpExecutableFinder)->find(false));
|
||||
$binary = escapeshellarg((new PhpExecutableFinder())->find(false));
|
||||
|
||||
echo "Daux development server started on http://{$host}:{$port}/\n";
|
||||
|
||||
|
@ -8,7 +8,7 @@ interface ContentType
|
||||
public function __construct(Config $config);
|
||||
|
||||
/**
|
||||
* Get the file extensions supported by this Content Type
|
||||
* Get the file extensions supported by this Content Type.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
@ -17,6 +17,7 @@ interface ContentType
|
||||
/**
|
||||
* @param string $raw The raw text to render
|
||||
* @param Content $node The original node we are converting
|
||||
*
|
||||
* @return string The generated output
|
||||
*/
|
||||
public function convert($raw, Content $node);
|
||||
|
@ -18,7 +18,7 @@ class ContentTypeHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all valid content file extensions
|
||||
* Get all valid content file extensions.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
@ -33,9 +33,8 @@ class ContentTypeHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ContentType able to handle this node
|
||||
* Get the ContentType able to handle this node.
|
||||
*
|
||||
* @param Content $node
|
||||
* @return ContentType
|
||||
*/
|
||||
public function getType(Content $node)
|
||||
|
@ -12,8 +12,6 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
||||
{
|
||||
/**
|
||||
* Create a new commonmark converter instance.
|
||||
*
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
|
@ -43,7 +43,8 @@ class ContentType implements \Todaymade\Daux\ContentTypes\ContentType
|
||||
|
||||
protected function doConversion($raw)
|
||||
{
|
||||
Daux::writeln("Running conversion", OutputInterface::VERBOSITY_VERBOSE);
|
||||
Daux::writeln('Running conversion', OutputInterface::VERBOSITY_VERBOSE);
|
||||
|
||||
return $this->getConverter()->convertToHtml($raw);
|
||||
}
|
||||
|
||||
@ -59,11 +60,11 @@ class ContentType implements \Todaymade\Daux\ContentTypes\ContentType
|
||||
$payload = Cache::get($cacheKey);
|
||||
|
||||
if ($can_cache && $payload) {
|
||||
Daux::writeln("Using cached version", OutputInterface::VERBOSITY_VERBOSE);
|
||||
Daux::writeln('Using cached version', OutputInterface::VERBOSITY_VERBOSE);
|
||||
}
|
||||
|
||||
if (!$can_cache || !$payload) {
|
||||
Daux::writeln($can_cache ? "Not found in the cache, generating..." : "Cache disabled, generating...", OutputInterface::VERBOSITY_VERBOSE);
|
||||
Daux::writeln($can_cache ? 'Not found in the cache, generating...' : 'Cache disabled, generating...', OutputInterface::VERBOSITY_VERBOSE);
|
||||
$payload = $this->doConversion($raw);
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,10 @@ class LinkRenderer implements InlineRendererInterface, ConfigurationAwareInterfa
|
||||
|
||||
/**
|
||||
* @param AbstractInline|Link $inline
|
||||
* @param ElementRendererInterface $htmlRenderer
|
||||
* @return HtmlElement
|
||||
*
|
||||
* @throws LinkNotFoundException
|
||||
*
|
||||
* @return HtmlElement
|
||||
*/
|
||||
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
|
||||
{
|
||||
@ -72,7 +73,7 @@ class LinkRenderer implements InlineRendererInterface, ConfigurationAwareInterfa
|
||||
} catch (LinkNotFoundException $e) {
|
||||
// For some reason, the filename could contain a # and thus the link needs to resolve to that.
|
||||
try {
|
||||
if (strlen($urlAndHash[1] ?? "") > 0) {
|
||||
if (strlen($urlAndHash[1] ?? '') > 0) {
|
||||
$file = DauxHelper::resolveInternalFile($this->daux, $url . '#' . $urlAndHash[1]);
|
||||
$url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
|
||||
$foundWithHash = true;
|
||||
@ -101,9 +102,6 @@ class LinkRenderer implements InlineRendererInterface, ConfigurationAwareInterfa
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigurationInterface $configuration
|
||||
*/
|
||||
public function setConfiguration(ConfigurationInterface $configuration)
|
||||
{
|
||||
$this->parent->setConfiguration($configuration);
|
||||
|
@ -6,11 +6,7 @@ use League\CommonMark\Cursor;
|
||||
class TableOfContents extends AbstractBlock
|
||||
{
|
||||
/**
|
||||
* Returns true if this block can contain the given block as a child node
|
||||
*
|
||||
* @param AbstractBlock $block
|
||||
*
|
||||
* @return bool
|
||||
* Returns true if this block can contain the given block as a child node.
|
||||
*/
|
||||
public function canContain(AbstractBlock $block): bool
|
||||
{
|
||||
@ -18,20 +14,13 @@ class TableOfContents extends AbstractBlock
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this is a code block
|
||||
*
|
||||
* @return bool
|
||||
* Whether this is a code block.
|
||||
*/
|
||||
public function isCode(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Cursor $cursor
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function matchesNextLine(Cursor $cursor): bool
|
||||
{
|
||||
return false;
|
||||
|
@ -6,12 +6,6 @@ use League\CommonMark\Cursor;
|
||||
|
||||
class TableOfContentsParser implements BlockParserInterface
|
||||
{
|
||||
/**
|
||||
* @param ContextInterface $context
|
||||
* @param Cursor $cursor
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function parse(ContextInterface $context, Cursor $cursor): bool
|
||||
{
|
||||
if ($cursor->isIndented()) {
|
||||
|
@ -13,6 +13,12 @@ class Daux
|
||||
|
||||
public static $output;
|
||||
|
||||
/** @var Tree\Root */
|
||||
public $tree;
|
||||
|
||||
/** @var Config */
|
||||
public $config;
|
||||
|
||||
/** @var \Todaymade\Daux\Format\Base\Generator */
|
||||
protected $generator;
|
||||
|
||||
@ -25,12 +31,6 @@ class Daux
|
||||
/** @var Processor */
|
||||
protected $processor;
|
||||
|
||||
/** @var Tree\Root */
|
||||
public $tree;
|
||||
|
||||
/** @var Config */
|
||||
public $config;
|
||||
|
||||
/** @var bool */
|
||||
private $merged_tree = false;
|
||||
|
||||
@ -38,12 +38,11 @@ class Daux
|
||||
{
|
||||
Daux::$output = $output;
|
||||
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the tree that will be used
|
||||
* Generate the tree that will be used.
|
||||
*/
|
||||
public function generateTree()
|
||||
{
|
||||
@ -94,6 +93,7 @@ class Daux
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
*
|
||||
* @deprecated Use getConfig instead
|
||||
*/
|
||||
public function getParams()
|
||||
@ -113,9 +113,6 @@ class Daux
|
||||
return $this->processor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Processor $processor
|
||||
*/
|
||||
public function setProcessor(Processor $processor)
|
||||
{
|
||||
$this->processor = $processor;
|
||||
@ -232,7 +229,7 @@ class Daux
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all content file extensions
|
||||
* Get all content file extensions.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
@ -257,7 +254,7 @@ class Daux
|
||||
/**
|
||||
* Writes a message to the output.
|
||||
*
|
||||
* @param string|array $messages The message as an array of lines or a single string
|
||||
* @param array|string $messages The message as an array of lines or a single string
|
||||
* @param bool $newline Whether to add a newline
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
*/
|
||||
@ -269,7 +266,7 @@ class Daux
|
||||
/**
|
||||
* Writes a message to the output and adds a newline at the end.
|
||||
*
|
||||
* @param string|array $messages The message as an array of lines of a single string
|
||||
* @param array|string $messages The message as an array of lines of a single string
|
||||
* @param int $options A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL
|
||||
*/
|
||||
public static function writeln($messages, $options = 0)
|
||||
|
@ -8,9 +8,8 @@ use Todaymade\Daux\Tree\Entry;
|
||||
class DauxHelper
|
||||
{
|
||||
/**
|
||||
* Set a new base_url for the configuration
|
||||
* Set a new base_url for the configuration.
|
||||
*
|
||||
* @param Config $config
|
||||
* @param string $base_url
|
||||
*/
|
||||
public static function rebaseConfiguration(Config $config, $base_url)
|
||||
@ -27,8 +26,8 @@ class DauxHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
* @param string $current_url
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function getTheme(Config $config, $current_url)
|
||||
@ -98,9 +97,10 @@ class DauxHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all '/./' and '/../' in a path, without actually checking the path
|
||||
* Remove all '/./' and '/../' in a path, without actually checking the path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getCleanPath($path)
|
||||
@ -125,8 +125,8 @@ class DauxHelper
|
||||
/**
|
||||
* Get the possible output file names for a source file.
|
||||
*
|
||||
* @param Config $config
|
||||
* @param string $part
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getFilenames(Config $config, $part)
|
||||
@ -140,11 +140,12 @@ class DauxHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate a file in the tree. Returns the file if found or false
|
||||
* Locate a file in the tree. Returns the file if found or false.
|
||||
*
|
||||
* @param Directory $tree
|
||||
* @param string $request
|
||||
* @return Tree\Content|Tree\Raw|false
|
||||
*
|
||||
* @return false|Tree\Content|Tree\Raw
|
||||
*/
|
||||
public static function getFile($tree, $request)
|
||||
{
|
||||
@ -163,6 +164,7 @@ class DauxHelper
|
||||
|
||||
if ($node == '..') {
|
||||
$tree = $tree->getParent();
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -171,6 +173,7 @@ class DauxHelper
|
||||
// node and proceed to the next url part
|
||||
if (isset($tree->getEntries()[$node])) {
|
||||
$tree = $tree->getEntries()[$node];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -178,6 +181,7 @@ class DauxHelper
|
||||
$node = DauxHelper::slug(urldecode($node));
|
||||
if (isset($tree->getEntries()[$node])) {
|
||||
$tree = $tree->getEntries()[$node];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -187,6 +191,7 @@ class DauxHelper
|
||||
foreach (static::getFilenames($tree->getConfig(), $node) as $filename) {
|
||||
if (isset($tree->getEntries()[$filename])) {
|
||||
$tree = $tree->getEntries()[$filename];
|
||||
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
@ -219,16 +224,17 @@ class DauxHelper
|
||||
* Taken from Stringy
|
||||
*
|
||||
* @param string $title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function slug($title)
|
||||
{
|
||||
// Convert to ASCII
|
||||
if (function_exists("transliterator_transliterate")) {
|
||||
$title = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC;", $title);
|
||||
if (function_exists('transliterator_transliterate')) {
|
||||
$title = transliterator_transliterate('Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC;', $title);
|
||||
}
|
||||
|
||||
$title = iconv("utf-8", "ASCII//TRANSLIT//IGNORE", $title);
|
||||
$title = iconv('utf-8', 'ASCII//TRANSLIT//IGNORE', $title);
|
||||
|
||||
// Remove unsupported characters
|
||||
$title = preg_replace('/[^\x20-\x7E]/u', '', $title);
|
||||
@ -250,6 +256,7 @@ class DauxHelper
|
||||
/**
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getRelativePath($from, $to)
|
||||
@ -276,10 +283,10 @@ class DauxHelper
|
||||
// add traversals up to first matching dir
|
||||
$padLength = (count($relPath) + $remaining - 1) * -1;
|
||||
$relPath = array_pad($relPath, $padLength, '..');
|
||||
|
||||
break;
|
||||
} else {
|
||||
//$relPath[0] = './' . $relPath[0];
|
||||
}
|
||||
//$relPath[0] = './' . $relPath[0];
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,11 +297,13 @@ class DauxHelper
|
||||
{
|
||||
if (!is_string($path)) {
|
||||
$mess = sprintf('String expected but was given %s', gettype($path));
|
||||
|
||||
throw new \InvalidArgumentException($mess);
|
||||
}
|
||||
|
||||
if (!ctype_print($path)) {
|
||||
$mess = 'Path can NOT have non-printable characters or be empty';
|
||||
|
||||
throw new \DomainException($mess);
|
||||
}
|
||||
|
||||
@ -310,6 +319,7 @@ class DauxHelper
|
||||
$parts = [];
|
||||
if (!preg_match($regExp, $path, $parts)) {
|
||||
$mess = sprintf('Path is NOT valid, was given %s', $path);
|
||||
|
||||
throw new \DomainException($mess);
|
||||
}
|
||||
|
||||
@ -333,8 +343,10 @@ class DauxHelper
|
||||
/**
|
||||
* @param Config $config
|
||||
* @param string $url
|
||||
* @return Entry
|
||||
*
|
||||
* @throws LinkNotFoundException
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public static function resolveInternalFile($config, $url)
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: onigoetz
|
||||
* Date: 06/11/15
|
||||
* Time: 20:27
|
||||
* Time: 20:27.
|
||||
*/
|
||||
namespace Todaymade\Daux\Format\Base;
|
||||
|
||||
@ -67,7 +67,6 @@ class EmbedImages
|
||||
//Get any file corresponding to the right one
|
||||
$file = DauxHelper::getFile($this->tree, $url);
|
||||
|
||||
|
||||
if ($file === false) {
|
||||
return false;
|
||||
}
|
||||
|
@ -6,15 +6,11 @@ use Todaymade\Daux\Daux;
|
||||
|
||||
interface Generator
|
||||
{
|
||||
/**
|
||||
* @param Daux $daux
|
||||
*/
|
||||
public function __construct(Daux $daux);
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
* @param int $width
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function generateAll(InputInterface $input, OutputInterface $output, $width);
|
||||
|
@ -6,8 +6,6 @@ use Todaymade\Daux\Tree\Entry;
|
||||
interface LiveGenerator extends Generator
|
||||
{
|
||||
/**
|
||||
* @param Entry $node
|
||||
* @param Config $config
|
||||
* @return \Todaymade\Daux\Format\Base\Page
|
||||
*/
|
||||
public function generateOne(Entry $node, Config $config);
|
||||
|
@ -3,14 +3,14 @@
|
||||
interface Page
|
||||
{
|
||||
/**
|
||||
* Get the converted content, without any template
|
||||
* Get the converted content, without any template.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPureContent();
|
||||
|
||||
/**
|
||||
* Get the full content
|
||||
* Get the full content.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
@ -24,7 +24,8 @@ class Api
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is public due to test purposes
|
||||
* This method is public due to test purposes.
|
||||
*
|
||||
* @return Client
|
||||
*/
|
||||
public function getClient()
|
||||
@ -39,9 +40,8 @@ class Api
|
||||
|
||||
/**
|
||||
* The standard error message from guzzle is quite poor in informations,
|
||||
* this will give little bit more sense to it and return it
|
||||
* this will give little bit more sense to it and return it.
|
||||
*
|
||||
* @param BadResponseException $e
|
||||
* @return \Exception
|
||||
*/
|
||||
protected function handleError(BadResponseException $e)
|
||||
@ -101,10 +101,11 @@ class Api
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of pages
|
||||
* Get a list of pages.
|
||||
*
|
||||
* @param int $rootPage
|
||||
* @param bool $recursive
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getList($rootPage, $recursive = false)
|
||||
@ -153,6 +154,7 @@ class Api
|
||||
* @param int $parent_id
|
||||
* @param string $title
|
||||
* @param string $content
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function createPage($parent_id, $title, $content)
|
||||
@ -224,7 +226,7 @@ class Api
|
||||
}
|
||||
|
||||
$start = max($lineNumber - 3, 0);
|
||||
$end = min($lineNumber + 2, count($lines));
|
||||
$end = min($lineNumber + 2, count($lines));
|
||||
|
||||
$maxWidth = strlen("$end");
|
||||
|
||||
@ -236,7 +238,7 @@ class Api
|
||||
$gutter = substr(' ' . (' ' . $number), -$maxWidth) . ' | ';
|
||||
|
||||
if ($number == $lineNumber) {
|
||||
$spacing = str_repeat(" ", strlen($gutter) + $column - 2);
|
||||
$spacing = str_repeat(' ', strlen($gutter) + $column - 2);
|
||||
$prepared[] = '>' . $gutter . $line . "\n " . $spacing . '^';
|
||||
} else {
|
||||
$prepared[] = ' ' . $gutter . $line;
|
||||
@ -247,9 +249,10 @@ class Api
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a page
|
||||
* Delete a page.
|
||||
*
|
||||
* @param int $page_id
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function deletePage($page_id)
|
||||
@ -267,6 +270,7 @@ class Api
|
||||
// this name is uploaded
|
||||
try {
|
||||
$url = "content/$id/child/attachment?filename=" . urlencode($attachment['filename']);
|
||||
|
||||
return json_decode($this->getClient()->get($url)->getBody(), true);
|
||||
} catch (BadResponseException $e) {
|
||||
throw $this->handleError($e);
|
||||
@ -318,7 +322,8 @@ class Api
|
||||
// the update URL is different
|
||||
if (count($result['results'])) {
|
||||
if ($this->getFileSize($attachment) == $result['results'][0]['extensions']['fileSize']) {
|
||||
$write(" ( An attachment of the same size already exists, skipping. )");
|
||||
$write(' ( An attachment of the same size already exists, skipping. )');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
$content,
|
||||
$this->file,
|
||||
function ($src, array $attributes, Entry $file) {
|
||||
|
||||
//Add the attachment for later upload
|
||||
if ($file instanceof Raw) {
|
||||
$filename = basename($file->getPath());
|
||||
@ -45,10 +44,11 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an image tag for the specified filename
|
||||
* Create an image tag for the specified filename.
|
||||
*
|
||||
* @param string $filename
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function createImageTag($filename, $attributes)
|
||||
@ -60,7 +60,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
$re = '/float:\s*?(left|right);?/';
|
||||
if (preg_match($re, $value, $matches)) {
|
||||
$img .= ' ac:align="' . $matches[1] . '"';
|
||||
$value = preg_replace($re, "", $value, 1);
|
||||
$value = preg_replace($re, '', $value, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ abstract class CodeRenderer implements BlockRendererInterface
|
||||
{
|
||||
public function escapeCDATA($content)
|
||||
{
|
||||
return str_replace("]]>", "]]]]><![CDATA[>", $content);
|
||||
return str_replace(']]>', ']]]]><![CDATA[>', $content);
|
||||
}
|
||||
|
||||
public function getHTMLElement($body, $language)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php namespace Todaymade\Daux\Format\Confluence\ContentTypes\Markdown;
|
||||
|
||||
use League\CommonMark\Environment;
|
||||
use League\CommonMark\Block\Element as BlockElement;
|
||||
use League\CommonMark\Environment;
|
||||
use League\CommonMark\Inline\Element as InlineElement;
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\ContentTypes\Markdown\TableOfContents;
|
||||
|
@ -36,8 +36,6 @@ class FencedCodeRenderer extends CodeRenderer
|
||||
protected $known_conversions = ['html' => 'html/xml', 'xml' => 'html/xml', 'js' => 'javascript'];
|
||||
|
||||
/**
|
||||
* @param AbstractBlock $block
|
||||
* @param ElementRendererInterface $htmlRenderer
|
||||
* @param bool $inTightList
|
||||
*
|
||||
* @return HtmlElement|string
|
||||
|
@ -27,7 +27,6 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
|
||||
|
||||
/**
|
||||
* @param Image $inline
|
||||
* @param ElementRendererInterface $htmlRenderer
|
||||
*
|
||||
* @return HtmlElement
|
||||
*/
|
||||
@ -49,9 +48,6 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
|
||||
return $this->parent->render($inline, $htmlRenderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigurationInterface $configuration
|
||||
*/
|
||||
public function setConfiguration(ConfigurationInterface $configuration)
|
||||
{
|
||||
$this->parent->setConfiguration($configuration);
|
||||
|
@ -8,8 +8,6 @@ use League\CommonMark\HtmlElement;
|
||||
class IndentedCodeRenderer extends CodeRenderer
|
||||
{
|
||||
/**
|
||||
* @param AbstractBlock $block
|
||||
* @param ElementRendererInterface $htmlRenderer
|
||||
* @param bool $inTightList
|
||||
*
|
||||
* @return HtmlElement
|
||||
@ -20,6 +18,6 @@ class IndentedCodeRenderer extends CodeRenderer
|
||||
throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
|
||||
}
|
||||
|
||||
return $this->getHTMLElement($block->getStringContent(), "");
|
||||
return $this->getHTMLElement($block->getStringContent(), '');
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
|
||||
{
|
||||
/**
|
||||
* @param AbstractInline|Link $inline
|
||||
* @param ElementRendererInterface $htmlRenderer
|
||||
*
|
||||
* @return HtmlElement
|
||||
*/
|
||||
|
@ -18,9 +18,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
/** @var Daux */
|
||||
protected $daux;
|
||||
|
||||
/**
|
||||
* @param Daux $daux
|
||||
*/
|
||||
public function __construct(Daux $daux)
|
||||
{
|
||||
$this->daux = $daux;
|
||||
|
@ -7,16 +7,6 @@ class Publisher
|
||||
{
|
||||
use RunAction;
|
||||
|
||||
/**
|
||||
* @var Api
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
protected $confluence;
|
||||
|
||||
/**
|
||||
* @var int terminal width
|
||||
*/
|
||||
@ -27,6 +17,16 @@ class Publisher
|
||||
*/
|
||||
public $output;
|
||||
|
||||
/**
|
||||
* @var Api
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var Config
|
||||
*/
|
||||
protected $confluence;
|
||||
|
||||
/**
|
||||
* @param $confluence
|
||||
*/
|
||||
@ -62,7 +62,7 @@ class Publisher
|
||||
);
|
||||
|
||||
$published = $this->run(
|
||||
"Create placeholder pages...",
|
||||
'Create placeholder pages...',
|
||||
function () use ($tree, $published) {
|
||||
return $this->createRecursive($this->confluence->getAncestorId(), $tree, $published);
|
||||
}
|
||||
@ -89,6 +89,7 @@ class Publisher
|
||||
if ($this->confluence->hasRootId()) {
|
||||
$published = $this->client->getPage($this->confluence->getRootId());
|
||||
$this->confluence->setAncestorId($published['ancestor_id']);
|
||||
|
||||
return $published;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@ class PublisherDelete
|
||||
protected $deletable;
|
||||
|
||||
/**
|
||||
* @var boolean should delete ?
|
||||
* @var bool should delete ?
|
||||
*/
|
||||
protected $delete;
|
||||
|
||||
@ -28,7 +28,6 @@ class PublisherDelete
|
||||
$this->delete = $delete;
|
||||
$this->client = $client;
|
||||
|
||||
|
||||
$this->deletable = [];
|
||||
}
|
||||
|
||||
@ -72,8 +71,8 @@ class PublisherDelete
|
||||
protected function displayDeletable()
|
||||
{
|
||||
$this->output->writeLn('Listing obsolete pages...');
|
||||
$this->output->writeLn("> The following pages will not be deleted, but just listed for information.");
|
||||
$this->output->writeLn("> If you want to delete these pages, you need to set the --delete flag on the command.");
|
||||
$this->output->writeLn('> The following pages will not be deleted, but just listed for information.');
|
||||
$this->output->writeLn('> If you want to delete these pages, you need to set the --delete flag on the command.');
|
||||
foreach ($this->deletable as $id => $title) {
|
||||
$this->output->writeLn("- $title");
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Config extends BaseConfig
|
||||
|
||||
return [
|
||||
'name' => 'GitHub',
|
||||
'basepath' => (strpos($url, 'https://github.com/') === 0 ? '' : 'https://github.com/') . trim($url, '/')
|
||||
'basepath' => (strpos($url, 'https://github.com/') === 0 ? '' : 'https://github.com/') . trim($url, '/'),
|
||||
];
|
||||
}
|
||||
|
||||
@ -20,11 +20,10 @@ class Config extends BaseConfig
|
||||
$edit_on = $this->getValue('edit_on');
|
||||
if (is_string($edit_on)) {
|
||||
return $this->prepareGithubUrl($edit_on);
|
||||
} else {
|
||||
$edit_on['basepath'] = rtrim($edit_on['basepath'], '/');
|
||||
|
||||
return $edit_on;
|
||||
}
|
||||
$edit_on['basepath'] = rtrim($edit_on['basepath'], '/');
|
||||
|
||||
return $edit_on;
|
||||
}
|
||||
|
||||
if ($this->hasValue('edit_on_github')) {
|
||||
|
@ -4,6 +4,10 @@ use Todaymade\Daux\Tree\Root;
|
||||
|
||||
class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
{
|
||||
/**
|
||||
* @var Template
|
||||
*/
|
||||
public $templateRenderer;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -14,11 +18,6 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
*/
|
||||
private $homepage;
|
||||
|
||||
/**
|
||||
* @var Template
|
||||
*/
|
||||
public $templateRenderer;
|
||||
|
||||
private function isHomepage(): bool
|
||||
{
|
||||
// If the current page isn't the index, no chance it is the landing page
|
||||
@ -49,6 +48,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
/**
|
||||
* @param \Todaymade\Daux\Tree\Directory[] $parents
|
||||
* @param bool $multilanguage
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getBreadcrumbTrail($parents, $multilanguage)
|
||||
@ -98,7 +98,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
'breadcrumbs' => $config->getHTML()->hasBreadcrumbs(),
|
||||
'prev' => $this->file->getPrevious(),
|
||||
'next' => $this->file->getNext(),
|
||||
'attributes' => $this->file->getAttribute()
|
||||
'attributes' => $this->file->getAttribute(),
|
||||
];
|
||||
|
||||
if ($page['breadcrumbs']) {
|
||||
@ -112,13 +112,13 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
|
||||
$context = ['page' => $page, 'config' => $config];
|
||||
|
||||
$template = "theme::content";
|
||||
$template = 'theme::content';
|
||||
if ($this->isLanding()) {
|
||||
$template = "theme::home";
|
||||
$template = 'theme::home';
|
||||
}
|
||||
|
||||
if (array_key_exists('template', $page['attributes'])) {
|
||||
$template = "theme::" . $page['attributes']['template'];
|
||||
$template = 'theme::' . $page['attributes']['template'];
|
||||
}
|
||||
|
||||
return $this->templateRenderer->render($template, $context);
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php namespace Todaymade\Daux\Format\HTML\ContentTypes\Markdown;
|
||||
|
||||
use League\CommonMark\Environment;
|
||||
use League\CommonMark\Block\Element as BlockElement;
|
||||
use League\CommonMark\Inline\Element as InlineElement;
|
||||
use League\CommonMark\Environment;
|
||||
use League\CommonMark\Event\DocumentParsedEvent;
|
||||
use League\CommonMark\Inline\Element as InlineElement;
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\ContentTypes\Markdown\TableOfContents;
|
||||
|
||||
|
@ -21,8 +21,6 @@ class FencedCodeRenderer implements BlockRendererInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AbstractBlock $block
|
||||
* @param ElementRendererInterface $htmlRenderer
|
||||
* @param bool $inTightList
|
||||
*
|
||||
* @return HtmlElement|string
|
||||
|
@ -38,6 +38,9 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
|
||||
* Relative URLs can be done using either the folder with
|
||||
* number prefix or the final name (with prefix stripped).
|
||||
* This ensures that we always use the final name when generating.
|
||||
*
|
||||
* @param mixed $url
|
||||
*
|
||||
* @throws LinkNotFoundException
|
||||
*/
|
||||
protected function getCleanUrl($url)
|
||||
@ -55,6 +58,7 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
|
||||
|
||||
try {
|
||||
$file = DauxHelper::resolveInternalFile($this->daux, $url);
|
||||
|
||||
return DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
|
||||
} catch (LinkNotFoundException $e) {
|
||||
if ($this->daux->isStatic()) {
|
||||
@ -67,11 +71,10 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
|
||||
|
||||
/**
|
||||
* @param Image $inline
|
||||
* @param ElementRendererInterface $htmlRenderer
|
||||
*
|
||||
* @return HtmlElement
|
||||
*
|
||||
* @throws LinkNotFoundException
|
||||
*
|
||||
* @return HtmlElement
|
||||
*/
|
||||
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
|
||||
{
|
||||
@ -84,9 +87,6 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
|
||||
return $this->parent->render($inline, $htmlRenderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ConfigurationInterface $configuration
|
||||
*/
|
||||
public function setConfiguration(ConfigurationInterface $configuration)
|
||||
{
|
||||
$this->config = $configuration;
|
||||
|
@ -6,7 +6,7 @@ class Entry
|
||||
{
|
||||
protected $content;
|
||||
protected $level;
|
||||
protected $parent = null;
|
||||
protected $parent;
|
||||
protected $children = [];
|
||||
|
||||
public function __construct(Heading $content)
|
||||
@ -56,7 +56,6 @@ class Entry
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entry $parent
|
||||
* @param bool $addChild
|
||||
*/
|
||||
public function setParent(Entry $parent, $addChild = true)
|
||||
@ -67,9 +66,6 @@ class Entry
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entry $child
|
||||
*/
|
||||
public function addChild(Entry $child)
|
||||
{
|
||||
$child->setParent($this, false);
|
||||
|
@ -28,11 +28,6 @@ class Processor
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentParsedEvent $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onDocumentParsed(DocumentParsedEvent $event)
|
||||
{
|
||||
$document = $event->getDocument();
|
||||
@ -48,6 +43,7 @@ class Processor
|
||||
|
||||
if ($node instanceof TableOfContents && !$event->isEntering()) {
|
||||
$tocs[] = $node;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -74,27 +70,25 @@ class Processor
|
||||
|
||||
protected function getUniqueId(Document $document, $proposed)
|
||||
{
|
||||
if ($proposed == "page_") {
|
||||
$proposed = "page_section_" . (count($document->heading_ids) + 1);
|
||||
if ($proposed == 'page_') {
|
||||
$proposed = 'page_section_' . (count($document->heading_ids) + 1);
|
||||
}
|
||||
|
||||
// Quick path, it's a unique ID
|
||||
if (!in_array($proposed, $document->heading_ids)) {
|
||||
$document->heading_ids[] = $proposed;
|
||||
|
||||
return $proposed;
|
||||
}
|
||||
|
||||
$extension = 1; // Initialize the variable at one, so on the first iteration we have 2
|
||||
do {
|
||||
$extension++;
|
||||
++$extension;
|
||||
} while (in_array("$proposed-$extension", $document->heading_ids));
|
||||
|
||||
return "$proposed-$extension";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Heading $node
|
||||
*/
|
||||
protected function ensureHeadingHasId(Document $document, Heading $node)
|
||||
{
|
||||
// If the node has an ID, no need to generate it, just check it's unique
|
||||
@ -129,9 +123,10 @@ class Processor
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a tree of the list of headings
|
||||
* Make a tree of the list of headings.
|
||||
*
|
||||
* @param Entry[] $headings
|
||||
*
|
||||
* @return RootEntry
|
||||
*/
|
||||
public function generate($headings)
|
||||
@ -147,19 +142,21 @@ class Processor
|
||||
|
||||
$parent->addChild($heading);
|
||||
$previous = $heading;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ($heading->getLevel() > $previous->getLevel()) {
|
||||
$previous->addChild($heading);
|
||||
$previous = $heading;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
//if ($heading->getLevel() == $previous->getLevel()) {
|
||||
$previous->getParent()->addChild($heading);
|
||||
$previous = $heading;
|
||||
|
||||
continue;
|
||||
//}
|
||||
}
|
||||
@ -169,6 +166,7 @@ class Processor
|
||||
|
||||
/**
|
||||
* @param Entry[] $entries
|
||||
*
|
||||
* @return ListBlock
|
||||
*/
|
||||
protected function render(array $entries)
|
||||
@ -220,7 +218,6 @@ class Processor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Heading $node
|
||||
* @return Node[]
|
||||
*/
|
||||
protected function cloneChildren(Heading $node)
|
||||
|
@ -25,6 +25,7 @@ class Renderer implements BlockRendererInterface
|
||||
}
|
||||
|
||||
$content = $htmlRenderer->renderBlocks($block->children());
|
||||
|
||||
return $this->config->templateRenderer
|
||||
->getEngine($this->config)
|
||||
->render('theme::partials/table_of_contents', ['content' => $content]);
|
||||
|
@ -16,7 +16,8 @@ use Todaymade\Daux\Tree\Raw;
|
||||
|
||||
class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
{
|
||||
use RunAction, HTMLUtils;
|
||||
use RunAction;
|
||||
use HTMLUtils;
|
||||
|
||||
/** @var Daux */
|
||||
protected $daux;
|
||||
@ -26,9 +27,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
|
||||
protected $indexed_pages = [];
|
||||
|
||||
/**
|
||||
* @param Daux $daux
|
||||
*/
|
||||
public function __construct(Daux $daux)
|
||||
{
|
||||
$config = $daux->getConfig();
|
||||
@ -93,9 +91,10 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
* script code, and embedded objects. Add line breaks around
|
||||
* block-level tags to prevent word joining after tag removal.
|
||||
* Also collapse whitespace to single space and trim result.
|
||||
* modified from: http://nadeausoftware.com/articles/2007/09/php_tip_how_strip_html_tags_web_page
|
||||
* modified from: http://nadeausoftware.com/articles/2007/09/php_tip_how_strip_html_tags_web_page.
|
||||
*
|
||||
* @param string $text
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function sanitize($text)
|
||||
@ -133,21 +132,18 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
|
||||
// Sometimes strings are detected as invalid UTF-8 and json_encode can't treat them
|
||||
// iconv can fix those strings
|
||||
$text = iconv('UTF-8', 'UTF-8//IGNORE', $text);
|
||||
|
||||
return $text;
|
||||
return iconv('UTF-8', 'UTF-8//IGNORE', $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively generate the documentation
|
||||
* Recursively generate the documentation.
|
||||
*
|
||||
* @param Directory $tree
|
||||
* @param string $output_dir
|
||||
* @param GlobalConfig $config
|
||||
* @param OutputInterface $output
|
||||
* @param int $width
|
||||
* @param bool $index_pages
|
||||
* @param string $base_url
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function generateRecursive(Directory $tree, $output_dir, GlobalConfig $config, $output, $width, $index_pages, $base_url = '')
|
||||
@ -185,7 +181,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
$this->indexed_pages[] = [
|
||||
'title' => $node->getTitle(),
|
||||
'text' => $this->sanitize($generated->getPureContent()),
|
||||
'tags' => '',
|
||||
'tags' => '',
|
||||
'url' => $node->getUrl(),
|
||||
];
|
||||
}
|
||||
@ -196,8 +192,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Entry $node
|
||||
* @param GlobalConfig $config
|
||||
* @return \Todaymade\Daux\Format\Base\Page
|
||||
*/
|
||||
public function generateOne(Entry $node, GlobalConfig $config)
|
||||
|
@ -14,7 +14,7 @@ trait HTMLUtils
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy all files from $local to $destination
|
||||
* Copy all files from $local to $destination.
|
||||
*
|
||||
* @param string $destination
|
||||
* @param string $local_base
|
||||
|
@ -55,7 +55,7 @@ class Template
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render($name, array $data = [])
|
||||
@ -196,6 +196,7 @@ class Template
|
||||
|
||||
/**
|
||||
* @param string $separator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getSeparator($separator)
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php namespace Todaymade\Daux\Format\HTMLFile;
|
||||
|
||||
use RuntimeException;
|
||||
use Todaymade\Daux\Tree\Content;
|
||||
use Todaymade\Daux\Tree\Directory;
|
||||
|
||||
@ -24,7 +23,7 @@ class Book
|
||||
|
||||
protected function getPageUrl($page)
|
||||
{
|
||||
return "file_" . str_replace('/', '_', $page->getUrl());
|
||||
return 'file_' . str_replace('/', '_', $page->getUrl());
|
||||
}
|
||||
|
||||
protected function buildNavigation(Directory $tree)
|
||||
@ -38,7 +37,7 @@ class Book
|
||||
|
||||
$nav[] = [
|
||||
'title' => $node->getTitle(),
|
||||
'href' => "#" . $this->getPageUrl($node),
|
||||
'href' => '#' . $this->getPageUrl($node),
|
||||
];
|
||||
} elseif ($node instanceof Directory) {
|
||||
if (!$node->hasContent()) {
|
||||
@ -49,7 +48,7 @@ class Book
|
||||
|
||||
$nav[] = [
|
||||
'title' => $node->getTitle(),
|
||||
'href' => "#" . $this->getPageUrl($page_index),
|
||||
'href' => '#' . $this->getPageUrl($page_index),
|
||||
'children' => $this->buildNavigation($node),
|
||||
];
|
||||
}
|
||||
@ -89,7 +88,7 @@ class Book
|
||||
|
||||
protected function generateCover()
|
||||
{
|
||||
return "<div>" .
|
||||
return '<div>' .
|
||||
"<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="PageBreak"> </div>';
|
||||
|
@ -13,7 +13,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
|
||||
// Embed images
|
||||
// We do it after generation so we can catch the images that were in html already
|
||||
$content = (new EmbedImages($this->config->getTree()))
|
||||
return (new EmbedImages($this->config->getTree()))
|
||||
->embed(
|
||||
$content,
|
||||
$this->file,
|
||||
@ -29,7 +29,5 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
||||
return "<img $attr src=\"data:image/png;base64,$content\"/>";
|
||||
}
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php namespace Todaymade\Daux\Format\HTMLFile\ContentTypes\Markdown;
|
||||
|
||||
use League\CommonMark\Environment;
|
||||
use Todaymade\Daux\Config;
|
||||
|
||||
class CommonMarkConverter extends \Todaymade\Daux\Format\HTML\ContentTypes\Markdown\CommonMarkConverter
|
||||
{
|
||||
|
@ -4,18 +4,17 @@ use League\CommonMark\ElementRendererInterface;
|
||||
use League\CommonMark\HtmlElement;
|
||||
use League\CommonMark\Inline\Element\AbstractInline;
|
||||
use League\CommonMark\Inline\Element\Link;
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\DauxHelper;
|
||||
use Todaymade\Daux\Exception\LinkNotFoundException;
|
||||
use Todaymade\Daux\Tree\Entry;
|
||||
|
||||
class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
|
||||
{
|
||||
/**
|
||||
* @param AbstractInline|Link $inline
|
||||
* @param ElementRendererInterface $htmlRenderer
|
||||
* @return HtmlElement
|
||||
*
|
||||
* @throws LinkNotFoundException
|
||||
*
|
||||
* @return HtmlElement
|
||||
*/
|
||||
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
|
||||
{
|
||||
|
@ -4,13 +4,14 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Todaymade\Daux\Console\RunAction;
|
||||
use Todaymade\Daux\Daux;
|
||||
use Todaymade\Daux\Format\HTML\Template;
|
||||
use Todaymade\Daux\Format\HTML\HTMLUtils;
|
||||
use Todaymade\Daux\Format\HTML\Template;
|
||||
use Todaymade\Daux\Format\HTMLFile\ContentTypes\Markdown\ContentType;
|
||||
|
||||
class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
{
|
||||
use RunAction, HTMLUtils;
|
||||
use RunAction;
|
||||
use HTMLUtils;
|
||||
|
||||
/** @var Daux */
|
||||
protected $daux;
|
||||
@ -18,9 +19,6 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
/** @var Template */
|
||||
protected $templateRenderer;
|
||||
|
||||
/**
|
||||
* @param Daux $daux
|
||||
*/
|
||||
public function __construct(Daux $daux)
|
||||
{
|
||||
$config = $daux->getConfig();
|
||||
@ -63,7 +61,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
||||
$data = [
|
||||
'author' => $config->getAuthor(),
|
||||
'title' => $config->getTitle(),
|
||||
'subject' => $config->getTagline()
|
||||
'subject' => $config->getTagline(),
|
||||
];
|
||||
|
||||
$book = new Book($this->daux->tree, $data);
|
||||
|
@ -11,7 +11,7 @@ class FormatDate
|
||||
$timetype = IntlDateFormatter::SHORT;
|
||||
$timezone = null;
|
||||
|
||||
if (!extension_loaded("intl")) {
|
||||
if (!extension_loaded('intl')) {
|
||||
$locale = 'en';
|
||||
$timezone = 'GMT';
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ use RuntimeException;
|
||||
class GeneratorHelper
|
||||
{
|
||||
/**
|
||||
* Remove a directory recursively
|
||||
* Remove a directory recursively.
|
||||
*
|
||||
* @param string $dir
|
||||
*/
|
||||
@ -26,7 +26,7 @@ class GeneratorHelper
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy files recursively
|
||||
* Copy files recursively.
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $destination
|
||||
|
@ -22,8 +22,6 @@ class Processor
|
||||
protected $width;
|
||||
|
||||
/**
|
||||
* @param Daux $daux
|
||||
* @param OutputInterface $output
|
||||
* @param int $width
|
||||
*/
|
||||
public function __construct(Daux $daux, OutputInterface $output, $width)
|
||||
@ -37,10 +35,8 @@ class Processor
|
||||
* With this connection point, you can transform
|
||||
* the tree as you want, move pages, modify
|
||||
* pages and even add new ones.
|
||||
*
|
||||
* @param Root $root
|
||||
*/
|
||||
public function manipulateTree(/** @scrutinizer ignore-unused */ Root $root)
|
||||
public function manipulateTree(/* @scrutinizer ignore-unused */ Root $root)
|
||||
{
|
||||
}
|
||||
|
||||
@ -48,10 +44,8 @@ class Processor
|
||||
* This connection point provides
|
||||
* a way to extend the Markdown
|
||||
* parser and renderer.
|
||||
*
|
||||
* @param Environment $environment
|
||||
*/
|
||||
public function extendCommonMarkEnvironment(/** @scrutinizer ignore-unused */ Environment $environment)
|
||||
public function extendCommonMarkEnvironment(/* @scrutinizer ignore-unused */ Environment $environment)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
use Symfony\Component\Mime\MimeTypeGuesserInterface;
|
||||
|
||||
/**
|
||||
* Guesses the mime type using the file's extension
|
||||
* Guesses the mime type using the file's extension.
|
||||
*/
|
||||
class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface
|
||||
{
|
||||
@ -22,12 +22,12 @@ class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface
|
||||
{
|
||||
$extension = pathinfo($path, PATHINFO_EXTENSION);
|
||||
|
||||
if ($extension == "css") {
|
||||
return "text/css";
|
||||
if ($extension == 'css') {
|
||||
return 'text/css';
|
||||
}
|
||||
|
||||
if ($extension == "js") {
|
||||
return "application/javascript";
|
||||
if ($extension == 'js') {
|
||||
return 'application/javascript';
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -5,8 +5,8 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Mime\MimeTypes;
|
||||
use Todaymade\Daux\Daux;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
use Todaymade\Daux\Daux;
|
||||
use Todaymade\Daux\DauxHelper;
|
||||
use Todaymade\Daux\Exception;
|
||||
use Todaymade\Daux\Format\Base\ComputedRawPage;
|
||||
@ -25,8 +25,16 @@ class Server
|
||||
*/
|
||||
private $request;
|
||||
|
||||
public function __construct(Daux $daux)
|
||||
{
|
||||
$this->daux = $daux;
|
||||
|
||||
$this->request = Request::createFromGlobals();
|
||||
$this->base_url = $this->request->getHttpHost() . $this->request->getBaseUrl() . '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Serve the documentation
|
||||
* Serve the documentation.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@ -63,25 +71,18 @@ class Server
|
||||
$server->createResponse($page)->prepare($server->request)->send();
|
||||
}
|
||||
|
||||
public function __construct(Daux $daux)
|
||||
{
|
||||
$this->daux = $daux;
|
||||
|
||||
$this->request = Request::createFromGlobals();
|
||||
$this->base_url = $this->request->getHttpHost() . $this->request->getBaseUrl() . "/";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a temporary file with the file suffix, for mime type detection.
|
||||
*
|
||||
* @param string $postfix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getTemporaryFile($postfix)
|
||||
{
|
||||
$sysFileName = tempnam(sys_get_temp_dir(), 'daux');
|
||||
if ($sysFileName === false) {
|
||||
throw new \RuntimeException("Could not create temporary file");
|
||||
throw new \RuntimeException('Could not create temporary file');
|
||||
}
|
||||
|
||||
$newFileName = $sysFileName . $postfix;
|
||||
@ -93,11 +94,10 @@ class Server
|
||||
return $newFileName;
|
||||
}
|
||||
|
||||
throw new \RuntimeException("Could not create temporary file");
|
||||
throw new \RuntimeException('Could not create temporary file');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @return Response
|
||||
*/
|
||||
public function createResponse(Page $page)
|
||||
@ -114,6 +114,7 @@ class Server
|
||||
if ($page instanceof ComputedRawPage) {
|
||||
$file = $this->getTemporaryFile($page->getFilename());
|
||||
file_put_contents($file, $page->getContent());
|
||||
|
||||
return new BinaryFileResponse($file);
|
||||
}
|
||||
|
||||
@ -129,16 +130,16 @@ class Server
|
||||
|
||||
DauxHelper::rebaseConfiguration($config, '//' . $this->base_url);
|
||||
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @return \Todaymade\Daux\Format\Base\Page
|
||||
* @throws Exception
|
||||
* @throws NotFoundException
|
||||
*
|
||||
* @return \Todaymade\Daux\Format\Base\Page
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
@ -158,11 +159,13 @@ class Server
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a request on custom themes
|
||||
* Handle a request on custom themes.
|
||||
*
|
||||
* @param string $request
|
||||
* @return \Todaymade\Daux\Format\Base\Page
|
||||
*
|
||||
* @throws NotFoundException
|
||||
*
|
||||
* @return \Todaymade\Daux\Format\Base\Page
|
||||
*/
|
||||
public function serveTheme($request)
|
||||
{
|
||||
@ -172,13 +175,15 @@ class Server
|
||||
return new RawPage($file);
|
||||
}
|
||||
|
||||
throw new NotFoundException;
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $request
|
||||
* @return \Todaymade\Daux\Format\Base\Page
|
||||
*
|
||||
* @throws NotFoundException
|
||||
*
|
||||
* @return \Todaymade\Daux\Format\Base\Page
|
||||
*/
|
||||
private function getPage($request)
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ class Builder
|
||||
'.DS_Store', 'Thumbs.db',
|
||||
];
|
||||
|
||||
protected static function isIgnored(\SplFileInfo $file, $ignore)
|
||||
protected static function isIgnored(SplFileInfo $file, $ignore)
|
||||
{
|
||||
$filename = $file->getFilename();
|
||||
|
||||
@ -34,9 +34,10 @@ class Builder
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name for a file
|
||||
* Get name for a file.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getName($path)
|
||||
@ -52,7 +53,7 @@ class Builder
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the initial tree
|
||||
* Build the initial tree.
|
||||
*
|
||||
* @param Directory $node
|
||||
* @param array $ignore
|
||||
@ -96,8 +97,6 @@ class Builder
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Directory $parent
|
||||
* @param SplFileInfo $file
|
||||
* @return Content|Raw
|
||||
*/
|
||||
public static function createContent(Directory $parent, SplFileInfo $file)
|
||||
@ -141,6 +140,7 @@ class Builder
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function removeSortingInformations($filename)
|
||||
@ -154,8 +154,8 @@ class Builder
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Directory $parent
|
||||
* @param string $title
|
||||
*
|
||||
* @return Directory
|
||||
*/
|
||||
public static function getOrCreateDir(Directory $parent, $title)
|
||||
@ -173,8 +173,8 @@ class Builder
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Directory $parent
|
||||
* @param string $path
|
||||
*
|
||||
* @return ContentAbstract
|
||||
*/
|
||||
public static function getOrCreatePage(Directory $parent, $path)
|
||||
@ -214,9 +214,7 @@ class Builder
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the tree recursively
|
||||
*
|
||||
* @param Directory $current
|
||||
* Sort the tree recursively.
|
||||
*/
|
||||
public static function sortTree(Directory $current)
|
||||
{
|
||||
@ -229,10 +227,10 @@ class Builder
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next and previous for all pages
|
||||
* Calculate next and previous for all pages.
|
||||
*
|
||||
* @param Directory $current
|
||||
* @param null|Content $prev
|
||||
*
|
||||
* @return null|Content
|
||||
*/
|
||||
public static function finalizeTree(Directory $current, $prev = null)
|
||||
|
@ -25,7 +25,7 @@ class Content extends ContentAbstract
|
||||
if ($this->manuallySetContent) {
|
||||
$content = $this->content;
|
||||
} elseif (!$this->getPath()) {
|
||||
throw new RuntimeException("Empty content");
|
||||
throw new RuntimeException('Empty content');
|
||||
} else {
|
||||
$content = file_get_contents($this->getPath());
|
||||
}
|
||||
@ -40,9 +40,6 @@ class Content extends ContentAbstract
|
||||
return $frontMatter->parse($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContent(): string
|
||||
{
|
||||
if ($this->attributes === null) {
|
||||
@ -52,9 +49,6 @@ class Content extends ContentAbstract
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
*/
|
||||
public function setContent(string $content): void
|
||||
{
|
||||
$this->manuallySetContent = true;
|
||||
@ -69,9 +63,6 @@ class Content extends ContentAbstract
|
||||
return $this->previous;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Content $previous
|
||||
*/
|
||||
public function setPrevious(Content $previous)
|
||||
{
|
||||
$this->previous = $previous;
|
||||
@ -85,9 +76,6 @@ class Content extends ContentAbstract
|
||||
return $this->next;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Content $next
|
||||
*/
|
||||
public function setNext(Content $next)
|
||||
{
|
||||
$this->next = $next;
|
||||
@ -130,10 +118,11 @@ class Content extends ContentAbstract
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one or all attributes for the content
|
||||
* Get one or all attributes for the content.
|
||||
*
|
||||
* @param string|null $key
|
||||
* @return array|mixed|null
|
||||
* @param null|string $key
|
||||
*
|
||||
* @return null|array|mixed
|
||||
*/
|
||||
public function getAttribute($key = null)
|
||||
{
|
||||
|
@ -5,17 +5,11 @@ abstract class ContentAbstract extends Entry
|
||||
/** @var string */
|
||||
protected $content;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContent(): string
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
*/
|
||||
public function setContent(string $content): void
|
||||
{
|
||||
$this->content = $content;
|
||||
|
@ -44,6 +44,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
|
||||
if ($name == 'index' || $name == '_index') {
|
||||
$buckets['index'][$key] = $entry;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -51,10 +52,12 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
if (is_numeric($name[1])) {
|
||||
$exploded = explode('_', $name);
|
||||
$buckets['down_numeric'][abs(substr($exploded[0], 1))][$key] = $entry;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$buckets['down'][$key] = $entry;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -62,16 +65,19 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
if (is_numeric($name[1])) {
|
||||
$exploded = explode('_', $name);
|
||||
$buckets['up_numeric'][abs(substr($exploded[0], 1))][$key] = $entry;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$buckets['up'][$key] = $entry;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_numeric($name[0])) {
|
||||
$exploded = explode('_', $name);
|
||||
$buckets['numeric'][abs($exploded[0])][$key] = $entry;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -124,9 +130,6 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
unset($this->children[$entry->getUri()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
*/
|
||||
public function getConfig(): Config
|
||||
{
|
||||
if (!$this->parent) {
|
||||
@ -147,9 +150,6 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Content|null
|
||||
*/
|
||||
public function getIndexPage(): ?Content
|
||||
{
|
||||
$indexPage = $this->getLocalIndexPage();
|
||||
@ -166,8 +166,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
}
|
||||
|
||||
/**
|
||||
* Seek the first available page from descendants
|
||||
* @return Content|null
|
||||
* Seek the first available page from descendants.
|
||||
*/
|
||||
public function seekFirstPage(): ?Content
|
||||
{
|
||||
@ -191,9 +190,6 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Content|null
|
||||
*/
|
||||
public function getFirstPage(): ?Content
|
||||
{
|
||||
if ($this->first_page) {
|
||||
@ -226,9 +222,6 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Content $first_page
|
||||
*/
|
||||
public function setFirstPage(Content $first_page)
|
||||
{
|
||||
$this->first_page = $first_page;
|
||||
@ -236,16 +229,15 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
|
||||
/**
|
||||
* Used when creating the navigation.
|
||||
* Hides folders without showable content
|
||||
*
|
||||
* @return bool
|
||||
* Hides folders without showable content.
|
||||
*/
|
||||
public function hasContent(): bool
|
||||
{
|
||||
foreach ($this->getEntries() as $node) {
|
||||
if ($node instanceof Content) {
|
||||
return true;
|
||||
} elseif ($node instanceof self) {
|
||||
}
|
||||
if ($node instanceof self) {
|
||||
if ($node->hasContent()) {
|
||||
return true;
|
||||
}
|
||||
@ -270,9 +262,11 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a offset exists
|
||||
* @param mixed $offset An offset to check for.
|
||||
* @return bool true on success or false on failure.
|
||||
* Whether a offset exists.
|
||||
*
|
||||
* @param mixed $offset an offset to check for
|
||||
*
|
||||
* @return bool true on success or false on failure
|
||||
*/
|
||||
public function offsetExists($offset): bool
|
||||
{
|
||||
@ -280,9 +274,11 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset to retrieve
|
||||
* @param mixed $offset The offset to retrieve.
|
||||
* @return Entry Can return all value types.
|
||||
* Offset to retrieve.
|
||||
*
|
||||
* @param mixed $offset the offset to retrieve
|
||||
*
|
||||
* @return Entry can return all value types
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
@ -290,10 +286,10 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset to set
|
||||
* @param mixed $offset The offset to assign the value to.
|
||||
* @param Entry $value The value to set.
|
||||
* @return void
|
||||
* Offset to set.
|
||||
*
|
||||
* @param mixed $offset the offset to assign the value to
|
||||
* @param Entry $value the value to set
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
@ -305,9 +301,9 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
||||
}
|
||||
|
||||
/**
|
||||
* Offset to unset
|
||||
* Offset to unset.
|
||||
*
|
||||
* @param string $offset the offset to unset
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
|
@ -23,7 +23,6 @@ abstract class Entry
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @param Directory $parent
|
||||
* @param string $uri
|
||||
* @param SplFileInfo $info
|
||||
*/
|
||||
@ -86,9 +85,6 @@ abstract class Entry
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle(string $title)
|
||||
{
|
||||
$this->title = $title;
|
||||
@ -103,7 +99,7 @@ abstract class Entry
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all parents starting with the root
|
||||
* Return all parents starting with the root.
|
||||
*
|
||||
* @return Directory[]
|
||||
*/
|
||||
@ -118,9 +114,6 @@ abstract class Entry
|
||||
return $parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Directory $parent
|
||||
*/
|
||||
protected function setParent(Directory $parent)
|
||||
{
|
||||
if ($this->parent) {
|
||||
@ -140,9 +133,7 @@ abstract class Entry
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to the file from the root of the documentation
|
||||
*
|
||||
* @return string
|
||||
* Get the path to the file from the root of the documentation.
|
||||
*/
|
||||
public function getRelativePath(): string
|
||||
{
|
||||
@ -154,17 +145,11 @@ abstract class Entry
|
||||
return substr($this->path, strlen($root->getPath()) + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SplFileInfo
|
||||
*/
|
||||
public function getFileinfo(): SplFileInfo
|
||||
{
|
||||
return $this->info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl(): string
|
||||
{
|
||||
$url = '';
|
||||
|
@ -11,7 +11,7 @@ class Root extends Directory
|
||||
protected $activeNode;
|
||||
|
||||
/**
|
||||
* The root doesn't have a parent
|
||||
* The root doesn't have a parent.
|
||||
*/
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
@ -21,17 +21,11 @@ class Root extends Directory
|
||||
$this->path = $config->getDocumentationDirectory();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Config
|
||||
*/
|
||||
public function getConfig(): Config
|
||||
{
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
*/
|
||||
public function setConfig(Config $config)
|
||||
{
|
||||
$this->config = $config;
|
||||
|
@ -21,8 +21,8 @@ $loader = loadApp();
|
||||
// find the daux processor extensions
|
||||
if ($loader) {
|
||||
$ext = __DIR__ . '/../daux';
|
||||
if (is_dir(getcwd() . "/daux")) {
|
||||
$ext = getcwd() . "/daux";
|
||||
if (is_dir(getcwd() . '/daux')) {
|
||||
$ext = getcwd() . '/daux';
|
||||
}
|
||||
|
||||
$env = getenv('DAUX_EXTENSION');
|
||||
@ -32,5 +32,5 @@ if ($loader) {
|
||||
|
||||
define('DAUX_EXTENSION', $ext);
|
||||
|
||||
$loader->setPsr4("Todaymade\\Daux\\Extension\\", $ext);
|
||||
$loader->setPsr4('Todaymade\\Daux\\Extension\\', $ext);
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
|
||||
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
use Todaymade\Daux\DauxHelper;
|
||||
use Todaymade\Daux\Tree\Builder;
|
||||
use Todaymade\Daux\Tree\Root;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LinkRendererTest extends TestCase
|
||||
{
|
||||
@ -45,6 +45,10 @@ class LinkRendererTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider providerRenderLink
|
||||
*
|
||||
* @param mixed $expected
|
||||
* @param mixed $string
|
||||
* @param mixed $current
|
||||
*/
|
||||
public function testRenderLink($expected, $string, $current)
|
||||
{
|
||||
@ -64,11 +68,10 @@ class LinkRendererTest extends TestCase
|
||||
->withDocumentationDirectory($root->url())
|
||||
->withValidContentExtensions(['md'])
|
||||
->with([
|
||||
'base_url' => ''
|
||||
'base_url' => '',
|
||||
])
|
||||
->build();
|
||||
|
||||
|
||||
$tree = new Root($config);
|
||||
Builder::build($tree, []);
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php namespace Todaymade\Daux;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
|
||||
class DauxHelperTest extends TestCase
|
||||
{
|
||||
@ -17,6 +16,9 @@ class DauxHelperTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider providerGetFilenames
|
||||
*
|
||||
* @param mixed $expected
|
||||
* @param mixed $node
|
||||
*/
|
||||
public function testGetFilenames($expected, $node)
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace Todaymade\Daux\Format\HTML;
|
||||
|
||||
use Todaymade\Daux\Config as MainConfig;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Todaymade\Daux\Config as MainConfig;
|
||||
|
||||
class ConfigTest extends TestCase
|
||||
{
|
||||
@ -34,13 +34,16 @@ class ConfigTest extends TestCase
|
||||
// Support any provider
|
||||
[
|
||||
['edit_on' => ['name' => 'Bitbucket', 'basepath' => 'https://bitbucket.org/dauxio/daux.io/src/master/docs/']],
|
||||
['name' => 'Bitbucket', 'basepath' => 'https://bitbucket.org/dauxio/daux.io/src/master/docs']
|
||||
]
|
||||
['name' => 'Bitbucket', 'basepath' => 'https://bitbucket.org/dauxio/daux.io/src/master/docs'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerEditOn
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $expected
|
||||
*/
|
||||
public function testEditOn($value, $expected)
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php namespace Todaymade\Daux\Format\HTML\Test;
|
||||
|
||||
use Todaymade\Daux\Config as MainConfig;
|
||||
use \Todaymade\Daux\Format\HTML\ContentTypes\Markdown\CommonMarkConverter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Todaymade\Daux\Config as MainConfig;
|
||||
use Todaymade\Daux\Format\HTML\ContentTypes\Markdown\CommonMarkConverter;
|
||||
|
||||
class Engine
|
||||
{
|
||||
@ -16,7 +16,7 @@ class Template
|
||||
{
|
||||
public function getEngine()
|
||||
{
|
||||
return new Engine;
|
||||
return new Engine();
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,8 +24,8 @@ class TableOfContentsTest extends TestCase
|
||||
{
|
||||
public function getConfig()
|
||||
{
|
||||
$config = new MainConfig;
|
||||
$config->templateRenderer = new Template;
|
||||
$config = new MainConfig();
|
||||
$config->templateRenderer = new Template();
|
||||
|
||||
return ['daux' => $config];
|
||||
}
|
||||
@ -42,7 +42,7 @@ class TableOfContentsTest extends TestCase
|
||||
$converter = new CommonMarkConverter($this->getConfig());
|
||||
|
||||
$source = "[TOC]\n# Title";
|
||||
$expected = <<<EXPECTED
|
||||
$expected = <<<'EXPECTED'
|
||||
<ul class="TableOfContents">
|
||||
<li>
|
||||
<p><a href="#page_Title">Title</a></p>
|
||||
@ -60,7 +60,7 @@ EXPECTED;
|
||||
$converter = new CommonMarkConverter($this->getConfig());
|
||||
|
||||
$source = "[TOC]\n# 基础操作\n# 操作基础";
|
||||
$expected = <<<EXPECTED
|
||||
$expected = <<<'EXPECTED'
|
||||
<ul class="TableOfContents">
|
||||
<li>
|
||||
<p><a href="#page_ji_chu_cao_zuo">基础操作</a></p>
|
||||
@ -82,7 +82,7 @@ EXPECTED;
|
||||
$converter = new CommonMarkConverter($this->getConfig());
|
||||
|
||||
$source = "[TOC]\n# Test\n# Test";
|
||||
$expected = <<<EXPECTED
|
||||
$expected = <<<'EXPECTED'
|
||||
<ul class="TableOfContents">
|
||||
<li>
|
||||
<p><a href="#page_Test">Test</a></p>
|
||||
@ -104,7 +104,7 @@ EXPECTED;
|
||||
$converter = new CommonMarkConverter($this->getConfig());
|
||||
|
||||
$source = "[TOC]\n# TEST : Test";
|
||||
$expected = <<<EXPECTED
|
||||
$expected = <<<'EXPECTED'
|
||||
<ul class="TableOfContents">
|
||||
<li>
|
||||
<p><a href="#page_TEST_Test">TEST : Test</a></p>
|
||||
|
@ -2,20 +2,17 @@
|
||||
namespace Todaymade\Daux\Format\Template;
|
||||
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
use Todaymade\Daux\Daux;
|
||||
use Todaymade\Daux\DauxHelper;
|
||||
use Todaymade\Daux\Format\HTML\Template;
|
||||
use Todaymade\Daux\Tree\Builder;
|
||||
use Todaymade\Daux\Tree\Entry;
|
||||
use Todaymade\Daux\Tree\Root;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Class TranslateTest
|
||||
*
|
||||
* @package Todaymade\Daux\Format\Template
|
||||
* Class TranslateTest.
|
||||
*/
|
||||
class TranslateTest extends TestCase
|
||||
{
|
||||
@ -36,7 +33,6 @@ class TranslateTest extends TestCase
|
||||
->withValidContentExtensions(['md'])
|
||||
->build();
|
||||
|
||||
|
||||
$tree = new Root($config);
|
||||
Builder::build($tree, []);
|
||||
|
||||
@ -74,22 +70,22 @@ class TranslateTest extends TestCase
|
||||
'language' => $language,
|
||||
],
|
||||
'html' => [
|
||||
'search' => '',
|
||||
'toggle_code' => false,
|
||||
'piwik_analytics' => '',
|
||||
'search' => '',
|
||||
'toggle_code' => false,
|
||||
'piwik_analytics' => '',
|
||||
'google_analytics' => '',
|
||||
],
|
||||
'theme' => [
|
||||
'js' => [''],
|
||||
'css' => [''],
|
||||
'fonts' => [''],
|
||||
'favicon' => '',
|
||||
'js' => [''],
|
||||
'css' => [''],
|
||||
'fonts' => [''],
|
||||
'favicon' => '',
|
||||
'templates' => 'name',
|
||||
],
|
||||
'strings' => [
|
||||
'en' => ['Link_previous' => 'Previous',],
|
||||
'it' => ['Link_previous' => 'Pagina precedente',],
|
||||
]
|
||||
'en' => ['Link_previous' => 'Previous'],
|
||||
'it' => ['Link_previous' => 'Pagina precedente'],
|
||||
],
|
||||
]);
|
||||
|
||||
$config->setCurrentPage(DauxHelper::getFile($config->getTree(), $current));
|
||||
|
@ -1,12 +1,12 @@
|
||||
<?php namespace Todaymade\Daux\Server;
|
||||
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Todaymade\Daux\Format\HTML\RawPage;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
use Todaymade\Daux\Daux;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use Todaymade\Daux\Format\HTML\RawPage;
|
||||
|
||||
class ServerTest extends TestCase
|
||||
{
|
||||
@ -16,11 +16,10 @@ class ServerTest extends TestCase
|
||||
'index.md' => 'first page',
|
||||
'Page.md' => 'another page',
|
||||
'somefile.css' => 'body {}',
|
||||
'22.png' => ''
|
||||
'22.png' => '',
|
||||
];
|
||||
$root = vfsStream::setup('root', null, $structure);
|
||||
|
||||
|
||||
$config = ConfigBuilder::withMode(Daux::LIVE_MODE)
|
||||
->withDocumentationDirectory($root->url())
|
||||
->build();
|
||||
@ -34,6 +33,6 @@ class ServerTest extends TestCase
|
||||
$server = new Server($daux);
|
||||
$response = $server->createResponse($page)->prepare(Request::createFromGlobals());
|
||||
|
||||
$this->assertEquals("text/css", $response->headers->get('Content-Type'));
|
||||
$this->assertEquals('text/css', $response->headers->get('Content-Type'));
|
||||
}
|
||||
}
|
||||
|
@ -3,9 +3,8 @@ namespace Todaymade\Daux\Tree;
|
||||
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
use Todaymade\Daux\Daux;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
|
||||
class BuilderIntegrationTest extends TestCase
|
||||
{
|
||||
|
@ -2,10 +2,8 @@
|
||||
namespace Todaymade\Daux\Tree;
|
||||
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
use Todaymade\Daux\Daux;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
|
||||
class BuilderTest extends TestCase
|
||||
{
|
||||
@ -37,6 +35,9 @@ class BuilderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider providerRemoveSorting
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $expected
|
||||
*/
|
||||
public function testRemoveSorting($value, $expected)
|
||||
{
|
||||
@ -85,12 +86,17 @@ class BuilderTest extends TestCase
|
||||
// File, Url, Uri, Title
|
||||
['A Page.md', 'dir/A_Page.html', 'A_Page.html', 'A Page'],
|
||||
['Page#1.md', 'dir/Page1.html', 'Page1.html', 'Page#1'],
|
||||
['你好世界.md', 'dir/ni_hao_shi_jie.html', 'ni_hao_shi_jie.html', '你好世界']
|
||||
['你好世界.md', 'dir/ni_hao_shi_jie.html', 'ni_hao_shi_jie.html', '你好世界'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider providerCreatePage
|
||||
*
|
||||
* @param mixed $file
|
||||
* @param mixed $url
|
||||
* @param mixed $uri
|
||||
* @param mixed $title
|
||||
*/
|
||||
public function testGetOrCreatePage($file, $url, $uri, $title)
|
||||
{
|
||||
@ -164,7 +170,7 @@ class BuilderTest extends TestCase
|
||||
'Page.md' => 'another page',
|
||||
'Button.md' => 'another page',
|
||||
'你好世界.md' => 'another page',
|
||||
'22.png' => ''
|
||||
'22.png' => '',
|
||||
];
|
||||
$root = vfsStream::setup('root', null, $structure);
|
||||
|
||||
@ -188,8 +194,8 @@ class BuilderTest extends TestCase
|
||||
'folder' => [
|
||||
'index.md' => "---\ntitle: new Title\n---\nThe content",
|
||||
'Page.md' => 'another page',
|
||||
'Button.md' => 'another page'
|
||||
]
|
||||
'Button.md' => 'another page',
|
||||
],
|
||||
];
|
||||
$root = vfsStream::setup('root', null, $structure);
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
namespace Todaymade\Daux\Tree;
|
||||
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
|
||||
class ContentTest extends TestCase
|
||||
{
|
||||
@ -31,6 +31,10 @@ class ContentTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider providerTestAttributes
|
||||
*
|
||||
* @param mixed $content
|
||||
* @param mixed $attributes
|
||||
* @param mixed $finalContent
|
||||
*/
|
||||
public function testAttributes($content, $attributes, $finalContent)
|
||||
{
|
||||
|
@ -1,9 +1,8 @@
|
||||
<?php
|
||||
namespace Todaymade\Daux\Tree;
|
||||
|
||||
use Todaymade\Daux\Daux;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Todaymade\Daux\ConfigBuilder;
|
||||
|
||||
class DirectoryTest extends TestCase
|
||||
{
|
||||
@ -28,6 +27,9 @@ class DirectoryTest extends TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider providerSort
|
||||
*
|
||||
* @param mixed $list
|
||||
* @param mixed $expected
|
||||
*/
|
||||
public function testSort($list, $expected)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user