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);
|
2010-10-30 18:34:00 +02:00
|
|
|
hook(type => "checkconfig", id => "sortnaturally", call => \&checkconfig);
|
2010-04-03 14:48:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sub getsetup {
|
|
|
|
return
|
|
|
|
plugin => {
|
|
|
|
safe => 1,
|
2010-04-07 05:15:39 +02:00
|
|
|
rebuild => undef,
|
2010-04-03 14:48:30 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
sub checkconfig () {
|
|
|
|
eval q{use Sort::Naturally};
|
|
|
|
error $@ if $@;
|
|
|
|
}
|
|
|
|
|
2010-04-03 14:57:38 +02:00
|
|
|
package IkiWiki::SortSpec;
|
2010-04-03 14:48:30 +02:00
|
|
|
|
|
|
|
sub cmp_title_natural {
|
2010-04-05 23:50:51 +02:00
|
|
|
Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($a)),
|
|
|
|
IkiWiki::pagetitle(IkiWiki::basename($b)))
|
2010-04-03 14:48:30 +02:00
|
|
|
}
|
|
|
|
|
2011-11-12 16:11:02 +01:00
|
|
|
sub cmp_path_natural {
|
|
|
|
Sort::Naturally::ncmp(IkiWiki::pagetitle($a),
|
|
|
|
IkiWiki::pagetitle($b))
|
|
|
|
}
|
|
|
|
|
2010-04-03 14:48:30 +02:00
|
|
|
1;
|