Various updates.

- Clearer error messages when no routes match.
- Favicon link fixed.
- “<base href="…">” tag removed from the layout.
This commit is contained in:
Julien Fontanet 2013-03-02 14:50:17 +01:00
parent b00064ca9b
commit c96a7ca308
4 changed files with 25 additions and 23 deletions

View File

@ -32,7 +32,7 @@ final class ServiceLocator extends Base
parent::__construct();
}
function get($id)
function get($id, $default = 'throws an exception')
{
if (isset($this->_entries[$id])
|| array_key_exists($id, $this->_entries))
@ -60,7 +60,13 @@ final class ServiceLocator extends Base
return new $id;
}
throw new Exception('no such entry: '.$id);
// Nothing found.
if (func_num_args() < 2)
{
throw new Exception('no such entry ('.$path.')');
}
return $default;
}
function set($id, $value)
@ -186,7 +192,7 @@ final class ServiceLocator extends Base
'url' => array($tu, 'url'),
);
$tm->defaultVariables += array(
'base_path' => $this->get('config')['base_path'].'/',
'base_path' => $this->get('config')['base_path'],
);
return $tm;

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -75,10 +75,11 @@ $routes = $locator->get('routes');
$parameters = $routes->match($context);
// Basic error message if no route found.
if (!$parameters)
if (!$parameters
|| !($controller = $locator->get('controller.'.$parameters['controller'], false)))
{
trigger_error(
'no route found',
'no route found for: '.$context['path'],
E_USER_ERROR
);
}
@ -86,8 +87,5 @@ if (!$parameters)
// @todo Not sure it is the right place to put the current route.
$locator->set('current_controller', $parameters['controller']);
// Gets the current controller.
$controller = $locator->get('controller.'.$parameters['controller']);
// Dispatches the current action.
$controller->dispatch($parameters['action']);

View File

@ -33,19 +33,17 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<base href="{$base_path}" />
<meta charset="utf-8" />
<title>{block title}Xen Orchestra{/block}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Web Interface for XCP">
<meta name="author" content="Olivier Lambert and Julien Fontanet">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Web Interface for XCP" />
<meta name="author" content="Olivier Lambert and Julien Fontanet" />
{* We use Bootstrap CSS. *}
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="{$base_path}/css/bootstrap.css" rel="stylesheet" />
<link href="{$base_path}/css/bootstrap-responsive.css" rel="stylesheet" />
{* IE support. *}
{* HTML5 shim, for IE6-8 support of HTML5 elements *}
@ -53,11 +51,11 @@
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
{* This font is used for icons. *}
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="{$base_path}/css/font-awesome.css" />
{* Our stylesheet and scripts. *}
<link rel="stylesheet" href="css/style.css">
<link rel="icon" href="img/favicon.ico" />
<link rel="stylesheet" href="{$base_path}/css/style.css" />
<link rel="icon" type="image/png" href="{$base_path}/img/favicon.png" />
{* Children templates may used this block to add extra headers. *}
@ -68,7 +66,7 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="./"><img src="img/bannerb.png"></a>
<a class="brand" href="./"><img src="{$base_path}/img/bannerb.png"></a>
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
@ -155,8 +153,8 @@
{block body}{/block}
{* JS Placed at the end of the document so the pages load faster *}
<script src="js/jquery.js"></script>
<script src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/xo.js"></script>
<script src="{$base_path}/js/jquery.js"></script>
<script src="{$base_path}/js/bootstrap.js"></script>
<script type="text/javascript" src="{$base_path}/js/xo.js"></script>
</body>
</html>