summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/sortnaturally.pm
blob: 62e42767c99a48170ddb58c1473b8b49131ad24b (plain)
  1. #!/usr/bin/perl
  2. # Sort::Naturally-powered title_natural sort order for IkiWiki
  3. package IkiWiki::Plugin::sortnaturally;
  4. use IkiWiki 3.00;
  5. no warnings;
  6. sub import {
  7. hook(type => "getsetup", id => "sortnaturally", call => \&getsetup);
  8. }
  9. sub getsetup {
  10. return
  11. plugin => {
  12. safe => 1,
  13. rebuild => undef,
  14. },
  15. }
  16. sub checkconfig () {
  17. eval q{use Sort::Naturally};
  18. error $@ if $@;
  19. }
  20. package IkiWiki::SortSpec;
  21. sub cmp_title_natural {
  22. Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($a)),
  23. IkiWiki::pagetitle(IkiWiki::basename($b)))
  24. }
  25. 1;