orphaned.pl 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/perl
  2. # Orphaned Pages for Oddmuse Wikis
  3. # Copyright (C) 2004 Alex Schroeder <alex@emacswiki.org>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. use CGI qw/:standard/;
  18. use CGI::Carp qw(fatalsToBrowser);
  19. use LWP::UserAgent;
  20. if (not param('url')) {
  21. print header(),
  22. start_html('Orphaned Pages'),
  23. h1('Orphaned Pages'),
  24. p('$Id: orphaned.pl,v 1.2 2004/03/21 00:33:41 as Exp $'),
  25. p('Returns a list of orphaned pages based on a dot-file.'),
  26. start_form(-method=>'GET'),
  27. p('URL for dot-file: ', textfield('url'), br(),
  28. 'Example: http://www.emacswiki.org/cgi-bin/alex?action=links;raw=1'),
  29. p('URL for list of nodes: ', textfield('nodes'), br(),
  30. 'Example: http://www.emacswiki.org/cgi-bin/alex?action=index;raw=1'),
  31. p(submit()),
  32. end_form(),
  33. end_html();
  34. exit;
  35. }
  36. print header(-type=>'text/plain; charset=UTF-8');
  37. $ua = LWP::UserAgent->new;
  38. $request = HTTP::Request->new('GET', param('url'));
  39. $response = $ua->request($request);
  40. $data = $response->content;
  41. while ($data =~ m/"(.*?)" -> "(.*?)"/g) {
  42. $page{$1} = 1;
  43. $link{$2} = 1;
  44. }
  45. $request = HTTP::Request->new('GET', param('nodes'));
  46. $response = $ua->request($request);
  47. $data = $response->content;
  48. foreach $pg (split(/\n/, $data)) {
  49. $pg =~ s/_/ /g;
  50. $page{$pg} = 1 if $pg;
  51. }
  52. foreach $pg (sort keys %page) {
  53. print $pg, "\n" unless $link{$pg};
  54. }