MediaWiki扩展:GraphViz图示功能
天下维客,你可以修改的网络知识库
本文取自元维基,欢迎共同翻译、整理与大家共享,促进中文wiki发展^_^
I have recently (2-oct-2004) created a extension to mediawiki in response to a basic need: Render Graphs online
I found the utility graphviz on another wiki, and thought about adopting it to mediawiki (the wiki I actually use). Exploring the Graphviz tool I discovered an incredible tool to making Graphs. Automatic graph drawing has many important applications in software engineering, database and web design, networking, and in visual interfaces for many other domains.
You can view a lot of samples at here, the original page.
Of course the only requisite for this plugin to work is the graphviz program; you can download it from here
You can find information on how to write a graph on the original page at here
目录 |
Requisites
Graphviz 1.12, download from here
Install instructions
- Download Graphviz.php.
- Alternate Download at SF.net CVS (This one always works)
- Copy Graphviz.php to the $mediawiki/extensions directory.
- Add these two lines to LocalSettings.php: (the path may vary depending on you distribution)
include("extensions/Graphviz.php");
$wgGraphVizSettings->dotCommand = "/usr/bin/dot";
Online samples
- http://www.wickle.com/wikis/index.php/Graphviz_extension
- http://www.islandseeds.org/wiki/Test:Graphviz (comments)
Other rendering engines
I wanted to use other layout engines besides dot(1), so I hacked Graphviz.php to allow a Unix-style interpreter specification for the other rendering engines in Graphviz. This is backwards compatible (since it is a legal dot comment) and avoids coming up with new syntax.
The interpreter spec must immediately follow the opening tag: "<graphviz>#!/sw/bin/neato" for example. I explicitly check for allowed rendering engines to avoid script injection security issues.
Extension at: http://www.Bytesmiths.com/InfoArk/Graphviz.php.gz
Annotated examples at: http://www.IslandSeeds.org/wiki/Test:Graphviz
Enjoy! --Bytesmiths 14:53, 15 Mar 2005 (UTC)
Dynamically managed cache
I wasn't happy with the ever-growing static cache used by this extension, so I rewrote it with a dynamic cache that can be limited to an arbitrary number of cached images that it will never exceed.
The rewritten extension with an example: http://nuclex.org/index.php/GraphViz_extension_for_MediaWiki
Have fun! --Cygon 10:42, 24 Sep 2005 (UTC)
safe_mode support would be nice. please use popen() instead of shell_exec(). also, use fopen/fwrite/fclose instead of file_put_contents() so those with php4 can use it too. --207.109.251.117 15:07, 5 November 2005 (UTC)
Alternate extension
There is an alternate Graphviz extension at User:IndyGreg/Graphviz. It was born when the source code for this extension had disappeared. Functionality between the two extensions appears almost identical.
原文参见: GraphViz


