Add path and path_natural sort orders
authorSimon McVittie <smcv@debian.org>
Sat, 12 Nov 2011 15:11:02 +0000 (15:11 +0000)
committerJoey Hess <joey@kitenet.net>
Tue, 6 Dec 2011 18:26:27 +0000 (14:26 -0400)
(cherry picked from commit 272e0b2f17c33c625b494b07f581da400066a216)

IkiWiki.pm
IkiWiki/Plugin/sortnaturally.pm
doc/ikiwiki/pagespec/sorting.mdwn

index 59fefc69933e49768e6c36d2b389f61d0fc68b6a..08e242a1f07de9e40bda8e91c521c69b9b7be0ba 100644 (file)
@@ -2808,6 +2808,7 @@ sub cmp_title {
        IkiWiki::pagetitle(IkiWiki::basename($b))
 }
 
+sub cmp_path { IkiWiki::pagetitle($a) cmp IkiWiki::pagetitle($b) }
 sub cmp_mtime { $IkiWiki::pagemtime{$b} <=> $IkiWiki::pagemtime{$a} }
 sub cmp_age { $IkiWiki::pagectime{$b} <=> $IkiWiki::pagectime{$a} }
 
index b038b2f9a662358c015806bd22a7159c51b922c6..108b489f80d6f7e71916c891345ecea8569e9ed3 100644 (file)
@@ -30,4 +30,9 @@ sub cmp_title_natural {
                IkiWiki::pagetitle(IkiWiki::basename($b)))
 }
 
+sub cmp_path_natural {
+       Sort::Naturally::ncmp(IkiWiki::pagetitle($a),
+               IkiWiki::pagetitle($b))
+}
+
 1;
index ccd7f7eaa84dc773a57003d2e38d332cc97e1a05..0c6cc74c7a7fdc808749c666625264598bba7a2a 100644 (file)
@@ -7,10 +7,14 @@ orders can be specified.
 
 * `mtime` - List pages with the most recently modified first.
 
-* `title` - Order by title (page name).
+* `title` - Order by title (page name), e.g. "z/a a/b a/c"
+
+* `path` - Order by page name including parents, e.g. "a/b a/c z/a"
 [[!if test="enabled(sortnaturally)" then="""
 * `title_natural` - Orders by title, but numbers in the title are treated
   as such, ("1 2 9 10 20" instead of "1 10 2 20 9")
+
+* `path_natural` - Like `path`, but numbers in the title are treated as such
 """]]
 [[!if test="enabled(meta)" then="""
 * `meta(title)` - Order according to the `\[[!meta title="foo" sortas="bar"]]`