plugin:format
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:format [2008-03-09 14:58] – garlicbread | plugin:format [2023-12-21 19:04] (current) – new download url Aleksandr | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Format Plugin ====== | ||
+ | ---- plugin ---- | ||
+ | description: | ||
+ | author | ||
+ | email : jason-doku@creativetrax.com | ||
+ | type : syntax | ||
+ | lastupdate : 2007-02-22 | ||
+ | compatible : 2006-11-06 | ||
+ | depends | ||
+ | conflicts | ||
+ | similar | ||
+ | tags : media, embed, program | ||
+ | |||
+ | downloadurl: | ||
+ | bugtracker : | ||
+ | sourcerepo : | ||
+ | donationurl: | ||
+ | |||
+ | screenshot_img: | ||
+ | ---- | ||
+ | |||
+ | ===== Description ===== | ||
+ | |||
+ | This plugin allows you to send text to an external program and display the resulting media (image, pdf, text, etc.) in the current wiki page. | ||
+ | |||
+ | ==== DISCLAIMER ==== | ||
+ | |||
+ | This plugin can be **very** dangerous, as it allows anyone who can edit a page on your wiki to potentially execute arbitrary code on your web server. | ||
+ | |||
+ | Personally, I am not using the gnuplot configuration noted below, since gnuplot gives the wiki user the ability to execute arbitrary code on the server. | ||
+ | |||
+ | The plugin takes precautions in that it does not put any user input on the command line. Instead, all user input is loaded in a file, wrapped in the ' | ||
+ | |||
+ | ==== Syntax ==== | ||
+ | |||
+ | After setting up the external programs in the '' | ||
+ | |||
+ | < | ||
+ | <format program-name> | ||
+ | text to feed into the program | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ==== Configuration settings ==== | ||
+ | |||
+ | All of the interesting setup happens in the '' | ||
+ | |||
+ | <code php> | ||
+ | $conf['< | ||
+ | '< | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | </ | ||
+ | |||
+ | The various fields are: | ||
+ | |||
+ | ^ %%< | ||
+ | ^ %%<user name>%% | The user-friendly name of the program | | ||
+ | ^ %%< | ||
+ | ^ %%< | ||
+ | ^ %%< | ||
+ | ^ %%< | ||
+ | ^ %%< | ||
+ | |||
+ | Here is an example '' | ||
+ | |||
+ | <code php> | ||
+ | <? | ||
+ | $conf[' | ||
+ | |||
+ | $conf[' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | foreach (array(' | ||
+ | $conf[$prog]=array(' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | |||
+ | $conf[' | ||
+ | ' | ||
+ | ' | ||
+ | // if you are using a version of gnuplot supporting the OLD PNG library | ||
+ | // this line has to be | ||
+ | // ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | $conf[' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | (the SERVERNAME and GV_FILE_PATH variables are set to help with security---see [[http:// | ||
+ | |||
+ | With this setup (assuming that you have all of the right programs in place), you could use gnuplot in a wiki page like this: | ||
+ | |||
+ | < | ||
+ | <format gnuplot> | ||
+ | plot [-20:20] sin(x)/x | ||
+ | </ | ||
+ | </ | ||
+ | and the block of code is replaced by the graph generated by gnuplot. | ||
+ | |||
+ | You could also use the GNU PIC implementation [[http:// | ||
+ | |||
+ | < | ||
+ | <format dpic> | ||
+ | box " | ||
+ | arrow 2 " | ||
+ | circle " | ||
+ | </ | ||
+ | </ | ||
+ | and the resulting diagram would show up on the page (see the Demo below for this example). | ||
+ | |||
+ | ===== File storage ===== | ||
+ | |||
+ | The generated media files are stored in the %%data/ | ||
+ | |||
+ | ===== Thanks ===== | ||
+ | |||
+ | This plugin is a modification and generalization of the existing graphviz and gnuplot plugins. | ||
+ | |||
+ | ===== Demo ===== | ||
+ | |||
+ | I've put a short page up demonstrating this plugin at [[http:// | ||
+ | |||
+ | I've put an other short page up demonstrating this plugin generating sequence diagrams. Look at [[http:// | ||
+ | |||
+ | This demonstrates how to use it with Trace2UML [[http:// | ||
+ | |||
+ | <code php> | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Discussion ===== | ||
+ | |||
+ | Some things had to be changed | ||
+ | |||
+ | On my machine, compiling dpic in safe mode and renaming it to dpic-safe had the consequence that it would not | ||
+ | produce output when called by PHP. Therefore, the command had to be | ||
+ | |||
+ | <code php> | ||
+ | ' | ||
+ | </ | ||
+ | instead of | ||
+ | <code php> | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | dpic still is compiled for safe mode, so security is not broken. | ||
+ | |||
+ | gnuplot has a problem also, because how gnuplot handles PNG output depends on the libraries available at compile time. | ||
+ | |||
+ | It the command | ||
+ | <code php> | ||
+ | ' | ||
+ | </ | ||
+ | does not work, changing the prologue for the older version of PNG like this | ||
+ | <code php> | ||
+ | ' | ||
+ | </ | ||
+ | can help. | ||
+ | Finally, for all the graphviz programs to work, the command had to be changed to | ||
+ | |||
+ | <code php> | ||
+ | ' | ||
+ | </ | ||
+ | from | ||
+ | <code php> | ||
+ | ' | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | I've recently created a patch against the 2007-02-22 version\\ | ||
+ | [[http:// | ||
+ | this puts the output image files into %%data/ | ||
+ | (I've added " | ||
+ | also on the first invocation of header() for a given page, it will remove any existing files within this directory\\ | ||
+ | (just the directory/ | ||
+ | probably not the best way to do things, but it does work, and avoids lots of old image files lying around when making small changes to the diagrams\\ | ||
+ | |||
+ | Also I've put up an example of altering the formatting of the diagram for gnuplot / graphviz (for example with dark themes), from within the default.php\\ | ||
+ | [[http:// | ||
+ | --- // | ||
+ | |||
+ | \\ | ||
+ | For Windows (at least) installations, | ||
+ | \\ | ||
+ | Here's my working mscgen section from default.php. | ||
+ | < | ||
+ | /* mscgen setup */ | ||
+ | foreach (array(' | ||
+ | $conf[$prog]=array(' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | } | ||
+ | </ | ||
+ | --- // bchartrand, 2010-02-25// | ||
+ | \\ | ||
+ | I have just completed a comment for the [[plugin: | ||
+ | - Jared Meeker (jaredm@tni.com) |