From 3dbead20601800ab6127df29ecee0227859bdc63 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 22 Aug 2016 14:04:58 +0200 Subject: [PATCH] new entry sorting; style updates --- mdref/Entry.php | 4 ++- mdref/Tree.php | 68 +++++++++++++++++++++++++++++++-------- public/index.css | 65 ++++++++++++++++++++++++++++++-------- views/edit.phtml | 2 ++ views/footer.phtml | 1 + views/index.phtml | 3 ++ views/layout.phtml | 31 ++++++++++-------- views/mdref.phtml | 7 +++++ views/sidebar.phtml | 77 +++++++++++++++++++++++++++++++++++++++------ 9 files changed, 208 insertions(+), 50 deletions(-) diff --git a/mdref/Entry.php b/mdref/Entry.php index 4febd76..9135dd7 100644 --- a/mdref/Entry.php +++ b/mdref/Entry.php @@ -236,8 +236,10 @@ class Entry implements \IteratorAggregate { ($loose && glob($this->getBasename() . "/*/$glob")); } elseif ($this->isRoot()) { return true; - } else { + } elseif ($this->getBasename() !== "/") { return is_dir($this->getBasename()); + } else { + return false; } } diff --git a/mdref/Tree.php b/mdref/Tree.php index 8f6c773..11cada0 100644 --- a/mdref/Tree.php +++ b/mdref/Tree.php @@ -8,19 +8,19 @@ class Tree implements \RecursiveIterator { * @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 @@ -33,11 +33,11 @@ class Tree implements \RecursiveIterator { } 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 @@ -50,16 +50,58 @@ class Tree implements \RecursiveIterator { 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 @@ -67,14 +109,14 @@ class Tree implements \RecursiveIterator { 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 @@ -82,7 +124,7 @@ class Tree implements \RecursiveIterator { public function key() { return key($this->iter); } - + /** * Implements \Iterator */ @@ -90,7 +132,7 @@ class Tree implements \RecursiveIterator { $this->iter = $this->list; reset($this->iter); } - + /** * Implements \Iterator * @return bool @@ -98,7 +140,7 @@ class Tree implements \RecursiveIterator { public function valid() { return null !== key($this->iter); } - + /** * Implements \RecursiveIterator * @return bool @@ -106,7 +148,7 @@ class Tree implements \RecursiveIterator { public function hasChildren() { return $this->current()->hasIterator(); } - + /** * Implements \RecursiveIterator * @return \mdref\Tree diff --git a/public/index.css b/public/index.css index 4fd8949..b71b5ae 100644 --- a/public/index.css +++ b/public/index.css @@ -7,7 +7,7 @@ html, body{ 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; @@ -40,12 +40,15 @@ div.page>ul, div.page>div>ul { 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; } @@ -118,6 +121,23 @@ ul { 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; } @@ -146,25 +166,30 @@ a.permalink { 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 { @@ -195,11 +220,24 @@ h1 .constant, pre>code .consant, li h3 .constant { 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; } @@ -247,6 +285,7 @@ table { } th, td { padding: .4em; + border-bottom: 1px solid rgba(112, 128, 144, 0.1); } dt { font-weight: bold; diff --git a/views/edit.phtml b/views/edit.phtml index aabbb02..dcce1ca 100644 --- a/views/edit.phtml +++ b/views/edit.phtml @@ -1,3 +1,5 @@ + getSelf()) && ($url = $entry->formatEditUrl())) : ?> + Edit Page diff --git a/views/footer.phtml b/views/footer.phtml index 12ef7fb..4aff00c 100644 --- a/views/footer.phtml +++ b/views/footer.phtml @@ -1,3 +1,4 @@ + - -- 2.30.2