Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  *
  * @throws Exception
  */
 public function internalProcess()
 {
     $paths = [];
     // prepares renderer
     if (is_dir($this->phpoole->getConfig()->getLayoutsPath())) {
         $paths[] = $this->phpoole->getConfig()->getLayoutsPath();
     }
     if ($this->phpoole->getConfig()->hasTheme()) {
         $paths[] = $this->phpoole->getConfig()->getThemePath($this->phpoole->getConfig()->get('theme'));
     }
     $this->phpoole->setRenderer(new Twig($paths, $this->phpoole->getConfig()));
     // adds global variables
     $this->phpoole->getRenderer()->addGlobal('site', array_merge($this->phpoole->getConfig()->get('site'), ['menus' => $this->phpoole->getMenus()], ['pages' => $this->phpoole->getPages()]));
     $this->phpoole->getRenderer()->addGlobal('phpoole', ['url' => 'http://phpoole.org/#v' . $this->phpoole->getVersion(), 'version' => $this->phpoole->getVersion(), 'poweredby' => 'PHPoole-library v' . $this->phpoole->getVersion()]);
     // start rendering
     Util::getFS()->mkdir($this->phpoole->getConfig()->getOutputPath());
     call_user_func_array($this->phpoole->getMessageCb(), ['RENDER', 'Rendering pages']);
     $max = count($this->phpoole->getPages());
     $count = 0;
     /* @var $page Page */
     foreach ($this->phpoole->getPages() as $page) {
         $count++;
         $pathname = $this->renderPage($page, $this->phpoole->getConfig()->getOutputPath());
         $message = substr($pathname, strlen($this->phpoole->getConfig()->getDestinationDir()) + 1);
         call_user_func_array($this->phpoole->getMessageCb(), ['RENDER_PROGRESS', $message, $count, $max]);
     }
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  *
  * @throws \PHPoole\Exception\Exception
  */
 public function internalProcess()
 {
     call_user_func_array($this->phpoole->getMessageCb(), ['COPY', 'Copy static files']);
     // copy theme static dir if exists
     if ($this->phpoole->getConfig()->hasTheme()) {
         $theme = $this->phpoole->getConfig()->get('theme');
         $themeStaticDir = $this->phpoole->getConfig()->getThemePath($theme, 'static');
         if (Util::getFS()->exists($themeStaticDir)) {
             Util::getFS()->mirror($themeStaticDir, $this->phpoole->getConfig()->getOutputPath(), null, ['override' => true]);
         }
     }
     // copy static dir if exists
     $staticDir = $this->phpoole->getConfig()->getStaticPath();
     if (Util::getFS()->exists($staticDir)) {
         $finder = new Finder();
         $finder->files()->filter(function (\SplFileInfo $file) {
             return !(is_array($this->phpoole->getConfig()->get('static.exclude')) && in_array($file->getBasename(), $this->phpoole->getConfig()->get('static.exclude')));
         })->in($staticDir);
         Util::getFS()->mirror($staticDir, $this->phpoole->getConfig()->getOutputPath(), $finder, ['override' => true]);
     }
     call_user_func_array($this->phpoole->getMessageCb(), ['COPY_PROGRESS', 'Done']);
 }
Exemplo n.º 3
0
 /**
  * Return version.
  *
  * @return string
  */
 public function getVersion()
 {
     if (!isset($this->version)) {
         try {
             $this->version = Util::runGitCommand('git describe --tags HEAD');
         } catch (\RuntimeException $exception) {
             $this->version = self::VERSION;
         }
     }
     return $this->version;
 }
Exemplo n.º 4
0
 /**
  * Is config has a valid theme?
  *
  * @throws Exception
  *
  * @return bool
  */
 public function hasTheme()
 {
     if ($this->get('theme')) {
         if (!Util::getFS()->exists($this->getThemePath($this->get('theme')))) {
             throw new Exception(sprintf("Theme directory '%s/%s/layouts' not found!", $this->getThemesPath(), $this->get('theme')));
         }
         return true;
     }
     return false;
 }