Difference between revisions of "MediaWiki/Installation"

From Jmol
Jump to navigation Jump to search
m (typo)
(Installation)
 
(3 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
'''Note:''' '''Version 6''' of the Jmol Extension has been tested against MediaWiki 1.39-1.43. There are significant changes in MediaWiki, so this procedure will not work with older versions.  
 
'''Note:''' '''Version 6''' of the Jmol Extension has been tested against MediaWiki 1.39-1.43. There are significant changes in MediaWiki, so this procedure will not work with older versions.  
  
== One-step installation ==
+
== Installation ==
  
 +
# In the {{folder|extensions}} folder of your wiki, create a {{folder|Jmol}} folder.
 
# Download all the [http://sourceforge.net/p/jmol/code/HEAD/tree/trunk/Jmol-extensions/wiki/MediaWiki/ source files of the Jmol extension] (version 6.x) and place them in the {{folder|extensions/Jmol}} folder.
 
# Download all the [http://sourceforge.net/p/jmol/code/HEAD/tree/trunk/Jmol-extensions/wiki/MediaWiki/ source files of the Jmol extension] (version 6.x) and place them in the {{folder|extensions/Jmol}} folder.
 +
# Download the [https://sourceforge.net/projects/jmol/files/Jmol/ latest release] of Jmol (<code>Jmol-16.xx.xx-binary.zip</code>)
 +
#* Extract into a temporary location the {{file|jsmol.zip}} file from the Jmol release.
 +
#* Open this file and extract the following contents (all located inside a {{folder|jsmol}} subfolder):
 +
#** the {{file|JSmol.min.js}} file,
 +
#** the {{file|JSmol.GLmol.min.js}} file,
 +
#** the {{folder|j2s}} and {{folder|php}} folders.
 +
#** ({{file|JmolData.jar}} and  {{file|JSmol.GLmol.min.nojq.js}}, shown in the figure, are not essential)
 +
# Upload the above files and folders to the {{folder|extensions/Jmol/JSmol}} folder.
 
# Edit {{file|LocalSettings.php}} adding a line <code>wfLoadExtension('Jmol');</code>
 
# Edit {{file|LocalSettings.php}} adding a line <code>wfLoadExtension('Jmol');</code>
  
== Alternative: update the installation with a newer JSmol version ==
+
The utility {{file|copyJSmolForJmolExtension.php}} is included as a convenient way to facilitate direct extraction of the needed files from <code>Jmol-16.xx.xx-binary.zip</code> (steps 3 and 4 below).
 
+
It is used like this:
# Download the [https://sourceforge.net/projects/jmol/files/Jmol/ latest release] of [[:en:Jmol|Jmol]] (<code>Jmol-16.xx.xx-binary.zip</code>)
+
:<code>copyJSmolForJmolExtension.php Jmol-xx.xx.xx-binary.zip /mediawiki/extensions/Jmol</code>
# Extract into a temporary location the {{file|jsmol.zip}} file from the Jmol release.
 
# Locate the {{folder|Jmol}} subfolder in the {{folder|extensions}} folder of your MediaWiki installation.
 
# Extract (upload) into this {{folder|Jmol}} folder the following contents from the {{file|jsmol.zip}} file (all located inside a {{folder|jsmol}} subfolder):
 
#* the {{file|JSmol.min.js}} file,
 
#* the {{file|JSmol.GLmol.min.js}} file,
 
#* the {{folder|j2s}} and {{folder|php}} folders.
 
  
 
== Further steps ==
 
== Further steps ==
 
Optional change of settings:
 
Optional change of settings:
  
You can configure the Jmol extension with several settings added after the <code>require_once</code> line (default value <u>underlined</u>):
+
You can configure the Jmol extension with several settings, usually added at the end of {{file|LocalSettings.php}}, and in any case after the  
* <tt>$wgJmolAuthorizeJmolTag = <u>true</u> / false</tt> : Authorize the use of the  {{Tag|jmol/}} tag.
+
<code>wfLoadExtension('Jmol');</code>
 +
(default value <u>underlined</u>):
 
* <tt>$wgJmolAuthorizeJmolFileTag = <u>true</u> / false</tt> : Authorize the use of the  {{Tag|jmolFile/}} tag.
 
* <tt>$wgJmolAuthorizeJmolFileTag = <u>true</u> / false</tt> : Authorize the use of the  {{Tag|jmolFile/}} tag.
 +
* <tt>$wgJmolAuthorizeJmolMolTag = <u>true</u> / false</tt> : Authorize the use of the  {{Tag|jmolMol/}} tag.
 
* <tt>$wgJmolAuthorizeJmolPdbTag = <u>true</u> / false</tt> : Authorize the use of the  {{Tag|jmolPdb/}} tag.  
 
* <tt>$wgJmolAuthorizeJmolPdbTag = <u>true</u> / false</tt> : Authorize the use of the  {{Tag|jmolPdb/}} tag.  
 
* <tt>$wgJmolAuthorizeJmolSmilesTag = <u>true</u> / false</tt> : Authorize the use of the {{Tag|jmolSmiles/}} tag.  
 
* <tt>$wgJmolAuthorizeJmolSmilesTag = <u>true</u> / false</tt> : Authorize the use of the {{Tag|jmolSmiles/}} tag.  
 +
* <tt>$wgJmolAuthorizeJmolTag = <u>true</u> / false</tt> : Authorize the use of the  {{Tag|jmol/}} tag.
 
* <tt>$wgJmolAuthorizeUploadedFile = true / <u>false</u></tt> : Authorize the use of {{Tag|uploadedFileContents}}.
 
* <tt>$wgJmolAuthorizeUploadedFile = true / <u>false</u></tt> : Authorize the use of {{Tag|uploadedFileContents}}.
 
* <tt>$wgJmolAuthorizeUrl = true / <u>false</u></tt> : Authorize the use of {{Tag|urlContents}}.
 
* <tt>$wgJmolAuthorizeUrl = true / <u>false</u></tt> : Authorize the use of {{Tag|urlContents}}.
 +
* <tt>$wgJmolDefaultScript = ...</tt> : Default script.
 
* <tt>$wgJmolDefaultAppletSize = <u>400</u></tt> : Size in pixels of the JSmol panel.
 
* <tt>$wgJmolDefaultAppletSize = <u>400</u></tt> : Size in pixels of the JSmol panel.
* <tt>$wgJmolDefaultScript = ...</tt> : Default script.
 
* <tt>$wgJmolExtensionPath = "<u>extensions/Jmol</u>"</tt> : Path to the directory where the Jmol extension is installed. This must be an absolute path, therefore if you customize it, make sure it is prepended with <tt>$wgScriptPath</tt> (see example in Jmol.php).
 
 
* <tt>$wgJmolForceNameSpace = ...</tt> : Force the NameSpace where JSmol will go looking for wiki pages containing molecular data (using {{Tag|wikiPageContents}}).
 
* <tt>$wgJmolForceNameSpace = ...</tt> : Force the NameSpace where JSmol will go looking for wiki pages containing molecular data (using {{Tag|wikiPageContents}}).
 
* <tt>$wgJmolShowWarnings = <u>true</u> / false</tt> : Display warnings when users try to use disabled features.
 
* <tt>$wgJmolShowWarnings = <u>true</u> / false</tt> : Display warnings when users try to use disabled features.
* Deprecated:
+
 
** <tt>$wgJmolUsingSignedAppletByDefault = true / <u>false</u></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.''
+
Additional settings:
** <tt>$wgJmolAuthorizeChoosingSignedApplet = true / <u>false</u></tt> : Authorize users to choose between the unsigned and the signed Jmol applet.
+
* <tt>$wgJmolDefaultAppletColor</tt>
 +
* <tt>$wgJmolMaxAppletSize</tt>
 +
* <tt>$wgJmolDefaultRenderingEngine  = <u>HTML5</u> / WebGL</tt>
 +
* <tt>$wgJmolMolServer</tt>
 +
* <tt>$wgJmolPdbServer</tt>
 +
* <tt>$wgJmolPlatformSpeed</tt>
 +
* <tt>$wgJmolDefaultCaptionCSS</tt> (used in Proteopedia)
 +
* <tt>$wgJmolDefaultTitleCSS</tt>
 +
 
  
 
== Managing molecular structure files ==
 
== Managing molecular structure files ==
Line 61: Line 74:
 
  $wgFileExtensions[] = 'cml';
 
  $wgFileExtensions[] = 'cml';
  
=== Configuring recognition of molecular files ===
 
 
By default, the MIME type detection of MediaWiki (read 'additional help' below) only detects some molecular files as basic MIME types (<code>text/plain</code>, <code>application/xml</code>, …).
 
 
Recent versions of MediwWiki (e.g. 1.41) already include by default recognition of MIME type of {{file|.pdb}}, {{file|.xyz}} and {{file|.mol}} files (as well as other MDL-MOLfile formats like 'sdf', 'rxn', 'rd' and 'rg' extensions).
 
However, there is still a mismatch with the detected MIME type that prevents the upload, so it may need to be fixed:
 
 
Near the end of your {{file|LocalSettings.php}} file, add these lines:
 
<pre>$wgHooks['MimeMagicImproveFromExtension'][] = static function ( $mimeAnalyzer, $ext, &$mime ) {
 
  if    ( $ext == 'mol' ) { $mime = 'chemical/x-mdl-molfile'; }
 
  elseif ( $ext == 'sdf' ) { $mime = 'chemical/x-mdl-sdfile'; }
 
  elseif ( $ext == 'xyz' ) { $mime = 'chemical/x-xyz'; }
 
  elseif ( $ext == 'pdb' ) { $mime = 'chemical/x-pdb'; }
 
  elseif ( $ext == 'cml' ) { $mime = 'chemical/x-cml'; }
 
};
 
</pre>
 
 
For molecular file formats based on XML (like [[:en:Chemical Markup Language|CML files]] {{File|*.cml}}), it is commonly needed to enhance the MIME type detection using {{MWmanual|$wgXMLMimeTypes}} , which allows the mapping between the root element of the file and the MIME type.
 
For example, add the following lines near the end of your {{file|LocalSettings.php}} file:
 
<pre>$wgXMLMimeTypes = array_merge( $wgXMLMimeTypes, array(
 
  'http://www.xml-cml.org/schema:cml'                => 'chemical/x-cml',
 
  'http://www.xml-cml.org/schema:molecule'          => 'chemical/x-cml',
 
  'http://www.xml-cml.org/schema/cml2/core:list'    => 'chemical/x-cml',
 
  'http://www.xml-cml.org/schema/cml2/core:molecule' => 'chemical/x-cml' ) );
 
</pre>
 
 
The following, alternative or complementary, solution seems not to be necessary in recent MW versions:
 
 
By default, MediaWiki checks that the file extension matches the MIME type that has been detected.
 
For this, MediaWiki uses {{file|includes/libs/mime/MimeMap.php}} in MediaWiki installation. In former MW versions, the file is {{file|includes/mime.types}}.
 
 
File extensions for molecular models are probably missing from this file by default, so you need to modify it.
 
For example, {{file|*.cml}} might be detected as <code>chemical/x-cml</code> or <code>application/xml</code> (depending on your {{MWmanual|Mime_type_detection|MIME type detection}} configuration), so you need to make the following additions to {{file|includes/libs/mime/MimeMap.php}} or {{file|includes/mime.types}}:
 
application/xml xml xsl xsd '''cml'''
 
'''chemical/x-cml cml'''
 
(check for location of several instances of <code>chemical/x-mdl-molfile</code> to find where and how to add this extra definition) or use the {{file|LocalSettings.php}} method described above.
 
 
=== Additional help ===
 
 
<blockquote>
 
<blockquote>
 
Configuration of file uploading for MediaWiki can be quite complex and may also depend on the servers configuration hosting the wiki. You can read several MediaWiki manual pages for correctly configuring file uploading for your own MediaWiki setup:
 
Configuration of file uploading for MediaWiki can be quite complex and may also depend on the servers configuration hosting the wiki. You can read several MediaWiki manual pages for correctly configuring file uploading for your own MediaWiki setup:
Line 105: Line 80:
 
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_administration Image administration]
 
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_administration Image administration]
 
</blockquote>
 
</blockquote>
 +
 +
=== Configuring recognition of molecular files ===
 +
 +
By default, MediaWiki checks that the file extension matches the MIME type that has been detected.
 +
Such MIME type detection may or not recognize properly the not-so-common extensions you might want to use. On the other hand, it is important to not allow arbitrary kinds of file being uploaded to MediaWiki.
 +
 +
I you find trouble, you may try reading MW documentation about recognition of MIME types as well as some settings that used to be able to fix this in [[MediaWiki/Installation/v5#Configuring_recognition_of_molecular_files|former versions]] of the Extension (with no warranties for this v6 and MW 1.43 to behave in the same way)
 +
 +
Also, this setting may be relevant:
 +
* <tt>$wgVerifyMimeType = false</tt>
  
 
=== File icons ===
 
=== File icons ===
Line 111: Line 96:
  
 
== Installation of older versions ==
 
== Installation of older versions ==
'''Version 5''' of the Jmol Extension is compatible with MediaWiki 1.32; [[MediaWiki/ExtensionV5|installation instructions]].
+
'''Version 5''' of the Jmol Extension is compatible with MediaWiki 1.32; [[MediaWiki/ExtensionV5#How_to_install_the_Jmol_Extension|installation instructions]].
  
 
'''Version 4''' of the Jmol Extension is compatible with MediaWiki 1.16; [https://www.mediawiki.org/w/index.php?title=Extension:Jmol&oldid=2497254 installation instructions].
 
'''Version 4''' of the Jmol Extension is compatible with MediaWiki 1.16; [https://www.mediawiki.org/w/index.php?title=Extension:Jmol&oldid=2497254 installation instructions].
Line 117: Line 102:
 
The Jmol Extension below '''version 3.3''' uses another extension, [[mw:Extension:StubManager|Stub Manager]], so you first need to install it.
 
The Jmol Extension below '''version 3.3''' uses another extension, [[mw:Extension:StubManager|Stub Manager]], so you first need to install it.
  
== Deprecated ==
+
== Extension documented in MediaWiki ==
 
Installation of the Jmol extension was described on [[:mw:Extension:Jmol#Installing Jmol Extension|the Jmol extension page on MediaWiki]].
 
Installation of the Jmol extension was described on [[:mw:Extension:Jmol#Installing Jmol Extension|the Jmol extension page on MediaWiki]].
  
That page has been removed since the Jmol Extension is not compatible with recent versions of MediaWiki.
+
That page has been removed since the Jmol Extension (up to v5) was not compatible with recent versions of MediaWiki.
 +
We are planning to restore that page soon pointing to the information here.
  
 
= See also =
 
= See also =
 
[[MediaWiki/Extension|How to use the Extension]]
 
[[MediaWiki/Extension|How to use the Extension]]

Latest revision as of 15:49, 17 January 2025

Installation of the Jmol (JSmol) Extension for Mediawiki

Admin All this must be done by the wiki administrator.

The files forming the Jmol Extension are part of the Jmol source code and may hence be retrieved from the SVN system.

arrangement of folders and files of the Jmol Extension

Note: Version 6 of the Jmol Extension has been tested against MediaWiki 1.39-1.43. There are significant changes in MediaWiki, so this procedure will not work with older versions.

Installation

  1. In the Folder icon.gifextensions folder of your wiki, create a Folder icon.gifJmol folder.
  2. Download all the source files of the Jmol extension (version 6.x) and place them in the Folder icon.gifextensions/Jmol folder.
  3. Download the latest release of Jmol (Jmol-16.xx.xx-binary.zip)
    • Extract into a temporary location the File icon.gifjsmol.zip file from the Jmol release.
    • Open this file and extract the following contents (all located inside a Folder icon.gifjsmol subfolder):
      • the File icon.gifJSmol.min.js file,
      • the File icon.gifJSmol.GLmol.min.js file,
      • the Folder icon.gifj2s and Folder icon.gifphp folders.
      • (File icon.gifJmolData.jar and File icon.gifJSmol.GLmol.min.nojq.js, shown in the figure, are not essential)
  4. Upload the above files and folders to the Folder icon.gifextensions/Jmol/JSmol folder.
  5. Edit File icon.gifLocalSettings.php adding a line wfLoadExtension('Jmol');

The utility File icon.gifcopyJSmolForJmolExtension.php is included as a convenient way to facilitate direct extraction of the needed files from Jmol-16.xx.xx-binary.zip (steps 3 and 4 below). It is used like this:

copyJSmolForJmolExtension.php Jmol-xx.xx.xx-binary.zip /mediawiki/extensions/Jmol

Further steps

Optional change of settings:

You can configure the Jmol extension with several settings, usually added at the end of File icon.gifLocalSettings.php, and in any case after the wfLoadExtension('Jmol'); (default value underlined):

  • $wgJmolAuthorizeJmolFileTag = true / false : Authorize the use of the <jmolFile/> tag.
  • $wgJmolAuthorizeJmolMolTag = true / false : Authorize the use of the <jmolMol/> tag.
  • $wgJmolAuthorizeJmolPdbTag = true / false : Authorize the use of the <jmolPdb/> tag.
  • $wgJmolAuthorizeJmolSmilesTag = true / false : Authorize the use of the <jmolSmiles/> tag.
  • $wgJmolAuthorizeJmolTag = true / false : Authorize the use of the <jmol/> tag.
  • $wgJmolAuthorizeUploadedFile = true / false : Authorize the use of <uploadedFileContents>.
  • $wgJmolAuthorizeUrl = true / false : Authorize the use of <urlContents>.
  • $wgJmolDefaultScript = ... : Default script.
  • $wgJmolDefaultAppletSize = 400 : Size in pixels of the JSmol panel.
  • $wgJmolForceNameSpace = ... : Force the NameSpace where JSmol will go looking for wiki pages containing molecular data (using <wikiPageContents>).
  • $wgJmolShowWarnings = true / false : Display warnings when users try to use disabled features.

Additional settings:

  • $wgJmolDefaultAppletColor
  • $wgJmolMaxAppletSize
  • $wgJmolDefaultRenderingEngine = HTML5 / WebGL
  • $wgJmolMolServer
  • $wgJmolPdbServer
  • $wgJmolPlatformSpeed
  • $wgJmolDefaultCaptionCSS (used in Proteopedia)
  • $wgJmolDefaultTitleCSS


Managing molecular structure files

Authorizing uploads

Web server PHP setup

The configuration of your web server needs to allow uploads by users (a global setting, not just for the wiki). Find a line with file_uploads in the File icon.gifphp.ini file and change it to file_uploads = on. Going to the Special:Upload page in your wiki will tell you if uploads are enabled or not.

Wiki upload setup

If you want to authorize users to upload files containing molecular data (for using the <uploadedFileContents> subtag), you need to do the following:

By default, MediaWiki authorizes the uploading of a very limited set of file types, based on file extensions and MIME types (see Configuring_file_uploads ). By default, uploading molecular files is not authorized, so the configuration must be modified to take advantage of all the Jmol extension features. You can check what file extensions are authorized in the Special:Upload page.

First, you need to authorize new file extensions being uploaded in the wiki, using $wgFileExtensions . For example, add one or several of the following lines at the end of your File icon.gifLocalSettings.php file:

$wgFileExtensions[] = 'pdb';
$wgFileExtensions[] = 'mol';
$wgFileExtensions[] = 'xyz';
$wgFileExtensions[] = 'cml';

Configuration of file uploading for MediaWiki can be quite complex and may also depend on the servers configuration hosting the wiki. You can read several MediaWiki manual pages for correctly configuring file uploading for your own MediaWiki setup:

Configuring recognition of molecular files

By default, MediaWiki checks that the file extension matches the MIME type that has been detected. Such MIME type detection may or not recognize properly the not-so-common extensions you might want to use. On the other hand, it is important to not allow arbitrary kinds of file being uploaded to MediaWiki.

I you find trouble, you may try reading MW documentation about recognition of MIME types as well as some settings that used to be able to fix this in former versions of the Extension (with no warranties for this v6 and MW 1.43 to behave in the same way)

Also, this setting may be relevant:

  • $wgVerifyMimeType = false

File icons

Example icon

Now that uploading new file extensions has been authorized, you can do a final modification so that molecular files are shown with a specific icon in categories (see examples in Category:XYZ_file).

You can add an icon in the Folder icon.gifskins/common/images/icons folder for each extension of molecular files (such as File icon.giffileicon-cml.png).

Installation of older versions

Version 5 of the Jmol Extension is compatible with MediaWiki 1.32; installation instructions.

Version 4 of the Jmol Extension is compatible with MediaWiki 1.16; installation instructions.

The Jmol Extension below version 3.3 uses another extension, Stub Manager, so you first need to install it.

Extension documented in MediaWiki

Installation of the Jmol extension was described on the Jmol extension page on MediaWiki.

That page has been removed since the Jmol Extension (up to v5) was not compatible with recent versions of MediaWiki. We are planning to restore that page soon pointing to the information here.

See also

How to use the Extension

Contributors

AngelHerraez