Reformat
This commit is contained in:
parent
684267b47c
commit
9c13185620
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@ static
|
|||||||
/vendor
|
/vendor
|
||||||
/build
|
/build
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
.php_cs.cache
|
||||||
|
|
||||||
/prettier.config.js
|
/prettier.config.js
|
||||||
/.eslintrc.js
|
/.eslintrc.js
|
||||||
|
14
.php_cs
Normal file
14
.php_cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$finder = PhpCsFixer\Finder::create()
|
||||||
|
->exclude('vendor')
|
||||||
|
->in(__DIR__)
|
||||||
|
;
|
||||||
|
|
||||||
|
return PhpCsFixer\Config::create()
|
||||||
|
->setRules([
|
||||||
|
'@PSR2' => true,
|
||||||
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
|
])
|
||||||
|
->setFinder($finder)
|
||||||
|
;
|
@ -46,6 +46,8 @@
|
|||||||
"mikey179/vfsstream": "^1.6"
|
"mikey179/vfsstream": "^1.6"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "build/phpunit"
|
"test": "build/phpunit",
|
||||||
|
"lint": "build/php-cs-fixer fix --config=.php_cs --dry-run -v",
|
||||||
|
"lint:fix": "build/php-cs-fixer fix --config=.php_cs"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use Todaymade\Daux\Daux;
|
|||||||
|
|
||||||
class Cache
|
class Cache
|
||||||
{
|
{
|
||||||
static $printed = false;
|
public static $printed = false;
|
||||||
|
|
||||||
public static function getDirectory(): string
|
public static function getDirectory(): string
|
||||||
{
|
{
|
||||||
@ -109,7 +109,6 @@ class Cache
|
|||||||
} else {
|
} else {
|
||||||
unlink($dir . "/" . $object);
|
unlink($dir . "/" . $object);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rmdir($dir);
|
rmdir($dir);
|
||||||
|
163
libs/Config.php
163
libs/Config.php
@ -8,91 +8,113 @@ use Todaymade\Daux\Format\Confluence\Config as ConfluenceConfig;
|
|||||||
|
|
||||||
class Config extends BaseConfig
|
class Config extends BaseConfig
|
||||||
{
|
{
|
||||||
public function getTitle() {
|
public function getTitle()
|
||||||
|
{
|
||||||
return $this->getValue('title');
|
return $this->getValue('title');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasAuthor(): bool {
|
public function hasAuthor(): bool
|
||||||
|
{
|
||||||
return $this->hasValue('author');
|
return $this->hasValue('author');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAuthor() {
|
public function getAuthor()
|
||||||
|
{
|
||||||
return $this->getValue('author');
|
return $this->getValue('author');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasTagline(): bool {
|
public function hasTagline(): bool
|
||||||
|
{
|
||||||
return $this->hasValue('tagline');
|
return $this->hasValue('tagline');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTagline() {
|
public function getTagline()
|
||||||
|
{
|
||||||
return $this->getValue('tagline');
|
return $this->getValue('tagline');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCurrentPage() {
|
public function getCurrentPage()
|
||||||
|
{
|
||||||
return $this->getValue('current_page');
|
return $this->getValue('current_page');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setCurrentPage(Content $entry) {
|
public function setCurrentPage(Content $entry)
|
||||||
|
{
|
||||||
$this->setValue('current_page', $entry);
|
$this->setValue('current_page', $entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDocumentationDirectory() {
|
public function getDocumentationDirectory()
|
||||||
|
{
|
||||||
return $this->getValue('docs_directory');
|
return $this->getValue('docs_directory');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getThemesDirectory() {
|
public function getThemesDirectory()
|
||||||
|
{
|
||||||
return $this->getValue('themes_directory');
|
return $this->getValue('themes_directory');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getThemesPath() {
|
public function getThemesPath()
|
||||||
|
{
|
||||||
return $this->getValue('themes_path');
|
return $this->getValue('themes_path');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormat() {
|
public function getFormat()
|
||||||
|
{
|
||||||
return $this->getValue('format');
|
return $this->getValue('format');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasTimezone(): bool {
|
public function hasTimezone(): bool
|
||||||
|
{
|
||||||
return isset($this['timezone']);
|
return isset($this['timezone']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTimezone() {
|
public function getTimezone()
|
||||||
|
{
|
||||||
return $this->getValue('timezone');
|
return $this->getValue('timezone');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTree() {
|
public function getTree()
|
||||||
|
{
|
||||||
return $this->getValue('tree');
|
return $this->getValue('tree');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTree($tree) {
|
public function setTree($tree)
|
||||||
|
{
|
||||||
$this->setValue('tree', $tree);
|
$this->setValue('tree', $tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isMultilanguage(): bool {
|
public function isMultilanguage(): bool
|
||||||
|
{
|
||||||
return $this->hasValue('languages') && !empty($this->getValue('languages'));
|
return $this->hasValue('languages') && !empty($this->getValue('languages'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLanguages(): array {
|
public function getLanguages(): array
|
||||||
|
{
|
||||||
return $this->getValue('languages');
|
return $this->getValue('languages');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLanguage(): string {
|
public function getLanguage(): string
|
||||||
|
{
|
||||||
return $this->getValue('language');
|
return $this->getValue('language');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMode() {
|
public function getMode()
|
||||||
|
{
|
||||||
return $this->getValue('mode');
|
return $this->getValue('mode');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isLive() {
|
public function isLive()
|
||||||
|
{
|
||||||
return $this->getValue('mode') == Daux::LIVE_MODE;
|
return $this->getValue('mode') == Daux::LIVE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isStatic() {
|
public function isStatic()
|
||||||
|
{
|
||||||
return $this->getValue('mode') == Daux::STATIC_MODE;
|
return $this->getValue('mode') == Daux::STATIC_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shouldInheritIndex() {
|
public function shouldInheritIndex()
|
||||||
|
{
|
||||||
// As the global configuration is always present, we
|
// As the global configuration is always present, we
|
||||||
// need to test for the existence of the legacy value
|
// need to test for the existence of the legacy value
|
||||||
// first. Then use the current value.
|
// first. Then use the current value.
|
||||||
@ -103,35 +125,43 @@ class Config extends BaseConfig
|
|||||||
return $this['html']['inherit_index'];
|
return $this['html']['inherit_index'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIndexKey() {
|
public function getIndexKey()
|
||||||
|
{
|
||||||
return $this->getValue('mode') == Daux::STATIC_MODE ? 'index.html' : 'index';
|
return $this->getValue('mode') == Daux::STATIC_MODE ? 'index.html' : 'index';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProcessor() {
|
public function getProcessor()
|
||||||
|
{
|
||||||
return $this->getValue('processor');
|
return $this->getValue('processor');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfluenceConfiguration(): ConfluenceConfig {
|
public function getConfluenceConfiguration(): ConfluenceConfig
|
||||||
|
{
|
||||||
return new ConfluenceConfig($this->hasValue('confluence') ? $this->getValue('confluence') : []);
|
return new ConfluenceConfig($this->hasValue('confluence') ? $this->getValue('confluence') : []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHTML(): HTMLConfig {
|
public function getHTML(): HTMLConfig
|
||||||
|
{
|
||||||
return new HTMLConfig($this->hasValue('html') ? $this->getValue('html') : []);
|
return new HTMLConfig($this->hasValue('html') ? $this->getValue('html') : []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTheme(): ?Theme {
|
public function getTheme(): ?Theme
|
||||||
|
{
|
||||||
return $this->hasValue('theme') ? new Theme($this->getValue('theme')) : null;
|
return $this->hasValue('theme') ? new Theme($this->getValue('theme')) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidContentExtensions() {
|
public function getValidContentExtensions()
|
||||||
|
{
|
||||||
return $this->getValue('valid_content_extensions');
|
return $this->getValue('valid_content_extensions');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setValidContentExtensions(array $value) {
|
public function setValidContentExtensions(array $value)
|
||||||
|
{
|
||||||
$this->setValue('valid_content_extensions', $value);
|
$this->setValue('valid_content_extensions', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canCache() {
|
public function canCache()
|
||||||
|
{
|
||||||
if ($this->hasValue('cache')) {
|
if ($this->hasValue('cache')) {
|
||||||
return $this->getValue('cache');
|
return $this->getValue('cache');
|
||||||
}
|
}
|
||||||
@ -139,7 +169,8 @@ class Config extends BaseConfig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCacheKey() {
|
public function getCacheKey()
|
||||||
|
{
|
||||||
$cloned = [];
|
$cloned = [];
|
||||||
foreach ($this as $key => $value) {
|
foreach ($this as $key => $value) {
|
||||||
$cloned[$key] = ($value instanceof Entry) ? $value->dump() : $value;
|
$cloned[$key] = ($value instanceof Entry) ? $value->dump() : $value;
|
||||||
@ -148,40 +179,48 @@ class Config extends BaseConfig
|
|||||||
return sha1(json_encode($cloned));
|
return sha1(json_encode($cloned));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasTranslationKey($language, $key): bool {
|
public function hasTranslationKey($language, $key): bool
|
||||||
|
{
|
||||||
return array_key_exists($language, $this['strings']) && array_key_exists($key, $this['strings'][$language]);
|
return array_key_exists($language, $this['strings']) && array_key_exists($key, $this['strings'][$language]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTranslationKey($language, $key) {
|
public function getTranslationKey($language, $key)
|
||||||
|
{
|
||||||
return $this['strings'][$language][$key];
|
return $this['strings'][$language][$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasImage(): bool {
|
public function hasImage(): bool
|
||||||
|
{
|
||||||
return $this->hasValue('image');
|
return $this->hasValue('image');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImage() {
|
public function getImage()
|
||||||
|
{
|
||||||
return $this->getValue('image');
|
return $this->getValue('image');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setImage($value) {
|
public function setImage($value)
|
||||||
|
{
|
||||||
$this->setValue('image', $value);
|
$this->setValue('image', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocalBase() {
|
public function getLocalBase()
|
||||||
|
{
|
||||||
return $this->getValue('local_base');
|
return $this->getValue('local_base');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplates() {
|
public function getTemplates()
|
||||||
|
{
|
||||||
return $this->getValue('templates');
|
return $this->getValue('templates');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBaseUrl() {
|
public function getBaseUrl()
|
||||||
|
{
|
||||||
return $this->getValue('base_url');
|
return $this->getValue('base_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBasePage() {
|
public function getBasePage()
|
||||||
|
{
|
||||||
if ($this->isLive()) {
|
if ($this->isLive()) {
|
||||||
$value = '//' . $this->getBaseUrl();
|
$value = '//' . $this->getBaseUrl();
|
||||||
if (!$this['live']['clean_urls']) {
|
if (!$this['live']['clean_urls']) {
|
||||||
@ -193,59 +232,73 @@ class Config extends BaseConfig
|
|||||||
return $this->getBaseUrl();
|
return $this->getBaseUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasEntryPage(): bool {
|
public function hasEntryPage(): bool
|
||||||
|
{
|
||||||
return $this->hasValue('entry_page') && !empty($this->getValue('entry_page'));
|
return $this->hasValue('entry_page') && !empty($this->getValue('entry_page'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEntryPage() {
|
public function getEntryPage()
|
||||||
|
{
|
||||||
return $this->getValue('entry_page');
|
return $this->getValue('entry_page');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setEntryPage($value) {
|
public function setEntryPage($value)
|
||||||
|
{
|
||||||
$this->setValue('entry_page', $value);
|
$this->setValue('entry_page', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasRequest(): bool {
|
public function hasRequest(): bool
|
||||||
|
{
|
||||||
return $this->hasValue('request') && !empty($this->getValue('request'));
|
return $this->hasValue('request') && !empty($this->getValue('request'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequest() {
|
public function getRequest()
|
||||||
|
{
|
||||||
return $this->getValue('request');
|
return $this->getValue('request');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRequest($value) {
|
public function setRequest($value)
|
||||||
|
{
|
||||||
$this->setValue('request', $value);
|
$this->setValue('request', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIndex() {
|
public function getIndex()
|
||||||
|
{
|
||||||
return $this->getValue('index');
|
return $this->getValue('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setIndex($value) {
|
public function setIndex($value)
|
||||||
|
{
|
||||||
$this->setValue('index', $value);
|
$this->setValue('index', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasProcessorInstance() {
|
public function hasProcessorInstance()
|
||||||
|
{
|
||||||
return $this->hasValue('processor_instance');
|
return $this->hasValue('processor_instance');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProcessorInstance() {
|
public function getProcessorInstance()
|
||||||
|
{
|
||||||
return $this->getValue('processor_instance');
|
return $this->getValue('processor_instance');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setProcessorInstance($value) {
|
public function setProcessorInstance($value)
|
||||||
|
{
|
||||||
$this->setValue('processor_instance', $value);
|
$this->setValue('processor_instance', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getIgnore() {
|
public function getIgnore()
|
||||||
|
{
|
||||||
return $this->getValue('ignore');
|
return $this->getValue('ignore');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasHost() {
|
public function hasHost()
|
||||||
|
{
|
||||||
return $this->hasValue('host');
|
return $this->hasValue('host');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHost() {
|
public function getHost()
|
||||||
|
{
|
||||||
return $this->getValue('host');
|
return $this->getValue('host');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,28 +7,33 @@ class ConfigBuilder
|
|||||||
|
|
||||||
private $configuration_override_file = null;
|
private $configuration_override_file = null;
|
||||||
|
|
||||||
private function __construct(string $mode) {
|
private function __construct(string $mode)
|
||||||
|
{
|
||||||
$this->config = new Config();
|
$this->config = new Config();
|
||||||
$this->config['mode'] = $mode;
|
$this->config['mode'] = $mode;
|
||||||
$this->config['local_base'] = dirname(__DIR__);
|
$this->config['local_base'] = dirname(__DIR__);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function fromFile($file): Config {
|
public static function fromFile($file): Config
|
||||||
|
{
|
||||||
return unserialize(file_get_contents($file));
|
return unserialize(file_get_contents($file));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function withMode($mode = Daux::STATIC_MODE): ConfigBuilder {
|
public static function withMode($mode = Daux::STATIC_MODE): ConfigBuilder
|
||||||
|
{
|
||||||
$builder = new ConfigBuilder($mode);
|
$builder = new ConfigBuilder($mode);
|
||||||
$builder->loadBaseConfiguration();
|
$builder->loadBaseConfiguration();
|
||||||
return $builder;
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function with(array $values): ConfigBuilder {
|
public function with(array $values): ConfigBuilder
|
||||||
|
{
|
||||||
$this->config->merge($values);
|
$this->config->merge($values);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setValue(&$array, $key, $value) {
|
private function setValue(&$array, $key, $value)
|
||||||
|
{
|
||||||
if (is_null($key)) {
|
if (is_null($key)) {
|
||||||
return $array = $value;
|
return $array = $value;
|
||||||
}
|
}
|
||||||
@ -44,65 +49,77 @@ class ConfigBuilder
|
|||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withValues(array $values): ConfigBuilder {
|
public function withValues(array $values): ConfigBuilder
|
||||||
|
{
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
$this->setValue($this->config, $value[0], $value[1]);
|
$this->setValue($this->config, $value[0], $value[1]);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withDocumentationDirectory($dir): ConfigBuilder {
|
public function withDocumentationDirectory($dir): ConfigBuilder
|
||||||
|
{
|
||||||
$this->config['docs_directory'] = $dir;
|
$this->config['docs_directory'] = $dir;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withValidContentExtensions(array $value): ConfigBuilder {
|
public function withValidContentExtensions(array $value): ConfigBuilder
|
||||||
|
{
|
||||||
$this->config['valid_content_extensions'] = $value;
|
$this->config['valid_content_extensions'] = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withThemesPath($themePath): ConfigBuilder {
|
public function withThemesPath($themePath): ConfigBuilder
|
||||||
|
{
|
||||||
$this->config['themes_path'] = $themePath;
|
$this->config['themes_path'] = $themePath;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withThemesDirectory($directory): ConfigBuilder {
|
public function withThemesDirectory($directory): ConfigBuilder
|
||||||
|
{
|
||||||
$this->config['themes_directory'] = $directory;
|
$this->config['themes_directory'] = $directory;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withCache(bool $value): ConfigBuilder {
|
public function withCache(bool $value): ConfigBuilder
|
||||||
|
{
|
||||||
$this->config['cache'] = $value;
|
$this->config['cache'] = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withFormat($format): ConfigBuilder {
|
public function withFormat($format): ConfigBuilder
|
||||||
|
{
|
||||||
$this->config['format'] = $format;
|
$this->config['format'] = $format;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withConfigurationOverride($file): ConfigBuilder {
|
public function withConfigurationOverride($file): ConfigBuilder
|
||||||
|
{
|
||||||
$this->configuration_override_file = $file;
|
$this->configuration_override_file = $file;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withProcessor($value): ConfigBuilder {
|
public function withProcessor($value): ConfigBuilder
|
||||||
|
{
|
||||||
$this->config['processor'] = $value;
|
$this->config['processor'] = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function withConfluenceDelete($value): ConfigBuilder {
|
public function withConfluenceDelete($value): ConfigBuilder
|
||||||
|
{
|
||||||
$this->config['confluence']['delete'] = $value;
|
$this->config['confluence']['delete'] = $value;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build(): Config {
|
public function build(): Config
|
||||||
|
{
|
||||||
$this->initializeConfiguration();
|
$this->initializeConfiguration();
|
||||||
|
|
||||||
return $this->config;
|
return $this->config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function resolveThemeVariant() {
|
private function resolveThemeVariant()
|
||||||
|
{
|
||||||
$theme = $this->config->getHTML()->getTheme();
|
$theme = $this->config->getHTML()->getTheme();
|
||||||
$themesPath = $this->config->getThemesPath() . DIRECTORY_SEPARATOR;
|
$themesPath = $this->config->getThemesPath() . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
@ -131,7 +148,8 @@ class ConfigBuilder
|
|||||||
* @param string $override_file
|
* @param string $override_file
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function initializeConfiguration() {
|
private function initializeConfiguration()
|
||||||
|
{
|
||||||
// Validate and set theme path
|
// Validate and set theme path
|
||||||
$docs_path = $this->normalizeDocumentationPath($this->config->getDocumentationDirectory());
|
$docs_path = $this->normalizeDocumentationPath($this->config->getDocumentationDirectory());
|
||||||
$this->config['docs_directory'] = $docs_path;
|
$this->config['docs_directory'] = $docs_path;
|
||||||
@ -163,10 +181,11 @@ class ConfigBuilder
|
|||||||
// Text search would be too slow on live server
|
// Text search would be too slow on live server
|
||||||
if ($this->config->isLive()) {
|
if ($this->config->isLive()) {
|
||||||
$this->config['html']['search'] = false;
|
$this->config['html']['search'] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function normalizeThemePath($path) {
|
private function normalizeThemePath($path)
|
||||||
|
{
|
||||||
$validPath = $this->findLocation($path, $this->config->getLocalBase(), 'dir');
|
$validPath = $this->findLocation($path, $this->config->getLocalBase(), 'dir');
|
||||||
|
|
||||||
if (!$validPath) {
|
if (!$validPath) {
|
||||||
@ -176,7 +195,8 @@ class ConfigBuilder
|
|||||||
return $validPath;
|
return $validPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function normalizeDocumentationPath($path) {
|
private function normalizeDocumentationPath($path)
|
||||||
|
{
|
||||||
$validPath = $this->findLocation($path, $this->config->getLocalBase(), 'dir');
|
$validPath = $this->findLocation($path, $this->config->getLocalBase(), 'dir');
|
||||||
|
|
||||||
if (!$validPath) {
|
if (!$validPath) {
|
||||||
@ -191,7 +211,8 @@ class ConfigBuilder
|
|||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function loadBaseConfiguration() {
|
private function loadBaseConfiguration()
|
||||||
|
{
|
||||||
// Set the default configuration
|
// Set the default configuration
|
||||||
$this->config->merge([
|
$this->config->merge([
|
||||||
'docs_directory' => 'docs',
|
'docs_directory' => 'docs',
|
||||||
@ -212,7 +233,8 @@ class ConfigBuilder
|
|||||||
* @param bool $optional
|
* @param bool $optional
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function loadConfiguration($config_file, $optional = true) {
|
private function loadConfiguration($config_file, $optional = true)
|
||||||
|
{
|
||||||
if (!file_exists($config_file)) {
|
if (!file_exists($config_file)) {
|
||||||
if ($optional) {
|
if ($optional) {
|
||||||
return;
|
return;
|
||||||
@ -235,7 +257,8 @@ class ConfigBuilder
|
|||||||
* @return string|null the path to a file to load for configuration overrides
|
* @return string|null the path to a file to load for configuration overrides
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function getConfigurationOverride($path) {
|
private function getConfigurationOverride($path)
|
||||||
|
{
|
||||||
$validPath = $this->findLocation($path, $this->config->getLocalBase(), 'file');
|
$validPath = $this->findLocation($path, $this->config->getLocalBase(), 'file');
|
||||||
|
|
||||||
if ($validPath === null) {
|
if ($validPath === null) {
|
||||||
@ -255,7 +278,8 @@ class ConfigBuilder
|
|||||||
* @param string $type
|
* @param string $type
|
||||||
* @return false|null|string
|
* @return false|null|string
|
||||||
*/
|
*/
|
||||||
private function findLocation($path, $basedir, $type) {
|
private function findLocation($path, $basedir, $type)
|
||||||
|
{
|
||||||
// If Path is explicitly null, it's useless to go further
|
// If Path is explicitly null, it's useless to go further
|
||||||
if ($path === null) {
|
if ($path === null) {
|
||||||
return null;
|
return null;
|
||||||
@ -280,4 +304,4 @@ class ConfigBuilder
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ use Todaymade\Daux\Daux;
|
|||||||
|
|
||||||
class DauxCommand extends SymfonyCommand
|
class DauxCommand extends SymfonyCommand
|
||||||
{
|
{
|
||||||
protected function configure()
|
protected function configure()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->addOption('configuration', 'c', InputOption::VALUE_REQUIRED, 'Configuration file')
|
->addOption('configuration', 'c', InputOption::VALUE_REQUIRED, 'Configuration file')
|
||||||
@ -46,7 +46,7 @@ class DauxCommand extends SymfonyCommand
|
|||||||
|
|
||||||
if ($input->hasOption('value')) {
|
if ($input->hasOption('value')) {
|
||||||
$values = array_map(
|
$values = array_map(
|
||||||
function($value) {
|
function ($value) {
|
||||||
return array_map("trim", explode('=', $value));
|
return array_map("trim", explode('=', $value));
|
||||||
},
|
},
|
||||||
$input->getOption('value')
|
$input->getOption('value')
|
||||||
|
@ -5,7 +5,8 @@ use Todaymade\Daux\Daux;
|
|||||||
|
|
||||||
trait RunAction
|
trait RunAction
|
||||||
{
|
{
|
||||||
protected function getLength($content) {
|
protected function getLength($content)
|
||||||
|
{
|
||||||
return function_exists('mb_strlen') ? mb_strlen($content) : strlen($content);
|
return function_exists('mb_strlen') ? mb_strlen($content) : strlen($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,7 +20,7 @@ trait RunAction
|
|||||||
$padding = $width - $this->getLength($title) - 10;
|
$padding = $width - $this->getLength($title) - 10;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $closure(function($content) use (&$padding, $verbose) {
|
$response = $closure(function ($content) use (&$padding, $verbose) {
|
||||||
$padding -= $this->getLength($content);
|
$padding -= $this->getLength($content);
|
||||||
Daux::write($content, $verbose);
|
Daux::write($content, $verbose);
|
||||||
});
|
});
|
||||||
|
@ -49,7 +49,7 @@ class Serve extends DauxCommand
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = stream_get_meta_data($file)['uri'];
|
$path = stream_get_meta_data($file)['uri'];
|
||||||
fwrite($file, serialize($daux->getConfig()));
|
fwrite($file, serialize($daux->getConfig()));
|
||||||
|
|
||||||
chdir(__DIR__ . '/../../');
|
chdir(__DIR__ . '/../../');
|
||||||
|
@ -19,11 +19,13 @@ class ContentType implements \Todaymade\Daux\ContentTypes\ContentType
|
|||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createConverter() {
|
protected function createConverter()
|
||||||
|
{
|
||||||
return new CommonMarkConverter(['daux' => $this->config]);
|
return new CommonMarkConverter(['daux' => $this->config]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getConverter() {
|
protected function getConverter()
|
||||||
|
{
|
||||||
if (!$this->converter) {
|
if (!$this->converter) {
|
||||||
$this->converter = $this->createConverter();
|
$this->converter = $this->createConverter();
|
||||||
}
|
}
|
||||||
@ -67,7 +69,7 @@ class ContentType implements \Todaymade\Daux\ContentTypes\ContentType
|
|||||||
|
|
||||||
if ($can_cache) {
|
if ($can_cache) {
|
||||||
Cache::put($cacheKey, $payload);
|
Cache::put($cacheKey, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $payload;
|
return $payload;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,6 @@ use Symfony\Component\Console\Output\NullOutput;
|
|||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Todaymade\Daux\ContentTypes\ContentTypeHandler;
|
use Todaymade\Daux\ContentTypes\ContentTypeHandler;
|
||||||
use Todaymade\Daux\Tree\Builder;
|
use Todaymade\Daux\Tree\Builder;
|
||||||
use Todaymade\Daux\Tree\Content;
|
|
||||||
use Todaymade\Daux\Tree\Directory;
|
|
||||||
use Todaymade\Daux\Tree\Root;
|
use Todaymade\Daux\Tree\Root;
|
||||||
|
|
||||||
class Daux
|
class Daux
|
||||||
@ -40,7 +38,7 @@ class Daux
|
|||||||
{
|
{
|
||||||
Daux::$output = $output;
|
Daux::$output = $output;
|
||||||
|
|
||||||
|
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +159,8 @@ class Daux
|
|||||||
return $class;
|
return $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function findAlternatives($input, $words) {
|
protected function findAlternatives($input, $words)
|
||||||
|
{
|
||||||
$alternatives = [];
|
$alternatives = [];
|
||||||
|
|
||||||
foreach ($words as $word) {
|
foreach ($words as $word) {
|
||||||
@ -246,7 +245,8 @@ class Daux
|
|||||||
return $this->validExtensions = $this->getContentTypeHandler()->getContentExtensions();
|
return $this->validExtensions = $this->getContentTypeHandler()->getContentExtensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getOutput() {
|
public static function getOutput()
|
||||||
|
{
|
||||||
if (!Daux::$output) {
|
if (!Daux::$output) {
|
||||||
Daux::$output = new NullOutput();
|
Daux::$output = new NullOutput();
|
||||||
}
|
}
|
||||||
@ -261,7 +261,8 @@ class Daux
|
|||||||
* @param bool $newline Whether to add a newline
|
* @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
|
* @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 write($messages, $newline = false, $options = 0) {
|
public static function write($messages, $newline = false, $options = 0)
|
||||||
|
{
|
||||||
Daux::getOutput()->write($messages, $newline, $options);
|
Daux::getOutput()->write($messages, $newline, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,11 +272,13 @@ class Daux
|
|||||||
* @param string|array $messages The message as an array of lines of a single string
|
* @param string|array $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
|
* @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) {
|
public static function writeln($messages, $options = 0)
|
||||||
|
{
|
||||||
Daux::getOutput()->write($messages, true, $options);
|
Daux::getOutput()->write($messages, true, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getVerbosity() {
|
public static function getVerbosity()
|
||||||
|
{
|
||||||
return Daux::getOutput()->getVerbosity();
|
return Daux::getOutput()->getVerbosity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ class DauxHelper
|
|||||||
// Convert all dashes into underscores
|
// Convert all dashes into underscores
|
||||||
$title = preg_replace('![' . preg_quote('-') . ']+!u', $separator, $title);
|
$title = preg_replace('![' . preg_quote('-') . ']+!u', $separator, $title);
|
||||||
|
|
||||||
// Remove all characters that are not valid in a URL:
|
// Remove all characters that are not valid in a URL:
|
||||||
// $-_.+!*'(), separator, letters, numbers, or whitespace.
|
// $-_.+!*'(), separator, letters, numbers, or whitespace.
|
||||||
$title = preg_replace('![^-' . preg_quote($separator) . '\!\'\(\),\.\+\*\$\pL\pN\s]+!u', '', $title);
|
$title = preg_replace('![^-' . preg_quote($separator) . '\!\'\(\),\.\+\*\$\pL\pN\s]+!u', '', $title);
|
||||||
|
|
||||||
@ -316,7 +316,8 @@ class DauxHelper
|
|||||||
return '' !== $parts['root'];
|
return '' !== $parts['root'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAbsolutePath($path) {
|
public static function getAbsolutePath($path)
|
||||||
|
{
|
||||||
if (DauxHelper::isAbsolutePath($path)) {
|
if (DauxHelper::isAbsolutePath($path)) {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
@ -324,7 +325,8 @@ class DauxHelper
|
|||||||
return getcwd() . '/' . $path;
|
return getcwd() . '/' . $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function is($path, $type) {
|
public static function is($path, $type)
|
||||||
|
{
|
||||||
return ($type == 'dir') ? is_dir($path) : file_exists($path);
|
return ($type == 'dir') ? is_dir($path) : file_exists($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ class EmbedImages
|
|||||||
{
|
{
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
"/<img\\s+[^>]*src=['\"]([^\"]*)['\"][^>]*>/",
|
"/<img\\s+[^>]*src=['\"]([^\"]*)['\"][^>]*>/",
|
||||||
function($matches) use ($file, $callback) {
|
function ($matches) use ($file, $callback) {
|
||||||
if ($result = $this->findImage($matches[1], $matches[0], $file, $callback)) {
|
if ($result = $this->findImage($matches[1], $matches[0], $file, $callback)) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,6 @@ class Api
|
|||||||
|
|
||||||
$prepared = [];
|
$prepared = [];
|
||||||
foreach ($filtered as $index => $line) {
|
foreach ($filtered as $index => $line) {
|
||||||
|
|
||||||
$number = $start + 1 + $index;
|
$number = $start + 1 + $index;
|
||||||
$gutter = substr(' ' . (' ' . $number), -$maxWidth) . ' | ';
|
$gutter = substr(' ' . (' ' . $number), -$maxWidth) . ' | ';
|
||||||
|
|
||||||
@ -318,7 +317,6 @@ class Api
|
|||||||
// If the attachment is already uploaded,
|
// If the attachment is already uploaded,
|
||||||
// the update URL is different
|
// the update URL is different
|
||||||
if (count($result['results'])) {
|
if (count($result['results'])) {
|
||||||
|
|
||||||
if ($this->getFileSize($attachment) == $result['results'][0]['extensions']['fileSize']) {
|
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;
|
return;
|
||||||
|
@ -4,7 +4,8 @@ use Todaymade\Daux\BaseConfig;
|
|||||||
|
|
||||||
class Config extends BaseConfig
|
class Config extends BaseConfig
|
||||||
{
|
{
|
||||||
public function shouldAutoDeleteOrphanedPages() {
|
public function shouldAutoDeleteOrphanedPages()
|
||||||
|
{
|
||||||
if ($this->hasValue('delete')) {
|
if ($this->hasValue('delete')) {
|
||||||
return $this->getValue('delete');
|
return $this->getValue('delete');
|
||||||
}
|
}
|
||||||
@ -12,55 +13,68 @@ class Config extends BaseConfig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUpdateThreshold() {
|
public function getUpdateThreshold()
|
||||||
|
{
|
||||||
return $this->hasValue('update_threshold') ? $this->getValue('update_threshold') : 2;
|
return $this->hasValue('update_threshold') ? $this->getValue('update_threshold') : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrefix() {
|
public function getPrefix()
|
||||||
|
{
|
||||||
return $this->getValue('prefix');
|
return $this->getValue('prefix');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBaseUrl() {
|
public function getBaseUrl()
|
||||||
|
{
|
||||||
return $this->getValue('base_url');
|
return $this->getValue('base_url');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser() {
|
public function getUser()
|
||||||
|
{
|
||||||
return $this->getValue('user');
|
return $this->getValue('user');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPassword() {
|
public function getPassword()
|
||||||
|
{
|
||||||
return $this->getValue('pass');
|
return $this->getValue('pass');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSpaceId() {
|
public function getSpaceId()
|
||||||
|
{
|
||||||
return $this->getValue('space_id');
|
return $this->getValue('space_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasAncestorId() {
|
public function hasAncestorId()
|
||||||
|
{
|
||||||
return $this->hasValue('ancestor_id');
|
return $this->hasValue('ancestor_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAncestorId() {
|
public function getAncestorId()
|
||||||
|
{
|
||||||
return $this->getValue('ancestor_id');
|
return $this->getValue('ancestor_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAncestorId($value) {
|
public function setAncestorId($value)
|
||||||
|
{
|
||||||
$this->setValue('ancestor_id', $value);
|
$this->setValue('ancestor_id', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasRootId() {
|
public function hasRootId()
|
||||||
|
{
|
||||||
return $this->hasValue('root_id');
|
return $this->hasValue('root_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRootId() {
|
public function getRootId()
|
||||||
|
{
|
||||||
return $this->getValue('root_id');
|
return $this->getValue('root_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasHeader() {
|
public function hasHeader()
|
||||||
|
{
|
||||||
return $this->hasValue('header');
|
return $this->hasValue('header');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeader() {
|
public function getHeader()
|
||||||
|
{
|
||||||
return $this->getValue('header');
|
return $this->getValue('header');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,13 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
|||||||
->embed(
|
->embed(
|
||||||
$content,
|
$content,
|
||||||
$this->file,
|
$this->file,
|
||||||
function($src, array $attributes, Entry $file) {
|
function ($src, array $attributes, Entry $file) {
|
||||||
|
|
||||||
//Add the attachment for later upload
|
//Add the attachment for later upload
|
||||||
if ($file instanceof Raw) {
|
if ($file instanceof Raw) {
|
||||||
$filename = basename($file->getPath());
|
$filename = basename($file->getPath());
|
||||||
$this->attachments[$filename] = ['filename' => $filename, 'file' => $file];
|
$this->attachments[$filename] = ['filename' => $filename, 'file' => $file];
|
||||||
} else if ($file instanceof ComputedRaw) {
|
} elseif ($file instanceof ComputedRaw) {
|
||||||
$filename = $file->getUri();
|
$filename = $file->getUri();
|
||||||
$this->attachments[$filename] = ['filename' => $filename, 'content' => $file->getContent()];
|
$this->attachments[$filename] = ['filename' => $filename, 'content' => $file->getContent()];
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,7 +5,6 @@ use League\CommonMark\HtmlElement;
|
|||||||
|
|
||||||
abstract class CodeRenderer implements BlockRendererInterface
|
abstract class CodeRenderer implements BlockRendererInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function escapeCDATA($content)
|
public function escapeCDATA($content)
|
||||||
{
|
{
|
||||||
return str_replace("]]>", "]]]]><![CDATA[>", $content);
|
return str_replace("]]>", "]]]]><![CDATA[>", $content);
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\Confluence\ContentTypes\Markdown;
|
<?php namespace Todaymade\Daux\Format\Confluence\ContentTypes\Markdown;
|
||||||
|
|
||||||
use Todaymade\Daux\Config;
|
|
||||||
|
|
||||||
class ContentType extends \Todaymade\Daux\ContentTypes\Markdown\ContentType
|
class ContentType extends \Todaymade\Daux\ContentTypes\Markdown\ContentType
|
||||||
{
|
{
|
||||||
protected function createConverter() {
|
protected function createConverter()
|
||||||
|
{
|
||||||
return new CommonMarkConverter(['daux' => $this->config]);
|
return new CommonMarkConverter(['daux' => $this->config]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,8 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
|
|||||||
*/
|
*/
|
||||||
protected $parent;
|
protected $parent;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
$this->parent = new \League\CommonMark\Inline\Renderer\ImageRenderer();
|
$this->parent = new \League\CommonMark\Inline\Renderer\ImageRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
|||||||
$tree = $this->runAction(
|
$tree = $this->runAction(
|
||||||
'Generating Tree ...',
|
'Generating Tree ...',
|
||||||
$width,
|
$width,
|
||||||
function() use ($config) {
|
function () use ($config) {
|
||||||
$tree = $this->generateRecursive($this->daux->tree, $config);
|
$tree = $this->generateRecursive($this->daux->tree, $config);
|
||||||
$tree['title'] = $this->prefix . $config->getTitle();
|
$tree['title'] = $this->prefix . $config->getTitle();
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class Publisher
|
|||||||
|
|
||||||
$this->run(
|
$this->run(
|
||||||
'Getting already published pages...',
|
'Getting already published pages...',
|
||||||
function() use (&$published) {
|
function () use (&$published) {
|
||||||
if ($published != null) {
|
if ($published != null) {
|
||||||
$published['children'] = $this->client->getList($published['id'], true);
|
$published['children'] = $this->client->getList($published['id'], true);
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ class Publisher
|
|||||||
|
|
||||||
$published = $this->run(
|
$published = $this->run(
|
||||||
"Create placeholder pages...",
|
"Create placeholder pages...",
|
||||||
function() use ($tree, $published) {
|
function () use ($tree, $published) {
|
||||||
return $this->createRecursive($this->confluence->getAncestorId(), $tree, $published);
|
return $this->createRecursive($this->confluence->getAncestorId(), $tree, $published);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -142,7 +142,7 @@ class Publisher
|
|||||||
|
|
||||||
protected function createRecursive($parent_id, $entry, $published)
|
protected function createRecursive($parent_id, $entry, $published)
|
||||||
{
|
{
|
||||||
$callback = function($parent_id, $entry, $published) {
|
$callback = function ($parent_id, $entry, $published) {
|
||||||
// nothing to do if the ID already exists
|
// nothing to do if the ID already exists
|
||||||
if (array_key_exists('id', $published)) {
|
if (array_key_exists('id', $published)) {
|
||||||
return $published;
|
return $published;
|
||||||
@ -163,7 +163,7 @@ class Publisher
|
|||||||
|
|
||||||
protected function updateRecursive($parent_id, $entry, $published)
|
protected function updateRecursive($parent_id, $entry, $published)
|
||||||
{
|
{
|
||||||
$callback = function($parent_id, $entry, $published) {
|
$callback = function ($parent_id, $entry, $published) {
|
||||||
if (array_key_exists('id', $published) && array_key_exists('page', $entry)) {
|
if (array_key_exists('id', $published) && array_key_exists('page', $entry)) {
|
||||||
$this->updatePage($parent_id, $entry, $published);
|
$this->updatePage($parent_id, $entry, $published);
|
||||||
}
|
}
|
||||||
@ -181,7 +181,7 @@ class Publisher
|
|||||||
|
|
||||||
$this->run(
|
$this->run(
|
||||||
'- ' . PublisherUtilities::niceTitle($entry['file']->getUrl()),
|
'- ' . PublisherUtilities::niceTitle($entry['file']->getUrl()),
|
||||||
function() use ($entry, $published, $parent_id, $updateThreshold) {
|
function () use ($entry, $published, $parent_id, $updateThreshold) {
|
||||||
$generated_content = $entry['page']->getContent();
|
$generated_content = $entry['page']->getContent();
|
||||||
if (PublisherUtilities::shouldUpdate($entry['page'], $generated_content, $published, $updateThreshold)) {
|
if (PublisherUtilities::shouldUpdate($entry['page'], $generated_content, $published, $updateThreshold)) {
|
||||||
$this->client->updatePage(
|
$this->client->updatePage(
|
||||||
@ -199,7 +199,7 @@ class Publisher
|
|||||||
foreach ($entry['page']->attachments as $attachment) {
|
foreach ($entry['page']->attachments as $attachment) {
|
||||||
$this->run(
|
$this->run(
|
||||||
" With attachment: $attachment[filename]",
|
" With attachment: $attachment[filename]",
|
||||||
function($write) use ($published, $attachment) {
|
function ($write) use ($published, $attachment) {
|
||||||
$this->client->uploadAttachment($published['id'], $attachment, $write);
|
$this->client->uploadAttachment($published['id'], $attachment, $write);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -60,7 +60,8 @@ class PublisherDelete
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function doDelete() {
|
protected function doDelete()
|
||||||
|
{
|
||||||
$this->output->writeLn('Deleting obsolete pages...');
|
$this->output->writeLn('Deleting obsolete pages...');
|
||||||
foreach ($this->deletable as $id => $title) {
|
foreach ($this->deletable as $id => $title) {
|
||||||
$this->output->writeLn("- $title");
|
$this->output->writeLn("- $title");
|
||||||
@ -68,7 +69,8 @@ class PublisherDelete
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function displayDeletable() {
|
protected function displayDeletable()
|
||||||
|
{
|
||||||
$this->output->writeLn('Listing obsolete pages...');
|
$this->output->writeLn('Listing obsolete pages...');
|
||||||
$this->output->writeLn("> The following pages will not be deleted, but just listed for information.");
|
$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("> If you want to delete these pages, you need to set the --delete flag on the command.");
|
||||||
|
@ -34,7 +34,8 @@ class Config extends BaseConfig
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasSearch() {
|
public function hasSearch()
|
||||||
|
{
|
||||||
return $this->hasValue('search') && $this->getValue('search');
|
return $this->hasValue('search') && $this->getValue('search');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,8 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
|||||||
return $this->file->getParent() instanceof Root;
|
return $this->file->getParent() instanceof Root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isLanding(): bool {
|
private function isLanding(): bool
|
||||||
|
{
|
||||||
return $this->config->getHTML()->hasLandingPage() && $this->homepage;
|
return $this->config->getHTML()->hasLandingPage() && $this->homepage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\HTML\ContentTypes\Markdown;
|
<?php namespace Todaymade\Daux\Format\HTML\ContentTypes\Markdown;
|
||||||
|
|
||||||
use Todaymade\Daux\Config;
|
|
||||||
|
|
||||||
class ContentType extends \Todaymade\Daux\ContentTypes\Markdown\ContentType
|
class ContentType extends \Todaymade\Daux\ContentTypes\Markdown\ContentType
|
||||||
{
|
{
|
||||||
protected function createConverter() {
|
protected function createConverter()
|
||||||
|
{
|
||||||
return new CommonMarkConverter(['daux' => $this->config]);
|
return new CommonMarkConverter(['daux' => $this->config]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@ class FencedCodeRenderer implements BlockRendererInterface
|
|||||||
*/
|
*/
|
||||||
private $hl;
|
private $hl;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
$this->hl = new Highlighter();
|
$this->hl = new Highlighter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Relative URLs can be done using either the folder with
|
* Relative URLs can be done using either the folder with
|
||||||
* number prefix or the final name (with prefix stripped).
|
* number prefix or the final name (with prefix stripped).
|
||||||
* This ensures that we always use the final name when generating.
|
* This ensures that we always use the final name when generating.
|
||||||
* @throws LinkNotFoundException
|
* @throws LinkNotFoundException
|
||||||
@ -70,7 +70,7 @@ class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterf
|
|||||||
* @param ElementRendererInterface $htmlRenderer
|
* @param ElementRendererInterface $htmlRenderer
|
||||||
*
|
*
|
||||||
* @return HtmlElement
|
* @return HtmlElement
|
||||||
*
|
*
|
||||||
* @throws LinkNotFoundException
|
* @throws LinkNotFoundException
|
||||||
*/
|
*/
|
||||||
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
|
public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
|
||||||
|
@ -72,7 +72,8 @@ class Processor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getUniqueId(Document $document, $proposed) {
|
protected function getUniqueId(Document $document, $proposed)
|
||||||
|
{
|
||||||
if ($proposed == "page_") {
|
if ($proposed == "page_") {
|
||||||
$proposed = "page_section_" . (count($document->heading_ids) + 1);
|
$proposed = "page_section_" . (count($document->heading_ids) + 1);
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
|||||||
$this->runAction(
|
$this->runAction(
|
||||||
'Copying Static assets ...',
|
'Copying Static assets ...',
|
||||||
$width,
|
$width,
|
||||||
function() use ($destination, $config) {
|
function () use ($destination, $config) {
|
||||||
$this->ensureEmptyDestination($destination);
|
$this->ensureEmptyDestination($destination);
|
||||||
|
|
||||||
$this->copyThemes($destination, $config->getThemesPath());
|
$this->copyThemes($destination, $config->getThemesPath());
|
||||||
@ -170,7 +170,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator, LiveGenerator
|
|||||||
$this->runAction(
|
$this->runAction(
|
||||||
'- ' . $node->getUrl(),
|
'- ' . $node->getUrl(),
|
||||||
$width,
|
$width,
|
||||||
function() use ($node, $output_dir, $key, $config, $index_pages) {
|
function () use ($node, $output_dir, $key, $config, $index_pages) {
|
||||||
if ($node instanceof Raw) {
|
if ($node instanceof Raw) {
|
||||||
copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
|
copy($node->getPath(), $output_dir . DIRECTORY_SEPARATOR . $key);
|
||||||
|
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
use Todaymade\Daux\GeneratorHelper;
|
use Todaymade\Daux\GeneratorHelper;
|
||||||
|
|
||||||
trait HTMLUtils {
|
trait HTMLUtils
|
||||||
|
{
|
||||||
public function ensureEmptyDestination($destination)
|
public function ensureEmptyDestination($destination)
|
||||||
{
|
{
|
||||||
if (is_dir($destination)) {
|
if (is_dir($destination)) {
|
||||||
@ -26,4 +27,4 @@ trait HTMLUtils {
|
|||||||
$destination . DIRECTORY_SEPARATOR . 'themes'
|
$destination . DIRECTORY_SEPARATOR . 'themes'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,13 +78,13 @@ class Template
|
|||||||
|
|
||||||
protected function registerFunctions($engine)
|
protected function registerFunctions($engine)
|
||||||
{
|
{
|
||||||
$engine->registerFunction('get_navigation', function($tree, $path, $current_url, $base_page, $mode) {
|
$engine->registerFunction('get_navigation', function ($tree, $path, $current_url, $base_page, $mode) {
|
||||||
$nav = $this->buildNavigation($tree, $path, $current_url, $base_page, $mode);
|
$nav = $this->buildNavigation($tree, $path, $current_url, $base_page, $mode);
|
||||||
|
|
||||||
return $this->renderNavigation($nav);
|
return $this->renderNavigation($nav);
|
||||||
});
|
});
|
||||||
|
|
||||||
$engine->registerFunction('translate', function($key) {
|
$engine->registerFunction('translate', function ($key) {
|
||||||
$language = $this->config->getLanguage();
|
$language = $this->config->getLanguage();
|
||||||
|
|
||||||
if (isset($this->engine->getData('page')['page'])) {
|
if (isset($this->engine->getData('page')['page'])) {
|
||||||
@ -105,7 +105,7 @@ class Template
|
|||||||
return "Unknown key $key";
|
return "Unknown key $key";
|
||||||
});
|
});
|
||||||
|
|
||||||
$engine->registerFunction('get_breadcrumb_title', function($page, $base_page) {
|
$engine->registerFunction('get_breadcrumb_title', function ($page, $base_page) {
|
||||||
$title = '';
|
$title = '';
|
||||||
$breadcrumb_trail = $page['breadcrumb_trail'];
|
$breadcrumb_trail = $page['breadcrumb_trail'];
|
||||||
$separator = $this->getSeparator($page['breadcrumb_separator']);
|
$separator = $this->getSeparator($page['breadcrumb_separator']);
|
||||||
|
@ -4,23 +4,28 @@ use Todaymade\Daux\BaseConfig;
|
|||||||
|
|
||||||
class Theme extends BaseConfig
|
class Theme extends BaseConfig
|
||||||
{
|
{
|
||||||
public function getFonts() {
|
public function getFonts()
|
||||||
|
{
|
||||||
return $this->getValue('fonts');
|
return $this->getValue('fonts');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCSS() {
|
public function getCSS()
|
||||||
|
{
|
||||||
return $this->getValue('css');
|
return $this->getValue('css');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJS() {
|
public function getJS()
|
||||||
|
{
|
||||||
return $this->getValue('js');
|
return $this->getValue('js');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFavicon() {
|
public function getFavicon()
|
||||||
|
{
|
||||||
return $this->getValue('favicon');
|
return $this->getValue('favicon');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplates() {
|
public function getTemplates()
|
||||||
|
{
|
||||||
return $this->getValue('templates');
|
return $this->getValue('templates');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
|
|||||||
->embed(
|
->embed(
|
||||||
$content,
|
$content,
|
||||||
$this->file,
|
$this->file,
|
||||||
function($src, array $attributes, Raw $file) {
|
function ($src, array $attributes, Raw $file) {
|
||||||
// TODO :: ignore absolute paths
|
// TODO :: ignore absolute paths
|
||||||
$content = base64_encode(file_get_contents($file->getPath()));
|
$content = base64_encode(file_get_contents($file->getPath()));
|
||||||
$attr = '';
|
$attr = '';
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\HTMLFile\ContentTypes\Markdown;
|
<?php namespace Todaymade\Daux\Format\HTMLFile\ContentTypes\Markdown;
|
||||||
|
|
||||||
use Todaymade\Daux\Config;
|
|
||||||
|
|
||||||
class ContentType extends \Todaymade\Daux\ContentTypes\Markdown\ContentType
|
class ContentType extends \Todaymade\Daux\ContentTypes\Markdown\ContentType
|
||||||
{
|
{
|
||||||
protected function createConverter() {
|
protected function createConverter()
|
||||||
|
{
|
||||||
return new CommonMarkConverter(['daux' => $this->config]);
|
return new CommonMarkConverter(['daux' => $this->config]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,4 +64,4 @@ class LinkRenderer extends \Todaymade\Daux\ContentTypes\Markdown\LinkRenderer
|
|||||||
|
|
||||||
return $element;
|
return $element;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
|||||||
$this->runAction(
|
$this->runAction(
|
||||||
'Cleaning destination folder ...',
|
'Cleaning destination folder ...',
|
||||||
$width,
|
$width,
|
||||||
function() use ($destination) {
|
function () use ($destination) {
|
||||||
$this->ensureEmptyDestination($destination);
|
$this->ensureEmptyDestination($destination);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -73,7 +73,7 @@ class Generator implements \Todaymade\Daux\Format\Base\Generator
|
|||||||
$this->runAction(
|
$this->runAction(
|
||||||
'Generating ' . $current->getTitle(),
|
'Generating ' . $current->getTitle(),
|
||||||
$width,
|
$width,
|
||||||
function() use ($book, $current, $config) {
|
function () use ($book, $current, $config) {
|
||||||
$contentType = $this->daux->getContentTypeHandler()->getType($current);
|
$contentType = $this->daux->getContentTypeHandler()->getType($current);
|
||||||
$content = ContentPage::fromFile($current, $config, $contentType);
|
$content = ContentPage::fromFile($current, $config, $contentType);
|
||||||
$content->templateRenderer = $this->templateRenderer;
|
$content->templateRenderer = $this->templateRenderer;
|
||||||
|
@ -4,7 +4,8 @@ use IntlDateFormatter;
|
|||||||
|
|
||||||
class FormatDate
|
class FormatDate
|
||||||
{
|
{
|
||||||
public static function format($config, $date) {
|
public static function format($config, $date)
|
||||||
|
{
|
||||||
$locale = $config->getLanguage();
|
$locale = $config->getLanguage();
|
||||||
$datetype = IntlDateFormatter::LONG;
|
$datetype = IntlDateFormatter::LONG;
|
||||||
$timetype = IntlDateFormatter::SHORT;
|
$timetype = IntlDateFormatter::SHORT;
|
||||||
@ -19,4 +20,4 @@ class FormatDate
|
|||||||
|
|
||||||
return $formatter->format($date);
|
return $formatter->format($date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,8 @@ class Server
|
|||||||
* @param string $postfix
|
* @param string $postfix
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getTemporaryFile($postfix) {
|
private function getTemporaryFile($postfix)
|
||||||
|
{
|
||||||
$sysFileName = tempnam(sys_get_temp_dir(), 'daux');
|
$sysFileName = tempnam(sys_get_temp_dir(), 'daux');
|
||||||
if ($sysFileName === false) {
|
if ($sysFileName === false) {
|
||||||
throw new \RuntimeException("Could not create temporary file");
|
throw new \RuntimeException("Could not create temporary file");
|
||||||
@ -99,7 +100,8 @@ class Server
|
|||||||
* @param Page $page
|
* @param Page $page
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function createResponse(Page $page) {
|
public function createResponse(Page $page)
|
||||||
|
{
|
||||||
// Add a custom MimeType guesser in case the default ones are not available
|
// Add a custom MimeType guesser in case the default ones are not available
|
||||||
// This makes sure that at least CSS and JS work fine.
|
// This makes sure that at least CSS and JS work fine.
|
||||||
$mimeTypes = MimeTypes::getDefault();
|
$mimeTypes = MimeTypes::getDefault();
|
||||||
|
@ -218,7 +218,8 @@ class Builder
|
|||||||
*
|
*
|
||||||
* @param Directory $current
|
* @param Directory $current
|
||||||
*/
|
*/
|
||||||
public static function sortTree(Directory $current) {
|
public static function sortTree(Directory $current)
|
||||||
|
{
|
||||||
$current->sort();
|
$current->sort();
|
||||||
foreach ($current->getEntries() as $entry) {
|
foreach ($current->getEntries() as $entry) {
|
||||||
if ($entry instanceof Directory) {
|
if ($entry instanceof Directory) {
|
||||||
@ -251,5 +252,4 @@ class Builder
|
|||||||
|
|
||||||
return $prev;
|
return $prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class Content extends ContentAbstract
|
|||||||
{
|
{
|
||||||
if ($this->manuallySetContent) {
|
if ($this->manuallySetContent) {
|
||||||
$content = $this->content;
|
$content = $this->content;
|
||||||
} else if (!$this->getPath()) {
|
} elseif (!$this->getPath()) {
|
||||||
throw new RuntimeException("Empty content");
|
throw new RuntimeException("Empty content");
|
||||||
} else {
|
} else {
|
||||||
$content = file_get_contents($this->getPath());
|
$content = file_get_contents($this->getPath());
|
||||||
|
@ -95,7 +95,7 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
|||||||
|
|
||||||
private function sortBucket($bucket, $final)
|
private function sortBucket($bucket, $final)
|
||||||
{
|
{
|
||||||
uasort($bucket, function(Entry $a, Entry $b) {
|
uasort($bucket, function (Entry $a, Entry $b) {
|
||||||
return strcasecmp($a->getName(), $b->getName());
|
return strcasecmp($a->getName(), $b->getName());
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -136,7 +136,8 @@ class Directory extends Entry implements \ArrayAccess, \IteratorAggregate
|
|||||||
return $this->parent->getConfig();
|
return $this->parent->getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocalIndexPage() {
|
public function getLocalIndexPage()
|
||||||
|
{
|
||||||
$index_key = $this->getConfig()->getIndexKey();
|
$index_key = $this->getConfig()->getIndexKey();
|
||||||
|
|
||||||
if (isset($this->children[$index_key])) {
|
if (isset($this->children[$index_key])) {
|
||||||
|
@ -190,7 +190,8 @@ abstract class Entry
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHotPath(Entry $node = null) {
|
public function isHotPath(Entry $node = null)
|
||||||
|
{
|
||||||
return $this->parent->isHotPath($node ?: $this);
|
return $this->parent->isHotPath($node ?: $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,8 @@ class Root extends Directory
|
|||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isHotPath(Entry $node = null): bool {
|
public function isHotPath(Entry $node = null): bool
|
||||||
|
{
|
||||||
if ($node == null) {
|
if ($node == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -59,7 +60,8 @@ class Root extends Directory
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setActiveNode(Entry $node) {
|
public function setActiveNode(Entry $node)
|
||||||
|
{
|
||||||
$this->activeNode = $node;
|
$this->activeNode = $node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function loadApp() {
|
function loadApp()
|
||||||
|
{
|
||||||
// Loaded as a dependency
|
// Loaded as a dependency
|
||||||
if (file_exists(__DIR__ . '/../../../autoload.php')) {
|
if (file_exists(__DIR__ . '/../../../autoload.php')) {
|
||||||
return require_once __DIR__ . '/../../../autoload.php';
|
return require_once __DIR__ . '/../../../autoload.php';
|
||||||
|
@ -7,3 +7,7 @@ fi
|
|||||||
echo "-- Install phpunit"
|
echo "-- Install phpunit"
|
||||||
curl -sSLo build/phpunit https://phar.phpunit.de/phpunit-8.phar
|
curl -sSLo build/phpunit https://phar.phpunit.de/phpunit-8.phar
|
||||||
chmod +x build/phpunit
|
chmod +x build/phpunit
|
||||||
|
|
||||||
|
echo "-- Install php-cs-fixer"
|
||||||
|
curl -sSLo build/php-cs-fixer https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.3/php-cs-fixer.phar
|
||||||
|
chmod +x build/php-cs-fixer
|
||||||
|
@ -26,21 +26,18 @@
|
|||||||
<?php
|
<?php
|
||||||
$hasPrevNext = (!empty($page['prev']) || !empty($page['next']));
|
$hasPrevNext = (!empty($page['prev']) || !empty($page['next']));
|
||||||
if ($hasPrevNext && $config->getHTML()->showPreviousNextLinks()) {
|
if ($hasPrevNext && $config->getHTML()->showPreviousNextLinks()) {
|
||||||
?>
|
?>
|
||||||
<nav>
|
<nav>
|
||||||
<ul class="Pager">
|
<ul class="Pager">
|
||||||
<?php if (!empty($page['prev'])) {
|
<?php if (!empty($page['prev'])) {
|
||||||
?><li class=Pager--prev><a href="<?= $base_url . $page['prev']->getUrl() ?>"><?= $this->translate("Link_previous") ?></a></li><?php
|
?><li class=Pager--prev><a href="<?= $base_url . $page['prev']->getUrl() ?>"><?= $this->translate("Link_previous") ?></a></li><?php
|
||||||
|
} ?>
|
||||||
} ?>
|
|
||||||
<?php if (!empty($page['next'])) {
|
<?php if (!empty($page['next'])) {
|
||||||
?><li class=Pager--next><a href="<?= $base_url . $page['next']->getUrl() ?>"><?= $this->translate("Link_next") ?></a></li><?php
|
?><li class=Pager--next><a href="<?= $base_url . $page['next']->getUrl() ?>"><?= $this->translate("Link_next") ?></a></li><?php
|
||||||
|
} ?>
|
||||||
} ?>
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<?php
|
<?php
|
||||||
|
} ?>
|
||||||
} ?>
|
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@
|
|||||||
<?php if ($config->getHTML()->hasLinks()) { ?>
|
<?php if ($config->getHTML()->hasLinks()) { ?>
|
||||||
<ul class="HomepageFooter__links">
|
<ul class="HomepageFooter__links">
|
||||||
<?php foreach ($config->getHTML()->getLinks() as $name => $url) {
|
<?php foreach ($config->getHTML()->getLinks() as $name => $url) {
|
||||||
echo '<li><a href="' . $url . '" target="_blank">' . $name . '</a></li>';
|
echo '<li><a href="' . $url . '" target="_blank">' . $name . '</a></li>';
|
||||||
} ?>
|
} ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
@ -34,13 +34,13 @@
|
|||||||
|
|
||||||
<!-- Font -->
|
<!-- Font -->
|
||||||
<?php foreach ($config->getTheme()->getFonts() as $font) {
|
<?php foreach ($config->getTheme()->getFonts() as $font) {
|
||||||
echo "<link href='$font' rel='stylesheet' type='text/css'>";
|
echo "<link href='$font' rel='stylesheet' type='text/css'>";
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
<!-- CSS -->
|
<!-- CSS -->
|
||||||
<?php foreach ($config->getTheme()->getCSS() as $css) {
|
<?php foreach ($config->getTheme()->getCSS() as $css) {
|
||||||
echo "<link href='$css' rel='stylesheet' type='text/css'>";
|
echo "<link href='$css' rel='stylesheet' type='text/css'>";
|
||||||
} ?>
|
} ?>
|
||||||
|
|
||||||
<?php if ($config->getHTML()->hasSearch()) { ?>
|
<?php if ($config->getHTML()->hasSearch()) { ?>
|
||||||
<!-- Search -->
|
<!-- Search -->
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!isset($config)) {
|
if (!isset($config)) {
|
||||||
$config = $params;
|
$config = $params;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!isset($config)) {
|
if (!isset($config)) {
|
||||||
$config = $params;
|
$config = $params;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
if (!isset($config)) {
|
if (!isset($config)) {
|
||||||
$config = $params;
|
$config = $params;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
|
||||||
namespace Todaymade\Daux\ContentTypes\Markdown;
|
|
||||||
|
|
||||||
use org\bovigo\vfs\vfsStream;
|
use org\bovigo\vfs\vfsStream;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config;
|
||||||
@ -13,7 +12,6 @@ class LinkRendererTest extends TestCase
|
|||||||
{
|
{
|
||||||
protected function getTree(Config $config)
|
protected function getTree(Config $config)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function providerRenderLink()
|
public function providerRenderLink()
|
||||||
|
@ -6,7 +6,8 @@ use PHPUnit\Framework\TestCase;
|
|||||||
|
|
||||||
class ConfigTest extends TestCase
|
class ConfigTest extends TestCase
|
||||||
{
|
{
|
||||||
function testHTMLConfigCreation() {
|
public function testHTMLConfigCreation()
|
||||||
|
{
|
||||||
$config = new MainConfig(['html' => ['edit_on' => 'test']]);
|
$config = new MainConfig(['html' => ['edit_on' => 'test']]);
|
||||||
|
|
||||||
$this->assertInstanceOf(Config::class, $config->getHTML());
|
$this->assertInstanceOf(Config::class, $config->getHTML());
|
||||||
|
@ -1,39 +1,44 @@
|
|||||||
<?php
|
<?php namespace Todaymade\Daux\Format\HTML\Test;
|
||||||
|
|
||||||
namespace Todaymade\Daux\Format\HTML\Test;
|
|
||||||
|
|
||||||
use Todaymade\Daux\Config as MainConfig;
|
use Todaymade\Daux\Config as MainConfig;
|
||||||
use \Todaymade\Daux\Format\HTML\ContentTypes\Markdown\CommonMarkConverter;
|
use \Todaymade\Daux\Format\HTML\ContentTypes\Markdown\CommonMarkConverter;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
class Engine {
|
class Engine
|
||||||
function render($template, $data) {
|
{
|
||||||
|
public function render($template, $data)
|
||||||
|
{
|
||||||
return $data['content'];
|
return $data['content'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Template {
|
class Template
|
||||||
function getEngine() {
|
{
|
||||||
|
public function getEngine()
|
||||||
|
{
|
||||||
return new Engine;
|
return new Engine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TableOfContentsTest extends TestCase
|
class TableOfContentsTest extends TestCase
|
||||||
{
|
{
|
||||||
function getConfig() {
|
public function getConfig()
|
||||||
|
{
|
||||||
$config = new MainConfig;
|
$config = new MainConfig;
|
||||||
$config->templateRenderer = new Template;
|
$config->templateRenderer = new Template;
|
||||||
|
|
||||||
return ['daux' => $config];
|
return ['daux' => $config];
|
||||||
}
|
}
|
||||||
|
|
||||||
function testNoTOCByDefault() {
|
public function testNoTOCByDefault()
|
||||||
|
{
|
||||||
$converter = new CommonMarkConverter($this->getConfig());
|
$converter = new CommonMarkConverter($this->getConfig());
|
||||||
|
|
||||||
$this->assertEquals("<h1 id=\"page_Test\">Test</h1>\n", $converter->convertToHtml('# Test'));
|
$this->assertEquals("<h1 id=\"page_Test\">Test</h1>\n", $converter->convertToHtml('# Test'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testTOCToken() {
|
public function testTOCToken()
|
||||||
|
{
|
||||||
$converter = new CommonMarkConverter($this->getConfig());
|
$converter = new CommonMarkConverter($this->getConfig());
|
||||||
|
|
||||||
$source = "[TOC]\n# Title";
|
$source = "[TOC]\n# Title";
|
||||||
@ -50,7 +55,8 @@ EXPECTED;
|
|||||||
$this->assertEquals($expected, $converter->convertToHtml($source));
|
$this->assertEquals($expected, $converter->convertToHtml($source));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testUnicodeTOC() {
|
public function testUnicodeTOC()
|
||||||
|
{
|
||||||
$converter = new CommonMarkConverter($this->getConfig());
|
$converter = new CommonMarkConverter($this->getConfig());
|
||||||
|
|
||||||
$source = "[TOC]\n# 基础操作\n# 操作基础";
|
$source = "[TOC]\n# 基础操作\n# 操作基础";
|
||||||
@ -71,7 +77,8 @@ EXPECTED;
|
|||||||
$this->assertEquals($expected, $converter->convertToHtml($source));
|
$this->assertEquals($expected, $converter->convertToHtml($source));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDuplicatedTOC() {
|
public function testDuplicatedTOC()
|
||||||
|
{
|
||||||
$converter = new CommonMarkConverter($this->getConfig());
|
$converter = new CommonMarkConverter($this->getConfig());
|
||||||
|
|
||||||
$source = "[TOC]\n# Test\n# Test";
|
$source = "[TOC]\n# Test\n# Test";
|
||||||
@ -92,7 +99,8 @@ EXPECTED;
|
|||||||
$this->assertEquals($expected, $converter->convertToHtml($source));
|
$this->assertEquals($expected, $converter->convertToHtml($source));
|
||||||
}
|
}
|
||||||
|
|
||||||
function testEscapedTOC() {
|
public function testEscapedTOC()
|
||||||
|
{
|
||||||
$converter = new CommonMarkConverter($this->getConfig());
|
$converter = new CommonMarkConverter($this->getConfig());
|
||||||
|
|
||||||
$source = "[TOC]\n# TEST : Test";
|
$source = "[TOC]\n# TEST : Test";
|
||||||
|
@ -4,16 +4,14 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Component\Console\Output\NullOutput;
|
use Symfony\Component\Console\Output\NullOutput;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Todaymade\Daux\Format\HTML\RawPage;
|
use Todaymade\Daux\Format\HTML\RawPage;
|
||||||
use Todaymade\Daux\Config;
|
|
||||||
use Todaymade\Daux\ConfigBuilder;
|
use Todaymade\Daux\ConfigBuilder;
|
||||||
use Todaymade\Daux\Daux;
|
use Todaymade\Daux\Daux;
|
||||||
use Todaymade\Daux\Server\Server;
|
|
||||||
use org\bovigo\vfs\vfsStream;
|
use org\bovigo\vfs\vfsStream;
|
||||||
|
|
||||||
class ServerTest extends TestCase
|
class ServerTest extends TestCase
|
||||||
{
|
{
|
||||||
function testCreateResponse() {
|
public function testCreateResponse()
|
||||||
|
{
|
||||||
$structure = [
|
$structure = [
|
||||||
'index.md' => 'first page',
|
'index.md' => 'first page',
|
||||||
'Page.md' => 'another page',
|
'Page.md' => 'another page',
|
||||||
@ -39,4 +37,3 @@ class ServerTest extends TestCase
|
|||||||
$this->assertEquals("text/css", $response->headers->get('Content-Type'));
|
$this->assertEquals("text/css", $response->headers->get('Content-Type'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user