/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $articles = $project->getWhatsNewArticles($input->getOption('locale')); if ($articles->count()) { $table = new Table($output); $table->setHeaders(['Name', 'Version', 'Title']); foreach ($articles as $article) { $table->addRow([$article->getShortName(), $article->getVersionNumber(), $article->getTitle()]); } $table->render(); $output->writeln(''); if ($articles->count() === 1) { $output->writeln('1 article found'); } else { $output->writeln($articles->count() . ' articles found'); } } else { $output->writeln('0 articles found'); } } else { $output->writeln('<error>This is not a valid Shade project</error>'); } }
/** * @param Project $project * @param string|null $locale */ private function renderEverything(Project &$project, $locale) { foreach ($project->getBooks($locale) as $book) { $book->renderBody(); foreach ($book->getPages() as $page) { $page->renderBody(); } } foreach ($project->getWhatsNewArticles($locale) as $article) { $article->renderBody(); } foreach ($project->getReleases($locale) as $release) { $release->renderBody(); } foreach ($project->getVideos($locale) as $video) { $video->renderBody(); } }
/** * Build what's new section of the project * * @param InputInterface $input * @param OutputInterface $output * @param Project $project * @param string $target_path * @param Theme $theme * @param string $locale * @return bool * @throws Exception * @throws \SmartyException */ public function buildWhatsNew(InputInterface $input, OutputInterface $output, Project $project, $target_path, Theme $theme, $locale) { $whats_new_path = $locale === $project->getDefaultLocale() ? "{$target_path}/whats-new" : "{$target_path}/{$locale}/whats-new"; $whats_new_images_path = $locale === $project->getDefaultLocale() ? "{$target_path}/assets/images/whats-new" : "{$target_path}/assets/images/{$locale}/whats-new"; Shade::createDir($whats_new_path, function ($path) use(&$output) { $output->writeln("Directory '{$path}' created"); }); Shade::createDir($whats_new_images_path, function ($path) use(&$output) { $output->writeln("Directory '{$path}' created"); }); $whats_new_articles = $project->getWhatsNewArticles($locale); foreach ($whats_new_articles as $whats_new_article) { $this->copyVersionImages($project, $whats_new_article, $target_path, $locale, $output); } $whats_new_articles_by_version = $this->getWhatsNewArticlesByVersion($whats_new_articles); $this->smarty->assign(['whats_new_articles' => $whats_new_articles, 'whats_new_articles_by_version' => $whats_new_articles_by_version, 'current_whats_new_article' => $this->getCurrentArticleFromSortedArticles($whats_new_articles_by_version), 'page_level' => 1, 'current_section' => 'whats_new']); Shade::writeFile("{$whats_new_path}/index.html", $this->smarty->fetch('whats_new_article.tpl'), function ($path) use(&$output) { $output->writeln("File '{$path}' created"); }); Shade::writeFile("{$whats_new_path}/rss.xml", $this->smarty->fetch('rss.tpl'), function ($path) use(&$output) { $output->writeln("File '{$path}' created"); }); foreach ($whats_new_articles as $whats_new_article) { $this->smarty->assign('current_whats_new_article', $whats_new_article); Shade::writeFile("{$whats_new_path}/" . $whats_new_article->getShortName() . ".html", $this->smarty->fetch('whats_new_article.tpl'), function ($path) use(&$output) { $output->writeln("File '{$path}' created"); }); } return true; }