[Crossfire-wiki] [Crossfire DokuWiki] page changed: user:mhoram:scripts:wiki_orphans

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Wed Dec 27 14:40:40 CST 2006


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2006/12/27 14:40
User        : 
Edit Summary: New version of code

@@ -5,8 +5,9 @@
  ===== Requirements =====
    * Perl
    * LWP::Simple (a perl module)
    * A reasonably fast internet connection.  It takes a few minutes across my wireless, so would probably take hours over dialup.
+ 
  
  ===== Code =====
  <code perl>
  #!/usr/bin/perl
@@ -17,15 +18,14 @@
  # and counts the number of links to each page.  Those with zero
  # links are reported as orphans.
  
  use LWP::Simple;
- use Data::Dumper;   # just in case I need it
  
  my $base_url  = 'http://wiki.metalforge.net';
  my $base_path = '/doku.php';
- my %page;       # stores page paths, whether they've been followed, and a count
+ my %page;  # stores page paths, whether they've been followed, and a count
  my %did_index;  # stores index directories that have been expanded
- my $DEBUG = 0;  # set to true to get a lot of stuff on stderr
+ my $DEBUG = 0;
  
  check_link($base_url.$base_path."/start?do=index");
  
  for my $link (sort keys %page){
@@ -46,21 +46,14 @@
  	$did_index{$index_link} = 1;
  	check_link("$base_url$base_path/$index_link");
        }
      } else {
-       # this is a page, parse it and mark it if it hasn't be done yet
+       # this is a page, parse it and mark it if it hasn't been done yet
        unless( $page{$index_link}->{done} ){
- 	debug("Getting $base_url$base_path/$index_link");
- 	my $text = get("$base_url$base_path/$index_link");
+ 	debug("Getting $base_url$base_path/$index_link?do=backlink");
+ 	my $text = get("$base_url$base_path/$index_link?do=backlink");
  	$text =~ s{^.+?wikipage start}{}s;
- 	my( @links ) = $text =~ m{"$base_path/([^"]+?)"}g;
- 	for my $link (@links){
- 	  $link =~ s/\#.*$//;
- 	  unless( $index_link eq $link ){
- 	    $page{$link}->{count}++;
- 	    debug( "Incremented count for $link from $index_link to $page{$link}->{count}\n");
- 	  }
- 	}
+ 	$page{$index_link}->{count} = $text =~ m{(wikilink1)}gs;
  	$page{$index_link}->{done} = 1;
        }
      }
    }
@@ -69,8 +62,9 @@
  
  sub debug {
    print STDERR @_, "\n" if $DEBUG;
  }
+ 
  </code>
  
  
  


IP-Address  : 206.71.197.56
Old Revision: http://wiki.metalforge.net/doku.php/user:mhoram:scripts:wiki_orphans?rev=1166736535
New Revision: http://wiki.metalforge.net/doku.php/user:mhoram:scripts:wiki_orphans

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list