created option for breadcrumb style titles

This commit is contained in:
Luke Carlson 2014-05-30 18:02:19 -04:00
bovenliggende 4a504b985f
commit 488704e307
2 gewijzigde bestanden met toevoegingen van 37 en 3 verwijderingen

9
README.md Normal file → Executable file
Bestand weergeven

@ -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.

31
libs/functions.php Normal file → Executable file
Bestand weergeven

@ -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("/", " <i class=\"glyphicon glyphicon-chevron-right\"></i> ", $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;