diff --git a/library/Zepto/PluginInterface.php b/library/Zepto/PluginInterface.php index 21b7ef1..9d3552b 100644 --- a/library/Zepto/PluginInterface.php +++ b/library/Zepto/PluginInterface.php @@ -17,12 +17,12 @@ public function after_config_load(&$settings); public function after_plugins_load(); - public function request_url(&$url); - public function before_file_load(&$content_dir); public function after_file_load(&$content); + public function request_url(&$url); + // Move all these methods into their own classes // public function before_file_meta_parsed(&$headers); diff --git a/library/Zepto/Zepto.php b/library/Zepto/Zepto.php index 1353437..993e691 100644 --- a/library/Zepto/Zepto.php +++ b/library/Zepto/Zepto.php @@ -30,25 +30,25 @@ class Zepto { * * $config = array( * 'zepto' => array( - * 'cache_dir' => ROOT_DIR . 'cache', - * 'content_dir' => ROOT_DIR . 'content', - * 'plugin_dir' => ROOT_DIR . 'plugins', - * 'templates_dir' => ROOT_DIR . 'templates', - * 'content_ext' => array('md', 'markdown') + * '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', - * 'theme' => 'default', - * 'date_format' => 'jS M Y', - * 'page_order' => 'asc', - * 'page_order_by' => 'date|a-z', - * 'excerpt_length' => '50' + * 'site_root' => 'Site root URL goes here', + * 'site_title' => 'Zepto', + * 'date_format' => 'jS M Y', + * 'excerpt_length' => '50' * ), * 'twig' => array( - * 'cache' => false, - * 'autoescape' => false, - * 'debug' => false + * 'charset' => 'utf-8', + * 'cache' => 'cache', + * 'strict_variables' => false, + * 'autoescape' => false, + * 'auto_reload' => true * ) * ); * @@ -149,6 +149,9 @@ public function run_hooks($hook_id, $args = array()) throw new \Exception('No such hook exists'); } + // Send app reference to hooks + $args = array_merge($args, array($this)); + // Run hooks associated with that event foreach ($plugins as $plugin_id => $plugin) { if (is_callable(array($plugin, $hook_id))) { @@ -180,6 +183,11 @@ protected function load_plugins() $this->run_hooks('after_plugins_load'); } + /** + * Loads files from the ``content`` folder + * + * @return + */ protected function load_files() { // Get local reference to file loader @@ -238,7 +246,7 @@ protected function setup_router() // Set Twig options $twig_options = array( - 'config' => $container['settings']['twig'], + 'config' => $container['settings'], 'base_dir' => '/zepto', 'base_url' => $container['settings']['site']['site_root'], 'site_title' => $container['settings']['site']['site_title'] @@ -258,6 +266,11 @@ protected function setup_router() } } + /** + * Helper function to create navigation links + * + * @return + */ protected function create_nav_links() { $container = $this->container; @@ -297,8 +310,8 @@ private function _configure_error_handler() // Configure the PrettyPageHandler: $errorPage = new Whoops\Handler\PrettyPageHandler(); - $errorPage->setPageTitle("Shit hit the fan!"); - $errorPage->setEditor("sublime"); + $errorPage->setPageTitle('Shit hit the fan!'); + $errorPage->setEditor('sublime'); $error_handler->pushHandler($errorPage); $error_handler->register(); } diff --git a/plugins/ExamplePlugin.php b/plugins/ExamplePlugin.php index 367e58b..28e0e14 100644 --- a/plugins/ExamplePlugin.php +++ b/plugins/ExamplePlugin.php @@ -21,11 +21,6 @@ public function after_plugins_load() echo __CLASS__ . '::after_plugins_load'; } - public function request_url(&$url) - { - echo __CLASS__ . '::request_url'; - } - public function before_file_load(&$content_dir) { echo __CLASS__ . '::before_file_load'; @@ -36,6 +31,11 @@ public function after_file_load(&$content) echo __CLASS__ . '::after_file_load'; } + public function request_url(&$url) + { + echo __CLASS__ . '::request_url'; + } + } ?> diff --git a/plugins/OtherExamplePlugin.php b/plugins/OtherExamplePlugin.php index 222ae63..def0208 100644 --- a/plugins/OtherExamplePlugin.php +++ b/plugins/OtherExamplePlugin.php @@ -21,11 +21,6 @@ public function after_plugins_load() echo __CLASS__ . '::after_plugins_load'; } - public function request_url(&$url) - { - echo __CLASS__ . '::request_url'; - } - public function before_file_load(&$content_dir) { echo __CLASS__ . '::before_file_load'; @@ -36,6 +31,11 @@ public function after_file_load(&$content) echo __CLASS__ . '::after_file_load'; } + public function request_url(&$url) + { + echo __CLASS__ . '::request_url'; + } + } ?>