From e3cd46c043e35ce3fa65e180df34d42113b93dcb Mon Sep 17 00:00:00 2001 From: Luke Carlson Date: Wed, 11 Jun 2014 11:58:56 -0400 Subject: [PATCH 1/7] edited generate_live to allow for landing pages per folder --- libs/live.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libs/live.php b/libs/live.php index 3ba2e66..72c76f2 100644 --- a/libs/live.php +++ b/libs/live.php @@ -8,8 +8,11 @@ $output_language = $b[0]; } $file = clean_url_to_file($page); - if (!is_file($file)) $file = FALSE; - return generate_page($file); + if (!is_file($file)) { + $index = clean_url_to_file($page . "index.md"); + $file = FALSE; + } + return generate_page($file, $index); } // Clean Live Url From e777af7593e65f247df36e97eebff990f051b919 Mon Sep 17 00:00:00 2001 From: Luke Carlson Date: Wed, 11 Jun 2014 11:59:28 -0400 Subject: [PATCH 2/7] 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); From 292fc04651277f677662f97635d0ad2eedb0f0aa Mon Sep 17 00:00:00 2001 From: Luke Carlson Date: Wed, 11 Jun 2014 12:01:03 -0400 Subject: [PATCH 3/7] created example landing page --- docs/01_Examples/index.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/01_Examples/index.md diff --git a/docs/01_Examples/index.md b/docs/01_Examples/index.md new file mode 100644 index 0000000..60392dd --- /dev/null +++ b/docs/01_Examples/index.md @@ -0,0 +1 @@ +####Index for Examples \ No newline at end of file From bdf906fcd63ae2768c36f403e9d18c87f16e924f Mon Sep 17 00:00:00 2001 From: Luke Carlson Date: Wed, 11 Jun 2014 12:52:00 -0400 Subject: [PATCH 4/7] Added more info to the section landing page --- docs/01_Examples/index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/01_Examples/index.md b/docs/01_Examples/index.md index 60392dd..b6889cb 100644 --- a/docs/01_Examples/index.md +++ b/docs/01_Examples/index.md @@ -1 +1,2 @@ -####Index for Examples \ No newline at end of file +### This is a landing page for the Examples section +Adding a landing page is pretty simple, all you need to do is add an "index.md" file to the related folder. \ No newline at end of file From 1b89808ecb6fe0f8893384dd1ed109c8b9313b86 Mon Sep 17 00:00:00 2001 From: Luke Carlson Date: Wed, 11 Jun 2014 12:52:35 -0400 Subject: [PATCH 5/7] described how to use section landing pages --- README.md | 4 ++++ docs/00_Getting_Started.md | 3 +++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index a0ba1ed..996e6a8 100755 --- a/README.md +++ b/README.md @@ -77,6 +77,10 @@ If you want to create a beautiful landing page for your project, simply create a Note: The image can be a local or remote image. +## Section landing page + +If you are interested in having a landing page for a subsection of your docs, all you need to do is add an `index.md` file to the folder. For example, `/docs/01_Examples` has a landing page for that section since there exists a `/docs/01_Examples/index.md` file. + ## Configuration To customize the look and feel of your documentation, you can create a `config.json` file in the of the `/docs` folder. The `config.json` file is a simple JSON object that you can use to change some of the basic settings of the documentation. diff --git a/docs/00_Getting_Started.md b/docs/00_Getting_Started.md index d1b0413..96c5029 100644 --- a/docs/00_Getting_Started.md +++ b/docs/00_Getting_Started.md @@ -77,6 +77,9 @@ If you want to create a beautiful landing page for your project, simply create a Note: The image can be a local or remote image. +## Section landing page + +If you are interested in having a landing page for a subsection of your docs, all you need to do is add an `index.md` file to the folder. For example, `/docs/01_Examples` has a landing page for that section since there exists a `/docs/01_Examples/index.md` file. ## Configuration To customize the look and feel of your documentation, you can create a `config.json` file in the of the `/docs` folder. The `config.json` file is a simple JSON object that you can use to change some of the basic settings of the documentation. From 5ac0fd4b75fcc009e283017f8b3aa3c581fe5b2a Mon Sep 17 00:00:00 2001 From: Luke Carlson Date: Wed, 11 Jun 2014 12:53:50 -0400 Subject: [PATCH 6/7] removed option used for debugging --- libs/functions.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/functions.php b/libs/functions.php index 40bcfc3..6594e8b 100755 --- a/libs/functions.php +++ b/libs/functions.php @@ -31,8 +31,7 @@ 'languages' => array(), 'file_editor' => false, 'template' => 'default', - 'breadcrumbs' => false, - 'log' => '' + 'breadcrumbs' => false ); // Load User Config @@ -167,7 +166,7 @@ $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']); From 0bae274e3aaa4e880b96c5639be0a60be72b4b57 Mon Sep 17 00:00:00 2001 From: Luke Carlson Date: Wed, 11 Jun 2014 13:21:07 -0400 Subject: [PATCH 7/7] realized this feature has already been implemented --- libs/functions.php | 28 ++++++---------------------- libs/live.php | 11 ++++------- 2 files changed, 10 insertions(+), 29 deletions(-) diff --git a/libs/functions.php b/libs/functions.php index 6594e8b..76d7f97 100755 --- a/libs/functions.php +++ b/libs/functions.php @@ -148,34 +148,18 @@ } // 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; $template = $options['template']; $file_relative_path = str_replace($docs_path . '/', "", $file); if ($file_relative_path === 'index.md') $homepage = TRUE; else $homepage = FALSE; if (!$file) { - 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'); - } - } + $page['path'] = ''; + $page['markdown'] = ''; + $page['title'] = 'Oh No'; + $page['content'] = "

Oh No. That page doesn't exist

"; + $options['file_editor'] = false; } else { $page['path'] = $file_relative_path; $page['markdown'] = file_get_contents($file); diff --git a/libs/live.php b/libs/live.php index 72c76f2..0cc0e9a 100644 --- a/libs/live.php +++ b/libs/live.php @@ -8,11 +8,8 @@ $output_language = $b[0]; } $file = clean_url_to_file($page); - if (!is_file($file)) { - $index = clean_url_to_file($page . "index.md"); - $file = FALSE; - } - return generate_page($file, $index); + if (!is_file($file)) $file = FALSE; + return generate_page($file); } // Clean Live Url @@ -36,8 +33,8 @@ else { if (empty($options['languages'])) return $base_doc; else { - $t = array_keys($base_doc); - return $base_doc[$t[0]]; + $t = array_keys($base_doc); + return $base_doc[$t[0]]; } } } else {