public function testNonExistantProcessor() { $path = dirname(__FILE__) . '/../project/.phrekyll/entries/'; $input = $path . '2011-02-24-wrong-file-type.wrong'; $factory = new Factory(); $view = $factory->setInputFile($input)->create(); $this->assertInstanceOf('\\Phrekyll\\Site\\View\\Plain', $view); }
protected function buildQueue() { $projectDir = $this->getProjectDir(); $outputDir = $this->getOutputDir(); $item = new \SplFileObject($this->getSingleFile()); if ($item->isFile()) { try { $factory = new View\Factory($item->getRealPath()); $view = $factory->create(); $view->setSiteConfig($this->getSiteConfig())->setOutputDir($outputDir); $this->addView($view); } catch (\Exception $e) { $this->getOutputter()->stderr(str_replace($projectDir, '', $item->getRealPath()) . ': ' . $e->getMessage()); } } return $this; }
/** * Create list of views to be created * * @return \Phrekyll\Site */ protected function buildQueue() { // guess the base path with Phrekyll project $projectDir = $this->getProjectDir(); $outputDir = $this->getOutputDir(); $config = $this->getSiteConfig(); // configure skip files options $skipToken = '-!SKIP!-'; $folders = array('entries', 'styles', 'scripts'); foreach ($folders as $folder) { $dir = new \RecursiveDirectoryIterator($projectDir . '/' . $folder); $it = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::SELF_FIRST); foreach ($it as $item) { $baseName = $item->getBaseName(); if (isset($config['skip'])) { $baseName = preg_replace($config['skip'], array_fill(0, count($config['skip']), $skipToken), $baseName); if (strpos($baseName, $skipToken) !== false) { continue; } } if ($item->isFile()) { try { $factory = new View\Factory($item->getRealPath()); $factory->setInputRootDir($projectDir); $view = $factory->create(); $view->setSiteConfig($this->getSiteConfig())->setOutputDir($outputDir); $this->views[] = $view; } catch (\Exception $e) { $this->getOutputter()->stderr(str_replace($projectDir, '', $item->getRealPath()) . ': ' . $e->getMessage()); } } } } return $this; }
/** * Two step view is used. View to wrap is provided with content variable. * * @param string $content View text to wrap into layout * @param array $vars List of variables passed to processors * * @return string */ protected function applyLayout($content, $vars) { $layoutName = $this->getParam('page.layout', ViewFactory::DEFAULT_LAYOUT_SCRIPT); $inputFile = $this->getInputFile(); $inputFile = str_replace('\\', '/', $inputFile); $pos = strpos($inputFile, '/entries'); // make sure that input path is normalized to root entries directory if (false !== $pos) { $inputFile = substr($inputFile, 0, $pos + 8) . '/entry'; } $layoutPath = realpath(dirname($inputFile) . '/../layouts/' . $layoutName); $factory = new ViewFactory($layoutPath); $layout = $factory->create(); // essentially layout is Site\View as well $layout->hasLayout(false); // no nested layouts $vars['content'] = $content; $vars['entry'] = $vars['page']; return $layout->render($vars); }