Example #1
0
 /**
  * @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()) {
         $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>');
     }
 }
Example #3
0
 /**
  * @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>');
     }
 }
Example #4
0
 /**
  * @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()) {
         $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>');
     }
 }
Example #6
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     ini_set('date.timezone', 'UTC');
     $project = new Project(getcwd());
     if ($project->isValid()) {
         Shade::initSmarty($project, Shade::getBuildTheme($project->getDefaultBuildTheme()));
         $this->renderEverything($project, $input->getOption('locale'));
         $todo_notes = Shade::getTodo();
         if (count($todo_notes)) {
             $table = new Table($output);
             $table->setHeaders(['Message', 'File']);
             $path_len = strlen(rtrim($project->getPath(), '/'));
             foreach ($todo_notes as $todo_note) {
                 $table->addRow([$todo_note['message'], substr($todo_note['file'], $path_len + 1)]);
             }
             $table->render();
             $output->writeln('');
             if (count($todo_notes) === 1) {
                 $output->writeln('1 todo note found');
             } else {
                 $output->writeln(count($todo_notes) . ' todo notes found');
             }
         } else {
             $output->writeln('0 todo notes found');
         }
     } else {
         $output->writeln('<error>This is not a valid Shade project</error>');
     }
 }
Example #7
0
 /**
  * @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>');
     }
 }
Example #8
0
 /**
  * @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>');
     }
 }
Example #9
0
 /**
  * @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>');
         }
     }
 }
Example #10
0
 /**
  * @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>');
     }
 }
Example #11
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     ini_set('date.timezone', 'UTC');
     $project = new Project(getcwd());
     if ($project->isValid()) {
         $target_path = $this->getBuildTarget($input, $project);
         $theme = $this->getTheme($input, $project);
         if (!$this->isValidTargetPath($target_path)) {
             $output->writeln("Build target '{$target_path}' not found or not writable");
             return;
         }
         if (!$theme instanceof Theme) {
             $output->writeln("Theme not found");
             return;
         }
         $this->smarty =& Shade::initSmarty($project, $theme);
         $this->prepareTargetPath($input, $output, $project, $target_path, $theme);
         foreach ($project->getLocales() as $locale => $locale_name) {
             Shade\SmartyHelpers::setCurrentLocale($locale);
             $this->smarty->assign('current_locale', $locale);
             foreach (['buildLandingPage', 'buildWhatsNew', 'buildReleaseNotes', 'buildBooks', 'buildVideos'] as $build_step) {
                 try {
                     if (!$this->{$build_step}($input, $output, $project, $target_path, $theme, $locale)) {
                         $output->writeln("Build process failed at step '{$build_step}'. Aborting...");
                         return;
                     }
                 } catch (Exception $e) {
                     $output->writeln('Exception: ' . $e->getMessage());
                     $output->writeln($e->getTraceAsString());
                 }
             }
         }
     } else {
         $output->writeln('<error>This is not a valid Shade project</error>');
     }
 }