($loose && glob($this->getBasename() . "/*/$glob"));
} elseif ($this->isRoot()) {
return true;
- } else {
+ } elseif ($this->getBasename() !== "/") {
return is_dir($this->getBasename());
+ } else {
+ return false;
}
}
* @var \mdref\Repo
*/
private $repo;
-
+
/**
* List of first level entries
* @var array
*/
private $list = array();
-
+
/**
* The list iterator
* @var array
*/
private $iter;
-
+
/**
* @param string $path
* @param \mdref\Repo $repo
}
if ($list) {
$this->list = array_filter($list, $this->generateFilter($list));
- sort($this->list, SORT_STRING);
+ usort($this->list, $this->generateSorter());
}
$this->repo = $repo;
}
-
+
/**
* @param array $list
* @return callable
if (false !== array_search("$v.md", $list, true)) {
return false;
}
-
+
$pi = pathinfo($v);
if (isset($pi["extension"]) && "md" !== $pi["extension"]) {
return false;
}
-
+
return true;
};
}
+ /**
+ * @return callable
+ */
+ private function generateSorter() {
+ return function($a, $b) {
+ $ab = basename($a, ".md");
+ $bb = basename($b, ".md");
+
+ if ($ab{0} === ":" && $bb{0} === ":") {
+ return strcmp($ab, $bb);
+ } elseif ($ab{0} === ":") {
+ return -1;
+ } elseif ($bb{0} === ":") {
+ return 1;
+ }
+
+ $ad = is_dir(dirname($a)."/$ab");
+ $bd = is_dir(dirname($b)."/$bb");
+
+ if ($ad && $bd) {
+ return strcmp($ab, $bb);
+ } elseif ($ad) {
+ return -1;
+ } elseif ($bd) {
+ return 1;
+ }
+
+ $au = preg_match("/^\p{Lu}/", $ab);
+ $bu = preg_match("/^\p{Lu}/", $bb);
+
+ if ($au && $bu) {
+ return strcmp($ab, $bb);
+ } elseif ($au) {
+ return -1;
+ } elseif ($bu) {
+ return 1;
+ }
+
+ return strcmp($ab, $bb);
+ };
+ }
+
/**
* Implements \Iterator
* @return \mdref\Entry
public function current() {
return $this->repo->getEntry($this->repo->hasFile(current($this->iter)));
}
-
+
/**
* Implements \Iterator
*/
public function next() {
next($this->iter);
}
-
+
/**
* Implements \Iterator
* @return int
public function key() {
return key($this->iter);
}
-
+
/**
* Implements \Iterator
*/
$this->iter = $this->list;
reset($this->iter);
}
-
+
/**
* Implements \Iterator
* @return bool
public function valid() {
return null !== key($this->iter);
}
-
+
/**
* Implements \RecursiveIterator
* @return bool
public function hasChildren() {
return $this->current()->hasIterator();
}
-
+
/**
* Implements \RecursiveIterator
* @return \mdref\Tree
min-height: 100%;
}
body, code {
- font-family: Inconsolata, 'Courier New', Courier, monospace;
+ font-family: Inconsolata, 'Inconsolata Awesome', 'Andale Mono', Monaco, 'Courier New', Courier, monospace;
}
body {
line-height: 1.5;
width: auto;
min-width: 200px;
padding-right: 1em;
+ padding-bottom: 1em;
+ margin-bottom: 1em;
}
.sidebar>ul {
}
.sidebar ul {
margin-left: 1em;
margin-top: .5em;
+ margin-bottom: 0;
padding: 0;
list-style-type: none;
}
margin-top: 1em;
margin-bottom: 2em;
}
+ol {
+ list-style-type: none;
+}
+ol ul {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+ol li {
+ margin-bottom: 0;
+}
+ol>li {
+ font-weight: bold;
+ margin-bottom: .5em;
+}
+ol>li>* {
+ font-weight: normal;
+}
li {
margin-bottom: .5em;
}
color: #2e8b57;
}
+h1, li h3, th, footer {
+ background: #708090;
+ color: #f5f5dc;
+}
+
+h1, footer {
+ margin: 0;
+ max-width: 1200px;
+ padding: 1em;
+}
+
h1 {
line-height: 1.5;
margin-left: 0 !important;
+ padding-left: 2em;
}
h1 code {
font-weight: normal;
font-size: .9em;
line-height: 1.33;
}
-
-footer, h1, li h3, th {
- background: #708090;
- color: #f5f5dc;
-}
-
-footer, h1 {
- margin: 0;
- max-width: 1200px;
- padding: 1em;
+h1 a.permalink {
+ left: -.8em;
+ margin-right: -.6em;
}
li h3 {
h1 .var, pre>code .var, li h3 .var {
color: #f4a460;
}
-
+h1 {
+ font-size: 125%;
+}
+h2 {
+ font-size: 120%;
+}
+h3 {
+ font-size: 110%;
+}
+h4 {
+ font-size: 100%;
+}
footer a, h1 a, pre>code a, li h3 a {
color: #b0e0e6;
}
-
+li h3 {
+ font-size: 100%;
+}
li h3 a {
text-decoration: none;
}
}
th, td {
padding: .4em;
+ border-bottom: 1px solid rgba(112, 128, 144, 0.1);
}
dt {
font-weight: bold;
+
<?php if (isset($listing) && ($entry = $listing->getSelf()) && ($url = $entry->formatEditUrl())) : ?>
+
<a class="edit" href="<?=$url?>">Edit Page</a>
<?php endif; ?>
+
<ul>
<li><a href="https://github.com/m6w6/mdref">mdref-v<?php readfile(__DIR__."/../VERSION") ?></a></li>
<li><a href="LICENSE">© <?= implode("-", array_unique([2013, idate("Y")])) ?>
+
<h1>mdref</h1>
<?php if (isset($html)) : ?>
<?= $html ?>
<?php elseif (isset($text)) : ?>
+
<p style="white-space:pre-wrap"><?= $esc($text) ?></p>
<?php elseif (isset($refs)) : ?>
<?php foreach ($refs as $repo) : /* @var \mdref\Repo $repo */ ?>
<?php foreach ($repo as $entry) : /* @var \mdref\Entry $entry */ ?>
+
<h2 id="<?= $anchor($entry->getTitle()) ?>">
<a href="<?= $esc($entry->getName()) ?>"
><?= $esc($entry->getTitle()) ?></a></h2>
<link rel="stylesheet" href="index.css">
<?php endif; ?>
+ <link href="https://fonts.googleapis.com/css?family=Inconsolata&subset=latin-ext" rel="stylesheet">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link rel="shortcut icon" href="<?= $baseUrl . "favicon.ico" ?>">
</head>
<?php endif; ?>
<?php if (@$_SERVER["SERVER_NAME"] != "localhost") : ?>
- <div id="disqus_thread"></div>
- <script>
- var disqus_shortname = 'mdref';
- var disqus_identifier = '<?=$ref?>';
- (function() {
- var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
- dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
- })();
- </script>
+
+ <div id="disqus_thread"></div>
+ <script>
+ var disqus_shortname = 'mdref';
+ var disqus_identifier = '<?=$ref?>';
+ (function() {
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
+ dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
+ })();
+ </script>
<?php endif; ?>
- <footer>
- <?php include __DIR__."/footer.phtml" ?>
- </footer>
+ <footer>
+ <?php include __DIR__."/footer.phtml" ?>
+
+ </footer>
<?php if (isset($baseUrl)) : ?>
+
<script src="index.js"></script>
<?php endif; ?>
+
</div>
</body>
</html>
+
<?= $file($entry->getPath()) ?>
<?php if ($entry->hasFunctions()) : ?>
+
<h2 id="Functions:">Functions:</h2>
<ul>
<?php foreach($entry as $sub) : if (!$sub->isFunction()) continue; ?>
+
<li>
<h3><a href="<?= $esc($sub->getName()) ?>"><?= $esc($sub) ?></a></h3>
<p><?= $quick($sub->getDescription()) ?></p>
<p><?= $esc($sub->getTitle()) ?></p>
</li>
<?php endforeach; ?>
+
</ul>
<?php endif; ?>
<?php if ($entry->hasNsClasses()) : ?>
+
<h2 id="Namespaces,.Interfaces.and.Classes:">Namespaces, Interfaces and Classes:</h2>
<ul>
<?php foreach ($entry as $sub) : if (!$sub->isNsClass()) continue; ?>
+
<li>
<h3><a href="<?= $esc($sub->getName()) ?>"><?= $esc($sub) ?></a></h3>
<p><?= $quick($sub->getDescription()) ?></p>
<p><?= $esc($sub->getTitle()) ?></p>
</li>
<?php endforeach; ?>
+
</ul>
<?php endif; ?>
+
<div class="sidebar">
<?php if (isset($entry)) : ?>
+
<div class="edit">
<a href="<?= $entry->getEditUrl() ?>">Edit</a>
</div>
<?php endif; ?>
- <?php
+
+ <?php
if (isset($baseUrl) || !isset($entry)) {
$up = "./";
} else {
$up = str_repeat("../", count($entry->getParents()));
}
?>
+
<ul>
<li>↰ <a href="<?= $up ?>">Home</a>
<?php if (isset($entry)) : /* @var \mdref\Entry $entry */ ?>
+
<ul>
<li>
- <?php foreach ($entry->getParents() as $parent) if ($parent->isFile()) : ?>
- ↑
- <a href="<?= $up.$esc($parent->getName()) ?>">
+ <?php foreach ($entry->getParents() as $parent) : ?>
+ <?php if ($parent->isFile()) : ?>
+
+ ↑ <a href="<?= $up.$esc($parent->getName()) ?>">
<?= $esc($entry->getRepo()->getEntry($parent)) ?>
+
</a>
<ul>
<li>
- <?php endif; ?>
- ↻ <a href="<?= $up.$esc($entry->getName()) ?>"
- ><?= $esc($entry) ?></a>
+ <?php endif; ?>
+ <?php endforeach; ?>
+
+ ↻ <strong><a href="<?= $up.$esc($entry->getName()) ?>"
+ ><?= $esc($entry) ?></a></strong>
+
+ <?php if ($entry->hasIterator()): ?>
+
<ul>
<?php foreach ($entry as $sub) : /* @var \mdref\Entry $sub */ ?>
+
<li>
↳ <a href="<?= $up.$esc($sub->getName()) ?>"
><?= $esc($sub) ?></a>
</li>
<?php endforeach; ?>
+
</ul>
- <?php foreach ($entry->getParents() as $parent) if ($parent->isFile()) : ?>
+ <?php endif; ?>
+
+ <?php if (isset($parent)) : ?>
+ <?php
+ while ($parent && !$parent->isFile()) {
+ $parent = $parent->getParent();
+ }
+ ?>
+ <?php if ($parent && $parent->hasIterator()) : ?>
+ <?php
+ $parent_closed = true;
+ ?>
+
+ </ul>
+ <?php foreach ($parent as $sub) : ?>
+ <?php
+ if ($sub->getName() === $entry->getName()) {
+ continue;
+ }
+ ?>
+
+ <li>↲ <a href="<?= $up.$esc($sub->getName()) ?>"><?= $esc($sub) ?></a></li>
+ <?php endforeach; ?>
+ <?php endif; ?>
+ <?php endif; ?>
+ <?php foreach ($entry->getParents() as $parent) : ?>
+ <?php if (!empty($parent_closed)) : ?>
+ <?php
+ $parent_closed = false;
+ ?>
+ <?php elseif ($parent->isFile()) : ?>
+ <?php if (isset($parent_closed)) : ?>
+ <?php
+ unset($parent_closed);
+ ?>
+ <?php else : ?>
+
</li>
+ <?php endif; ?>
+
</ul>
- <?php endif; ?>
+ <?php endif; ?>
+ <?php endforeach; ?>
+
</li>
</ul>
<?php elseif (isset($refs)) : ?>
+
<ul>
<?php foreach ($refs as $repo) : /* @var \mdref\Repo $repo */ ?>
<?php foreach ($repo as $sub) : /* @var \mdref\Entry $entry */ ?>
+
<li>
↳ <a href="<?= $esc($sub->getName()) ?>"
><?= $esc($sub->getTitle()) ?></a>
</li>
<?php endforeach; ?>
<?php endforeach; ?>
+
</ul>
<?php endif; ?>
+
</li>
</ul>
</div>
-