/** * Setup before tests * * @return void */ public function setUp() { mkdir('foobar'); mkdir('foobar' . DIRECTORY_SEPARATOR . 'templates'); file_put_contents('foobar' . DIRECTORY_SEPARATOR . 'layout.html', '{{ layout.content|raw }}'); file_put_contents('foobar' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'main.html', '{{ content | raw }}'); $testThemesDir = APP_PATH . DIRECTORY_SEPARATOR . 'tests'; $theme = new Theme('foobar', '/baseurl', $testThemesDir); $view = new View($theme); $view->setContentDir(realpath('.')); file_put_contents('mycontentfile.md', '#contents'); $this->_object = new Content('mycontentfile.md', $view); }
/** * Execute the request * * @return void */ public function execute() { $request = new Request(); $uri = $request->getRequestedFile(); // Special option to clear cache for this file with ?cache=clear if ($request->cache == 'clear') { $this->getCache()->clear($uri); } $this->getCache()->start($uri); $sitemap = new Sitemap($this->getContentDir(), $request->getBaseUrl()); $location = $sitemap->getLocationForUrl($uri); // If canonical is set, we should redirect thither instead. if ($location->getCanonical()) { $this->redirect($request->getBaseUrl('/') . $location->getCanonical()); } $theme = $this->makeTheme($request); $view = new View($theme); $view->setContentDir($this->getContentDir()); $view->setParams($this->getConfig()); $this->setupNavigationItems($request, $uri, $view); echo $view->renderContentFile($location); $this->getCache()->end(); }