This commit is contained in:
Stéphane Goetz 2015-07-18 21:23:02 +02:00
parent aa5602a0fb
commit 7dc7c045d4
10 changed files with 22 additions and 18 deletions

BIN
daux.phar

Binary file not shown.

1
generate.php → generate Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env php
<?php <?php
/* /*

View File

@ -109,9 +109,9 @@ class Compiler
private function addBinary($phar) private function addBinary($phar)
{ {
$content = file_get_contents(__DIR__ . '/../generate.php'); $content = file_get_contents(__DIR__ . '/../generate');
//$content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content); $content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);
$phar->addFromString('generate.php', $content); $phar->addFromString('generate', $content);
} }
/** /**
@ -166,7 +166,7 @@ define('PHAR_DIR', dirname(__FILE__));
Phar::mapPhar('daux.phar'); Phar::mapPhar('daux.phar');
require 'phar://daux.phar/generate.php'; require 'phar://daux.phar/generate';
__HALT_COMPILER(); __HALT_COMPILER();
EOF; EOF;

View File

@ -98,7 +98,7 @@ class DauxHelper
* *
* @param Directory $tree * @param Directory $tree
* @param string $request * @param string $request
* @return Tree\Entry|false * @return Tree\Content|Tree\Raw
*/ */
public static function getFile($tree, $request) public static function getFile($tree, $request)
{ {

View File

@ -20,12 +20,16 @@ class MarkdownPage extends \Todaymade\Daux\Format\Base\MarkdownPage
$this->language = ''; $this->language = '';
if ($this->params['multilanguage'] && count($this->file->getParents())) { if ($this->params['multilanguage'] && count($this->file->getParents())) {
reset($this->file->getParents()); $language_dir = $this->file->getParents()[0];
$language_dir = current($this->file->getParents()); $this->language = $language_dir->getName();
$this->language = $language_dir->name;
} }
} }
/**
* @param \Todaymade\Daux\Tree\Directory[] $parents
* @param bool $multilanguage
* @return array
*/
private function getBreadcrumbTrail($parents, $multilanguage) private function getBreadcrumbTrail($parents, $multilanguage)
{ {
if ($multilanguage && !empty($parents)) { if ($multilanguage && !empty($parents)) {

View File

@ -25,7 +25,7 @@ class Helper
* *
* @param string $dir * @param string $dir
*/ */
private static function rmdir($dir) protected static function rmdir($dir)
{ {
$it = new \RecursiveDirectoryIterator($dir); $it = new \RecursiveDirectoryIterator($dir);
$files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST); $files = new \RecursiveIteratorIterator($it, \RecursiveIteratorIterator::CHILD_FIRST);
@ -47,7 +47,7 @@ class Helper
* @param string $source * @param string $source
* @param string $destination * @param string $destination
*/ */
private static function copyRecursive($source, $destination) protected static function copyRecursive($source, $destination)
{ {
if (!is_dir($destination)) { if (!is_dir($destination)) {
mkdir($destination); mkdir($destination);

View File

@ -5,7 +5,6 @@ use Todaymade\Daux\DauxHelper;
use Todaymade\Daux\Exception; use Todaymade\Daux\Exception;
use Todaymade\Daux\Format\HTML\MarkdownPage; use Todaymade\Daux\Format\HTML\MarkdownPage;
use Todaymade\Daux\Format\HTML\RawPage; use Todaymade\Daux\Format\HTML\RawPage;
use Todaymade\Daux\Format\HTML\SimplePage;
use Todaymade\Daux\Tree\Raw; use Todaymade\Daux\Tree\Raw;
class Server class Server

View File

@ -38,7 +38,6 @@ class Builder
continue; continue;
} }
$entry = null;
if (is_dir($path)) { if (is_dir($path)) {
$new = new Directory($node, static::getUriFromFilename(static::getFilename($path)), $path); $new = new Directory($node, static::getUriFromFilename(static::getFilename($path)), $path);
$new->setName(DauxHelper::pathinfo($path)['filename']); $new->setName(DauxHelper::pathinfo($path)['filename']);

View File

@ -37,11 +37,11 @@ abstract class Entry
$this->setUri($uri); $this->setUri($uri);
$this->setParent($parent); $this->setParent($parent);
if ($path) { if ($path !== null) {
$this->path = $path; $this->path = $path;
} }
if ($last_modified) { if ($last_modified !== null) {
$this->last_modified = $last_modified; $this->last_modified = $last_modified;
} }
} }
@ -118,7 +118,8 @@ abstract class Entry
// First we try to find a real page // First we try to find a real page
foreach ($this->getEntries() as $node) { foreach ($this->getEntries() as $node) {
if ($node instanceof Content) { 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 //the homepage should not count as first page
continue; continue;
} }
@ -174,7 +175,7 @@ abstract class Entry
/** /**
* Return all parents starting with the root * Return all parents starting with the root
* *
* @return array<Directory> * @return Directory[]
*/ */
public function getParents() public function getParents()
{ {
@ -231,7 +232,7 @@ abstract class Entry
'name' => $this->getName(), 'name' => $this->getName(),
'uri' => $this->getUri(), 'uri' => $this->getUri(),
'url' => $this->getUrl(), 'url' => $this->getUrl(),
'index' => $this->getIndexPage()? $this->getIndexPage()->getUrl() : '', 'index' => $this->getIndexPage() ? $this->getIndexPage()->getUrl() : '',
'first' => $this->getFirstPage() ? $this->getFirstPage()->getUrl() : '', 'first' => $this->getFirstPage() ? $this->getFirstPage()->getUrl() : '',
'path' => $this->path 'path' => $this->path
]; ];

View File

@ -5,7 +5,7 @@ class Root extends Directory
/** /**
* The root doesn't have a parent * The root doesn't have a parent
* *
* @param Directory $uri * @param string $uri
*/ */
public function __construct($uri) public function __construct($uri)
{ {