Commit: 4ac200024caca72279c1c2a6787d9be0e20ebc71

Author: gwoo | Date: 2010-02-15 17:45:34 -0800
updating asset filter and associated usage
diff --git a/config/bootstrap.php b/config/bootstrap.php index df768f8..44f627d 100644 --- a/config/bootstrap.php +++ b/config/bootstrap.php @@ -1,22 +1,33 @@ <?php + +/** + * Require the g11n if it has not been included yet. + * + */ +require_once LITHIUM_APP_PATH . '/config/bootstrap/g11n.php'; + +/** + * Filter to serve the assets from plugins. + * + */ use \lithium\action\Dispatcher; +use \lithium\core\Libraries; use \lithium\net\http\Media; Dispatcher::applyFilter('_callable', function($self, $params, $chain) { - $assets = array('js','css'); - $isAsset = in_array($params['request']->type(), $assets); - if ($isAsset) { - return function ($request, $params) { - extract($params); - $media = Media::asset($asset, $type, array( - 'plugin' => 'li3_docs', 'absolute' => true - )); - return file_get_contents($media); + list($plugin, $asset) = explode('/', $params['request']->url, 2); + $library = Libraries::get($plugin); + $asset = "{$library['path']}/webroot/{$asset}"; + + if (file_exists($asset)) { + return function () use ($asset) { + $info = pathinfo($asset); + $type = Media::type($info['extension']); + header("Content-type: {$type}"); + return file_get_contents($asset); }; } return $chain->next($self, $params, $chain); }); -require_once LITHIUM_APP_PATH . '/config/bootstrap/g11n.php'; - ?> \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index 9978550..3cf8196 100644 --- a/config/routes.php +++ b/config/routes.php @@ -6,6 +6,4 @@ Router::connect('/docs', array('plugin' => 'li3_docs', 'controller' => 'browser' Router::connect('/docs/{:library}/{:args}', array( 'plugin' => 'li3_docs', 'controller' => 'browser', 'action' => 'view' )); -Router::connect('/{:type:js|css}/li3_docs/{:asset}'); - ?> diff --git a/views/layouts/default.html.php b/views/layouts/default.html.php index 794874a..43839a1 100644 --- a/views/layouts/default.html.php +++ b/views/layouts/default.html.php @@ -11,7 +11,7 @@ <head> <?php echo $this->html->charset(); ?> <title>Lithium API <?php echo $this->title(); ?></title> - <?php echo $this->html->style(array('lithium', 'li3_docs/li3_docs')); ?> + <?php echo $this->html->style(array('lithium', '/li3_docs/css/li3_docs')); ?> <?php echo $this->scripts(); ?> <?php echo $this->html->link('Icon', null, array('type' => 'icon')); ?> </head> @@ -41,13 +41,12 @@ <?php $jQuery = 'http://code.jquery.com/jquery-1.4.1.min.js'; if (\lithium\core\Environment::is('development')) { - $jQuery = 'li3_docs/jquery-1.4.1.min'; + $jQuery = '/li3_docs/js/jquery-1.4.1.min'; } + echo $this->html->script(array( + $jQuery, '/li3_docs/js/showdown.min' + )); ?> -<?php echo $this->html->script(array( - $jQuery, - 'li3_docs/showdown.min' -)); ?> <script type="text/javascript" charset="utf-8"> $(document).ready(function () { var converter = new Showdown.converter("/"); diff --git a/webroot/css/li3_docs.css b/webroot/css/li3_docs.css index 82efc98..20bba2f 100644 --- a/webroot/css/li3_docs.css +++ b/webroot/css/li3_docs.css @@ -6,7 +6,10 @@ -------------------------------------------------------------------------------------------------*/ /*--- This is the stylesheet for li3_docs ---*/ - +.crumbs li { + list-style-type: none; + display: inline; +} .crumbs li + li:before { content: ' \\ '; }