Jump to content

Extension:WolframCDF: Difference between revisions

From mediawiki.org
Content deleted Content added
translation tweaks
m Update syntaxhighlight tags - remove use of deprecated <source> tags
Line 38: Line 38:
==Installation==
==Installation==
To install this extension, place the wolfram_cdf directory in your extensions directory, and add the following to {{ll|Manual:LocalSettings.php|LocalSettings.php}}:
To install this extension, place the wolfram_cdf directory in your extensions directory, and add the following to {{ll|Manual:LocalSettings.php|LocalSettings.php}}:
<source lang="php">
<syntaxhighlight lang="php">
require_once("$IP/extensions/wolfram_cdf/CDF.php");
require_once("$IP/extensions/wolfram_cdf/CDF.php");
</syntaxhighlight>
</source>
Note that, in order to actually upload and use .cdf files, you will need to ensure that file uploads are enabled (<code>$wgEnableUploads</code> is <code>true</code>) and cdf extensions are allowed. For example:
Note that, in order to actually upload and use .cdf files, you will need to ensure that file uploads are enabled (<code>$wgEnableUploads</code> is <code>true</code>) and cdf extensions are allowed. For example:
<source lang="php">
<syntaxhighlight lang="php">
$wgEnableUploads = true;
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgUseImageMagick = true;
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'txt', 'cdf' );
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'txt', 'cdf' );
</syntaxhighlight>
</source>
You may also need to either ensure that your webserver serves up .cdf files as <code>application/x-netcdf</code> or, if that is not possible, you may need to modify <code>$IP/includes/mime.types</code> to contain
You may also need to either ensure that your webserver serves up .cdf files as <code>application/x-netcdf</code> or, if that is not possible, you may need to modify <code>$IP/includes/mime.types</code> to contain


Line 63: Line 63:


For example, your {{ll|Manual:LocalSettings.php|LocalSettings.php}} file may contain:
For example, your {{ll|Manual:LocalSettings.php|LocalSettings.php}} file may contain:
<source lang="php">
<syntaxhighlight lang="php">
require_once("$IP/extensions/wolfram_cdf/CDF.php");
require_once("$IP/extensions/wolfram_cdf/CDF.php");
$wgCDFAllowExternalURLs = false;
$wgCDFAllowExternalURLs = false;
$wgCDFShowDownloadLink = true;
$wgCDFShowDownloadLink = true;
</syntaxhighlight>
</source>


The following css classes can also be used to apply styling to the html generated by this extension:
The following css classes can also be used to apply styling to the html generated by this extension:

Revision as of 03:19, 15 April 2020

MediaWiki extensions manual
WolframCDF
Release status: beta
Implementation Tag
Description Shows Wolfram CDF files in wiki pages.
Author(s) TWtalk
Latest version 0.2.1 (Goodge Street) (2012-04-25)
MediaWiki 1.18+ (requires 'position' support in ResourceLoader)
  • $wgCDFAllowExternalURLs
  • $wgCDFShowDownloadLink
‎<cdf>
Licence GNU General Public License 3.0 or later
Download

Description

Allows Wolfram CDF files (interactive content generated by Wolfram Mathematica) to be shown in wiki pages.

Usage

The basic syntax for the cdf extension is:

<cdf width="width in pixels" height="height in pixels">filename</cdf>

When specifying the filename, you do not need to include the `File:` namespace in the filename - it will work with or without it. If enabled, you may also provide an absolute URL instead of a filename to show a CDF file from another server.

Examples:

<cdf width="650" height="400">SomeExample.cdf</cdf>
<cdf width="565" height="589">http://demonstrations.wolfram.com/HobermanCube/HobermanCube.cdf</cdf>

Note that the second example above will only work if $wgCDFAllowExternalURLs is set to true; the default is to not show external URLs.

Download instructions

To download the extension, you may obtain a zip of the latest code from the download link in the infobox. Alternatively, you may clone the git repository with the following command:

git clone git://github.com/TheWatcher/wolfram_cdf.git

Installation

To install this extension, place the wolfram_cdf directory in your extensions directory, and add the following to LocalSettings.php :

require_once("$IP/extensions/wolfram_cdf/CDF.php");

Note that, in order to actually upload and use .cdf files, you will need to ensure that file uploads are enabled ($wgEnableUploads is true) and cdf extensions are allowed. For example:

$wgEnableUploads  = true;
$wgUseImageMagick = true;
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'txt', 'cdf' );

You may also need to either ensure that your webserver serves up .cdf files as application/x-netcdf or, if that is not possible, you may need to modify $IP/includes/mime.types to contain

text/plain txt cdf

This should only be done in exceptional circumstances, however!

Parameters

The following parameters can be set in the LocalSettings.php file:

$wgCDFAllowExternalURLs
If this is set to true (the default is false) then <cdf> tags may contain URLs to load .cdf files from other web servers. This should be enabled with caution, as it may have security implications!
$wgCDFShowDownloadLink
If set to true (the default is false), the extension will place a 'Click here to download this CDF' link beneath each CDF box to allow users to save a copy of the CDF for offline use.

For example, your LocalSettings.php file may contain:

require_once("$IP/extensions/wolfram_cdf/CDF.php");
$wgCDFAllowExternalURLs = false;
$wgCDFShowDownloadLink = true;

The following css classes can also be used to apply styling to the html generated by this extension:

div.cdf
Each CDF box is contained within a div with this class
div.cdflink
If $wgCDFShowDownloadLink is true, the CDF download link is placed in a div with this class.