From e777af7593e65f247df36e97eebff990f051b919 Mon Sep 17 00:00:00 2001 From: Luke Carlson Date: Wed, 11 Jun 2014 11:59:28 -0400 Subject: [PATCH] edited generate_page to allow for landing pages per folder --- libs/functions.php | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/libs/functions.php b/libs/functions.php index 76d7f97..40bcfc3 100755 --- a/libs/functions.php +++ b/libs/functions.php @@ -31,7 +31,8 @@ 'languages' => array(), 'file_editor' => false, 'template' => 'default', - 'breadcrumbs' => false + 'breadcrumbs' => false, + 'log' => '' ); // Load User Config @@ -148,18 +149,34 @@ } // Generate Documentation from Markdown file - function generate_page($file) { + function generate_page($file, $with_index="") { global $base, $base_doc, $base_path, $docs_path, $options, $mode, $relative_base; $template = $options['template']; $file_relative_path = str_replace($docs_path . '/', "", $file); if ($file_relative_path === 'index.md') $homepage = TRUE; else $homepage = FALSE; if (!$file) { - $page['path'] = ''; - $page['markdown'] = ''; - $page['title'] = 'Oh No'; - $page['content'] = "

Oh No. That page doesn't exist

"; - $options['file_editor'] = false; + if (file_get_contents($with_index) === FALSE) { + $page['path'] = ''; + $page['markdown'] = ''; + $page['title'] = 'Oh No'; + $page['content'] = "

Oh No. That page doesn't exist

"; + $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 { $page['path'] = $file_relative_path; $page['markdown'] = file_get_contents($file);