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>');
     }
 }
Example #2
0
 /**
  * @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();
     }
 }
Example #3
0
 /**
  * Build videos
  *
  * @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 buildVideos(InputInterface $input, OutputInterface $output, Project $project, $target_path, Theme $theme, $locale)
 {
     $videos_path = $locale === $project->getDefaultLocale() ? "{$target_path}/videos" : "{$target_path}/{$locale}/videos";
     Shade::createDir($videos_path, function ($path) use(&$output) {
         $output->writeln("Directory '{$path}' created");
     });
     if (is_dir($project->getFinder()->getVideosPath($locale) . '/images')) {
         $video_images_path = $locale === $project->getDefaultLocale() ? "{$target_path}/assets/images/videos" : "{$target_path}/assets/images/{$locale}/videos";
         Shade::createDir($video_images_path, function ($path) use(&$output) {
             $output->writeln("Directory '{$path}' created");
         });
         Shade::copyDir($project->getFinder()->getVideosPath($locale) . '/images', $video_images_path, null, function ($path) use(&$output) {
             $output->writeln("{$path} copied");
         });
     }
     $videos = $project->getVideos();
     if (!$videos->count()) {
         return true;
         // Skip video section rendering
     }
     $video_groups = $project->getVideoGroups();
     $this->smarty->assign(['video_groups' => $video_groups, 'videos' => $videos, 'page_level' => 1, 'video_player' => $project->getVideoPlayer(), 'current_video' => $this->getCurrentVideo($video_groups, $videos), 'current_section' => 'videos']);
     Shade::writeFile("{$videos_path}/index.html", $this->smarty->fetch('videos.tpl'), function ($path) use(&$output) {
         $output->writeln("File '{$path}' created");
     });
     foreach ($videos as $video) {
         $this->smarty->assign(['current_video' => $video]);
         Shade::writeFile("{$videos_path}/" . $video->getSlug() . ".html", $this->smarty->fetch('videos.tpl'), function ($path) use(&$output) {
             $output->writeln("File '{$path}' created");
         });
     }
     return true;
 }