diff --git a/config.php b/config.php index b0d06d7..75bbafd 100644 --- a/config.php +++ b/config.php @@ -1,28 +1,22 @@ array( - 'environment' => 'dev', - 'content_dir' => 'content', - 'plugins_dir' => 'plugins', - 'templates_dir' => 'templates', - 'default_template' => 'base.twig', - 'content_ext' => array('.md', '.markdown'), - 'plugins_enabled' => true - ), - 'site' => array( - 'site_root' => 'Site root URL goes here', - 'site_title' => 'Zepto', - 'date_format' => 'jS M Y', - 'excerpt_length' => '50', - 'nav' => array( - 'class' => 'nav', - 'dropdown_li_class' => 'dropdown', - 'dropdown_ul_class' => 'dropdown-menu', - 'dropdown_li_markup' => '
- * $config = array(
- * 'zepto' => array(
- * 'environment' => 'dev',
- * 'content_dir' => 'content',
- * 'plugins_dir' => 'plugins',
- * 'templates_dir' => 'templates',
- * 'default_template' => 'base.twig',
- * 'content_ext' => array('.md', '.markdown'),
- * 'plugins_enabled' => true
- * ),
- * 'site' => array(
- * 'site_root' => 'Site root URL goes here',
- * 'site_title' => 'Zepto',
- * 'date_format' => 'jS M Y',
- * 'excerpt_length' => '50',
- * 'nav' => array(
- * 'class' => 'nav',
- * 'dropdown_li_class' => 'dropdown',
- * 'dropdown_ul_class' => 'dropdown-menu'
- * )
- * ),
- * 'twig' => array(
- * 'charset' => 'utf-8',
- * 'cache' => 'cache',
- * 'strict_variables' => false,
- * 'autoescape' => false,
- * 'auto_reload' => true
- * )
- * );
- *
* @param array $settings
*/
public function __construct(array $settings = array())
@@ -111,7 +80,7 @@ function ($app) {
$app['content_loader'] = $app->share(
function ($app) {
return new FileLoader\MarkdownLoader(
- $app['ROOT_DIR'] . $app['settings']['zepto']['content_dir'],
+ $app['ROOT_DIR'] . $app['settings']['zepto.content_dir'],
new \Michelf\MarkdownExtra
);
}
@@ -126,7 +95,9 @@ function ($app) {
$app['twig'] = $app->share(
function($app) {
$twig = new \Twig_Environment(
- new \Twig_Loader_Filesystem($app['ROOT_DIR'] . 'templates')
+ new \Twig_Loader_Filesystem($app['ROOT_DIR'] . 'templates',
+ $app['settings']['twig']
+ )
);
$twig->addExtension(new Extension\Twig);
return $twig;
@@ -143,7 +114,7 @@ function($app) {
}
// Set this particular setting now
- $app['plugins_enabled'] = $settings['zepto']['plugins_enabled'];
+ $app['plugins_enabled'] = $settings['zepto.plugins_enabled'];
// So if plugins ARE indeed enabled, initialise the plugin loader
// and load the fuckers
@@ -151,7 +122,7 @@ function($app) {
$app['plugin_loader'] = $app->share(
function($c) use ($settings) {
return new FileLoader\PluginLoader(
- $c['ROOT_DIR'] . $settings['zepto']['plugins_dir']
+ $c['ROOT_DIR'] . $settings['zepto.plugins_dir']
);
}
);
@@ -267,8 +238,8 @@ protected function setup_router()
// Set Twig options
$twig_vars = array(
'config' => $app['settings'],
- 'base_url' => $app['settings']['site']['site_root'],
- 'site_title' => $app['settings']['site']['site_title']
+ 'base_url' => $app['settings']['site.site_root'],
+ 'site_title' => $app['settings']['site.site_title']
);
$app['nav'] = isset($app['nav']) === TRUE ? $app['nav'] : array();
@@ -280,7 +251,7 @@ protected function setup_router()
// Get template name from file, if not set, then use default
$template_name = array_key_exists('template', $content['meta']) === true
? $content['meta']['template']
- : $app['settings']['zepto']['default_template'];
+ : $app['settings']['zepto.default_template'];
// Render template with Twig
return $app['twig']->render($template_name, $options);
diff --git a/tests/Zepto/HelperTest.php b/tests/Zepto/HelperTest.php
index b9a2292..8e6d5ca 100644
--- a/tests/Zepto/HelperTest.php
+++ b/tests/Zepto/HelperTest.php
@@ -33,27 +33,18 @@ protected function tearDown()
public function testDefaultConfig()
{
$expected = array(
- 'zepto' => array(
- 'environment' => 'dev',
- 'content_dir' => 'content',
- 'plugins_dir' => 'plugins',
- 'templates_dir' => 'templates',
- 'default_template' => 'base.twig',
- 'content_ext' => array('.md', '.markdown'),
- 'plugins_enabled' => true
- ),
- 'site' => array(
- 'site_root' => 'http://localhost:8888/zepto/',
- 'site_title' => 'Zepto',
- 'date_format' => 'jS M Y',
- 'excerpt_length' => '50',
- 'nav' => array(
- 'class' => 'nav',
- 'dropdown_li_class' => 'dropdown',
- 'dropdown_ul_class' => 'dropdown-menu'
- )
- ),
- 'twig' => array(
+ 'zepto.environment' => 'dev',
+ 'zepto.content_dir' => 'content',
+ 'zepto.plugins_dir' => 'plugins',
+ 'zepto.templates_dir' => 'templates',
+ 'zepto.default_template' => 'base.twig',
+ 'zepto.content_ext' => array('.md', '.markdown'),
+ 'zepto.plugins_enabled' => false,
+ 'site.site_root' => 'http://localhost:8888/zepto/',
+ 'site.site_title' => 'Zepto',
+ 'site.date_format' => 'jS M Y',
+ 'site.excerpt_length' => '50',
+ 'twig' => array(
'charset' => 'utf-8',
'cache' => 'cache',
'strict_variables' => false,
@@ -80,7 +71,7 @@ public function testValidateConfig()
public function testConfigWithInvalidContentDir()
{
$config = Helper::default_config();
- $config['zepto']['content_dir'] = 'no_such_dir';
+ $config['zepto.content_dir'] = 'no_such_dir';
Helper::validate_config($config);
}
@@ -91,7 +82,7 @@ public function testConfigWithInvalidContentDir()
public function testConfigWithInvalidPluginsDir()
{
$config = Helper::default_config();
- $config['zepto']['plugins_dir'] = 'no_such_dir';
+ $config['zepto.plugins_dir'] = 'no_such_dir';
Helper::validate_config($config);
}
@@ -102,7 +93,7 @@ public function testConfigWithInvalidPluginsDir()
public function testConfigWithInvalidTemplatesDir()
{
$config = Helper::default_config();
- $config['zepto']['templates_dir'] = 'no_such_dir';
+ $config['zepto.templates_dir'] = 'no_such_dir';
Helper::validate_config($config);
}
@@ -113,7 +104,7 @@ public function testConfigWithInvalidTemplatesDir()
public function testConfigWithInvalidDefaultTemplate()
{
$config = Helper::default_config();
- $config['zepto']['default_template'] = 'no_such_file';
+ $config['zepto.default_template'] = 'no_such_file';
Helper::validate_config($config);
}
@@ -124,7 +115,7 @@ public function testConfigWithInvalidDefaultTemplate()
public function testConfigWithInvalidSiteRoot()
{
$config = Helper::default_config();
- $config['zepto']['environment'] = 'production';
+ $config['zepto.environment'] = 'production';
$config['site']['site_root'] = 'fuck://this@should?fail';
Helper::validate_config($config);
}
@@ -138,7 +129,6 @@ public function testUrlFor()
$helper = new Helper($zepto->app);
$actual = $helper->url_for('index.md');
$expected = 'http://localhost:8888/zepto/';
-
$this->assertEquals($expected, $actual);
}
@@ -147,11 +137,12 @@ public function testUrlFor()
*/
public function testUrlForFailure()
{
+ ob_start();
$zepto = new Zepto;
$helper = new Helper($zepto->app);
$actual = $helper->url_for('non-index.md');
-
$this->assertNull($actual);
+ ob_end_clean();
}
/**
@@ -163,7 +154,6 @@ public function testLinkFor()
$helper = new Helper($zepto->app);
$actual = $helper->link_for('index.md');
$expected = ' Welcome ';
-
$this->assertEquals($expected, $actual);
}
@@ -172,11 +162,12 @@ public function testLinkFor()
*/
public function testLinkForFailure()
{
+ ob_start();
$zepto = new Zepto;
$helper = new Helper($zepto->app);
$actual = $helper->link_for('non-index.md');
-
$this->assertNull($actual);
+ ob_end_clean();
}
}
diff --git a/tests/Zepto/ZeptoTest.php b/tests/Zepto/ZeptoTest.php
index be24efc..c6e1bbd 100644
--- a/tests/Zepto/ZeptoTest.php
+++ b/tests/Zepto/ZeptoTest.php
@@ -48,27 +48,22 @@ public function testConstructWithSettings()
{
ob_start();
$config = array(
- 'zepto' => array(
- 'environment' => 'prod',
- 'content_dir' => 'content',
- 'plugins_dir' => 'plugins',
- 'templates_dir' => 'templates',
- 'default_template' => 'base.twig',
- 'content_ext' => array('.md', '.markdown'),
- 'plugins_enabled' => true
- ),
- 'site' => array(
- 'site_root' => 'http://www.zepto.com/',
- 'site_title' => 'Zepto',
- 'date_format' => 'jS M Y',
- 'excerpt_length' => '50',
- 'nav' => array(
- 'class' => 'nav',
- 'dropdown_li_class' => 'dropdown',
- 'dropdown_ul_class' => 'dropdown-menu'
- )
- ),
- 'twig' => array(
+ 'zepto.environment' => 'dev',
+ 'zepto.content_dir' => 'content',
+ 'zepto.plugins_dir' => 'plugins',
+ 'zepto.templates_dir' => 'templates',
+ 'zepto.default_template' => 'base.twig',
+ 'zepto.content_ext' => array('.md', '.markdown'),
+ 'zepto.plugins_enabled' => true,
+ 'site.site_root' => 'http://localhost:8888/zepto/',
+ 'site.site_title' => 'Zepto',
+ 'site.date_format' => 'jS M Y',
+ 'site.excerpt_length' => '50',
+ 'site.nav.class' => 'nav',
+ 'site.nav.dropdown_li_class' => 'dropdown',
+ 'site.nav.dropdown_ul_class' => 'dropdown-menu',
+ 'site.nav.dropdown_li_markup' => '