diff --git a/daux.phar b/daux.phar index 28ceb57..d798523 100644 Binary files a/daux.phar and b/daux.phar differ diff --git a/libs/Format/HTML/Generator.php b/libs/Format/HTML/Generator.php index 6d3c019..dc4370a 100644 --- a/libs/Format/HTML/Generator.php +++ b/libs/Format/HTML/Generator.php @@ -1,6 +1,7 @@ generateRecursive($daux->tree, $destination, $params, $output, $width); } + private function rebaseConfig(Config $config, $base_url) + { + // Avoid changing the url if it is already correct + if ($config['base_url'] == $base_url && !empty($config['theme']) && !is_string($config['theme'])) { + return; + } + + // Change base url for all links on the pages + $config['base_url'] = $config['base_page'] = $base_url; + $config['theme'] = DauxHelper::getTheme($config, $base_url); + $config['image'] = str_replace('', $base_url, $config['image']); + } + /** * Recursively generate the documentation * @@ -45,20 +59,20 @@ class Generator */ private function generateRecursive(Directory $tree, $output_dir, $params, $output, $width, $base_url = '') { - $params['base_url'] = $params['base_page'] = $base_url; + $this->rebaseConfig($params, $base_url); - // Rebase Theme - $params['theme'] = DauxHelper::getTheme($params, $base_url); - - $params['image'] = str_replace('', $base_url, $params['image']); if ($base_url !== '' && empty($params['entry_page'])) { $params['entry_page'] = $tree->getFirstPage(); } + foreach ($tree->getEntries() as $key => $node) { if ($node instanceof Directory) { $new_output_dir = $output_dir . DS . $key; mkdir($new_output_dir); $this->generateRecursive($node, $new_output_dir, $params, $output, $width, '../' . $base_url); + + // Rebase configuration again as $params is a shared object + $this->rebaseConfig($params, $base_url); } elseif ($node instanceof Content) { $this->runAction( "- " . $node->getUrl(), diff --git a/libs/Tree/Builder.php b/libs/Tree/Builder.php index 0df78f5..e45252a 100644 --- a/libs/Tree/Builder.php +++ b/libs/Tree/Builder.php @@ -1,6 +1,5 @@