-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstart.php
More file actions
70 lines (59 loc) · 1.26 KB
/
start.php
File metadata and controls
70 lines (59 loc) · 1.26 KB
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
<?php
/**
* Load the Markdown library.
*/
if ( ! defined('MARKDOWN_VERSION'))
{
require_once Bundle::path('bundocs').'/libraries/markdown.php';
}
/**
* Get the root path for the documentation Markdown.
*
* @return string
*/
function bundocs_root($bundle)
{
$dir = Bundle::path($bundle).'docs/';
switch (true)
{
case is_dir(Bundle::path($bundle).'docs/') :
return Bundle::path($bundle).'docs/';
break;
case is_dir(Bundle::path($bundle).'documentation/') :
return Bundle::path($bundle).'documentation/';
break;
}
return null;
}
/**
* Get the parsed Markdown contents of a given page.
*
* @param string $page
* @return string
*/
function bundocs_document($bundle, $page)
{
return Markdown(file_get_contents(bundocs_root($bundle).$page.'.md'));
}
/**
* Determine if a documentation page exists.
*
* @param string $page
* @return bool
*/
function bundocs_document_exists($bundle, $page)
{
return file_exists(bundocs_root($bundle).$page.'.md');
}
/**
* Attach the sidebar to the documentation template.
*/
View::composer('bundocs::template', function($view)
{
$sidebar = '';
if (bundocs_document_exists($view->bundle, 'contents'))
{
$sidebar = bundocs_document($view->bundle, 'contents');
}
$view->with('sidebar', $sidebar);
});