Files
spa-api/bundles/docs/routes.php

38 lines
970 B
PHP
Raw Normal View History

2012-04-01 22:45:19 +01:00
<?php
2012-04-02 11:02:09 -05:00
require_once __DIR__.'/libraries/markdown.php';
2012-04-01 22:45:19 +01:00
View::composer('docs::template', function($view)
{
2012-04-02 19:48:26 +01:00
Asset::add('stylesheet', 'laravel/css/style.css');
Asset::add('modernizr', 'laravel/js/modernizr-2.5.3.min.js');
Asset::container('footer')->add('prettify', 'laravel/js/prettify.js');
2012-04-02 11:02:09 -05:00
$view->with('sidebar', Markdown(file_get_contents(path('storage').'documentation/contents.md')));
2012-04-01 22:45:19 +01:00
});
Route::get('(:bundle)', function()
{
return View::make('docs::home');
});
2012-04-02 11:02:09 -05:00
Route::get('docs/(:any)/(:any?)', function($section, $page = null)
{
2012-04-02 11:19:15 -05:00
$root = path('storage').'documentation/';
2012-04-02 11:02:09 -05:00
2012-04-02 11:19:15 -05:00
$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');
}
2012-04-02 11:02:09 -05:00
return View::make('docs::page')->with('content', $content);
});