From 488704e307a1aced6d2a0e92a5c073dadb8bb639 Mon Sep 17 00:00:00 2001 From: Luke Carlson Date: Fri, 30 May 2014 18:02:19 -0400 Subject: [PATCH] created option for breadcrumb style titles --- README.md | 9 +++++++++ libs/functions.php | 31 ++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) mode change 100644 => 100755 README.md mode change 100644 => 100755 libs/functions.php diff --git a/README.md b/README.md old mode 100644 new mode 100755 index e8c0551..a0ba1ed --- a/README.md +++ b/README.md @@ -243,6 +243,15 @@ By default, Daux.io will create clean url's that do not include index.php. On se } ``` +###Breadcrumb titles +Daux.io provides the option to present page titles as breadcrumb navigation. + +```json +{ + "breadcrumbs": true +} +``` + ###Date Modified By default, daux.io will display the last modified time as reported by the system underneath the title for each document. To disable this, change the option in your config.json to false. diff --git a/libs/functions.php b/libs/functions.php old mode 100644 new mode 100755 index c088c3f..76d7f97 --- a/libs/functions.php +++ b/libs/functions.php @@ -30,7 +30,8 @@ 'ignore' => array(), 'languages' => array(), 'file_editor' => false, - 'template' => 'default' + 'template' => 'default', + 'breadcrumbs' => false ); // Load User Config @@ -165,9 +166,13 @@ $page['modified'] = filemtime($file); $Parsedown = new Parsedown(); - $page['content'] = $Parsedown->text($page['markdown']); - $page['title'] = clean_url($file, 'Title'); + + if ($options['breadcrumbs']) { + $page['title'] = url_to_title(get_url($file), 'Colons'); + } else { + $page['title'] = clean_url($file, 'Title'); + } } $relative_base = ($mode === 'Static') ? relative_path("", $file) : "http://" . $base_path . '/'; ob_start(); @@ -177,6 +182,26 @@ return $return; } + // Converts a URL to a readable breadcrumb string for the page title + function url_to_title($url, $separator = "Chevrons") { + $url = str_replace("index.php?", "", $url); + $url = str_replace("_", " ", $url); + switch ($separator) { + case 'Chevrons': + $url = str_replace("/", " ", $url); + return $url; + case 'Colons': + $url = str_replace("/", ": ", $url); + return $url; + case 'Spaces': + $url = str_replace("/", " ", $url); + return $url; + + } + + return $url; + } + // File to URL function clean_url($url, $mode = 'Static') { global $docs_path, $output_path, $options;