mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-05 16:17:29 +02:00
Showing index.md if a directory was requested
This commit is contained in:
@@ -9,10 +9,13 @@ class Main {
|
||||
// - $appPath: E.g. '/slim-wiki'
|
||||
// - $requestPathArray: E.g. array('myfolder', 'mypage')
|
||||
public function dispatch($baseUrl, $appPath, $requestPathArray) {
|
||||
|
||||
$articleBaseDir = realpath(__DIR__ . '/../../articles');
|
||||
$articleFilename = $articleBaseDir . '/' . implode('/', $requestPathArray);
|
||||
|
||||
if (is_dir($articleFilename)) {
|
||||
$articleFilename = rtrim($articleFilename, '/') . '/index.md';
|
||||
}
|
||||
|
||||
if (($articleFilename == realpath($articleFilename)) && file_exists($articleFilename) && is_readable($articleFilename)) {
|
||||
$articleContent = file_get_contents($articleFilename);
|
||||
$articleMarkup = Parsedown::instance()->text($articleContent);
|
||||
|
Reference in New Issue
Block a user