in-depth overview on the start page
authorMichael Wallner <mike@php.net>
Fri, 13 Dec 2013 16:50:14 +0000 (17:50 +0100)
committerMichael Wallner <mike@php.net>
Fri, 13 Dec 2013 16:50:14 +0000 (17:50 +0100)
mdref/Finder.php
mdref/RefEntry.php
public/index.css
views/index.phtml

index cf04fbf6a9f517b9b5aa896b253fa027af28bdbb..8f0f2315e41a56c8ede79481f00dcc7db8ceba7a 100644 (file)
@@ -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.
index 32ef3ceb6c9a0fdc432bc65938cbc3343a64e068..0becc69988b52ae844c52b108959b5194fd1b5f2 100644 (file)
@@ -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
index a4493e95df67ebd697ceb0cf22c1c1b1f121bc78..2f86d6662aa6d626b68cb5cb47547ff51613031e 100644 (file)
@@ -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;
index 676fe10fb8a33226c2d70122c5d58c09a5b2d415..dbd3017f372b7b4c479a8ab53597d767083cb744 100644 (file)
@@ -7,12 +7,14 @@
                <h2>Available References</h2>
                <?php foreach ($listing as $entry) : ?>
                        <h3><a href="<?=$entry->formatUrl()?>"><?=$entry->formatLink()?></a></h3>
+                       <?php $entry->recurse($refs, "/*.md", function($entry, $pattern, callable $recursor) { ?>
                        <ul>
-                               <?php foreach (new mdref\RefListing($path = $refs->find($baseUrl->mod($entry->formatUrl())), $refs->glob($path, "/*.md")) as $entry) : ?>
-                               <li><a href="<?=$entry->formatUrl()?>"><?=$entry->formatLink()?></a><br>
-                                       <?=$entry->readDescription()?></li>
-                               <?php endforeach; ?>
+                               <li><p><a href="<?=$entry->formatUrl()?>"><?=$entry->formatLink()?></a></p>
+                                       <?=$entry->readDescription()?>
+                                       <?php $recursor($entry, "/[A-Z]*.md") ?>
+                               </li>
                        </ul>
+                       <?php }); ?>
                <?php endforeach; ?>
        <?php endif; ?>
 <?php endif; ?>