Changeset 760 for utils/get-guide-versions
- Timestamp:
- 04/08/06 10:03:14 (3 years ago)
- Files:
-
- 1 modified
-
utils/get-guide-versions (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
utils/get-guide-versions
r755 r760 5 5 use strict; 6 6 use warnings; 7 use WWW::Mechanize; 7 use XML::Simple; 8 use LWP::UserAgent; 8 9 9 10 my $out = "/srv/www/dev.openguides.org/html/static/versions.html"; … … 26 27 'Boston, MA' => 'http://boston.openguides.org/', 27 28 'Saint Paul, MN' => 'http://saintpaul.openguides.org/', 28 'The Tourist Engineer' => 'http://engineer.openguides.org/' 29 'The Tourist Engineer' => 'http://engineer.openguides.org/', 30 "Earle's testing" => 'http://openguides.org/testing/' 29 31 ); 30 32 31 my $mech = WWW::Mechanize->new(agent => "OpenGuides get-guide-versions", 32 autocheck => 1); 33 my $ua = LWP::UserAgent->new(agent => "OpenGuides get-guide-versions"); 33 34 34 35 open OUT, ">$out" or die $!; 35 36 36 37 print OUT "<html><head><title>Versions of OpenGuides in use</title></head>\n"; 37 print OUT "<body><table>\n"; 38 print OUT "<body>\n"; 39 print OUT "Last updated: " . scalar(localtime(time)) . "\n"; 40 print OUT "<table>\n"; 38 41 39 foreach my $guide ( keys %guides) {42 foreach my $guide (sort keys %guides) { 40 43 print OUT "<tr><td><a href=\"$guides{$guide}\">$guide</td><td>"; 41 $mech->add_header( Referer => undef ); 42 $mech->get($guides{$guide}); 43 my $content = $mech->content; 44 if ($content =~ /version.(0\.\d+)/s) { 45 print OUT $1; 46 } else { 47 print OUT "Not found"; 44 45 # Try DOAP 46 my $success = 0; 47 my $response = $ua->get("$guides{$guide}?action=about;format=rdf"); 48 if ($response->is_success) { 49 my $doap = eval { XMLin($response->content)} ; 50 if ($@) { 51 # fall through 52 } else { 53 if (my $version = eval { $doap->{Project}->{release}->{Version}->{revision} }) { 54 print OUT "$version (DOAP)"; 55 $success++; 56 } 57 } 48 58 } 49 print OUT "</td></tr>\n"; 59 if ($success == 0) { 60 $response = $ua->get($guides{$guide}); 61 if ($response->is_success) { 62 my $content = $response->content; 63 if ($content =~ /version.(0\.\d+)/s) { 64 print OUT $1; 65 } else { 66 print OUT "Not found"; 67 } 68 print OUT " (HTML)"; 69 } else { 70 print "No methods worked"; 71 } 72 print OUT "</td></tr>\n"; 73 } 50 74 } 51 75
