1
0
mirror of https://github.com/til-schneider/slim-wiki.git synced 2025-10-23 04:26:05 +02:00

Added edit mode (just showing the source in editor - no saving, no preview update)

This commit is contained in:
til-schneider
2015-12-21 18:36:59 +01:00
parent 79b6597459
commit 4bdc404d7a
242 changed files with 53246 additions and 14 deletions

View File

@@ -9,6 +9,13 @@ class Main {
// - $basePath: E.g. '/slim-wiki/'
// - $requestPathArray: E.g. array('myfolder', 'mypage')
public function dispatch($baseUrl, $basePath, $requestPathArray) {
$config = $this->loadConfig();
$isEditMode = isset($requestPathArray[0]) && $requestPathArray[0] == 'edit';
if ($isEditMode) {
array_shift($requestPathArray);
}
$articleBaseDir = realpath(__DIR__ . '/../../articles') . '/';
$articleFilename = $this->getArticleFilename($articleBaseDir, $requestPathArray);
if ($articleFilename == null) {
@@ -16,11 +23,10 @@ class Main {
header('Content-Type:text/html; charset=utf-8');
echo '<h1>File not found</h1>'; // TODO: Show error page
} else {
$config = $this->loadConfig();
$data = array();
$data['baseUrl'] = $baseUrl;
$data['basePath'] = $basePath;
$data['baseUrl'] = $baseUrl;
$data['basePath'] = $basePath;
$data['isEditMode'] = $isEditMode;
foreach (array('wikiName', 'footerHtml') as $key) {
$data[$key] = $config[$key];
@@ -28,8 +34,9 @@ class Main {
$data['breadcrumbs'] = $this->createBreadcrumbs($articleBaseDir, $requestPathArray, $config['wikiName']);
$articleContent = file_get_contents($articleFilename);
$data['articleHtml'] = Parsedown::instance()->text($articleContent);
$articleMarkdown = file_get_contents($articleFilename);
$data['articleMarkdown'] = $articleMarkdown;
$data['articleHtml'] = Parsedown::instance()->text($articleMarkdown);
$this->renderPage($data);
}