From ffce00dece2fdbb25ad8d16258aa4315c5bd83a9 Mon Sep 17 00:00:00 2001 From: til-schneider Date: Mon, 28 Dec 2015 15:14:43 +0100 Subject: [PATCH] Showing directories having no 'index.md' in breadcrumbs (configurable) --- src/client/less/view.less | 1 + src/config-example.php | 3 +++ src/server/layout/page.php | 2 +- src/server/logic/Context.php | 3 ++- src/server/logic/Main.php | 9 ++++++--- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/client/less/view.less b/src/client/less/view.less index f3b0757..1273011 100644 --- a/src/client/less/view.less +++ b/src/client/less/view.less @@ -36,6 +36,7 @@ body { .breadcrumbs { background-color: white; + cursor: default; .main-column { padding: 15px 0; diff --git a/src/config-example.php b/src/config-example.php index ad3f4e5..a24cc17 100644 --- a/src/config-example.php +++ b/src/config-example.php @@ -7,4 +7,7 @@ if (function_exists('date_default_timezone_set')) { $config['wikiName'] = 'Slim Wiki'; $config['lang'] = 'en'; // 'de' or 'en' +// Hide directories having no 'index.md' in breadcrumbs +//$config['showCompleteBreadcrumbs'] = false; + //$config['footerHtml'] = '© Copyright 2000-'.date('Y').' My name'; diff --git a/src/server/layout/page.php b/src/server/layout/page.php index 66f8eda..2e81a53 100644 --- a/src/server/layout/page.php +++ b/src/server/layout/page.php @@ -110,7 +110,7 @@ if ($mode == 'edit') { if (! $isFirst) { echo ' / '; } - if ($item['active']) { + if ($item['active'] || is_null($item['path'])) { echo $item['name']; } else { ?> 'Slim Wiki', 'timezone' => 'Europe/Berlin', - 'lang' => 'en' + 'lang' => 'en', + 'showCompleteBreadcrumbs' => true ); if (file_exists(__DIR__ . '/../../config.php')) { diff --git a/src/server/logic/Main.php b/src/server/logic/Main.php index 6cf84cc..4e7c62f 100644 --- a/src/server/logic/Main.php +++ b/src/server/logic/Main.php @@ -172,7 +172,9 @@ class Main { } private function createBreadcrumbs($requestPathArray) { - $wikiName = $this->context->getConfig()['wikiName']; + $config = $this->context->getConfig(); + $wikiName = $config['wikiName']; + $showCompleteBreadcrumbs = $config['showCompleteBreadcrumbs']; $pathCount = count($requestPathArray); $breadcrumbArray = array(array('name' => $wikiName, 'path' => '', 'active' => ($pathCount == 0))); @@ -183,11 +185,12 @@ class Main { $currentPath .= ($i == 0 ? '' : '/') . $pathPart; $isLast = ($i == $pathCount - 1); - if ($isLast || file_exists($articleBaseDir . $currentPath . '/index.md')) { + $hasContent = ($isLast || file_exists($articleBaseDir . $currentPath . '/index.md')); + if ($hasContent || $showCompleteBreadcrumbs) { // This is the requested file or an directory having an index -> Add it $breadcrumbArray[] = array( 'name' => str_replace('_', ' ', $pathPart), - 'path' => urlencode($currentPath), + 'path' => $hasContent ? urlencode($currentPath) : null, 'active' => $isLast); } }