fix routing.

This commit is contained in:
Taylor Otwell 2012-04-02 11:19:15 -05:00
parent 21530751a5
commit c0a80d132f
1 changed files with 15 additions and 2 deletions

View File

@ -17,9 +17,22 @@
Route::get('docs/(:any)/(:any?)', function($section, $page = null) Route::get('docs/(:any)/(:any?)', function($section, $page = null)
{ {
$page = rtrim(implode('/', array($section, $page)), '/').'.md'; $root = path('storage').'documentation/';
$content = Markdown(file_get_contents(path('storage').'documentation/'.$page)); $file = rtrim(implode('/', array($section, $page)), '/').'.md';
if (file_exists($path = $root.$file))
{
$content = Markdown(file_get_contents($path));
}
elseif (file_exists($path = $root.$section.'/home.md'))
{
$content = Markdown(file_get_contents($path));
}
else
{
return Response::error('404');
}
return View::make('docs::page')->with('content', $content); return View::make('docs::page')->with('content', $content);
}); });