diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..85e7c1d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea/ diff --git a/src/.htaccess b/src/.htaccess new file mode 100644 index 0000000..1a481d8 --- /dev/null +++ b/src/.htaccess @@ -0,0 +1,6 @@ +RewriteEngine On + +RewriteCond %{THE_REQUEST} !^GET\ /.*?client/(css|js|img) +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ index.php [L,QSA] diff --git a/src/articles/index.md b/src/articles/index.md new file mode 100644 index 0000000..3cb1153 --- /dev/null +++ b/src/articles/index.md @@ -0,0 +1,5 @@ +Example Wiki +============ + +Place the content of you *slim wiki* into this directory. Write it using +[GitHub flavored](https://help.github.com/articles/github-flavored-markdown) [Markdown](https://daringfireball.net/projects/markdown/). diff --git a/src/index.php b/src/index.php new file mode 100644 index 0000000..a3d73fe --- /dev/null +++ b/src/index.php @@ -0,0 +1,40 @@ + $uriDir) { + $scriptDir = isset($scriptPathArray[$level]) ? $scriptPathArray[$level] : null; + if ($isAppPath && $scriptDir != $uriDir) { + // The URI path differs from the script path here -> We arrived at the level where the app is installed + $isAppPath = false; + } + + if ($isAppPath) { + $appPathArray[] = $uriDir; + } else { + $requestPathArray[] = $uriDir; + } +} +$appPath = rtrim(implode('/', $appPathArray), '/'); + +$https = false; +if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { + $https = true; +} +$baseUrl = 'http' . ($https ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . $appPath; + +unset($uriPathArray, $scriptPathArray, $appPathArray, $isAppPath, $https); + +require_once __DIR__ . '/server/logic/main.php'; + +(new Main())->dispatch($baseUrl, $appPath, $requestPathArray); diff --git a/src/server/layout/page.php b/src/server/layout/page.php new file mode 100644 index 0000000..7cb61c9 --- /dev/null +++ b/src/server/layout/page.php @@ -0,0 +1,13 @@ + + + + + + + + Slim Wiki + + +
+ + diff --git a/src/server/logic/Main.php b/src/server/logic/Main.php new file mode 100644 index 0000000..65275a6 --- /dev/null +++ b/src/server/logic/Main.php @@ -0,0 +1,27 @@ +text($articleContent); + include(__DIR__ . '/../layout/page.php'); + } else { + // TODO: Show error page + echo '

File does not exist or is not readable: '.$articleFilename.'

'; + } + + } + +}