]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/sortnaturally.pm
Update changelog
[git.ikiwiki.info.git] / IkiWiki / Plugin / sortnaturally.pm
1 #!/usr/bin/perl
2 # Sort::Naturally-powered title_natural sort order for IkiWiki
3 package IkiWiki::Plugin::sortnaturally;
5 use IkiWiki 3.00;
6 no warnings;
8 sub import {
9         hook(type => "getsetup", id => "sortnaturally", call => \&getsetup);
10         hook(type => "checkconfig", id => "sortnaturally", call => \&checkconfig);
11 }
13 sub getsetup {
14         return
15                 plugin => {
16                         safe => 1,
17                         rebuild => undef,
18                 },
19 }
21 sub checkconfig () {
22         eval q{use Sort::Naturally};
23         error $@ if $@;
24 }
26 package IkiWiki::SortSpec;
28 sub cmp_title_natural {
29         Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($a)),
30                 IkiWiki::pagetitle(IkiWiki::basename($b)))
31 }
33 sub cmp_path_natural {
34         Sort::Naturally::ncmp(IkiWiki::pagetitle($a),
35                 IkiWiki::pagetitle($b))
36 }
38 1;