Fix index pages detection in live mode
This commit is contained in:
bovenliggende
d921c412b5
commit
f903b0060c
@ -69,8 +69,6 @@ class Daux
|
||||
|
||||
//config.json
|
||||
$this->loadConfigOverrides($override_file);
|
||||
|
||||
$this->generateTree();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,7 +143,7 @@ class Daux
|
||||
/**
|
||||
* Generate the tree that will be used
|
||||
*/
|
||||
private function generateTree()
|
||||
public function generateTree()
|
||||
{
|
||||
$this->tree = new Root($this->getParams(), $this->docs_path);
|
||||
Builder::build($this->tree, $this->options['ignore']);
|
||||
|
@ -3,7 +3,8 @@
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\Tree\Entry;
|
||||
|
||||
interface LiveGenerator {
|
||||
interface LiveGenerator
|
||||
{
|
||||
/**
|
||||
* @param Entry $node
|
||||
* @param Config $params
|
||||
|
@ -96,7 +96,7 @@ class Template
|
||||
foreach ($tree->getEntries() as $node) {
|
||||
$url = $node->getUri();
|
||||
if ($node instanceof Content) {
|
||||
if ($node->getName() === '_index') {
|
||||
if (in_array($node->getName(), ['index', '_index'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,8 @@ class Command extends SymfonyCommand
|
||||
// Instiantiate the processor if one is defined
|
||||
$this->prepareProcessor($daux, $input, $output, $width);
|
||||
|
||||
// Improve the tree with a processor
|
||||
// Generate the tree
|
||||
$daux->generateTree();
|
||||
$daux->getProcessor()->manipulateTree($daux->tree);
|
||||
|
||||
// Set the format if requested
|
||||
|
@ -5,7 +5,6 @@ use Todaymade\Daux\Daux;
|
||||
use Todaymade\Daux\DauxHelper;
|
||||
use Todaymade\Daux\Exception;
|
||||
use Todaymade\Daux\Format\Base\LiveGenerator;
|
||||
use Todaymade\Daux\Format\HTML\Generator;
|
||||
use Todaymade\Daux\Format\HTML\RawPage;
|
||||
|
||||
class Server
|
||||
@ -23,7 +22,6 @@ class Server
|
||||
public static function serve()
|
||||
{
|
||||
$daux = new Daux(Daux::LIVE_MODE);
|
||||
|
||||
$daux->initialize();
|
||||
|
||||
$class = $daux->getProcessorClass();
|
||||
@ -31,14 +29,17 @@ class Server
|
||||
$daux->setProcessor(new $class($daux, new NullOutput(), 0));
|
||||
}
|
||||
|
||||
// Set this critical configuration
|
||||
// for the tree generation
|
||||
$daux->getParams()['index_key'] = 'index';
|
||||
|
||||
// Improve the tree with a processor
|
||||
$daux->generateTree();
|
||||
$daux->getProcessor()->manipulateTree($daux->tree);
|
||||
|
||||
$server = new static($daux);
|
||||
|
||||
try {
|
||||
|
||||
|
||||
$page = $server->handle($_REQUEST);
|
||||
} catch (NotFoundException $e) {
|
||||
http_response_code(404);
|
||||
@ -85,7 +86,6 @@ class Server
|
||||
{
|
||||
$params = $this->daux->getParams();
|
||||
|
||||
$params['index_key'] = 'index';
|
||||
$params['host'] = $this->host;
|
||||
|
||||
DauxHelper::rebaseConfiguration($params, '//' . $this->base_url);
|
||||
@ -111,8 +111,8 @@ class Server
|
||||
|
||||
$request = $this->getRequest();
|
||||
$request = urldecode($request);
|
||||
if ($request == 'first_page') {
|
||||
$request = $this->daux->tree->getFirstPage()->getUri();
|
||||
if ($request == 'index_page') {
|
||||
$request = $this->daux->tree->getIndexPage()->getUri();
|
||||
}
|
||||
|
||||
return $this->getPage($request);
|
||||
@ -171,7 +171,7 @@ class Server
|
||||
}
|
||||
$uri = str_replace(array('//', '../'), '/', trim($uri, '/'));
|
||||
if ($uri == "") {
|
||||
$uri = "first_page";
|
||||
$uri = "index_page";
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
|
Laden…
Verwijs in nieuw issue
Block a user