sistersites.pl 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # Copyright (C) 2007–2023 Alex Schroeder <alex@gnu.org>
  2. #
  3. # This program is free software: you can redistribute it and/or modify it under
  4. # the terms of the GNU General Public License as published by the Free Software
  5. # Foundation, either version 3 of the License, or (at your option) any later
  6. # version.
  7. #
  8. # This program is distributed in the hope that it will be useful, but WITHOUT
  9. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License along with
  13. # this program. If not, see <http://www.gnu.org/licenses/>.
  14. use strict;
  15. use v5.10;
  16. AddModuleDescription('sistersites.pl', 'Sister Pages');
  17. our (%Action, $ScriptName, $UsePathInfo, %NearSource, %PermanentAnchors);
  18. $Action{'sisterpages'} = \&DoSisterPages;
  19. sub DoSisterPages {
  20. print GetHttpHeader('text/plain');
  21. my @pages = SisterPages();
  22. foreach my $id (@pages) {
  23. print $ScriptName . ($UsePathInfo ? '/' : '?') . UrlEncode($id)
  24. . ' ' . NormalToFree($id) . "\n";
  25. }
  26. }
  27. # Mostly DoIndex() without the printing.
  28. sub SisterPages {
  29. my @pages;
  30. push(@pages, AllPagesList()) if GetParam('pages', 1);
  31. push(@pages, keys %PermanentAnchors) if GetParam('permanentanchors', 1);
  32. push(@pages, keys %NearSource) if GetParam('near', 0);
  33. @pages = Matched(GetParam('match', ''), @pages);
  34. @pages = sort @pages;
  35. return @pages;
  36. }