Bladeren bron

Some fixes to the admin plugin

Belle Aerni 2 jaren geleden
bovenliggende
commit
7ea9cb2e5d
1 gewijzigde bestanden met toevoegingen van 19 en 0 verwijderingen
  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);
                     $pagePath = AntTools::repairFilePath($pagePath);
 
 
                     $page = file_get_contents($pagePath);
                     $page = file_get_contents($pagePath);
+
+                    //Finally, we strip off the antContentPath for compatibility with the save function.
+                    $pagePath = str_replace(antContentPath, '', $pagePath);
                 } else {
                 } else {
                     $pagePath = '/' . $_POST['newpage'];
                     $pagePath = '/' . $_POST['newpage'];
 
 
@@ -199,6 +202,14 @@ class AdminPlugin extends AntPlugin
                 array_shift($route);
                 array_shift($route);
                 $pagePath = AntTools::repairFilePath(antContentPath . '/' . implode('/', $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
                 // Find the key associated with the functional page path, then remove it from our temp pages array
                 foreach ($pages as $key => $page) {
                 foreach ($pages as $key => $page) {
                     if ($page['fullPagePath'] == $pagePath) {
                     if ($page['fullPagePath'] == $pagePath) {
@@ -219,6 +230,14 @@ class AdminPlugin extends AntPlugin
                 array_shift($route);
                 array_shift($route);
                 $pagePath = AntTools::repairFilePath(antContentPath . '/' . implode('/', $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) {
                 foreach ($pages as $key => $page) {
                     if ($page['fullPagePath'] == $pagePath) {
                     if ($page['fullPagePath'] == $pagePath) {
                         $pages[$key]['showInNav'] = !$page['showInNav'];
                         $pages[$key]['showInNav'] = !$page['showInNav'];