From c0d7ce7e3ca21ef24d419d7edf3090cf353aaa1d Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Fri, 13 Dec 2013 17:50:14 +0100 Subject: [PATCH] in-depth overview on the start page --- mdref/Finder.php | 4 ++++ mdref/RefEntry.php | 14 ++++++++++++-- public/index.css | 4 ++++ views/index.phtml | 10 ++++++---- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/mdref/Finder.php b/mdref/Finder.php index cf04fbf..8f0f231 100644 --- a/mdref/Finder.php +++ b/mdref/Finder.php @@ -36,6 +36,10 @@ class Finder $this->baseUrl = $baseUrl; } + function getBaseUrl() { + return $this->baseUrl; + } + /** * Find a markdown reference file in one REFPATH. If nothing could be found * an empty Path will be returned. diff --git a/mdref/RefEntry.php b/mdref/RefEntry.php index 32ef3ce..0becc69 100644 --- a/mdref/RefEntry.php +++ b/mdref/RefEntry.php @@ -74,10 +74,10 @@ class RefEntry $file = $this->getPath(); if (!$file->isFile()) { - throw new \Exception("Not a file: '{$this->entry}'"); + throw new \Exception("Not a file: '{$file}'"); } if (!$this->file = fopen($file->getFullPath(".md"), "r")) { - throw new \Exception("Could not open {$this->entry}"); + throw new \Exception("Could not open {$file}"); } } } @@ -105,4 +105,14 @@ class RefEntry $this->entry); } } + + function recurse(Finder $refs, $pattern, callable $cb) { + $path = $refs->find($refs->getBaseUrl()->mod($this->entry)); + foreach (new RefListing($path, $refs->glob($path, $pattern)) as $entry) { + /* @var $entry RefEntry */ + $cb($entry, $pattern, function($entry, $pattern) use ($refs, $cb) { + $entry->recurse($refs, $pattern, $cb); + }); + } + } } \ No newline at end of file diff --git a/public/index.css b/public/index.css index a4493e9..2f86d66 100644 --- a/public/index.css +++ b/public/index.css @@ -79,6 +79,10 @@ p, pre { margin: 1em 2em; } +li>p { + margin: 1em 0; +} + blockquote { border-top: 1px solid #800000; border-bottom: 1px solid #800000; diff --git a/views/index.phtml b/views/index.phtml index 676fe10..dbd3017 100644 --- a/views/index.phtml +++ b/views/index.phtml @@ -7,12 +7,14 @@

Available References

formatLink()?>

+ recurse($refs, "/*.md", function($entry, $pattern, callable $recursor) { ?> + -- 2.30.2