Browse Source

Some fixes to the admin plugin

Belle Aerni 2 years ago
parent
commit
7ea9cb2e5d
1 changed files with 19 additions and 0 deletions
  1. 19 0
      src/Plugins/Admin/AdminPlugin.php

+ 19 - 0
src/Plugins/Admin/AdminPlugin.php

@@ -159,6 +159,9 @@ class AdminPlugin extends AntPlugin
                     $pagePath = AntTools::repairFilePath($pagePath);
 
                     $page = file_get_contents($pagePath);
+
+                    //Finally, we strip off the antContentPath for compatibility with the save function.
+                    $pagePath = str_replace(antContentPath, '', $pagePath);
                 } else {
                     $pagePath = '/' . $_POST['newpage'];
 
@@ -199,6 +202,14 @@ class AdminPlugin extends AntPlugin
                 array_shift($route);
                 $pagePath = AntTools::repairFilePath(antContentPath . '/' . implode('/', $route));
 
+                if (empty($pagePath) || is_dir($pagePath)) {
+                    $pagePath .= '/index.md';
+                }
+
+                if (!str_ends_with($pagePath, ".md")) {
+                    $pagePath .= '.md';
+                }
+
                 // Find the key associated with the functional page path, then remove it from our temp pages array
                 foreach ($pages as $key => $page) {
                     if ($page['fullPagePath'] == $pagePath) {
@@ -219,6 +230,14 @@ class AdminPlugin extends AntPlugin
                 array_shift($route);
                 $pagePath = AntTools::repairFilePath(antContentPath . '/' . implode('/', $route));
 
+                if (empty($pagePath) || is_dir($pagePath)) {
+                    $pagePath .= '/index.md';
+                }
+
+                if (!str_ends_with($pagePath, ".md")) {
+                    $pagePath .= '.md';
+                }
+
                 foreach ($pages as $key => $page) {
                     if ($page['fullPagePath'] == $pagePath) {
                         $pages[$key]['showInNav'] = !$page['showInNav'];