Skip to content

Commit

Permalink
corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Arbeit authored and Arbeit committed Feb 24, 2018
1 parent 8ffe6ce commit 6ef9633
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/Leaf.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function __construct($uri)
{
$uri_parts = explode('/', $uri);
$uri_base = $uri_parts[0] . '/index.md';
$this->base = $this->retriveMetas($uri_base, 'leaves');
$this->base['slug'] = $uri_parts[0];

$this->constructBase();
$this->menu = $this->constructMenu($uri_parts[0]);
}
return $this->uri;
Expand All @@ -54,6 +54,16 @@ public function exists($uri)
return false;
}

public function constructBase()
{
$uri_parts = explode('/', $uri);
$base = $uri_parts[0];
if ($base != "/") {
$this->base['slug'] = $uri_parts[0];
$this->base = $this->retriveMetas($uri_base, 'leaves');
}
}

public function cssStandards($content)
{
if ( !empty(config('iba.short_keys')) )
Expand Down Expand Up @@ -88,6 +98,7 @@ public function render($file, $disk = 'seed')

public function retriveMetas($file, $disk)
{
$metas = false;
$rawContent = Storage::disk($disk)->get($file);
$pattern = "/^(\/(\*)|---)[[:blank:]]*(?:\r)?\n"
. "(?:(.*?)(?:\r)?\n)?(?(2)\*\/|---)[[:blank:]]*(?:(?:\r)?\n|$)/s";
Expand Down Expand Up @@ -126,6 +137,13 @@ public function display() {
$leaf = $this->render($this->uri, 'leaves');
$base = $this->base;
$menu = $this->menu;

$uri_parts = explode('/', $this->uri);
if ( (end($uri_parts) == "index.md") || (end($uri_parts) == "index.html") )
{
$leaf['children'] = $this->retriveChildrenMetas();
}

if ( array_key_exists('style', $leaf) )
{
$blade_file = 'leaf.' . $leaf['style'];
Expand Down Expand Up @@ -169,4 +187,22 @@ public function constructMenu($base) {
}
return $directories;
}

public function retriveChildrenMetas()
{
$uri = rtrim($this->uri, "index.md");
$uri = rtrim($uri, "index.md");
$return = array();
// dd($uri);
// dd(Storage::disk('leaves')->files($uri));
foreach (Storage::disk('leaves')->files($uri) as $file)
{
$metas = $this->retriveMetas($file, 'leaves');
if ($metas != false)
{
$return[$file] = $metas;
}
}
return $return;
}
}

0 comments on commit 6ef9633

Please sign in to comment.