diff --git a/content/00-welcome/00-setup-your-website.yaml b/content/00-welcome/00-setup-your-website.yaml index 52c647d..38ccecb 100644 --- a/content/00-welcome/00-setup-your-website.yaml +++ b/content/00-welcome/00-setup-your-website.yaml @@ -1,10 +1,11 @@ meta: navtitle: 'setup your website' - owner: Sebastian - created: '2023-06-12' - time: 22-36-14 - modified: '2023-10-23' title: 'Setup your website' description: ' You will find all configurations and settings under the main navigation point settings with the following sub-navigation:' + owner: Sebastian + manualdate: '2023-11-22' + modified: '2023-10-23' + created: '2023-06-12' + time: 15-18-48 hide: false noindex: false diff --git a/system/typemill/Controllers/ControllerApiAuthorMeta.php b/system/typemill/Controllers/ControllerApiAuthorMeta.php index 7bd7bb5..8db13e1 100644 --- a/system/typemill/Controllers/ControllerApiAuthorMeta.php +++ b/system/typemill/Controllers/ControllerApiAuthorMeta.php @@ -254,9 +254,13 @@ class ControllerApiAuthorMeta extends Controller $pathWithoutFile = str_replace($item->originalName, "", $item->path); $newPathWithoutType = $pathWithoutFile . $datetime . '-' . $item->slug; - $meta->renamePost($item->pathWithoutType, $newPathWithoutType); + $renameresults = $meta->renamePost($item->pathWithoutType, $newPathWithoutType); $navigation->clearNavigation(); + + # WE HAVE TO REGENERATE ITEM AND NAVIGATION + $draftNavigation = $navigation->getDraftNavigation($urlinfo, $this->settings['langattr']); + $item = $navigation->getItemWithKeyPath($draftNavigation, $item->keyPathArray); } } @@ -334,14 +338,15 @@ class ControllerApiAuthorMeta extends Controller $response->getBody()->write(json_encode([ 'navigation' => $draftNavigation, - 'item' => $item + 'item' => $item, + 'rename' => $renameresults ?? false ])); return $response->withHeader('Content-Type', 'application/json'); } $response->getBody()->write(json_encode([ - 'message' => $store, + 'message' => $store, ])); return $response->withHeader('Content-Type', 'application/json')->withStatus(500); diff --git a/system/typemill/Middleware/ApiAuthentication.php b/system/typemill/Middleware/ApiAuthentication.php index c1457ca..c38c2b5 100644 --- a/system/typemill/Middleware/ApiAuthentication.php +++ b/system/typemill/Middleware/ApiAuthentication.php @@ -19,6 +19,7 @@ class ApiAuthentication # check if it is a session based authentication if ($request->hasHeader('X-Session-Auth')) { + # proceed, if a session based authentication has been done before in middleware if($request->getAttribute('c_username') && $request->getAttribute('c_userrole')) { $response = $handler->handle($request); @@ -31,7 +32,6 @@ class ApiAuthentication } } - # api authentication with basic auth # inspired by tuupola $host = $request->getUri()->getHost(); diff --git a/system/typemill/Models/Meta.php b/system/typemill/Models/Meta.php index 5755ef2..4d2d203 100644 --- a/system/typemill/Models/Meta.php +++ b/system/typemill/Models/Meta.php @@ -178,6 +178,25 @@ class Meta return false; } + public function renamePost($oldPathWithoutType,$newPathWithoutType) + { + $filetypes = [ + 'txt' => true, + 'md' => true, + 'yaml' => true + ]; + + foreach($filetypes as $filetype => $result) + { + if(!$this->storage->renameFile('contentFolder', '', $oldPathWithoutType . '.' . $filetype, $newPathWithoutType . '.' . $filetype)) + { + $filetypes[$filetype] = $this->storage->getError(); + } + } + + return $filetypes; + } + # just route it to storageWrapper because wrapper is initialized here and we dont want to initialize it in controllers public function transformPostsToPages($folder) {