1
0
mirror of https://github.com/til-schneider/slim-wiki.git synced 2025-08-06 00:27:28 +02:00

Made .md extension optional

This commit is contained in:
til-schneider
2015-12-21 11:21:20 +01:00
parent c8141b3b9e
commit eb95407e17
3 changed files with 10 additions and 2 deletions

View File

@@ -5,4 +5,4 @@ If you add an `index.md` into a directory, it will become a part of the breadcru
Use it as overview for subpages of that directory:
- [Markdown cheat sheet](cheat-sheets/Markdown_cheat_sheet.md) - shows the markdown syntax.
- [Markdown cheat sheet](cheat-sheets/Markdown_cheat_sheet) - shows the markdown syntax.

View File

@@ -7,4 +7,6 @@ Place the content of your *slim wiki* into this directory. Write it using
Use the main page as overview and add links to subpages:
- [Cheat Sheets](cheat-sheets) - You can add links to directories having a `index.md`.
- [Markdown cheat sheet](cheat-sheets/Markdown_cheat_sheet.md) - Or add direct a link to a markdown file.
- [Markdown cheat sheet](cheat-sheets/Markdown_cheat_sheet) - Or add direct a link to a markdown file.
**Note:** The `.md` extension is optional when linking to markdown files.

View File

@@ -12,10 +12,16 @@ class Main {
$articleBaseDir = realpath(__DIR__ . '/../../articles') . '/';
$articleFilename = $articleBaseDir . implode('/', $requestPathArray);
// Support `index.md` for directories
if (is_dir($articleFilename)) {
$articleFilename = rtrim($articleFilename, '/') . '/index.md';
}
// Make the extension `.md` optional
if (! file_exists($articleFilename) && file_exists($articleFilename . '.md')) {
$articleFilename .= '.md';
}
if (($articleFilename == realpath($articleFilename)) && file_exists($articleFilename) && is_readable($articleFilename)) {
$wikiName = 'Slim Wiki'; // TODO: Make this configurable