public function run(ChefContext $context) { $pieCrust = $context->getApp(); $result = $context->getResult(); $outputDir = $result->command->options['output']; // Warn about deprecated stuff. if ($result->command->options['file_urls']) { $context->getLog()->warning("The `--fileurls` option has been deprecated. Please use `--portable` instead."); $result->command->options['portable_urls'] = true; } if ($result->command->options['pretty_urls_old']) { $context->getLog()->err("The `--prettyurls` option has been deprecated. Please use a config variant instead."); return; } if ($result->command->options['root_url_old']) { $context->getLog()->err("The `--rooturl` option has been deprecated. Please use a config variant instead."); return; } // Set-up the app and the baker. $bakerParameters = array('smart' => !$result->command->options['force'], 'clean_cache' => $result->command->options['force'], 'info_only' => $result->command->options['info_only'], 'config_variant' => $result->command->options['config_variant']); $baker = new PieCrustBaker($pieCrust, $bakerParameters, $context->getLog()); if ($outputDir) { $baker->setBakeDir($outputDir); } if ($result->command->options['portable_urls']) { $pieCrust->getConfig()->setValue('baker/portable_urls', true); // Also disable pretty URLs because it doesn't make much sense // when there's no web server handling default documents. $pieCrust->getConfig()->setValue('site/pretty_urls', false); } // Start baking! $baker->bake(); }
public function testBakeCategoryPage() { $fs = MockFileSystem::create()->withConfig(array('site' => array('default_format' => 'none')))->withTemplate('post', '{{content|raw}}')->withPage('_category', array('layout' => 'none'), <<<EOD {% for post in pagination.posts %} {{ post.content|raw }} {% endfor %} EOD )->withPost('post1', 1, 1, 2010, array('category' => 'foo'), 'POST ONE')->withPost('post2', 2, 1, 2010, array('category' => 'foo'), 'POST TWO')->withPost('post3', 3, 1, 2010, array('category' => 'bar'), 'POST THREE')->withPost('post4', 4, 1, 2010, array('category' => 'bar'), 'POST FOUR')->withPost('post5', 5, 1, 2010, array('category' => 'foo'), 'POST FIVE'); $app = $fs->getApp(); $baker = new PieCrustBaker($app); $baker->setBakeDir($fs->url('counter')); $baker->bake(); $this->assertEquals("POST FIVE\nPOST TWO\nPOST ONE\n", file_get_contents($fs->url('counter/foo.html'))); $this->assertEquals("POST FOUR\nPOST THREE\n", file_get_contents($fs->url('counter/bar.html'))); }
public function testPageDeletionByPagination() { $fs = MockFileSystem::create()->withConfig(array('site' => array('default_format' => 'none', 'posts_per_page' => 4)))->withTemplate('default', '{{content|raw}}')->withTemplate('post', '{{content|raw}}')->withPost('post1', 1, 1, 2010, array(), 'POST ONE')->withPost('post2', 5, 2, 2010, array(), 'POST TWO')->withPost('post3', 10, 3, 2010, array(), 'POST THREE')->withPost('post4', 1, 4, 2010, array(), 'POST FOUR')->withPost('post5', 5, 5, 2010, array(), 'POST FIVE')->withPost('post6', 10, 6, 2010, array(), 'POST SIX')->withPost('post7', 15, 7, 2010, array(), 'POST SEVEN')->withPost('post8', 1, 8, 2010, array(), 'POST EIGHT')->withPost('post9', 5, 9, 2010, array(), 'POST NINE')->withPost('post10', 1, 10, 2010, array(), 'POST TEN')->withPage('_index', array(), <<<EOD {% for p in pagination.posts %} {{ p.title }} {% endfor %} EOD )->withPage('foo', array(), <<<EOD {% for p in pagination.posts %} {{ p.title }} {% endfor %} EOD ); $app = $fs->getApp(); $baker = new PieCrustBaker($app); $baker->setBakeDir($fs->url('counter')); $baker->bake(); $structure = $fs->getStructure(); $counter = $structure[$fs->getRootName()]['counter']; $this->assertEquals(array('2010', 'index.html', '2.html', '3.html', 'foo.html', 'foo'), $this->getVfsEntries($counter)); $this->assertEquals(array('2.html', '3.html'), array_keys($counter['foo'])); $fs->withConfig(array('site' => array('default_format' => 'none', 'posts_per_page' => 11))); $app = $fs->getApp(); $baker = new PieCrustBaker($app); $baker->setBakeDir($fs->url('counter')); $baker->bake(); $structure = $fs->getStructure(); $counter = $structure[$fs->getRootName()]['counter']; $this->assertEquals(array('2010', 'index.html', 'foo.html', 'foo'), $this->getVfsEntries($counter)); $this->assertEquals(array(), array_keys($counter['foo'])); }