#!/usr/bin/perl # # Prints out a list of guides and the software versions they're using. use strict; use warnings; use XML::Simple; use LWP::UserAgent; my $out = "/srv/www/dev.openguides.org/html/static/versions.html"; my %guides = ( Cambridge => 'http://cambridge.openguides.org/', Cotswolds => 'http://cotswolds.openguides.org/', London => 'http://london.openguides.org/', 'Randomness (London)' => 'http://london.randomness.org.uk/', 'Milton Keynes' => 'http://miltonkeynes.openguides.org/', Oxford => 'http://oxford.openguides.org/', 'Vegan Oxford' => 'http://the.earth.li/~kake/cgi-bin/openguides/vegan-oxford.cgi', 'Reading' => 'http://reading.openguides.org/', Southampton => 'http://southampton.openguides.org/', Vienna => 'http://vienna.openguides.org/', Brussels => 'http://brussels.openguides.org/', 'Montreal, QC' => 'http://montreal.openguides.org/', ); my $ua = LWP::UserAgent->new(agent => "OpenGuides get-guide-versions"); open OUT, ">$out" or die $!; print OUT "Versions of OpenGuides in use\n"; print OUT "\n"; print OUT "Last updated: " . scalar(localtime(time)) . "\n"; print OUT "\n"; foreach my $guide (sort keys %guides) { print OUT "\n"; } } print OUT "
$guide"; # Try DOAP my $success = 0; my $response = $ua->get("$guides{$guide}?action=about;format=rdf"); if ($response->is_success) { my $doap = eval { XMLin($response->content)} ; if ($@) { # fall through } else { if (my $version = eval { $doap->{Project}->{release}->{Version}->{revision} }) { print OUT "$version (DOAP)"; $success++; } } } if ($success == 0) { $response = $ua->get($guides{$guide}); if ($response->is_success) { my $content = $response->content; if ($content =~ /version.(0\.\d+(-\w+)?)/s) { print OUT $1; } else { print OUT "Not found"; } print OUT " (HTML)"; } else { print OUT "No methods worked"; } print OUT "
\n"; close OUT;