<commit_before><?php namespace Todaymade\Daux\Format\HTML;

use Todaymade\Daux\Daux;
use Todaymade\Daux\DauxHelper;
use Todaymade\Daux\Generator\Helper;
use Todaymade\Daux\Tree\Directory;
use Todaymade\Daux\Tree\Content;

class Generator
{
    public function generate(Daux $daux, $destination)
    {
        $params = $daux->getParams();
        if (is_null($destination)) {
            $destination = $daux->local_base . DS . 'static';
        }

        echo "Copying Static assets ...\n";
        Helper::copyAssets($destination, $daux->local_base);

        echo "Generating ...\n";
        $this->generateRecursive($daux->tree, $destination, $params);
        echo "Done !\n";
    }

    private function generateRecursive($tree, $output_dir, $params, $base_url = '')
    {
        $params['base_url'] = $params['base_page'] = $base_url;

        // Rebase Theme
        $params['theme'] = DauxHelper::getTheme($params, $base_url);

        $params['image'] = str_replace('<base_url>', $base_url, $params['image']);
        if ($base_url !== '') {
            $params['entry_page'] = $tree->getFirstPage();
        }
        foreach ($tree->value 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, '../' . $base_url);
            } elseif ($node instanceof Content) {
                echo "- " . $node->getUrl() . "\n";
                $params['request'] = $node->getUrl();
                $params['file_uri'] = $node->getName();

                $page = MarkdownPage::fromFile($node, $params);
                file_put_contents($output_dir . DS . $key, $page->getContent());
            } else {
                echo "- " . $node->getUrl() . "\n";
                copy($node->getPath(), $output_dir . DS . $key);
            }
        }
    }
}
<commit_msg>Use the right entry page<commit_after><?php namespace Todaymade\Daux\Format\HTML;

use Todaymade\Daux\Daux;
use Todaymade\Daux\DauxHelper;
use Todaymade\Daux\Generator\Helper;
use Todaymade\Daux\Tree\Directory;
use Todaymade\Daux\Tree\Content;

class Generator
{
    public function generate(Daux $daux, $destination)
    {
        $params = $daux->getParams();
        if (is_null($destination)) {
            $destination = $daux->local_base . DS . 'static';
        }

        echo "Copying Static assets ...\n";
        Helper::copyAssets($destination, $daux->local_base);

        echo "Generating ...\n";
        $this->generateRecursive($daux->tree, $destination, $params);
        echo "Done !\n";
    }

    private function generateRecursive($tree, $output_dir, $params, $base_url = '')
    {
        $params['base_url'] = $params['base_page'] = $base_url;

        // Rebase Theme
        $params['theme'] = DauxHelper::getTheme($params, $base_url);

        $params['image'] = str_replace('<base_url>', $base_url, $params['image']);
        if ($base_url !== '' && empty($params['entry_page'])) {
            $params['entry_page'] = $tree->getFirstPage();
        }
        foreach ($tree->value 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, '../' . $base_url);
            } elseif ($node instanceof Content) {
                echo "- " . $node->getUrl() . "\n";
                $params['request'] = $node->getUrl();
                $params['file_uri'] = $node->getName();

                $page = MarkdownPage::fromFile($node, $params);
                file_put_contents($output_dir . DS . $key, $page->getContent());
            } else {
                echo "- " . $node->getUrl() . "\n";
                copy($node->getPath(), $output_dir . DS . $key);
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.17042289187135984, 'fraction_numerical': 0.0, 'mean_word_length': 2.188054882970137, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3926692', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1195, 'n_words': 225}