summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/sortnaturally.pm
blob: 92453749d9048f3acdea42bfc4058360e67d1e63 (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 => 1,
  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;