summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/sortnaturally.pm
blob: 0023f31f942b124cd3fc251fbbf55c7e34761f4f (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::PageSpec;
  21. sub cmp_title_natural {
  22. Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($_[0])),
  23. IkiWiki::pagetitle(IkiWiki::basename($_[1])))
  24. }
  25. 1;