created option for breadcrumb style titles

Cette révision appartient à :
Luke Carlson 2014-05-30 18:02:19 -04:00
Parent 4a504b985f
révision 488704e307
2 fichiers modifiés avec 37 ajouts et 3 suppressions

9
README.md Fichier normal → Fichier exécutable
Voir le fichier

@ -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 Fichier normal → Fichier exécutable
Voir le fichier

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