Difference between revisions of "MediaWiki/Installation"

From Jmol
Jump to navigation Jump to search
(a separate page for collecting installation instructions (not available any more on MW))
m
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
= Installation of the Jmol (JSmol) Extension for Mediawiki =
 
= Installation of the Jmol (JSmol) Extension for Mediawiki =
  
(''This must be done by the wiki administrator.'')
+
:<span style="color:white;font-weight:bold;background:#008F00;padding:0 1ex;">Admin</span> ''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 [{{SVN Trunk}}Jmol-extensions/wiki/MediaWiki/ the SVN system].
 
The files forming the Jmol Extension are part of the Jmol source code and may hence be retrieved from [{{SVN Trunk}}Jmol-extensions/wiki/MediaWiki/ the SVN system].
  
[[File:Jmol Extension 5 folders setup 2.jpg|frame|right|arrangement of folders and files of the Jmol Extension]]
+
[[File:Jmol_Extension_5_folders_setup_3.png|frame|right|arrangement of folders and files of the Jmol Extension]]
'''Note:''' Version 5 of the Jmol Extension has been tested against MediaWiki 1.32. There are significant changes in MediaWiki, so this procedure will not work with older versions.
+
'''Note:''' '''Version 5''' of the Jmol Extension has been tested against MediaWiki 1.32. There are significant changes in MediaWiki, so this procedure will not work with older versions. It is not compatible either with newest versions of MediaWiki.
  
== To install the Jmol extension using Jmol 14: ==
+
== To install the Jmol extension using Jmol 14 ==
# Download the [https://sourceforge.net/projects/jmol/files/Jmol/ latest release] of [[:en:Jmol|Jmol]] (<code>Jmol-14.xx.xx-binary.zip</code>) You need version 14.29.32 or later.
+
# Download the [https://sourceforge.net/projects/jmol/files/Jmol/Version%2014.32/ release] of [[:en:Jmol|Jmol]] (<code>Jmol-14.xx.xx-binary.zip</code>) You need version 14.29.32 or later.
 
# Extract into a temporary location the {{file|jsmol.zip}} file from the Jmol release.
 
# Extract into a temporary location the {{file|jsmol.zip}} file from the Jmol release.
 
# Create a {{folder|Jmol}} subfolder in the {{folder|extensions}} folder of your MediaWiki installation.
 
# Create a {{folder|Jmol}} subfolder in the {{folder|extensions}} folder of your MediaWiki installation.
# Extract into this {{folder|Jmol}} folder the following contents from the {{file|jsmol.zip}} file:
+
# Extract (upload) into this {{folder|Jmol}} folder the following contents from the {{file|jsmol.zip}} file:
 
#* the {{file|JSmol.min.js}} file,
 
#* the {{file|JSmol.min.js}} file,
 
#* the {{file|JSmol.GLmol.min.js}} file,
 
#* the {{file|JSmol.GLmol.min.js}} file,
 
#* the {{folder|j2s}}, {{folder|php}} and {{folder|idioma}} folders ''(the latter one may not exist in latest Jmol versions)''.
 
#* the {{folder|j2s}}, {{folder|php}} and {{folder|idioma}} folders ''(the latter one may not exist in latest Jmol versions)''.
  
== To install the Jmol extension using Jmol 16: ==
+
== To install the Jmol extension using Jmol 16 ==
# Download the [https://sourceforge.net/projects/jmol/files/Jmol/ latest release] of [[:en:Jmol|Jmol]] (<code>Jmol-16.xx.xx-binary.zip</code>) Good compatibility may be expected, but has not been tested yet.
+
# Download the [https://sourceforge.net/projects/jmol/files/Jmol/ latest release] of [[:en:Jmol|Jmol]] (<code>Jmol-16.xx.xx-binary.zip</code>) Good compatibility may be expected, but the Extension has not been tested yet against Jmol 16.
 
# Extract into a temporary location the {{file|jsmol.zip}} file from the Jmol release.
 
# Extract into a temporary location the {{file|jsmol.zip}} file from the Jmol release.
 
# Create a {{folder|Jmol}} subfolder in the {{folder|extensions}} folder of your MediaWiki installation.
 
# Create a {{folder|Jmol}} subfolder in the {{folder|extensions}} folder of your MediaWiki installation.
# Extract into this {{folder|Jmol}} folder the following contents from the {{file|jsmol.zip}} file (all located inside a {{folder|jsmol}} subfolder):
+
# 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.min.js}} file,
 
#* the {{file|JSmol.GLmol.min.js}} file,
 
#* the {{file|JSmol.GLmol.min.js}} file,
#* the {{folder|j2s}} and {{folder|php}} folders.
+
#* the {{folder|j2s}} and {{folder|php}} folders. ''Note:'' if the latter folder contains a {{file|jsmol2.php}} file, rename it to {{file|jsmol.php}} before uploading.  
 
+
#* the {{folder|idioma}} folder, if present (at least until version 16.1.39); this is used to support language localization.
  
 
== Further steps ==
 
== Further steps ==
  
 
# Download all the [http://sourceforge.net/p/jmol/code/HEAD/tree/trunk/Jmol-extensions/wiki/MediaWiki/ source files of the Jmol extension] and place them in the <code>extensions/Jmol</code> folder.
 
# Download all the [http://sourceforge.net/p/jmol/code/HEAD/tree/trunk/Jmol-extensions/wiki/MediaWiki/ source files of the Jmol extension] and place them in the <code>extensions/Jmol</code> folder.
# Add the following line to your [https://www.mediawiki.org/wiki/Manual:LocalSettings.php LocalSettings.php file] (near the end):
+
# Add the following line to your [https://www.mediawiki.org/wiki/Manual:LocalSettings.php LocalSettings.php file] (near the end): <code>require_once("extensions/Jmol/Jmol.php");</code>
::<code>require_once("extensions/Jmol/Jmol.php");</code>
+
# 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>):
 +
* <tt>$wgJmolAuthorizeJmolTag = <u>true</u> / false</tt> : Authorize the use of the  {{Tag|jmol/}} tag.
 +
* <tt>$wgJmolAuthorizeJmolFileTag = <u>true</u> / false</tt> : Authorize the use of the  {{Tag|jmolFile/}} 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>$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>$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>$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.''
 +
** <tt>$wgJmolAuthorizeChoosingSignedApplet = true / <u>false</u></tt> : Authorize users to choose between the unsigned and the signed Jmol applet.
 +
 
 +
== Managing molecular structure files ==
 +
=== Authorizing uploads ===
 +
If you want to authorize users to upload files containing molecular data (for using the {{Tag|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 {{File|*.cml}} files, add <tt>$wgFileExtensions[] = 'cml';</tt> in {{File|LocalSettings.php}}.
 +
-->
 +
a very limited set of file types, based on file extensions and MIME types (see {{MWmanual|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.
 +
 
 +
<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:
 +
* {{MWmanual|Configuring_file_uploads}}
 +
* {{MWmanual|Mime_type_detection}}
 +
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_administration Image administration]
 +
</blockquote>
 +
 
 +
First, you need to authorize new file extensions being uploaded in the wiki, using {{MWmanual|$wgFileExtensions}}.
 +
For example, if you want to authorize uploading of [[:en:Chemical Markup Language|CML files]] {{File|*.cml}}, you can add the following line in your {{file|LocalSettings.php}} file:
 +
$wgFileExtensions[] = 'cml';
 +
 
 +
By default, the {{MWmanual|Mime_type_detection|MIME type detection}} configuration of MediaWiki only detects molecular files as basic  MIME types (<code>text/plain</code>, <code>application/xml</code>, …). Having a more precise MIME type detection is better, especially for the Media Handler.
 +
For molecular file formats based on XML, the MIME type detection can be enhanced using {{MWmanual|$wgXMLMimeTypes}} which allows the mapping between the root element of the file and the MIME type.
 +
For example, for enhancing detection for [[:en:Chemical Markup Language|CML files]] {{File|*.cml}}, you can add the following lines in 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>
 +
''Note: This description needs to be completed, especially for dealing with MIME types which is quite complex and depends on your server configuration.''
 +
 
 +
By default, MediaWiki checks that the file extension matches the MIME type that has been detected.
 +
For this, MediaWiki uses the {{file|includes/mime.types}} file in MediaWiki installation.
 +
File extensions for molecular models are probably missing from this file by default, so you need to modify it.
 +
For example, {{file|*.cml}} can 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/mime.types}}:
 +
application/xml xml xsl xsd '''cml'''
 +
'''chemical/x-cml cml'''
  
You can configure the Jmol extension with several settings added after the <code>require_once</code> line (default value in '''bold'''):
+
=== File icons ===
* <tt>$wgJmolAuthorizeChoosingSignedApplet</tt> (<tt>true</tt>, '''<tt>false</tt>''') : Authorize users to choose between the unsigned and the signed Jmol applet.
+
[[File:Fileicon_Chemical.png|50px|right|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]]).
* <tt>$wgJmolAuthorizeUploadedFile</tt> ('''<tt>true</tt>''', <tt>false</tt>) : Authorize the use of {{Tag|uploadedFileContents}}.
+
You can add an icon in the {{folder|skins/common/images/icons}} folder for each extension of molecular files (such as {{file|fileicon-cml.png}}).
* <tt>$wgJmolAuthorizeUrl</tt> (<tt>true</tt>, '''<tt>false</tt>''') : Authorize the use of {{Tag|urlContents}}.
 
* <tt>$wgJmolDefaultAppletSize</tt> ('''<tt>400</tt>''') : Size in pixels of the Jmol applet.
 
* <tt>$wgJmolDefaultScript</tt> : Default script.
 
* <tt>$wgJmolExtensionPath ('''extensions/Jmol''')</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 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>$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.''
 
  
 +
== Installation of older versions ==
 +
'''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].
  
'''Note:''' If you want to authorize users to upload files containing molecular data (for using the {{Tag|uploadedFileContents}} tag), you need to do the following:
+
The Jmol Extension below '''version 3.3''' uses another extension, [[mw:Extension:StubManager|Stub Manager]], so you first need to install it.
* 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 {{File|*.cml}} files, add <tt>$wgFileExtensions[] = 'cml';</tt> in {{File|LocalSettings.php}}.
 
* You can add an icon in the {{Directory|skins/common/images/icons/}} directory for each extension (for example, {{File|fileicon-cml.png}}). In this wiki, we are using [[:Image:Fileicon_Chemical.png|this image]], which leads to the [[:Category:Molecular_Data|following result]].
 
  
 
== Deprecated ==
 
== Deprecated ==
Line 53: Line 101:
  
 
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 is not compatible with recent versions of MediaWiki.
 +
 +
= See also =
 +
[[MediaWiki/Extension|How to use the Extension]]

Latest revision as of 10:47, 3 May 2024

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 5 of the Jmol Extension has been tested against MediaWiki 1.32. There are significant changes in MediaWiki, so this procedure will not work with older versions. It is not compatible either with newest versions of MediaWiki.

To install the Jmol extension using Jmol 14

  1. Download the release of Jmol (Jmol-14.xx.xx-binary.zip) You need version 14.29.32 or later.
  2. Extract into a temporary location the File icon.gifjsmol.zip file from the Jmol release.
  3. Create a Folder icon.gifJmol subfolder in the Folder icon.gifextensions folder of your MediaWiki installation.
  4. Extract (upload) into this Folder icon.gifJmol folder the following contents from the File icon.gifjsmol.zip file:
    • the File icon.gifJSmol.min.js file,
    • the File icon.gifJSmol.GLmol.min.js file,
    • the Folder icon.gifj2s, Folder icon.gifphp and Folder icon.gifidioma folders (the latter one may not exist in latest Jmol versions).

To install the Jmol extension using Jmol 16

  1. Download the latest release of Jmol (Jmol-16.xx.xx-binary.zip) Good compatibility may be expected, but the Extension has not been tested yet against Jmol 16.
  2. Extract into a temporary location the File icon.gifjsmol.zip file from the Jmol release.
  3. Create a Folder icon.gifJmol subfolder in the Folder icon.gifextensions folder of your MediaWiki installation.
  4. Extract (upload) into this Folder icon.gifJmol folder the following contents from the File icon.gifjsmol.zip file (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. Note: if the latter folder contains a File icon.gifjsmol2.php file, rename it to File icon.gifjsmol.php before uploading.
    • the Folder icon.gifidioma folder, if present (at least until version 16.1.39); this is used to support language localization.

Further steps

  1. Download all the source files of the Jmol extension and place them in the extensions/Jmol folder.
  2. Add the following line to your LocalSettings.php file (near the end): require_once("extensions/Jmol/Jmol.php");
  3. Optional change of settings:

You can configure the Jmol extension with several settings added after the require_once line (default value underlined):

  • $wgJmolAuthorizeJmolTag = true / false : Authorize the use of the <jmol/> tag.
  • $wgJmolAuthorizeJmolFileTag = true / false : Authorize the use of the <jmolFile/> tag.
  • $wgJmolAuthorizeJmolPdbTag = true / false : Authorize the use of the <jmolPdb/> tag.
  • $wgJmolAuthorizeJmolSmilesTag = true / false : Authorize the use of the <jmolSmiles/> tag.
  • $wgJmolAuthorizeUploadedFile = true / false : Authorize the use of <uploadedFileContents>.
  • $wgJmolAuthorizeUrl = true / false : Authorize the use of <urlContents>.
  • $wgJmolDefaultAppletSize = 400 : Size in pixels of the JSmol panel.
  • $wgJmolDefaultScript = ... : Default script.
  • $wgJmolExtensionPath = "extensions/Jmol" : 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 $wgScriptPath (see example in Jmol.php).
  • $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.
  • Deprecated:
    • $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.
    • $wgJmolAuthorizeChoosingSignedApplet = true / false : Authorize users to choose between the unsigned and the signed Jmol applet.

Managing molecular structure files

Authorizing uploads

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 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.

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:

First, you need to authorize new file extensions being uploaded in the wiki, using $wgFileExtensions . For example, if you want to authorize uploading of CML files File icon.gif*.cml, you can add the following line in your File icon.gifLocalSettings.php file:

$wgFileExtensions[] = 'cml';

By default, the MIME type detection configuration of MediaWiki only detects molecular files as basic MIME types (text/plain, application/xml, …). Having a more precise MIME type detection is better, especially for the Media Handler. For molecular file formats based on XML, the MIME type detection can be enhanced using $wgXMLMimeTypes which allows the mapping between the root element of the file and the MIME type. For example, for enhancing detection for CML files File icon.gif*.cml, you can add the following lines in your File icon.gifLocalSettings.php file:

$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' ) );

Note: This description needs to be completed, especially for dealing with MIME types which is quite complex and depends on your server configuration.

By default, MediaWiki checks that the file extension matches the MIME type that has been detected. For this, MediaWiki uses the File icon.gifincludes/mime.types file in MediaWiki installation. File extensions for molecular models are probably missing from this file by default, so you need to modify it. For example, File icon.gif*.cml can be detected as chemical/x-cml or application/xml (depending on your MIME type detection configuration), so you need to make the following additions to File icon.gifincludes/mime.types:

application/xml xml xsl xsd cml
chemical/x-cml cml

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 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.

Deprecated

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

That page has been removed since the Jmol Extension is not compatible with recent versions of MediaWiki.

See also

How to use the Extension

Contributors

AngelHerraez