Documente Academic
Documente Profesional
Documente Cultură
developers
Document Release: 1.4
2011 april, Maths for More
www.wiris.com
Contents
WIRIS editor and WIRIS plugins for developers............................................................................................................. 2
WIRIS plugin configuration ........................................................................................................................................ 3
Runtime configuration........................................................................................................................................... 3
Other ways to set the configuration...................................................................................................................... 3
Editing and displaying formulas with a Web HTML editor ........................................................................................ 3
Low level visualization of formulas ........................................................................................................................... 3
Filtering formulas in a bunch of content ............................................................................................................... 4
Low level use of the editor Java plugin ..................................................................................................................... 4
WIRIS plugin core reference ...................................................................................................................................... 5
Formula persistence and cache ............................................................................................................................. 5
Configuration override .......................................................................................................................................... 5
Storing MathML ..................................................................................................................................................... 6
WIRIS plugin core server API ................................................................................................................................. 6
WIRIS plugin core client API .................................................................................................................................. 6
WIRIS editor API reference ........................................................................................................................................ 6
The place of the configuration files and its possible values can be found at
1. http://www.wiris.com/plugins/docs/resources/configuration-table
2. The XXX_plugin.js that can be located in any WIRIS plugin.
The configuration of the font typeface can be found at
http://www.wiris.com/en/editor/docs/resources/font-configuration
Runtime configuration
The configuration described above can be overridden at runtime. For example, if you have a multilingual Web site,
you will need to select the language at runtime regardless the value of the configuration.
How to set a runtime configuration will depend on the configuration item. For example, the language of the editor
should be specified in the user interface scripting while there are other parameters that have to be set at the
server scripting. In any case, to learn how to set the runtime configuration, you will need to check the specific
installation documentation for each plugin.
Other ways to set the configuration
The section of this document concerning the WIRIS plugin core reference explains other ways to store the
configuration in the server-side. For example, some values could be stored in a database.
Editing and displaying formulas with a Web HTML editor
The most frequent use case is solved directly by the WIRIS plugins with minimal configuration. For example, the
following scenario is fully supported
1. A user edits some piece of content with a Web HTML editor.
2. The user adds a formula using a WYSIWYG editor in a very straightforward way.
3. Formulas are displayed properly when the content is finally rendered.
4. Formulas can be changed when the main content is reedited.
Other uses not covered by the above scenario can be implemented in any system with the help of the WIRIS plugin
core features.
Low level visualization of formulas
This section starts with the hypothesis that there is some MathML that needs to be rendered in the browser. The
MathML might come from the WIRIS editor, WIRIS quizzes or even from any other software (like a mathematical
engine or, more specifically, a computer algebra system).
The easiest, but not recommended, way to do that is simply writing in the html page
<img src=http://www.wiris.net/demo/formula?mml=<mahtml> />
Assuming that <mathml> is property encoded as URL, the above might fail if the formula is too long. The solution
needs that the server calls the createimage previous generate the <img>. It is as follows:
1. In the server, send the formula to the Web service createimage implemented by the WIRIS plugin core.
2. Write an img tag with a src with the form
<img src=http://<domain>/<some-path>/showimage?formula=<digest>.png />
The WIRIS applet exposes a public API that allows, for example, setting or getting the MathML of the formula with
JavaScript. Such API is documented at
http://www.wiris.net/demo/formula/docs/api/
For example, a form that submits the content of the editor might be:
<form
onsubmit="getElementById('formula').value=getElementById('edt').getContent();">
<applet id="edt" code="WirisFormulaEditor"
archive="wiriseditor.jar"
codebase="http://www.wiris.net/demo/formula/codebase"
width="600" height="400">
Your browser does not appear to support applets
<param name="version" value="2.0"/>
</applet>
<br/>
The configuration of the plugin allows selecting how formulas are stored.
WIRIS plugin core reference
You need to know about the WIRIS plugin core if you require a functionality not currently provided by the existing
WIRIS plugins.
WIRIS plugin core is the common part of all WIRIS plugins. The main objective is to grant the long term software
maintenance of the plugins via a reusable component.
WIRIS plugin core is divided in two main subcomponents: client and server parts. The client subcomponent of the
core is based on a series of html and JavaScript files. The server subcomponent is implemented in different server
technologies: PHP, Java, .NET, ASP.
Formula persistence and cache
The WIRIS plugin needs to store two kind of information (see the section Low level use of the editor). By default,
such information is stored in the file system.
1. The inverse association <digest> to MathML. This information cannot be removed unless exists a
mechanism that is able to regenerate them.
2. A cache with the images generated from MathML. This cache can be removed if necessary and it will be
regenerated when formulas are displayed.
Configuring the formula persistence and cache
In the configuration.ini is specified the class that will perform the persistence and cache of the formulas. You will
not generally need to change such class unless you want to redefine any of the following features:
1. The algorism used as <digest> of a formula. For example, change from md5 to sha1.
2. Change the way the <digest> values are stored. For example, they could be stored in a relational
database. The default behavior is use the file system.
3. Change the way the images are stored. For example, they could be stored in a relational database. The
default behavior is use the file system.
You can define your own class. That class should implement the interface
com.wiris.plugin.storage.StorageAndCache
and modify the configuration.ini to point to your class. The documentation of the interface can be found at
http://www.wiris.com/pluginwiris_engine/docs/api
For the Java plugin, inside pluginwiris_engine.war can be found the compilation-time library WEBINF/lib/wirisplugin-api.jar.
Configuration override
The configuration of the plugin is read from the configuration.ini file. However, it is possible to provide a class used
to override any value of the configuration. For example, it could be used to store some entries of the configuration
in a database.
Such class must be specified in the configuration.ini (the class overrides some definitions but the configuration.ini
file is still necessary). The class must implement the interface
com.wiris.plugin.configuration.ConfigurationUpdater
For the Java plugin, inside pluginwiris_engine.war can be found the compilation-time library WEBINF/lib/wirisplugin-api.jar. The API documentation is at
http://www.wiris.com/pluginwiris_engine/docs/api
Storing MathML
WIRIS plugin, by default, stores formulas edited with the HTML editor as <img> tags with the MathML in the alt
attribute. Let us note that the src attribute of the <img> tag contains only the <digest> value.
You can configure to store directly MathML instead of the <img> tag. In this case, a filter should be applied to
transform the MathML content into images. This is the recommended way to use the WIRIS plugin if there is the
possibility to develop such filter. The WIRIS plugin core server API contains functions to help develop such filter.
WIRIS plugin core server API
The server subcomponent provides the following services:
createimage. Inputs the MathML of a formula and styling attributes. It returns the URL where the image
showimage. Inputs the <digest> of a formula and returns the associated image in png format. It is
possible to specify additional styling attributes in addition to the ones encoded inside the <digest>.
getmathml. Inputs the <digest> of a formula and returns the MathML of the formula and styling
attributes.
Note. The <digest> is the computed id of the MathML and styling attributes. It is usually the md5, sha1 or even
the gzipped compression of the formula.
The server components are also responsible to caching the images. This feature is especially important when the
WIRIS editor is hosted in a different server for performance reasons.
WIRIS plugin core client API
At present, the WIRIS pluginc core client components are not documented and not expected to be reused.
WIRIS editor API reference
WIRIS editor API reference can be accessed at
http://www.wiris.net/demo/formula/docs/api/
The parameters that the applet accept are defined at
http://www.wiris.net/demo/formula/docs/other/parameters.html