ikiwiki/IkiWiki/Plugin/sortnaturally.pm

34 lines
634 B
Perl
Raw Normal View History

2010-04-03 14:48:30 +02:00
#!/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);
hook(type => "checkconfig", id => "sortnaturally", call => \&checkconfig);
2010-04-03 14:48:30 +02:00
}
sub getsetup {
return
plugin => {
safe => 1,
rebuild => undef,
2010-04-03 14:48:30 +02:00
},
}
sub checkconfig () {
eval q{use Sort::Naturally};
error $@ if $@;
}
package IkiWiki::SortSpec;
2010-04-03 14:48:30 +02:00
sub cmp_title_natural {
Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($a)),
IkiWiki::pagetitle(IkiWiki::basename($b)))
2010-04-03 14:48:30 +02:00
}
1;