DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:format

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
plugin:format [2010-01-17 08:15]
82.60.88.211
plugin:format [2018-05-24 08:11] (current)
Aleksandr
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description:​ Sends text to external programs and embeds the resulting media in a wiki page (can replace the basic functionality of the graphviz and gnuplot plugins, for example).+description:​ Sends text to external programs and embeds the resulting media in a wiki page (can replace the basic functionality of the graphviz and gnuplot plugins, for example)
 author ​    : Jason Grout author ​    : Jason Grout
 email      : jason-doku@creativetrax.com email      : jason-doku@creativetrax.com
Line 12: Line 12:
 similar ​   : graphviz, gnuplot, latex similar ​   : graphviz, gnuplot, latex
 tags       : media, embed, program tags       : media, embed, program
----- 
  
-^  Authors | [[jason-doku@creativetrax.com| Jason Grout]] | +downloadurl:​ https://​trello-attachments.s3.amazonaws.com/​5af4815352fa15728c62aaae/​5b06532f1c1e9f8328a46f14/​6ecd76fd4e09ad2250c7c4eee29d7cc1/​format-2007-02-22.zip 
-^  Version | 2007-02-22 ​| +bugtracker :  
-^  Required DokuWiki version | 2006-11-06 | +sourcerepo ​:  
-^  Download | [[http://​math.byu.edu/​~grout/​format.zip]] | +donationurl:​  
-^  Main page |  |+ 
 +screenshot_img:​  
 +----
  
 ===== Description ===== ===== Description =====
Line 25: Line 26:
  
 ==== DISCLAIMER ==== ==== 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. ​ Use the plugin at your own risk.  You may only use the plugin with the understanding that I will not be liable for anything that you do with it. 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. ​ Use the plugin at your own risk.  You may only use the plugin with the understanding that I will not be liable for anything that you do with it.
  
 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. ​ There is apparently no easy way around this.  I am only using "​safe"​ versions of other programs that disallow any file access and any system access to the user. 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. ​ There is apparently no easy way around this.  I am only using "​safe"​ versions of other programs that disallow any file access and any system access to the user.
  
-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 '​pre'​ and '​post'​ text specified in the configuration file.  The resulting file is then made available through the @INPUTFILE@ variable for the command line. +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 '​pre'​ and '​post'​ text specified in the configuration file.  The resulting file is then made available through the ''​@INPUTFILE@'' ​variable for the command line.
  
 ==== Syntax ==== ==== Syntax ====
  
-After setting up the external programs in the conf/​default.php file, you can call an external program like:+After setting up the external programs in the ''​conf/​default.php'' ​file, you can call an external program like: 
 <​code>​ <​code>​
 <format program-name>​ <format program-name>​
Line 43: Line 45:
 ==== Configuration settings ==== ==== Configuration settings ====
  
-All of the interesting setup happens in the conf/​default.php file.  For each program to be called, add a block to the conf/​default.php file that is similar to:+All of the interesting setup happens in the ''​conf/​default.php'' ​file. For each program to be called, add a block to the ''​conf/​default.php file'' ​that is similar to:
  
-<​code>​+<​code ​php>
 $conf['<​program-name>'​]=array('​name'​ => "<​user name>",​ $conf['<​program-name>'​]=array('​name'​ => "<​user name>",​
                     '<​mode>'​ => array('​ext'​ => "<​extension>",​                     '<​mode>'​ => array('​ext'​ => "<​extension>",​
Line 56: Line 58:
 The various fields are: The various fields are:
  
-^ %%<​program-name>​%% | The name of the program, as it will be used in the %%<​format program-name>​%% syntax |+^ %%<​program-name>​%% | The name of the program, as it will be used in the ''​%%<​format program-name>​%%'' ​syntax |
 ^ %%<user name>%% | The user-friendly name of the program | ^ %%<user name>%% | The user-friendly name of the program |
-^ %%<​mode>​%% | The mode these particular commands apply to.  You can run different programs based on the rendering pass of the page.  For example, you can return some text in the '​metadata'​ mode, but render an image in XHTML mode, and render a PDFimage in '​latex'​ mode. | +^ %%<​mode>​%% | The mode these particular commands apply to. You can run different programs based on the rendering pass of the page.  For example, you can return some text in the '​metadata'​ mode, but render an image in XHTML mode, and render a PDFimage in '​latex'​ mode. | 
-^ %%<​extension>​%% | The extension of the file that will be generated. ​ This will also determine the mime type of the generated media | +^ %%<​extension>​%% | The extension of the file that will be generated. This will also determine the mime type of the generated media | 
-^ %%<​pre>​%% | Text to go before the text the user wrote in the wiki page.  You can use this to set parameters in the program or otherwise set up the environment of the program. | +^ %%<​pre>​%% | Text to go before the text the user wrote in the wiki page. You can use this to set parameters in the program or otherwise set up the environment of the program. | 
-^ %%<​post>​%% | Text to go after the text the user wrote in the wiki page.  You can use this to clean up variables, generate pictures, etc. | +^ %%<​post>​%% | Text to go after the text the user wrote in the wiki page. You can use this to clean up variables, generate pictures, etc. | 
-^ %%<​command line>%% | The command to run via the PHP system call.  There are two variables that can be substituted in the command line. @INPUTFILE@ refers to the file containing, in order, the %%<​pre>​%% text, the text the user wrote in the wiki, and the %%<​post>​%% text.  @MEDIAFILE@ contains the path and name of the file you should put your result into.  There'​s actually another variable substituted (@OUTFILE@),​ but that's experimental only. |+^ %%<​command line>%% | The command to run via the PHP system call. There are two variables that can be substituted in the command line. ''​@INPUTFILE@'' ​refers to the file containing, in order, the ''​%%<​pre>​%%'' ​text, the text the user wrote in the wiki, and the ''​%%<​post>​%%'' ​text. ''​@MEDIAFILE@'' ​contains the path and name of the file you should put your result into.  There'​s actually another variable substituted (''​@OUTFILE@''​), but that's experimental only.  |
  
-Here is an example conf/​default.php file:+Here is an example ​''​conf/​default.php'' ​file:
  
-<​code>​+<​code ​php>
 <?​php ​ <?​php ​
 $conf['​tmpdir'​]="/​tmp";​ $conf['​tmpdir'​]="/​tmp";​
Line 103: Line 105:
  
 With this setup (assuming that you have all of the right programs in place), you could use gnuplot in a wiki page like this: With this setup (assuming that you have all of the right programs in place), you could use gnuplot in a wiki page like this:
 +
 <​code>​ <​code>​
 <format gnuplot> <format gnuplot>
Line 110: Line 113:
 and the block of code is replaced by the graph generated by gnuplot. and the block of code is replaced by the graph generated by gnuplot.
  
-You could also use the GNU PIC implementation [[http://​www.ece.uwaterloo.ca/​~aplevich/​dpic/​| dpic]] to generate diagrams, like this:+You could also use the GNU PIC implementation [[http://​www.ece.uwaterloo.ca/​~aplevich/​dpic/​|dpic]] to generate diagrams, like this: 
 <​code>​ <​code>​
 <format dpic> <format dpic>
Line 124: Line 128:
 The generated media files are stored in the %%data/​media/​format/<​program-name>/​%% folder (the %%:​format:<​program-name>:​%% media namespace). ​ Permissions are not checked on this directory. ​ If someone wants to make a patch to check permissions,​ feel free to send it to me.  I'm thinking it would be nice to check permissions on the %%:​format:<​program-name>:​%% namespace so that administrators can easily disable an external program for certain users/​groups. The generated media files are stored in the %%data/​media/​format/<​program-name>/​%% folder (the %%:​format:<​program-name>:​%% media namespace). ​ Permissions are not checked on this directory. ​ If someone wants to make a patch to check permissions,​ feel free to send it to me.  I'm thinking it would be nice to check permissions on the %%:​format:<​program-name>:​%% namespace so that administrators can easily disable an external program for certain users/​groups.
  
 +===== Thanks =====
  
-===== Thanks ===== 
 This plugin is a modification and generalization of the existing graphviz and gnuplot plugins. ​ Special thanks goes to the authors of those plugins. This plugin is a modification and generalization of the existing graphviz and gnuplot plugins. ​ Special thanks goes to the authors of those plugins.
- 
  
 ===== Demo ===== ===== Demo =====
Line 133: Line 136:
 I've put a short page up demonstrating this plugin at [[http://​math.byu.edu/​~grout/​software/​dokuwiki/​format-plugin]]. ​ I've put a short page up demonstrating this plugin at [[http://​math.byu.edu/​~grout/​software/​dokuwiki/​format-plugin]]. ​
  
-I've put an other short page up demonstrating this plugin ​generatimg ​sequence diagrams. Look at [[http://​astade.homeip.net/​wiki/​doku.php?​id=howto:​trace2uml_in_dokuwiki|my Wiki page]].\\+I've put an other short page up demonstrating this plugin ​generating ​sequence diagrams. Look at [[http://​astade.homeip.net/​wiki/​doku.php?​id=howto:​trace2uml_in_dokuwiki|my Wiki page]]. 
 This demonstrates how to use it with Trace2UML [[http://​trace2uml.tigris.org]] This demonstrates how to use it with Trace2UML [[http://​trace2uml.tigris.org]]
 +
 <code php> <code php>
-  ​'​command'​ => '​xvfb-run /​usr/​bin/​Trace2UML -i @INFILE@ -o @MEDIAFILE@'​))+'​command'​ => '​xvfb-run /​usr/​bin/​Trace2UML -i @INFILE@ -o @MEDIAFILE@'​))
 </​code>​ </​code>​
- 
- 
- 
- 
- 
- 
- 
- 
- 
  
  
Line 154: Line 150:
  
 On my machine, compiling dpic in safe mode and renaming it to dpic-safe had the consequence that it would not 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+produce output when called by PHP. Therefore, the command had to be 
 <code php> <code php>
                     '​command'​ => '/​usr/​local/​bin/​dpic -r @INFILE@ | /​usr/​local/​bin/​convert -density 200 - png:- > @MEDIAFILE@'​));​                     '​command'​ => '/​usr/​local/​bin/​dpic -r @INFILE@ | /​usr/​local/​bin/​convert -density 200 - png:- > @MEDIAFILE@'​));​
Line 199: Line 196:
  --- //​[[garlicbready@googlemail.com|Richard Westwell]] 2008-03-09 14:48//  --- //​[[garlicbready@googlemail.com|Richard Westwell]] 2008-03-09 14:48//
  
 +\\
 +For Windows (at least) installations,​ I found some changes were necessary; in particular, the @MEDIAFILE@ and @INFILE@ items in the default.php had to be quoted. (Otherwise, the c:\Program Files\... path would cause problems, among others.)\\
 +\\
 +Here's my working mscgen section from default.php. ​ (mscgen is c:​\usr\bin\mscgen.exe)\\
 +<​code>​
 +  /*  mscgen setup */
 +  foreach (array('​mscgen'​) as $key => $prog) {
 +    $conf[$prog]=array('​name'​ => "​MSCGen",​
 +     '​xhtml'​ => array('​ext'​ => '​png',​
 +           '​pre'​ => "​msc{",​
 +           '​post'​ => "​}",​
 +           '​command'​ => '/​usr/​bin/'​.$prog.'​ -Tpng -o "​@MEDIAFILE@"​ "​@INFILE@"'​));​
 +  }
 +</​code>​
 + --- // bchartrand, 2010-02-25//​
 +\\
 +I have just completed a comment for the [[plugin:​chain]] plugin that will apply wiki formatting to syntax text. Since these two plugins are very similar, it should work here too. If you've been interested in bringing in external wiki-formatted text, check it out.\\
 +- Jared Meeker (jaredm@tni.com) ​ 25Aug2010
plugin/format.1263712509.txt.gz · Last modified: 2010-01-17 08:15 by 82.60.88.211