Permalink
Browse files

Fixed handling root and index pages

+ Always add root content directory to returned `Page::parents`
  • Loading branch information...
1 parent 85691a9 commit b2dafefd0a7a5470dafad3305d42fc9b69d07a0d @Sija committed Mar 3, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 app/src/Gizmo/Page.php
View
@@ -68,7 +68,7 @@ static public function fromFullPath($full_path) {
if (0 !== strpos($full_path, $app['gizmo.content_path'])) {
return false;
}
- $path = preg_replace("#^{$app['gizmo.content_path']}/#", '', $full_path);
+ $path = preg_replace("#^{$app['gizmo.content_path']}/?#", '', $full_path);
$path = preg_replace(array('/^\d+?\./', '/(\/)\d+?\./'), '\\1', $path);
return self::fromPath($path);
@@ -78,7 +78,7 @@ public function __construct($meta_file, $full_path, $path) {
$this->app = Gizmo::getInstance();
$this->full_path = $full_path;
$this->path = $path;
- $this->url = $this->app['request']->getBaseURL() . '/' . $this->path;
+ $this->url = $this->app['request']->getBaseURL() . '/' . preg_replace('#/?index#', '', $this->path);
$this->slug = preg_replace('#(.*?)/([^/]+)$#', '\\2', $this->path);
$this->title = ucfirst(preg_replace('/[-_]/', ' ', $this->slug));
@@ -281,6 +281,7 @@ public function getParents() {
array_pop($path_parts);
$parents[] = $this->app['gizmo.content_path'] . '/' . implode('/', $path_parts);
}
+ $parents[] = $this->app['gizmo.content_path'];
$parents = array_reverse($parents);
return $parents;
}

0 comments on commit b2dafef

Please sign in to comment.