small.pl 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Copyright (C) 2007 Alex Schroeder <alex@emacswiki.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 2 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the
  15. # Free Software Foundation, Inc.
  16. # 59 Temple Place, Suite 330
  17. # Boston, MA 02111-1307 USA
  18. use strict;
  19. use v5.10;
  20. AddModuleDescription('small.pl', 'List Small Pages Extension');
  21. our ($q, %Page, %Action, $DeletedPage, $LinkPattern, $FreeLinks, $FreeLinkPattern, $WikiLinks);
  22. my $SmallLimit = 1000;
  23. $Action{small} = \&DoSmall;
  24. sub DoSmall {
  25. print GetHeader('', T('Index of all small pages')),
  26. $q->start_div({-class=>'content index small'}),
  27. $q->start_p();
  28. foreach my $id (AllPagesList()) {
  29. OpenPage($id);
  30. if (length($Page{text}) < $SmallLimit
  31. # skip redirects
  32. and (not $FreeLinks
  33. or $Page{text} !~ /^\#REDIRECT\s+\[\[$FreeLinkPattern\]\]/)
  34. and (not $WikiLinks
  35. or $Page{text} !~ /^\#REDIRECT\s+$LinkPattern/)
  36. # skip deleted pages
  37. and $Page{text} !~ /^\s*$/
  38. and (not $DeletedPage
  39. or substr($Page{text}, 0, length($DeletedPage)) ne $DeletedPage)) {
  40. PrintPage($id);
  41. }
  42. }
  43. print $q->end_p(), $q->end_div();
  44. PrintFooter();
  45. }