From 8180d323fc626095d569f60d4180399cdd2b87c4 Mon Sep 17 00:00:00 2001 From: til-schneider Date: Mon, 21 Dec 2015 12:32:19 +0100 Subject: [PATCH] Made wiki name configurable --- .gitignore | 1 + src/config-example.php | 3 +++ src/server/logic/Main.php | 20 ++++++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 src/config-example.php diff --git a/.gitignore b/.gitignore index b20c1da..d066e4a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /dist/ /src/.tmp/ /src/node_modules/ +/src/config.php diff --git a/src/config-example.php b/src/config-example.php new file mode 100644 index 0000000..e891feb --- /dev/null +++ b/src/config-example.php @@ -0,0 +1,3 @@ +File not found'; // TODO: Show error page } else { - $wikiName = 'Slim Wiki'; // TODO: Make this configurable + $config = $this->loadConfig(); $data = array(); $data['baseUrl'] = $baseUrl; $data['basePath'] = $basePath; - $data['wikiName'] = $wikiName; + $data['wikiName'] = $config['wikiName']; - $data['breadcrumbs'] = $this->createBreadcrumbs($articleBaseDir, $requestPathArray, $wikiName); + $data['breadcrumbs'] = $this->createBreadcrumbs($articleBaseDir, $requestPathArray, $config['wikiName']); $articleContent = file_get_contents($articleFilename); $data['articleHtml'] = Parsedown::instance()->text($articleContent); $this->renderPage($data); } - } private function getArticleFilename($articleBaseDir, $requestPathArray) { @@ -56,6 +55,19 @@ class Main { } } + private function loadConfig() { + // Defaults + $config = array( + 'wikiName' => 'Slim Wiki' + ); + + if (file_exists(__DIR__ . '/../../config.php')) { + include(__DIR__ . '/../../config.php'); + } + + return $config; + } + private function createBreadcrumbs($articleBaseDir, $requestPathArray, $wikiName) { $pathCount = count($requestPathArray); $breadcrumbArray = array(array('name' => $wikiName, 'path' => '', 'active' => ($pathCount == 0)));