/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $releases = $project->getReleases($input->getOption('locale')); if (count($releases)) { $table = new Table($output); $table->setHeaders(['Version']); foreach ($releases as $release) { $table->addRow([$release->getVersionNumber()]); } $table->render(); $output->writeln(''); if (count($releases) === 1) { $output->writeln('1 release found'); } else { $output->writeln(count($releases) . ' releases found'); } } else { $output->writeln('0 releases found'); } } else { $output->writeln('<error>This is not a valid Shade project</error>'); } }
/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $videos = $project->getVideos($input->getOption('locale')); if ($videos->count()) { $table = new Table($output); $table->setHeaders(['Name', 'Group', 'Title', 'Play Time', 'Wistia Code']); foreach ($videos as $video) { $table->addRow([$video->getShortName(), $video->getGroupName(), $video->getTitle(), $video->getPlayTime(), $video->getProperty('wistia_code')]); } $table->render(); $output->writeln(''); if ($videos->count() === 1) { $output->writeln('1 video found'); } else { $output->writeln($videos->count() . ' videos found'); } } else { $output->writeln('0 videos found'); } } else { $output->writeln('<error>This is not a valid Shade project</error>'); } }
/** * @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 InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $common_questions = $project->getCommonQuestions($input->getOption('locale')); if (count($common_questions)) { $table = new Table($output); $table->setHeaders(['Question', 'Book', 'Page', 'Position']); foreach ($common_questions as $common_question) { $table->addRow([$common_question['question'], $common_question['book'], $common_question['page'], $common_question['position']]); } $table->render(); $output->writeln(''); if (count($common_questions) === 1) { $output->writeln('1 question found'); } else { $output->writeln(count($common_questions) . ' questions found'); } } else { $output->writeln('0 questions found'); } } else { $output->writeln('<error>This is not a valid Shade project</error>'); } }
/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $book = $project->getBook($input->getArgument('name'), $input->getOption('locale')); if ($book instanceof Book) { $table = new Table($output); $table->setHeaders(['Property', 'Value']); $table->addRow(['Short Name', $book->getShortName()]); $table->addRow(['Title', $book->getTitle()]); $pages = $book->getPages(); if ($pages->count() > 0) { $page_titles = []; foreach ($pages as $page) { $page_titles[] = $page->getTitle(); } $table->addRow(['Pages', implode("\n", $page_titles)]); } else { $table->addRow(['Pages', '--']); } $table->render(); } else { $output->writeln('<error>Book "' . $input->getArgument('name') . ' not found"</error>'); } } else { $output->writeln('<error>This is not a valid Shade project</error>'); } }
/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $books = $project->getBooks($input->getOption('locale')); if (count($books)) { $table = new Table($output); $table->setHeaders(['Name', 'Title', 'Pages', 'Position']); foreach ($books as $book) { $table->addRow([$book->getShortName(), $book->getTitle(), $book->getPages()->count(), $book->getPosition()]); } $table->render(); $output->writeln(''); if (count($books) === 1) { $output->writeln('1 book found'); } else { $output->writeln(count($books) . ' books found'); } } else { $output->writeln('0 books found'); } } else { $output->writeln('<error>This is not a valid Shade project</error>'); } }
/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $default_locale = $project->getDefaultLocale(); $table = new Table($output); $table->setHeaders(['Code', 'Name', 'Is Default?']); foreach ($project->getLocales() as $code => $name) { $table->addRow([$code, $name, $code === $default_locale ? 'Yes' : 'No']); } $table->render(); } else { $output->writeln('<error>This is not a valid Shade project</error>'); } }
/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $output->writeln('Project already initialized'); } else { $configuration = ['name' => $input->getArgument('name'), 'default_build_theme' => 'bootstrap', 'video_groups' => [Video::GETTING_STARTED => 'Getting Started']]; if (empty($configuration['name'])) { $configuration['name'] = basename($project->getPath()); } $default_locale = $input->getOption('default-locale'); if ($default_locale) { $configuration['is_multilingual'] = true; $configuration['default_locale'] = $default_locale; } if (file_put_contents($project->getPath() . '/project.json', json_encode($configuration, JSON_PRETTY_PRINT))) { $output->writeln('Project initialized'); } else { $output->writeln('<error>Failed to create a project configuration file</error>'); } if ($default_locale) { if (!mkdir($project->getPath() . '/' . $default_locale)) { $output->writeln("<error>Failed to create '{$default_locale}' folder</error>"); } if (!file_put_contents($project->getPath() . '/' . $default_locale . '/index.md', $this->getProjectIndexMd())) { $output->writeln("<error>Failed to create '{$default_locale}/index.md' folder</error>"); } } else { if (!file_put_contents($project->getPath() . '/index.md', $this->getProjectIndexMd())) { $output->writeln("<error>Failed to create 'index.md' folder</error>"); } } foreach (['books', 'releases', 'videos', 'whats_new'] as $what_to_make) { if ($default_locale) { $what_to_make = "{$default_locale}/{$what_to_make}"; } if (!mkdir($project->getPath() . '/' . $what_to_make)) { $output->writeln("<error>Failed to create '{$what_to_make}' folder</error>"); } } if (!mkdir($project->getPath() . '/temp')) { $output->writeln('<error>Failed to create /temp folder</error>'); } if (!mkdir($project->getPath() . '/build')) { $output->writeln('<error>Failed to create /build folder</error>'); } } }
/** * @param string $sub_dir * @param string $locale * @return string */ private function getLocalizedPath($sub_dir, $locale) { if ($this->project->isMultilingual()) { return $this->project->getPath() . "/{$locale}/{$sub_dir}"; } else { return $this->project->getPath() . "/{$sub_dir}"; } }
/** * @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(); } }
/** * @param InputInterface $input * @param OutputInterface $output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $project = new Project(getcwd()); if ($project->isValid()) { $table = new Table($output); $table->setHeaders(['Plugin', 'Enabled?']); foreach (Shade::getPlugins($project) as $plugin) { $is_enabled = $plugin->isEnabled(); if ($is_enabled === true) { $is_enabled = 'Yes'; } elseif ($is_enabled === false) { $is_enabled = ''; } $table->addRow([$plugin->getName(), $is_enabled]); } $table->render(); } else { $output->writeln('<error>This is not a valid Shade project</error>'); } }
/** * @param InputInterface $input * @param Project $project * @return Theme * @throws Shade\Error\ThemeNotFoundError */ private function getTheme(InputInterface $input, Project &$project) { return $project->getBuildTheme($input->getOption('theme')); }
/** * Method that is used for collecting to-do items * * @param string $message * @param Project|Element $element */ public static function recordTodo($message, $element) { if ($element instanceof Element) { $path = $element->getPath(); } elseif ($element instanceof Project) { $path = $element->getPath(); } else { $path = '-UNKNOWN-'; } self::$todo[] = ['message' => $message, 'file' => $path]; }