summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/more.pm
blob: 6880e366df3ad40b9404d915b04c28e4d3e3bfa4 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::more;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 3.00;
  6. my $linktext = gettext("more");
  7. sub import {
  8. hook(type => "getsetup", id => "more", call => \&getsetup);
  9. hook(type => "preprocess", id => "more", call => \&preprocess);
  10. }
  11. sub getsetup () {
  12. return
  13. plugin => {
  14. safe => 1,
  15. rebuild => undef,
  16. section => "widget",
  17. },
  18. }
  19. sub preprocess (@) {
  20. my %params=@_;
  21. $params{linktext} = $linktext unless defined $params{linktext};
  22. if ($params{page} ne $params{destpage} &&
  23. (! exists $params{pages} ||
  24. pagespec_match($params{destpage}, $params{pages},
  25. location => $params{page}))) {
  26. return "\n".
  27. htmllink($params{page}, $params{destpage}, $params{page},
  28. linktext => $params{linktext},
  29. anchor => "more");
  30. }
  31. else {
  32. return "<a name=\"more\"></a>\n\n".
  33. IkiWiki::preprocess($params{page}, $params{destpage},
  34. $params{text});
  35. }
  36. }
  37. 1