-
Notifications
You must be signed in to change notification settings - Fork 2
/
routes.php
72 lines (64 loc) · 1.59 KB
/
routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Handle the documentation homepage.
*
* This page contains the "introduction" to Laravel.
*/
Route::get('(:bundle)', function()
{
$bundles = array();
foreach (Bundle::all() as $bundle => $config)
{
if ( ! is_null(bundocs_root($bundle)))
{
$bundles[] = $bundle;
}
}
// We need to get all available bundle
return View::make('bundocs::page')
->with('bundle', 'bundocs')
->with('content', View::make('bundocs::list', array('bundles' => $bundles)));
});
Route::get('(:bundle)/(:any)', function($bundle)
{
if (bundocs_document_exists($bundle, 'home'))
{
return View::make('bundocs::page')
->with('bundle', $bundle)
->with('content', bundocs_document($bundle, 'home'));
}
else
{
return Response::error('404');
}
});
/**
* Handle documentation routes for sections and pages.
*
* @param string $section
* @param string $page
* @return mixed
*/
Route::get('(:bundle)/(:any)/(:any?)/(:any?)', function($bundle, $page = null)
{
$segments = func_get_args();
$bundle = array_shift($segments);
$file = rtrim(implode('/', $segments), '/');
// If no page was specified, but a "home" page exists for the section,
// we'll set the file to the home page so that the proper page is
// displayed back out to the client for the requested doc page.
if (is_null($page) and bundocs_document_exists($bundle, $file.'/home'))
{
$file .= '/home';
}
if (bundocs_document_exists($bundle, $file))
{
return View::make('bundocs::page')
->with('bundle', $bundle)
->with('content', bundocs_document($bundle, $file));
}
else
{
return Response::error('404');
}
});