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