diff --git a/daux.phar b/daux.phar index f903c1b..d247e8b 100755 Binary files a/daux.phar and b/daux.phar differ diff --git a/generate.php b/generate old mode 100644 new mode 100755 similarity index 99% rename from generate.php rename to generate index 89cfdd2..146dd5b --- a/generate.php +++ b/generate @@ -1,3 +1,4 @@ +#!/usr/bin/env php addFromString('generate.php', $content); + $content = file_get_contents(__DIR__ . '/../generate'); + $content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content); + $phar->addFromString('generate', $content); } /** @@ -166,7 +166,7 @@ define('PHAR_DIR', dirname(__FILE__)); Phar::mapPhar('daux.phar'); -require 'phar://daux.phar/generate.php'; +require 'phar://daux.phar/generate'; __HALT_COMPILER(); EOF; diff --git a/libs/DauxHelper.php b/libs/DauxHelper.php index a5b5623..49f0a59 100644 --- a/libs/DauxHelper.php +++ b/libs/DauxHelper.php @@ -98,7 +98,7 @@ class DauxHelper * * @param Directory $tree * @param string $request - * @return Tree\Entry|false + * @return Tree\Content|Tree\Raw */ public static function getFile($tree, $request) { diff --git a/libs/Format/HTML/MarkdownPage.php b/libs/Format/HTML/MarkdownPage.php index 3a43d25..fa0faef 100644 --- a/libs/Format/HTML/MarkdownPage.php +++ b/libs/Format/HTML/MarkdownPage.php @@ -20,12 +20,16 @@ class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage $this->language = ''; if ($this->params['multilanguage'] && count($this->file->getParents())) { - reset($this->file->getParents()); - $language_dir = current($this->file->getParents()); - $this->language = $language_dir->name; + $language_dir = $this->file->getParents()[0]; + $this->language = $language_dir->getName(); } } + /** + * @param \Todaymade\Daux\Tree\Directory[] $parents + * @param bool $multilanguage + * @return array + */ private function getBreadcrumbTrail($parents, $multilanguage) { if ($multilanguage && !empty($parents)) { diff --git a/libs/Generator/Helper.php b/libs/Generator/Helper.php index cdda5e2..167dead 100644 --- a/libs/Generator/Helper.php +++ b/libs/Generator/Helper.php @@ -25,7 +25,7 @@ class Helper * * @param string $dir */ - private static function rmdir($dir) + protected static function rmdir($dir) { $it = new \RecursiveDirectoryIterator($dir); $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); @@ -47,7 +47,7 @@ class Helper * @param string $source * @param string $destination */ - private static function copyRecursive($source, $destination) + protected static function copyRecursive($source, $destination) { if (!is_dir($destination)) { mkdir($destination); diff --git a/libs/Server/Server.php b/libs/Server/Server.php index 1469b69..5007182 100644 --- a/libs/Server/Server.php +++ b/libs/Server/Server.php @@ -5,7 +5,6 @@ use Todaymade\Daux\DauxHelper; use Todaymade\Daux\Exception; use Todaymade\Daux\Format\HTML\MarkdownPage; use Todaymade\Daux\Format\HTML\RawPage; -use Todaymade\Daux\Format\HTML\SimplePage; use Todaymade\Daux\Tree\Raw; class Server diff --git a/libs/Tree/Builder.php b/libs/Tree/Builder.php index 94713d5..e4f0225 100644 --- a/libs/Tree/Builder.php +++ b/libs/Tree/Builder.php @@ -38,7 +38,6 @@ class Builder continue; } - $entry = null; if (is_dir($path)) { $new = new Directory($node, static::getUriFromFilename(static::getFilename($path)), $path); $new->setName(DauxHelper::pathinfo($path)['filename']); diff --git a/libs/Tree/Entry.php b/libs/Tree/Entry.php index d922dc9..5c23919 100644 --- a/libs/Tree/Entry.php +++ b/libs/Tree/Entry.php @@ -37,11 +37,11 @@ abstract class Entry $this->setUri($uri); $this->setParent($parent); - if ($path) { + if ($path !== null) { $this->path = $path; } - if ($last_modified) { + if ($last_modified !== null) { $this->last_modified = $last_modified; } } @@ -118,7 +118,8 @@ abstract class Entry // First we try to find a real page foreach ($this->getEntries() as $node) { if ($node instanceof Content) { - if (!$node->getParent() && $node->title == 'index') { + // TODO :: this condition looks weird ... + if (!$node->getParent() && $node->getTitle() == 'index') { //the homepage should not count as first page continue; } @@ -174,7 +175,7 @@ abstract class Entry /** * Return all parents starting with the root * - * @return array + * @return Directory[] */ public function getParents() { @@ -231,7 +232,7 @@ abstract class Entry 'name' => $this->getName(), 'uri' => $this->getUri(), 'url' => $this->getUrl(), - 'index' => $this->getIndexPage()? $this->getIndexPage()->getUrl() : '', + 'index' => $this->getIndexPage() ? $this->getIndexPage()->getUrl() : '', 'first' => $this->getFirstPage() ? $this->getFirstPage()->getUrl() : '', 'path' => $this->path ]; diff --git a/libs/Tree/Root.php b/libs/Tree/Root.php index 6aae9d7..92eec5c 100644 --- a/libs/Tree/Root.php +++ b/libs/Tree/Root.php @@ -5,7 +5,7 @@ class Root extends Directory /** * The root doesn't have a parent * - * @param Directory $uri + * @param string $uri */ public function __construct($uri) {