mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-07 00:56:35 +02:00
Made wiki name configurable
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
/dist/
|
||||
/src/.tmp/
|
||||
/src/node_modules/
|
||||
/src/config.php
|
||||
|
3
src/config-example.php
Normal file
3
src/config-example.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
$config['wikiName'] = 'Slim Wiki';
|
@@ -16,21 +16,20 @@ class Main {
|
||||
header('Content-Type:text/html; charset=utf-8');
|
||||
echo '<h1>File not found</h1>'; // 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)));
|
||||
|
Reference in New Issue
Block a user