Difference between revisions of "MediaWiki"

From Jmol
Jump to navigation Jump to search
(Documentation)
(content moved to a new page)
 
(86 intermediate revisions by 10 users not shown)
Line 1: Line 1:
__TOC__
+
{{Running_Jmol_Sections}}
 
= Description =
 
= Description =
  
 
[http://www.mediawiki.org/ MediaWiki] is an open source wiki engine licensed under the [http://www.gnu.org/copyleft/gpl.html GNU General Public License]. It is used by [[metawikipedia:Sites_using_MediaWiki|many websites]], including this one.
 
[http://www.mediawiki.org/ MediaWiki] is an open source wiki engine licensed under the [http://www.gnu.org/copyleft/gpl.html GNU General Public License]. It is used by [[metawikipedia:Sites_using_MediaWiki|many websites]], including this one.
  
The Jmol Mediawiki Extension enables the use of the Jmol applet inside of Mediawiki pages. This [[Jmol_MediaWiki_Extension|simple page]] demonstrates how to use the extension.
+
The '''Jmol Mediawiki Extension''' enables the use of the '''JSmol''' object inside of Mediawiki pages.
  
''Note: The Jmol Mediawiki Extension is currently under development. It will go under several changes, different versions will probably be incompatible between each other''
+
'''Current version: 5.1''', compatible with '''JSmol'''
 +
(You can check which version a Wiki is using by going to the <code>[[Special:Version]]</code> page in that Wiki)
  
 +
'''Current status: (version 5, JSmol)'''
 +
* The Jmol Mediawiki Extension is now using JSmol (in HTML5 modality by default, but also compatible with Java modality if you use a web browser that still supports Java applets). Some functionality was added, apart from compatibility with MediaWiki version 1.32.
 +
'''Old status: (version 4, JSmol)'''
 +
* The Jmol Mediawiki Extension used JSmol (in HTML5 modality by default, but also compatible with Java modality)
 +
'''Older status: (version 3, Jmol-Java)'''
 +
* Security is hopefully correct now. The delay effect can be obtained by using [[MediaWiki#Jmol_applet_in_a_popup_window | Jmol applet in a popup window]].
 +
* 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.
  
 
= Wikis using the Jmol Extension =
 
= Wikis using the Jmol Extension =
  
If you know a Wiki using the Jmol MediaWiki Extension, please add it in the following list:
+
If you know a Wiki using the Jmol MediaWiki Extension, please add it to the list of [[Wikis_Using_Jmol |Wikis using Jmol]].
* [[Main_Page|This]] wiki
 
* [http://fahwiki.net/ Folding@Home] wiki
 
 
 
  
 
= How to use the Jmol Extension =
 
= How to use the Jmol Extension =
  
Once the Jmol Extension is installed in the Wiki, you can start adding Jmol applets and controls.
+
Once the Jmol Extension is installed in the Wiki, you can start adding JSmol objects and controls.
 
 
'''''This following documentation is subject to change since the Jmol Extension is currently under development'''''
 
 
 
To add a Jmol applet to a MediaWiki page, just add the following:
 
 
 
&lt;jmol&gt;
 
  <contents>contents of the current.xyz file</contents>
 
  <script>script to execute</script>
 
  <name>applet name</name>
 
  <size>applet size</size>
 
  <color>applet background color</color>
 
&lt;/jmol&gt;
 
 
 
To add buttons to send scripts to the applet, just add the following:
 
  
&lt;jmolButton&gt;
+
How to know if the Extension is installed, and which version it is? Visit the <code>Special:Version</code> page in your wiki; the extension should be listed there.
  <script>script to execute</script>
 
  <text>text of the button</text>
 
  <name>applet name</name>
 
&lt;/jmolButton&gt;
 
  
 +
* [[MediaWiki/ExtensionV5|How to use version 5 of the Jmol Extension]]. Compatible with MediaWiki 1.32, PHP 7.0 and JSmol 14.29.32
 +
* [[MediaWiki/ExtensionV4|How to use version 4 of the Jmol Extension]]
 +
* [[MediaWiki/ExtensionV3|How to use version 3 of the Jmol Extension]]
  
 
= Installation =
 
= Installation =
 +
(''This must be done by the wiki administrator.'')
  
[http://www.jmol.org/files/ Download Jmol] and extract all the files in a temporary directory.
+
See [[MediaWiki/Installation]]
 
 
Create the directory <tt>Jmol</tt> in <tt>$mediawiki/extensions</tt>, and copy the following files in it:
 
* <tt>COPYRIGHT.txt</tt>
 
* <tt>Jmol.js</tt>
 
* <tt>JmolApplet_i18n.jar</tt>
 
* <tt>JmolApplet0.jar</tt>
 
* <tt>JmolApplet1.jar</tt>
 
* <tt>JmolApplet2.jar</tt>
 
* <tt>JmolApplet3.jar</tt>
 
* <tt>JmolApplet4.jar</tt>
 
* <tt>JmolApplet5.jar</tt>
 
* <tt>JmolApplet6.jar</tt>
 
* <tt>LICENSE.txt</tt>
 
* <tt>README.txt</tt>
 
 
 
Add the following line to the end of <tt>LocalSettings.php</tt>:
 
require_once('extensions/Jmol/JmolExtension.php');
 
 
 
Copy the following code and paste it into <tt>extensions/Jmol/JmolExtension.php</tt>:
 
  
<pre><?php
+
= Problems yet to be solved =
$wgExtensionFunctions[] = "wfJmolExtension";
 
$currentTag = "";
 
$appletContents = "";
 
$appletScript = "";
 
$appletName = "";
 
$appletSize = "";
 
$appletColor = "";
 
$appletText = "";
 
  
function wfJmolExtension() {
+
* Having problems with Jmol applets that are placed below the flow of a link, button, or other user interface element in markup. I get what appears to be a Java error when loading an uploaded file. --[[User:Mevans86|Mevans86]] 18:58, 13 October 2010 (UTC)
  global $wgParser;
 
  $wgParser->setHook( "jmol", "renderJmol" );
 
  $wgParser->setHook( "jmolButton", "renderJmolButton" );
 
}
 
  
function startElement( $parser, $name, $attrs ) {
+
* Does not work with Media wiki 1.17 (and probably 1.15,1.16).  I think there was a rewrite of mediawiki code and I get:
  global $currentTag;
+
: Warning: Parameter 1 to Jmol::tag_jmol() expected to be a reference, value given in /var/www/mediawiki/extensions/StubManager/StubManager.php on line 783
 +
: --[[User:Jacksmind|Jacksmind]] 01:00, 10 October 2010 (UTC)
 +
:: Hopefully this is solved with version 3.3 of the Extension, since it no longer depends on StubManager. (Still to be confirmed, but it is working fine with MW 1.16 in this site.) --[[User:AngelHerraez|AngelHerraez]] 12:32, 22 November 2010 (CET)
  
  $currentTag = $name;
+
* 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 [https://bugzilla.wikimedia.org/show_bug.cgi?id=16491 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?
 +
:: New tags are available since version 3.3 of the extension, which are much more simple to use ({{Tag|jmolFile}}, {{tag|jmolPdb}}, {{tag|jmolSmiles}}), but are currently not flexible. A solution to explore may be the use of HTML templates to give the opporunity to choose between differently configured viewers (with different controls and informations). --[[User:NicolasVervelle|NicolasVervelle]] 22:44, 28 November 2010 (CET)
  
function endElement( $parser, $name ) {
+
* 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 [[User:Bduke#How_should_molecules_be_shown_on_Wikipedia | example]] of this idea, though not server-generated).
  global $currentTag;
 
  
  $currentTag = "";
+
* I have just upgraded to MediaWiki 1.18.1 and I now have:
}
+
:Warning: Parameter 3 to Jmol::jmolPdbTag() expected to be a reference, value given in /var/www/SklogWiki/includesparser/Parser.php  on line 3580
 +
:Any advice? --[[User:SklogWiki|SklogWiki]] 19:31, 31 January 2012 (CET)
 +
  
function characterData( $parser, $data ) {
+
== Already solved ==
  global $currentTag;
+
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.
  global $appletContents;
 
  global $appletScript;
 
  global $appletName;
 
  global $appletSize;
 
  global $appletColor;
 
  global $appletText;
 
  
  switch ($currentTag) {
+
* The installation does not work when the wiki is installed in a non-root folder of the server (e.g.  <nowiki>http://www.myserver.com/mywiki/index.php</nowiki> instead of <nowiki>http://mywiki.myserver.com/index.php</nowiki>).
  case "CONTENTS":
+
: '''Fixed''' (2008-Nov-29) in [http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol-extensions/wiki/MediaWiki/ revision 10393].
    $data = trim($data);
 
    if ($data != "") {
 
      $appletContents = $appletContents . "\n" . $data;
 
    }
 
    break;
 
  case "SCRIPT":
 
    $appletScript = $data;
 
    break;
 
  case "NAME":
 
    $appletName = $data;
 
    break;
 
  case "SIZE":
 
    $appletSize = $data;
 
    break;
 
  case "COLOR":
 
    $appletColor = $data;
 
    break;
 
  case "TEXT":
 
    $appletText = $data;
 
    break;
 
  default:
 
    break;
 
  }
 
}
 
  
function renderJmol( $input ) {
+
* Using {{Tag|jmolAppletButton}} or {{Tag|jmolAppletlink}} throws an error in Internet Explorer: "Invalid argument", and prevents the pop-up.
  global $appletContents;
+
: '''Partially fixed''' (2008-Dec-2) in [http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol-extensions/wiki/MediaWiki/ revision 10411].
  global $appletScript;
+
: '''Completely fixed''' (2008-Dec-8) in [http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol-extensions/wiki/MediaWiki/ revision 10467].
  global $appletName;
 
  global $appletSize;
 
  global $appletColor;
 
  
  resetValues();
+
* The scripts associated to checkboxes rendered by {{tag|jmolCheckbox}} have no effect on the applet.
  $xmlParser = xml_parser_create();
+
: '''Fixed''' (2008-Dec-8) in [http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol-extensions/wiki/MediaWiki/ revision 10467].
  xml_set_element_handler($xmlParser, "startElement", "endElement");
+
:: This was the discussion of the problem:
  xml_set_character_data_handler($xmlParser, "characterData");
+
<div style="border:1px dashed #000099; margin-left:6ex;">
  $input = "<jmolApplet>$input<jmolApplet>";
+
(Bob)  something in {{file|/skins/common/wikibits.js?97}} is disabling checkboxes.<br />
  if (!xml_parse($xmlParser, $input)) {
+
(Nico) Yes, good catch, thanks a lot. Now, I need to find a way to overcome the behaviour of <code>setupCheckboxShiftClick()</code>. I am going to ask on mediawiki list.<br />
    die(sprintf(
+
(Bugzilla) [https://bugzilla.wikimedia.org/show_bug.cgi?id=10642 discussion]
      "XML error: %s at line %d",
+
</div>
      xml_error_string(xml_get_error_code($xmlParser)),
+
:: The problem was due to a conflict in the <code>onClick</code> event for checkboxes correctly written by the Jmol Extension and a javascript library ({{file|wikibits.js}}) included in MediaWiki. The offending js function is now overwritten by the extension.
      xml_get_current_line_number($xmlParser)));
 
  }
 
  xml_parser_free($xmlParser);
 
  $appletContents = trim($appletContents);
 
  $appletContents = preg_replace("/\t/", " ", $appletContents);
 
  $appletContents = preg_replace("/\n/", "\\n'+\n'", $appletContents);
 
  $output = $output .
 
    "<script src='/extensions/Jmol/Jmol.js'></script>\n".
 
    "<script>\n" .
 
    "jmolInitialize('/extensions/Jmol');\n".
 
    "jmolCheckBrowser('popup', '/extensions/Jmol/browsercheck', 'onClick');\n".
 
    "jmolSetAppletColor('$appletColor');\n".
 
    "jmolAppletInline($appletSize, \n'$appletContents', \n'$appletScript', \n'$appletName');\n" .
 
    "jmolBr();\n" .
 
    "</script>\n"
 
    ;
 
  return $output;
 
}
 
  
function renderJmolButton( $input ) {
+
* 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 [[User:Ilmari_Karonen/JS_injection_demo | 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 <code>javascript</code> command in Jmol scripts run from the MediaWiki Extension.
  global $appletScript;
+
: '''Fixed''' (2008-Dec-8) in [http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol-extensions/wiki/MediaWiki/ revision 10467].
  global $appletName;
+
:: No javascript will be executed by Jmol applets inserted by the Extension.
  global $appletText;
 
  
  resetValues();
+
* The signed applet was not being used even when explicitly authorized in the wiki configuration (<code>$wgJmolAuthorizeChoosingSignedApplet=true</code>) and requested for the applet (<code><signed>true</signed></code>).  
  $xmlParser = xml_parser_create();
+
: '''Fixed''' (2008-Dec-8) in [http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol-extensions/wiki/MediaWiki/ revision 10467].
  xml_set_element_handler($xmlParser, "startElement", "endElement");
+
:: Now you can also have both signed and unsigned applets in the same page.
  xml_set_character_data_handler($xmlParser, "characterData");
 
  $input = "<jmolApplet>$input<jmolApplet>";
 
  if (!xml_parse($xmlParser, $input)) {
 
    die(sprintf(
 
      "XML error: %s at line %d",
 
      xml_error_string(xml_get_error_code($xmlParser)),
 
      xml_get_current_line_number($xmlParser)));
 
  }
 
  xml_parser_free($xmlParser);
 
  $output = $output .
 
    "<script>\n" .
 
    "jmolSetTarget('$appletName');\n" .
 
    "jmolButton('$appletScript', '$appletText');\n" .
 
    "</script>\n"
 
    ;
 
  return $output;
 
}
 
  
function resetValues() {
+
* Inserting applets with models read from php pages fails. The applet is using the {{tag|urlContents}} tag and the url contains the '&' character.
  global $currentTag;
+
: '''Fixed''' (2009-Nov-13) in [http://jmol.svn.sourceforge.net/viewvc/jmol/trunk/Jmol-extensions/wiki/MediaWiki/ revision 11738], version 3.2 of the Extension.
  global $appletContents;
+
:: The '&' is not tolerated by the wikicode. The solution is to use %26 (the wikicode for &) instead of the ampersand(s) in the url, content of the {{tag|urlContents}} tag. The Extension will later filter those %26 codes and convert them to & so that the server correctly provides the model.
  global $appletScript;
 
  global $appletName;
 
  global $appletSize;
 
  global $appletColor;
 
  
  $currentTag = "";
+
= External links =
  $appletContents = "";
 
  $appletScript = "set spin Y 10; spin on";
 
  $appletName = "FahWiki";
 
  $appletSize = "400";
 
  $appletColor = "black";
 
  $appletText = "";
 
}
 
  
?></pre>
+
* Wikipedia: [[wikipedia:Wikipedia:Using Jmol to display molecular models|Using Jmol to display molecular models]]
 +
* Wikipedia: [[wikipedia:Wikipedia:WikiProject Chemistry|WikiProject Chemistry]]
 +
* MediaWiki: [http://www.mediawiki.org/wiki/Extension:Jmol Jmol Extension for MediaWiki]

Latest revision as of 06:25, 23 April 2024

Running Jmol / JSmol

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 JSmol object inside of Mediawiki pages.

Current version: 5.1, compatible with JSmol (You can check which version a Wiki is using by going to the Special:Version page in that Wiki)

Current status: (version 5, JSmol)

  • The Jmol Mediawiki Extension is now using JSmol (in HTML5 modality by default, but also compatible with Java modality if you use a web browser that still supports Java applets). Some functionality was added, apart from compatibility with MediaWiki version 1.32.

Old status: (version 4, JSmol)

  • The Jmol Mediawiki Extension used JSmol (in HTML5 modality by default, but also compatible with Java modality)

Older status: (version 3, Jmol-Java)

  • Security is hopefully correct now. The delay effect can be obtained by using Jmol applet in a popup window.
  • 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.

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 JSmol objects and controls.

How to know if the Extension is installed, and which version it is? Visit the Special:Version page in your wiki; the extension should be listed there.

Installation

(This must be done by the wiki administrator.)

See MediaWiki/Installation

Problems yet to be solved

  • Having problems with Jmol applets that are placed below the flow of a link, button, or other user interface element in markup. I get what appears to be a Java error when loading an uploaded file. --Mevans86 18:58, 13 October 2010 (UTC)
  • Does not work with Media wiki 1.17 (and probably 1.15,1.16). I think there was a rewrite of mediawiki code and I get:
Warning: Parameter 1 to Jmol::tag_jmol() expected to be a reference, value given in /var/www/mediawiki/extensions/StubManager/StubManager.php on line 783
--Jacksmind 01:00, 10 October 2010 (UTC)
Hopefully this is solved with version 3.3 of the Extension, since it no longer depends on StubManager. (Still to be confirmed, but it is working fine with MW 1.16 in this site.) --AngelHerraez 12:32, 22 November 2010 (CET)
  • 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?
New tags are available since version 3.3 of the extension, which are much more simple to use (<jmolFile>, <jmolPdb>, <jmolSmiles>), but are currently not flexible. A solution to explore may be the use of HTML templates to give the opporunity to choose between differently configured viewers (with different controls and informations). --NicolasVervelle 22:44, 28 November 2010 (CET)
  • 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).
  • I have just upgraded to MediaWiki 1.18.1 and I now have:
Warning: Parameter 3 to Jmol::jmolPdbTag() expected to be a reference, value given in /var/www/SklogWiki/includesparser/Parser.php on line 3580
Any advice? --SklogWiki 19:31, 31 January 2012 (CET)


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 File icon.gif/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

The problem was due to a conflict in the onClick event for checkboxes correctly written by the Jmol Extension and a javascript library (File icon.gifwikibits.js) included in MediaWiki. The offending js function is now overwritten by the extension.
  • 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.
No javascript will be executed by Jmol applets inserted 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.
  • Inserting applets with models read from php pages fails. The applet is using the <urlContents> tag and the url contains the '&' character.
Fixed (2009-Nov-13) in revision 11738, version 3.2 of the Extension.
The '&' is not tolerated by the wikicode. The solution is to use %26 (the wikicode for &) instead of the ampersand(s) in the url, content of the <urlContents> tag. The Extension will later filter those %26 codes and convert them to & so that the server correctly provides the model.

External links