diff --git a/public/index.php b/public/index.php index 2825b3b..0ed91d5 100644 --- a/public/index.php +++ b/public/index.php @@ -119,6 +119,21 @@ class CodePressCMS { } elseif (file_exists($filePath . '.html')) { $actualFilePath = $filePath . '.html'; $result = $this->parseHTML(file_get_contents($actualFilePath)); + } elseif (is_dir($filePath)) { + // Check for index files in directory + if (file_exists($filePath . '/index.md')) { + $actualFilePath = $filePath . '/index.md'; + $result = $this->parseMarkdown(file_get_contents($actualFilePath)); + } elseif (file_exists($filePath . '/index.php')) { + $actualFilePath = $filePath . '/index.php'; + $result = $this->parsePHP($actualFilePath); + } elseif (file_exists($filePath . '/index.html')) { + $actualFilePath = $filePath . '/index.html'; + $result = $this->parseHTML(file_get_contents($actualFilePath)); + } else { + // Generate directory listing + return $this->generateDirectoryListing($filePath, $page); + } } elseif (file_exists($filePath)) { $actualFilePath = $filePath; $extension = pathinfo($filePath, PATHINFO_EXTENSION); @@ -166,6 +181,41 @@ class CodePressCMS { return round($bytes, 2) . ' ' . $units[$pow]; } + private function generateDirectoryListing($dirPath, $urlPath) { + $title = ucfirst(basename($dirPath)); + $content = '