From: Arno H. <aho...@xm...> - 2001-01-11 08:50:21
|
Malcom, > Just for kicks, I added a "Site Map" function to the Wiki, which takes = a > given starting page and does a breadth-first-search of the entire Wiki > using that page as the root. The result is remarkably readable (for my > Wiki, at least). Have a look at: > > http://ccls1.cse.unsw.edu.au/~malcolmr/nomicwiki/index.php?map=3DNomicW= iki Looks nice :o) Post the code please. > 1) I want to render it more like a standard Wiki page. In particular, I > want to make all the links active. Is there an appropriate function > to output the HTML code for a link? In stdlib.php there are two functions called LinkExistingWikiWord() and=20 LinkUnknownWikiWord(). I guess this is what you're looking for. Also, you can check the existence of a page with IsWikiPage(). Problem with sitemaps like these is, that they are quite expensive to=20 compute. If your wiki is small and has view visitors it doesn't matter mu= ch. But my public wiki at senseis.xmp.net gets mirrored via wget at least twi= ce=20 a week. And those !&@(? mirror every link they get, even the edit page an= d similar stuff. They also would mirror the sitemap for every page. So=20 basically each mirroring would be a small DoS attack on your wiki. That's= =20 why Ward's c2.com wiki uses the referer header to get rid of robots. > 2) I am using ExtractWikiPageLinks to get a list of outgoing links from > a page, but this also returns things I don't want: outside links, > disabled links, and text of the form '[[...]'. What is the best way > to filter these out? I think there's a bug in 1.1.9 which causes this behaviour. Try the lates= t=20 nightly build instead. Or replace it with the following function function ExtractWikiPageLinks($content) { global $WikiNameRegexp; $wikilinks =3D array(); $numlines =3D count($content); for($l =3D 0; $l < $numlines; $l++) { // remove escaped '[' $line =3D str_replace('[[', ' ', $content[$l]); // bracket links (only type wiki-* is of interest) $numBracketLinks =3D=20 preg_match_all("/\[\s*([^\]|]+\|)?\s*(.+?)\s*\]/", $line, $brktlinks); for ($i =3D 0; $i < $numBracketLinks; $i++) { $link =3D ParseAndLink($brktlinks[0][$i]); if (preg_match("#^wiki#", $link['type'])) $wikilinks[$brktlinks[2][$i]] =3D 1; $brktlink =3D preg_quote($brktlinks[0][$i]); $line =3D preg_replace("|$brktlink|", '', $line); } // BumpyText old-style wiki links if (preg_match_all("/!?$WikiNameRegexp/", $line, $link)) { for ($i =3D 0; isset($link[0][$i]); $i++) { if($link[0][$i][0] <> '!') $wikilinks[$link[0][$i]] =3D 1; } } } return $wikilinks; } =20 This should return only wiki internal links. /Arno |