diff options
author | Simon McVittie <smcv@debian.org> | 2010-04-03 13:48:30 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2010-04-03 14:28:21 +0100 |
commit | a875ee8be702bd4575e009dc652015c1157c7c2e (patch) | |
tree | 91aa52cda28325f2791cb4a234f83fee4a30a259 /IkiWiki/Plugin | |
parent | b86276ffed7ee001b35cd610e5d56e5afb4088cf (diff) | |
download | ikiwiki-a875ee8be702bd4575e009dc652015c1157c7c2e.tar ikiwiki-a875ee8be702bd4575e009dc652015c1157c7c2e.tar.gz |
Split out sortnaturally into a plugin
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/sortnaturally.pm | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/sortnaturally.pm b/IkiWiki/Plugin/sortnaturally.pm new file mode 100644 index 000000000..0023f31f9 --- /dev/null +++ b/IkiWiki/Plugin/sortnaturally.pm @@ -0,0 +1,32 @@ +#!/usr/bin/perl +# Sort::Naturally-powered title_natural sort order for IkiWiki +package IkiWiki::Plugin::sortnaturally; + +use IkiWiki 3.00; +no warnings; + +sub import { + hook(type => "getsetup", id => "sortnaturally", call => \&getsetup); +} + +sub getsetup { + return + plugin => { + safe => 1, + rebuild => 1, + }, +} + +sub checkconfig () { + eval q{use Sort::Naturally}; + error $@ if $@; +} + +package IkiWiki::PageSpec; + +sub cmp_title_natural { + Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($_[0])), + IkiWiki::pagetitle(IkiWiki::basename($_[1]))) +} + +1; |