[Mediawiki-l] site map

Aaron Sherman ajs at ajs.com
Mon Mar 6 22:44:45 UTC 2006


On Mon, 2006-03-06 at 16:17 -0500, Aaron Sherman wrote:
> On Sat, 2006-03-04 at 18:27 +0100, jdd wrote:
> > Hello :-)
> > 
> > Do you know of any mean to build a sitemap on a mediawiki
> > (other than by hand)?
> 
> Well I use this Perl "one liner" to map, that uses graphviz to visualize
> the connectivity of Categories:

I played around with it, and found some really fun things graphviz can
do. I now have an SVG map of my site that Firefox can actually browse:

http://www.ajs.com/~ajs/AJSWIKI.svg

Here's the even bigger, better one-liner:

(echo "digraph G {";echo 'ratio=0.6';perl -MLWP::Simple -le '$n="Your top-level category name";$base="http://www.yourwiki.com/wiki";sub trans {local $_=shift;s/([^ :.\-\w])/sprintf "%%%2X",ord($1)/egi;s/ /_/g;return $_}sub untrans {local $_=shift;s/_/ /g;s/\%([a-f0-9]{2})/chr(hex("0x".$1))/egi;$_}push @pages,$n;while($p=shift @pages){$w="$base/Category:".trans($p);$seen{$p}=1;print STDERR $w;$h=get($w);sleep 1;while($h=~/href=\"[^\"]*\bCategory:\s*([^\"\#\?\&]+)[\?\#\"]/g){$n=untrans($1);next if $all{"$n==$p"}++ || $all{"$p==$n"}++;push(@{$point{$n}},$p);push(@pages,$n) unless $seen{$n}}}foreach $p (sort keys %point){$u="$base/Category:".trans($p);print qq{"$p" [ URL="$u" ]};print qq{"$_" -> "$p"} foreach @{$point{$p}}}';echo "}") | tee YOURWIKI.dot | dot -Tsvg > YOURWIKI.svg

You could, of course, generate this from the database directly much
faster.

-- 
Aaron Sherman <ajs at ajs.com>
Senior Systems Engineer and Toolsmith
"We had some good machines, but they don't work no more." -Shriekback





More information about the MediaWiki-l mailing list