summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/sortnaturally.pm
blob: b038b2f9a662358c015806bd22a7159c51b922c6 (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. hook(type => "checkconfig", id => "sortnaturally", call => \&checkconfig);
  9. }
  10. sub getsetup {
  11. return
  12. plugin => {
  13. safe => 1,
  14. rebuild => undef,
  15. },
  16. }
  17. sub checkconfig () {
  18. eval q{use Sort::Naturally};
  19. error $@ if $@;
  20. }
  21. package IkiWiki::SortSpec;
  22. sub cmp_title_natural {
  23. Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($a)),
  24. IkiWiki::pagetitle(IkiWiki::basename($b)))
  25. }
  26. 1;