Is there any reason to allow logged in users to view the userguide?
I would add something like this to the bootstrap
//Add modules that are only relevant to local development
if(Kohana::$environment == Kohana::DEVELOPMENT)
{
Kohana::modules(array_merge(Kohana::modules(), array(
'codebench' => MODPATH.'codebench', // Benchmarking tool
'userguide' => MODPATH.'userguide', // User guide and API documentation
'unittest' => MODPATH.'unittest', // Unit testing
)));
}
then any public facing sites just change the $environment
to something else like STAGING
or TESTING
Kohana::$environment = Kohana::TESTING //In the bootstrap file
Alternatively
SetEnv KOHANA_ENV TESTING //to the .htaccess file
OPTION 2 - Load the auth module first
I've just tried this, seems to work for me. In your bootstrap file, load the modules like this:
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
'auth' => MODPATH.'auth', // Basic authentication
'cache' => MODPATH.'cache', // Caching with multiple backends
'database' => MODPATH.'database', // Database access
'image' => MODPATH.'image', // Image manipulation
'orm' => MODPATH.'orm', // Object Relationship Mapping
));
//Add modules that are only relevant to testing
if(Kohana::$environment == Kohana::DEVELOPMENT and Auth::instance()->logged_in())
{
Kohana::modules(array_merge(Kohana::modules(), array(
'codebench' => MODPATH.'codebench', // Benchmarking tool
'userguide' => MODPATH.'userguide', // User guide and API documentation
'unittest' => MODPATH.'unittest', // Unit testing
)));
}
Option 3 - Isolating the API browser
There is a config option in the userguide config:
// Enable the API browser. TRUE or FALSE
'api_browser' => TRUE,
which you could set to false if the user isn't logged in, similar to the loading of the modules above. The is currently a bug with it that crashes the userguide template because it can't find the route to the API.
IF you want to go to the effort to get this to work (until there is an update), then copy /modules/userguide/views/userguide/template.php
to /application/views/userguide/template.php
and then replace lines 28 to 30 with this:
<li class="api">
<a href="<?php echo (Kohana::$config->load('userguide.api_browser') === TRUE)?Route::url('docs/api'):'#'; ?>"><?php echo __('API Browser') ?></a>
</li>
and put this in /application/config/userguide.php
:
<?php defined('SYSPATH') or die('No direct script access.');
$config = array();
if(Kohana::$environment == Kohana::DEVELOPMENT and Auth::instance()->logged_in())
{
$config['api_browser'] = FALSE;
}
return $config;