Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Added more comments and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
hassankhan committed Nov 25, 2013
1 parent b5c0386 commit 22ed769
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 30 deletions.
4 changes: 2 additions & 2 deletions library/Zepto/PluginInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
49 changes: 31 additions & 18 deletions library/Zepto/Zepto.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ class Zepto {
* <code>
* $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
* )
* );
* </code>
Expand Down Expand Up @@ -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))) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand All @@ -258,6 +266,11 @@ protected function setup_router()
}
}

/**
* Helper function to create navigation links
*
* @return
*/
protected function create_nav_links()
{
$container = $this->container;
Expand Down Expand Up @@ -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();
}
Expand Down
10 changes: 5 additions & 5 deletions plugins/ExamplePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -36,6 +31,11 @@ public function after_file_load(&$content)
echo __CLASS__ . '::after_file_load';
}

public function request_url(&$url)
{
echo __CLASS__ . '::request_url';
}

}

?>
10 changes: 5 additions & 5 deletions plugins/OtherExamplePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -36,6 +31,11 @@ public function after_file_load(&$content)
echo __CLASS__ . '::after_file_load';
}

public function request_url(&$url)
{
echo __CLASS__ . '::request_url';
}

}

?>

0 comments on commit 22ed769

Please sign in to comment.