Difference between revisions of "MediaWiki"
AngelHerraez (talk | contribs) (progress report - some achievements) |
AngelHerraez (talk | contribs) |
||
Line 54: | Line 54: | ||
{{Tag|/jmolApplet}} | {{Tag|/jmolApplet}} | ||
{{Tag|/jmol}} | {{Tag|/jmol}} | ||
+ | |||
+ | : If the file is in a server different than the wiki, you need to use the signed applet ({{Tag|signed}} tag). | ||
=== Controls for the Jmol applet === | === Controls for the Jmol applet === | ||
− | To add | + | To add a '''button''' to send scripts to the applet, just add the following: |
{{Tag|jmol}} | {{Tag|jmol}} | ||
Line 66: | Line 68: | ||
{{Tag|/jmol}} | {{Tag|/jmol}} | ||
− | To add | + | To add a '''link''' to send scripts to the applet, just add the following: |
{{Tag|jmol}} | {{Tag|jmol}} | ||
Line 75: | Line 77: | ||
{{Tag|/jmol}} | {{Tag|/jmol}} | ||
− | To add | + | To add a '''checkbox''' to send scripts to the applet, just add the following: |
{{Tag|jmol}} | {{Tag|jmol}} | ||
Line 85: | Line 87: | ||
{{Tag|/jmol}} | {{Tag|/jmol}} | ||
− | To add radio | + | To add a '''group of radio buttons''' to send scripts to the applet, just add the following: |
{{Tag|jmol}} | {{Tag|jmol}} | ||
Line 100: | Line 102: | ||
{{Tag|/jmol}} | {{Tag|/jmol}} | ||
− | To add | + | To add a '''menu''' to send scripts to the applet, just add the following: |
{{Tag|jmol}} | {{Tag|jmol}} | ||
Line 119: | Line 121: | ||
=== Jmol applet in a popup window === | === Jmol applet in a popup window === | ||
− | To add a button that opens a new window | + | To add a '''button''' that opens a new window containing a Jmol applet, use the {{Tag|JmolAppletButton}} tag instead of the {{Tag|JmolApplet}} tag and also add the {{Tag|text}} tag in it. For example: |
{{Tag|jmol}} | {{Tag|jmol}} | ||
Line 128: | Line 130: | ||
{{Tag|/jmol}} | {{Tag|/jmol}} | ||
− | To add a link that opens a new window | + | To add a '''link''' that opens a new window containing a Jmol applet, use the {{Tag|JmolAppletLink}} tag instead of the {{Tag|JmolApplet}} tag and also add the {{Tag|text}} tag in it. For example: |
{{Tag|jmol}} | {{Tag|jmol}} | ||
Line 136: | Line 138: | ||
{{Tag|/jmolAppletLink}} | {{Tag|/jmolAppletLink}} | ||
{{Tag|/jmol}} | {{Tag|/jmol}} | ||
+ | |||
+ | In both cases, the new window will be resizable and the applet inside will resize with it. | ||
== Reference == | == Reference == | ||
Line 142: | Line 146: | ||
* {{Tag|jmolApplet}} : Jmol Applet. | * {{Tag|jmolApplet}} : Jmol Applet. | ||
** {{Tag|signed}} (<tt>true</tt>, <tt>false</tt>) : To use the signed or unsigned version of the applet. This attribute can be disabled by the Wiki administrator with the <tt>$wgJmolAuthorizeChoosingSignedApplet</tt> setting in {{File|LocalSettings.php}}. | ** {{Tag|signed}} (<tt>true</tt>, <tt>false</tt>) : To use the signed or unsigned version of the applet. This attribute can be disabled by the Wiki administrator with the <tt>$wgJmolAuthorizeChoosingSignedApplet</tt> setting in {{File|LocalSettings.php}}. | ||
− | ** {{Tag|color}} : To | + | ** {{Tag|color}} : To set the background color of the Jmol applet (default is black). |
** {{Tag|uploadedFileContents}} : Name of an uploaded file in this wiki containing the molecular data to load in the Jmol applet. The Wiki needs to be configured to authorize the upload of molecular data files (using <tt>$wgFileExtensions</tt> in {{File|LocalSettings.php}}). This attribute can be disabled by the Wiki administrator with the <tt>$wgJmolAuthorizeUploadedFile</tt> setting in {{File|LocalSettings.php}}. | ** {{Tag|uploadedFileContents}} : Name of an uploaded file in this wiki containing the molecular data to load in the Jmol applet. The Wiki needs to be configured to authorize the upload of molecular data files (using <tt>$wgFileExtensions</tt> in {{File|LocalSettings.php}}). This attribute can be disabled by the Wiki administrator with the <tt>$wgJmolAuthorizeUploadedFile</tt> setting in {{File|LocalSettings.php}}. | ||
** {{Tag|wikiPageContents}} : Name of a page of this wiki containing the molecular data to load in the Jmol applet. | ** {{Tag|wikiPageContents}} : Name of a page of this wiki containing the molecular data to load in the Jmol applet. | ||
Line 148: | Line 152: | ||
** {{Tag|inlineContents}} : Molecular data to load in the Jmol applet. | ** {{Tag|inlineContents}} : Molecular data to load in the Jmol applet. | ||
** {{Tag|size}} : Size of the applet. | ** {{Tag|size}} : Size of the applet. | ||
− | ** {{Tag|script}} : Script to execute | + | ** {{Tag|script}} : Script to execute right after loading the molecule. |
** {{Tag|name}} : Name of the Jmol applet (useful if you want to use several Jmol applets in the same page). | ** {{Tag|name}} : Name of the Jmol applet (useful if you want to use several Jmol applets in the same page). | ||
* {{Tag|jmolButton}} : Button. | * {{Tag|jmolButton}} : Button. | ||
Line 170: | Line 174: | ||
** {{Tag|name}} : Name of the menu. | ** {{Tag|name}} : Name of the menu. | ||
** {{Tag|target}} : Name of the Jmol applet linked with the menu (useful only if you want to use several Jmol applets in the same page). | ** {{Tag|target}} : Name of the Jmol applet linked with the menu (useful only if you want to use several Jmol applets in the same page). | ||
− | ** {{Tag|menuHeight}} : Number of visible menu items (1: combo-box, 2 or greater: list with the specified number of lines, -1: calculated). | + | ** {{Tag|menuHeight}} : Number of visible menu items (1: combo-box, 2 or greater: list with the specified number of lines, -1: calculated). Default is 1. |
− | * {{Tag|jmolRadioGroup}} : | + | * {{Tag|jmolRadioGroup}} : Group of radio buttons. |
** {{Tag|item}} : Radio button. | ** {{Tag|item}} : Radio button. | ||
*** {{Tag|script}} : Jmol script to execute when the radio button is selected. | *** {{Tag|script}} : Jmol script to execute when the radio button is selected. | ||
Line 179: | Line 183: | ||
** {{Tag|target}} : Name of the Jmol applet linked with the radio group (useful only if you want to use several Jmol applets in the same page). | ** {{Tag|target}} : Name of the Jmol applet linked with the radio group (useful only if you want to use several Jmol applets in the same page). | ||
** {{Tag|vertical}} (<tt>true</tt>, <tt>false</tt>) : Indicates if the radio buttons are stacked vertically or horizontally. | ** {{Tag|vertical}} (<tt>true</tt>, <tt>false</tt>) : Indicates if the radio buttons are stacked vertically or horizontally. | ||
− | * {{Tag|jmolAppletButton}} : A button for opening a new window | + | * {{Tag|jmolAppletButton}} : A button for opening a new window containing a Jmol Applet. It can contain the same tags as the {{Tag|jmolApplet}} tag, and also the following tags : |
** {{Tag|title}} : Title of the new window. Defaults to "Jmol". | ** {{Tag|title}} : Title of the new window. Defaults to "Jmol". | ||
** {{Tag|text}} : Text of the button. Defaults to the contents of {{Tag|title}}. | ** {{Tag|text}} : Text of the button. Defaults to the contents of {{Tag|title}}. | ||
** {{Tag|x}} and {{Tag|y}} : Position of the new window. | ** {{Tag|x}} and {{Tag|y}} : Position of the new window. | ||
− | * {{Tag|jmolAppletLink}} : A link for opening a new window | + | * {{Tag|jmolAppletLink}} : A link for opening a new window containing a Jmol Applet. Same tags as {{Tag|jmolAppletButton}}. |
== Test Pages == | == Test Pages == | ||
− | # [[Jmol_MediaWiki_Extension | demo page]] | + | # [[Jmol_MediaWiki_Extension | A demo page]] |
# [[Uploaded XYZ File]] -- includes test of jmolCheckbox() | # [[Uploaded XYZ File]] -- includes test of jmolCheckbox() | ||
# [[Uploaded MDL Molfile]] | # [[Uploaded MDL Molfile]] | ||
Line 197: | Line 201: | ||
= Installation = | = Installation = | ||
+ | (''This must be done by the wiki administrator.'') | ||
− | The Jmol extension | + | The Jmol extension uses another extension, [[mw:Extension:StubManager|Stub Manager]], so you first need to install Stub Manager. |
[http://www.jmol.org/files/ Download Jmol] and extract all the files in a temporary directory. | [http://www.jmol.org/files/ Download Jmol] and extract all the files in a temporary directory. | ||
Line 214: | Line 219: | ||
Add the following line to the end of {{File|LocalSettings.php}}: | Add the following line to the end of {{File|LocalSettings.php}}: | ||
require_once('extensions/Jmol/Jmol.php'); | require_once('extensions/Jmol/Jmol.php'); | ||
− | |||
You can configure the Jmol extension with several settings added after the above line (default value in '''bold'''): | You can configure the Jmol extension with several settings added after the above line (default value in '''bold'''): | ||
Line 225: | Line 229: | ||
* <tt>$wgJmolForceNameSpace</tt> : Force the NameSpace where the applet will go looking for wiki pages containing molecular data (using {{Tag|wikiPageContents}}). | * <tt>$wgJmolForceNameSpace</tt> : Force the NameSpace where the applet will go looking for wiki pages containing molecular data (using {{Tag|wikiPageContents}}). | ||
* <tt>$wgJmolShowWarnings</tt> ('''<tt>true</tt>''', <tt>false</tt>) : Display warnings when users try to use disabled features. | * <tt>$wgJmolShowWarnings</tt> ('''<tt>true</tt>''', <tt>false</tt>) : Display warnings when users try to use disabled features. | ||
− | * <tt>$wgJmolUsingSignedAppletByDefault</tt> (<tt>true</tt>, '''<tt>false</tt>''') : Choose if the signed Jmol applet will be used by default. ''Note: the signed Jmol applet is signed with a default | + | * <tt>$wgJmolUsingSignedAppletByDefault</tt> (<tt>true</tt>, '''<tt>false</tt>''') : Choose if the signed Jmol applet will be used by default. ''Note: the signed Jmol applet is signed with a default certificate. If you want to use the signed Jmol applet in your wiki, I suggest resigning the Jmol applet with your own certificate.'' |
Revision as of 23:05, 10 December 2008
- Jmol as a standalone application.
- J(S)mol as a web applet or HTML5 object.
- compatibility with JavaScript frameworks or libraries.
- J(S)mol embedded in wikis or blogs.
- Borrowed JSmol, or running JSmol without your own server.
- Running Jmol using Java Web Start.
- JSmol in a Jupyter notebook.
- Jmol in an Android tablet.
- Troubleshooting.
Contents
Description
MediaWiki is an open source wiki engine licensed under the GNU General Public License. It is used by many websites, including this one.
The Jmol Mediawiki Extension enables the use of the Jmol applet inside of Mediawiki pages. This simple page demonstrates how to use the extension.
Current status: the Jmol Mediawiki Extension is fully functional and stabilized. It currently needs to be modified for a few things: better security, ability to delay loading the applet.
- Security is hopefully correct now. The delay effect can be obtained by using Jmol applet in a popup window.
Wikis using the Jmol Extension
If you know a Wiki using the Jmol MediaWiki Extension, please add it to the list of Wikis using Jmol.
How to use the Jmol Extension
Once the Jmol Extension is installed in the Wiki, you can start adding Jmol applets and controls.
Simple usage
Jmol applet in a MediaWiki page
To add a Jmol applet to a MediaWiki page, just add the following:
<jmol> <jmolApplet> <uploadedFileContents>name of file uploaded in the wiki containing the molecular data</uploadedFileContents> </jmolApplet> </jmol>
- The file must be uploaded to the wiki as if it were an image, using the "Upload file" link in the "Toolbox" panel on the left. Its location is hence [[Image:MyMolecule.mol]], but only the name, MyMolecule.mol, must be inserted inside the <uploadedFileContents> tags.
or
<jmol> <jmolApplet> <wikiPageContents>page of the wiki containing the molecular data</wikiPageContents> </jmolApplet> </jmol>
or
<jmol> <jmolApplet> <inlineContents>contents of the molecular file</inlineContents> </jmolApplet> </jmol>
or
<jmol> <jmolApplet> <urlContents>URL of the molecular file</urlContents> </jmolApplet> </jmol>
- If the file is in a server different than the wiki, you need to use the signed applet (<signed> tag).
Controls for the Jmol applet
To add a button to send scripts to the applet, just add the following:
<jmol> <jmolButton> <script>script to execute</script> <text>text of the button</text> </jmolButton> </jmol>
To add a link to send scripts to the applet, just add the following:
<jmol> <jmolLink> <script>script to execute</script> <text>text of the link</text> </jmolLink> </jmol>
To add a checkbox to send scripts to the applet, just add the following:
<jmol> <jmolCheckbox> <scriptWhenChecked>script to execute when the checkbox is checked</scriptWhenChecked> <scriptWhenUnchecked>script to execute when the checkbox is unchecked</scriptWhenUnchecked> <text>text of the checkbox</text> </jmolCheckbox> </jmol>
To add a group of radio buttons to send scripts to the applet, just add the following:
<jmol> <jmolRadioGroup> <item> <script>script to execute when the radio button is selected</script> <text>text of the radio button</text> </item> <item> <script>script to execute when the radio button is selected</script> <text>text of the radio button</text> </item> </jmolRadioGroup> </jmol>
To add a menu to send scripts to the applet, just add the following:
<jmol> <jmolMenu> <item> <script>script to execute when the menu item is selected</script> <text>text of the menu item</text> </item> <item> <script>script to execute when the menu item is selected</script> <text>text of the menu item</text> </item> </jmolMenu> </jmol>
Applets and other controls can be combined in a single <jmol> tag.
Jmol applet in a popup window
To add a button that opens a new window containing a Jmol applet, use the <JmolAppletButton> tag instead of the <JmolApplet> tag and also add the <text> tag in it. For example:
<jmol> <jmolAppletButton> <uploadedFileContents>file uploaded in the wiki containing the molecular data</uploadedFileContents> <text>text displayed in the button</text> </jmolAppletButton> </jmol>
To add a link that opens a new window containing a Jmol applet, use the <JmolAppletLink> tag instead of the <JmolApplet> tag and also add the <text> tag in it. For example:
<jmol> <jmolAppletLink> <uploadedFileContents>file uploaded in the wiki containing the molecular data</uploadedFileContents> <text>text displayed in the link</text> </jmolAppletLink> </jmol>
In both cases, the new window will be resizable and the applet inside will resize with it.
Reference
The <jmol> tag can contain the following:
- <jmolApplet> : Jmol Applet.
- <signed> (true, false) : To use the signed or unsigned version of the applet. This attribute can be disabled by the Wiki administrator with the $wgJmolAuthorizeChoosingSignedApplet setting in LocalSettings.php.
- <color> : To set the background color of the Jmol applet (default is black).
- <uploadedFileContents> : Name of an uploaded file in this wiki containing the molecular data to load in the Jmol applet. The Wiki needs to be configured to authorize the upload of molecular data files (using $wgFileExtensions in LocalSettings.php). This attribute can be disabled by the Wiki administrator with the $wgJmolAuthorizeUploadedFile setting in LocalSettings.php.
- <wikiPageContents> : Name of a page of this wiki containing the molecular data to load in the Jmol applet.
- <urlContents> : URL of the molecular file to load. This attribute can be disabled by the Wiki administrator with the $wgJmolAuthorizeUrl setting in LocalSettings.php.
- <inlineContents> : Molecular data to load in the Jmol applet.
- <size> : Size of the applet.
- <script> : Script to execute right after loading the molecule.
- <name> : Name of the Jmol applet (useful if you want to use several Jmol applets in the same page).
- <jmolButton> : Button.
- <script> : Jmol script to execute when the button is clicked.
- <text> : Text of the button.
- <name> : Name of the button.
- <target> : Name of the Jmol applet linked with the button (useful only if you want to use several Jmol applets in the same page).
- <jmolLink> : Link. Same tags as <jmolButton>.
- <jmolCheckbox> : Checkbox.
- <scriptWhenChecked> : Jmol script to execute when the checkbox is checked.
- <scriptWhenUnchecked> : Jmol script to execute when the checkbox is unchecked.
- <checked> (true, false) : Indicates if the checkbox is checked when the page loads.
- <text> : Text of the button.
- <name> : Name of the button.
- <target> : Name of the Jmol applet linked with the button (useful only if you want to use several Jmol applets in the same page).
- <jmolMenu> : Menu.
- <item> : Menu item.
- <script> : Jmol script to execute when the menu item is selected.
- <text> : Text of the menu item.
- <checked> (true, false) : Indicates if the menu item is selected when the page loads.
- <name> : Name of the menu.
- <target> : Name of the Jmol applet linked with the menu (useful only if you want to use several Jmol applets in the same page).
- <menuHeight> : Number of visible menu items (1: combo-box, 2 or greater: list with the specified number of lines, -1: calculated). Default is 1.
- <item> : Menu item.
- <jmolRadioGroup> : Group of radio buttons.
- <item> : Radio button.
- <script> : Jmol script to execute when the radio button is selected.
- <text> : Text of the radio button.
- <checked> (true, false) : Indicates if the radio button is checked when the page loads.
- <name> : Name of the radio group.
- <target> : Name of the Jmol applet linked with the radio group (useful only if you want to use several Jmol applets in the same page).
- <vertical> (true, false) : Indicates if the radio buttons are stacked vertically or horizontally.
- <item> : Radio button.
- <jmolAppletButton> : A button for opening a new window containing a Jmol Applet. It can contain the same tags as the <jmolApplet> tag, and also the following tags :
- <title> : Title of the new window. Defaults to "Jmol".
- <text> : Text of the button. Defaults to the contents of <title>.
- <x> and <y> : Position of the new window.
- <jmolAppletLink> : A link for opening a new window containing a Jmol Applet. Same tags as <jmolAppletButton>.
Test Pages
- A demo page
- Uploaded XYZ File -- includes test of jmolCheckbox()
- Uploaded MDL Molfile
- Uploaded CML File
- Inlined MDL Molfile
- Inlined CML File
- Test page (Brian's)
- Test page (Sandbox)
Installation
(This must be done by the wiki administrator.)
The Jmol extension uses another extension, Stub Manager, so you first need to install Stub Manager.
Download Jmol and extract all the files in a temporary directory.
Create the directory Jmol in $mediawiki/extensions, and copy the following files in it:
- COPYRIGHT.txt
- Jmol.js
- All the JmolApplet0*.jar files
- All the JmolAppletSigned0*.jar files, if you want to be able to use the signed applet.
- LICENSE.txt
- README.txt
- All the files for the extension, which can be found here.
Add the following line to the end of LocalSettings.php:
require_once('extensions/Jmol/Jmol.php');
You can configure the Jmol extension with several settings added after the above line (default value in bold):
- $wgJmolAuthorizeChoosingSignedApplet (true, false) : Authorize users to choose between the unsigned and the signed Jmol applet.
- $wgJmolAuthorizeUploadedFile (true, false) : Authorize the use of <uploadedFileContents>.
- $wgJmolAuthorizeUrl (true, false) : Authorize the use of <urlContents>.
- $wgJmolDefaultAppletSize (400) : Size in pixels of the Jmol applet.
- $wgJmolDefaultScript : Default script.
- $wgJmolExtensionPath : Path to the directory where the Jmol extension is installed.
- $wgJmolForceNameSpace : Force the NameSpace where the applet will go looking for wiki pages containing molecular data (using <wikiPageContents>).
- $wgJmolShowWarnings (true, false) : Display warnings when users try to use disabled features.
- $wgJmolUsingSignedAppletByDefault (true, false) : Choose if the signed Jmol applet will be used by default. Note: the signed Jmol applet is signed with a default certificate. If you want to use the signed Jmol applet in your wiki, I suggest resigning the Jmol applet with your own certificate.
Note: If you want to authorize users to upload files containing molecular data (for using the <uploadedFileContents> tag), you need to do the following:
- By default, MediaWiki authorizes the uploading of files whose name ends with a limited number of extensions. For example, if you want to authorize uploading *.cml files, add $wgFileExtensions[] = 'cml'; in LocalSettings.php.
- You can add an icon in the skins/common/images/icons/ directory for each extension (for example, fileicon-cml.png). In this wiki, we are using this image, which leads to the following result.
Problems yet to be solved
- The developers at WikiMedia / WikiMedia Commons / Wikipedia apparently advocate the use of a simpler way of inserting Jmol applets, by just linking to the (previously uploaded) model file (as it is done e.g. with images) and having the server decide upon the way to handle it, with something simpler than the current Extension (see a discussion about this).
- However, in my opinion rendering of a 3D molecular model clearly calls for something more flexible than a simple, barebone viewer with default settings. Maybe we would have to resort to a simpler extension for Wikipedia and a full one for other wikis?
- An interesting feature would be the server-side automation of the snapshot ability of the Jmol application, so that images are generated into the wiki page as a thumbnail that will link to --or be replaced by-- the applet when the user clicks on the image, or on a link below it (see an example of this idea, though not server-generated).
Already solved
These are left here for reference, as you may still have these problems depending on your version of MediaWiki or your version of the Jmol MediaWiki Extension.
- The installation does not work when the wiki is installed in a non-root folder of the server (e.g. http://www.myserver.com/mywiki/index.php instead of http://mywiki.myserver.com/index.php).
- Fixed (2008-Nov-29) in revision 10393.
- Using <jmolAppletButton> or <jmolAppletlink> throws an error in Internet Explorer: "Invalid argument", and prevents the pop-up.
- Partially fixed (2008-Dec-2) in revision 10411.
- Completely fixed (2008-Dec-8) in revision 10467.
- The scripts associated to checkboxes rendered by
<jmolCheckbox>
have no effect on the applet.
- Fixed (2008-Dec-8) in revision 10467.
- This was the discussion of the problem:
(Bob) something in /skins/common/wikibits.js?97 is disabling checkboxes.
(Nico) Yes, good catch, thanks a lot. Now, I need to find a way to overcome the behaviour of setupCheckboxShiftClick()
. I am going to ask on mediawiki list.
(Bugzilla) discussion
- Since Jmol scripting can include a call to javascript commands, the Jmol applet inserted by the Jmol MediaWiki Extension can execute arbitrary javascript added by any user editing the page (see demo). This is an unacceptable security hole for some systems such as Wikipedia, and will prevent Jmol from being used there. There is hence a need to implement a "scripting-without-javascript" mode of the applet, i.e. a way to completely disable the
javascript
command in Jmol scripts run from the MediaWiki Extension.
- Fixed (2008-Dec-8) in revision 10467.
- Any tag (<script> or otherwise) whose content includes the word "javascript" will be ignored by the Extension.
- The signed applet was not being used even when explicitly authorized in the wiki configuration (
$wgJmolAuthorizeChoosingSignedApplet=true
) and requested for the applet (<signed>true</signed>
).
- Fixed (2008-Dec-8) in revision 10467.
- Now you can also have both signed and unsigned applets in the same page.
External links
- Wikipedia: Using Jmol to display molecular models
- Wikipedia: WikiProject Chemistry
Contributors
AngelHerraez, NicolasVervelle, Rzepa, Mevans86, Ngreeves, Pimpim, SklogWiki, Jacksmind, EricMartz