private function generateRecursive(Directory $tree, Config $params, $base_url = '') { $final = ['title' => $this->prefix . $tree->getTitle()]; $params['base_url'] = $params['base_page'] = $base_url; $params['image'] = str_replace('<base_url>', $base_url, $params['image']); if ($base_url !== '') { $params['entry_page'] = $tree->getFirstPage(); } foreach ($tree->getEntries() as $key => $node) { if ($node instanceof Directory) { $final['children'][$this->prefix . $node->getTitle()] = $this->generateRecursive($node, $params, '../' . $base_url); } elseif ($node instanceof Content) { $params['request'] = $node->getUrl(); $contentType = $this->daux->getContentTypeHandler()->getType($node); $data = ['title' => $this->prefix . $node->getTitle(), 'file' => $node, 'page' => ContentPage::fromFile($node, $params, $contentType)]; // As the page is lazily generated // We do it now to fail fast in case of problem $data['page']->getContent(); if ($key == 'index.html') { $final['title'] = $this->prefix . $tree->getTitle(); $final['file'] = $node; $final['page'] = $data['page']; } else { $final['children'][$data['title']] = $data; } } } return $final; }
/** * {@inheritdoc} */ public function generateAll(InputInterface $input, OutputInterface $output, $width) { $params = $this->daux->getParams(); $data = ['author' => $params['author'], 'title' => $params['title'], 'subject' => $params['tagline']]; $book = new Book($this->daux->tree, $data); $current = $this->daux->tree->getIndexPage(); while ($current) { $this->runAction('Generating ' . $current->getTitle(), $output, $width, function () use($book, $current, $params) { $contentType = $this->daux->getContentTypeHandler()->getType($current); $content = ContentPage::fromFile($current, $params, $contentType)->getContent(); $book->addPage($current, $content); }); $current = $current->getNext(); } $content = $book->generate(); file_put_contents($input->getOption('destination') . '/file.html', $content); }
/** * @param Entry $node * @param Config $params * @return \Todaymade\Daux\Format\Base\Page */ public function generateOne(Entry $node, Config $params) { if ($node instanceof Raw) { return new RawPage($node->getPath()); } $params['request'] = $node->getUrl(); return ContentPage::fromFile($node, $params, $this->daux->getContentTypeHandler()->getType($node)); }