realized this feature has already been implemented

This commit is contained in:
Luke Carlson 2014-06-11 13:21:07 -04:00
parent 5ac0fd4b75
commit 0bae274e3a
2 changed files with 10 additions and 29 deletions

View File

@ -148,34 +148,18 @@
} }
// Generate Documentation from Markdown file // Generate Documentation from Markdown file
function generate_page($file, $with_index="") { function generate_page($file) {
global $base, $base_doc, $base_path, $docs_path, $options, $mode, $relative_base; global $base, $base_doc, $base_path, $docs_path, $options, $mode, $relative_base;
$template = $options['template']; $template = $options['template'];
$file_relative_path = str_replace($docs_path . '/', "", $file); $file_relative_path = str_replace($docs_path . '/', "", $file);
if ($file_relative_path === 'index.md') $homepage = TRUE; if ($file_relative_path === 'index.md') $homepage = TRUE;
else $homepage = FALSE; else $homepage = FALSE;
if (!$file) { if (!$file) {
if (file_get_contents($with_index) === FALSE) { $page['path'] = '';
$page['path'] = ''; $page['markdown'] = '';
$page['markdown'] = ''; $page['title'] = 'Oh No';
$page['title'] = 'Oh No'; $page['content'] = "<h3>Oh No. That page doesn't exist</h3>";
$page['content'] = "<h3>Oh No. That page doesn't exist</h3>"; $options['file_editor'] = false;
$options['file_editor'] = false;
} else {
$file_relative_path = str_replace($docs_path . '/', "", $with_index);
$page['path'] = $file_relative_path;
$page['markdown'] = file_get_contents($with_index);
$page['modified'] = filemtime($with_index);
$Parsedown = new Parsedown();
$page['content'] = $Parsedown->text($page['markdown']);
if ($options['breadcrumbs']) {
$page['title'] = url_to_title(get_url($with_index), 'Colons');
} else {
$page['title'] = clean_url($with_index, 'Title');
}
}
} else { } else {
$page['path'] = $file_relative_path; $page['path'] = $file_relative_path;
$page['markdown'] = file_get_contents($file); $page['markdown'] = file_get_contents($file);

View File

@ -8,11 +8,8 @@
$output_language = $b[0]; $output_language = $b[0];
} }
$file = clean_url_to_file($page); $file = clean_url_to_file($page);
if (!is_file($file)) { if (!is_file($file)) $file = FALSE;
$index = clean_url_to_file($page . "index.md"); return generate_page($file);
$file = FALSE;
}
return generate_page($file, $index);
} }
// Clean Live Url // Clean Live Url
@ -36,8 +33,8 @@
else { else {
if (empty($options['languages'])) return $base_doc; if (empty($options['languages'])) return $base_doc;
else { else {
$t = array_keys($base_doc); $t = array_keys($base_doc);
return $base_doc[$t[0]]; return $base_doc[$t[0]];
} }
} }
} else { } else {