diff options
author | chrysn <chrysn@fsfe.org> | 2009-03-17 20:19:11 +0100 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2009-03-19 15:31:46 -0400 |
commit | 55b83cb7bd1cd7c60bb45dc22c3745dd80a63fed (patch) | |
tree | 44df56ffe83969e67a8e6aa9987eab9c390d6a64 | |
parent | 888e67bf4e44b66dcecde07395a50135e19b911d (diff) |
implement sort=title_natural for inline
adds a new sorting order, title_natural, that uses Sort::Naturally's
ncmp function to provide better sorting for inlines
-rw-r--r-- | IkiWiki/Plugin/inline.pm | 4 | ||||
-rw-r--r-- | doc/ikiwiki/directive/inline.mdwn | 5 |
2 files changed, 8 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 2205ebffc..a89e827c1 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -194,6 +194,10 @@ sub preprocess_inline (@) { if (exists $params{sort} && $params{sort} eq 'title') { @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list; } + elsif (exists $params{sort} && $params{sort} eq 'title_natural') { + require Sort::Naturally; + @list=sort { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) } @list; + } elsif (exists $params{sort} && $params{sort} eq 'mtime') { @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list; } diff --git a/doc/ikiwiki/directive/inline.mdwn b/doc/ikiwiki/directive/inline.mdwn index 40670e1e7..3f9a9ede5 100644 --- a/doc/ikiwiki/directive/inline.mdwn +++ b/doc/ikiwiki/directive/inline.mdwn @@ -87,7 +87,10 @@ Here are some less often needed parameters: inlining page. * `sort` - Controls how inlined pages are sorted. The default, "age" is to sort newest created pages first. Setting it to "title" will sort pages by - title, and "mtime" sorts most recently modified pages first. + title, and "mtime" sorts most recently modified pages first. If + [Sort::Naturally](http://search.cpan.org/dist/Sort-Naturally/lib/Sort/Naturally.pm) + is installed, `sort` can be set to "title_natural" to sort by title with + numbers treated as such ("1 2 9 10 20" instead of "1 10 2 20 9"). * `reverse` - If set to "yes", causes the sort order to be reversed. * `feedshow` - Specify the maximum number of matching pages to include in the rss/atom feeds. The default is the same as the `show` value above. |