Rename some global variables that violate the naming convention

* $wg(.*) variables from extension should start with the extension name
    i.e. for extension Math $wgMath(.*)
* But keep $wgUseMathJax, because it has been used for 2 years now.
* Add release notes

Change-Id: Ib70a9f7767890cc4618bc10c2610784f5b17e670
This commit is contained in:
physikerwelt 2014-01-26 00:43:41 +00:00 committed by Physikerwelt
parent 52d206c4b4
commit dd4f911d87
4 changed files with 33 additions and 20 deletions

View file

@ -96,6 +96,8 @@ $wgMathDirectory = false;
* that's scalable for zooming, printing, and high-resolution displays.
*
* Not guaranteed to be stable at this time.
*
* @todo Rename to $wgMathJax
*/
$wgUseMathJax = false;
@ -104,15 +106,15 @@ $wgUseMathJax = false;
* <http://latexml.mathweb.org/help>
*
* If you want or need to run your own server, follow these installation
* instructions and override $wgLaTeXMLUrl:
* <https://svn.mathweb.org/repos/LaTeXML/branches/arXMLiv/INSTALL>
* instructions and override $wgMathLaTeXMLUrl:
* <http://www.formulasearchengine.com/LaTeXML>
*
* If you expect heavy load you can specify multiple servers. In that case one
* server is randomly chosen for each rendering process. Specify the list of
* servers in an array e.g $wgLaTeXMLUrl = array ( 'http://latexml.example.com/convert',
* servers in an array e.g $wgMathLaTeXMLUrl = array ( 'http://latexml.example.com/convert',
* 'http://latexml2.example.com/convert');
*/
$wgLaTeXMLUrl = 'http://latexml.mathweb.org/convert';
$wgMathLaTeXMLUrl = 'http://latexml.mathweb.org/convert';
/**
* Allows to use LaTeXML as renderer for mathematical equation.
@ -123,12 +125,12 @@ $wgUseLaTeXML = false;
* The timeout for the HTTP-Request sent to the LaTeXML to render an equation,
* in seconds.
*/
$wgLaTeXMLTimeout = 240;
$wgMathLaTeXMLTimeout = 240;
/**
* Setting for the LaTeXML renderer.
* See http://dlmf.nist.gov/LaTeXML/manual/commands/latexmlpost.xhtml for details.
*/
$wgDefaultLaTeXMLSetting = 'format=xhtml&whatsin=math&whatsout=math&pmml&cmml&nodefaultresources&preload=LaTeX.pool&preload=article.cls&preload=amsmath.sty&preload=amsthm.sty&preload=amstext.sty&preload=amssymb.sty&preload=eucal.sty&preload=[dvipsnames]xcolor.sty&preload=url.sty&preload=hyperref.sty&preload=[ids]latexml.sty&preload=texvc';
$wgMathDefaultLaTeXMLSetting = 'format=xhtml&whatsin=math&whatsout=math&pmml&cmml&nodefaultresources&preload=LaTeX.pool&preload=article.cls&preload=amsmath.sty&preload=amsthm.sty&preload=amstext.sty&preload=amssymb.sty&preload=eucal.sty&preload=[dvipsnames]xcolor.sty&preload=url.sty&preload=hyperref.sty&preload=[ids]latexml.sty&preload=texvc';
/**
* The link to the texvc executable
*/

View file

@ -35,15 +35,15 @@ class MathLaTeXML extends MathRenderer {
}
/**
* Gets the settings for the LaTeXML daemon.
*
* @global type $wgMathDefaultLaTeXMLSetting
* @return string
*/
public function getLaTeXMLSettings() {
global $wgDefaultLaTeXMLSetting;
global $wgMathDefaultLaTeXMLSetting;
if ( $this->LaTeXMLSettings ) {
return $this->LaTeXMLSettings;
} else {
return $wgDefaultLaTeXMLSetting;
return $wgMathDefaultLaTeXMLSetting;
}
}
@ -106,10 +106,11 @@ class MathLaTeXML extends MathRenderer {
/**
* Performs a HTTP Post request to the given host.
* Uses $wgLaTeXMLTimeout as timeout.
* Uses $wgMathLaTeXMLTimeout as timeout.
* Generates error messages on failure
* @see Http::post()
*
* @global type $wgMathLaTeXMLTimeout
* @param string $host
* @param string $post the encoded post request
* @param mixed $res the result
@ -118,12 +119,12 @@ class MathLaTeXML extends MathRenderer {
* @return boolean success
*/
public function makeRequest( $host, $post, &$res, &$error = '', $httpRequestClass = 'MWHttpRequest' ) {
global $wgLaTeXMLTimeout;
global $wgMathLaTeXMLTimeout;
wfProfileIn( __METHOD__ );
$error = '';
$res = null;
$options = array( 'method' => 'POST', 'postData' => $post, 'timeout' => $wgLaTeXMLTimeout );
$options = array( 'method' => 'POST', 'postData' => $post, 'timeout' => $wgMathLaTeXMLTimeout );
$req = $httpRequestClass::factory( $host, $options );
$status = $req->execute();
if ( $status->isGood() ) {
@ -136,7 +137,7 @@ class MathLaTeXML extends MathRenderer {
$res = false;
wfDebugLog( "Math", "\nLaTeXML Timeout:"
. var_export( array( 'post' => $post, 'host' => $host
, 'wgLaTeXMLTimeout' => $wgLaTeXMLTimeout ), true ) . "\n\n" );
, 'timeout' => $wgMathLaTeXMLTimeout ), true ) . "\n\n" );
} else {
// for any other unkonwn http error
$errormsg = $status->getHtml();
@ -162,15 +163,15 @@ class MathLaTeXML extends MathRenderer {
/**
* Picks a LaTeXML daemon.
* If more than one demon are availible one is chosen from the
* $wgLaTeXMLUrl array.
* $wgMathLaTeXMLUrl array.
* @return string
*/
private static function pickHost() {
global $wgLaTeXMLUrl;
if ( is_array( $wgLaTeXMLUrl ) ) {
$host = array_rand( $wgLaTeXMLUrl );
global $wgMathLaTeXMLUrl;
if ( is_array( $wgMathLaTeXMLUrl ) ) {
$host = array_rand( $wgMathLaTeXMLUrl );
} else {
$host = $wgLaTeXMLUrl;
$host = $wgMathLaTeXMLUrl;
}
wfDebugLog( "Math", "picking host " . $host );
return $host;

10
RELEASE-NOTES-2.0 Normal file
View file

@ -0,0 +1,10 @@
== Math 2.0 ==
THIS IS NOT A RELEASE YET
Math 2.0 is an alpha-quality branch and is not recommended for use in
production.
=== Configuration changes in 2.0 ===
* $wgLaTeXMLUrl was renamed to $wgMathLaTeXMLUrl
* $wgLaTeXMLUrl was renamed to $wgMathLaTeXMLTimeout

View file

@ -125,8 +125,8 @@ class MathLaTeXMLTest extends MediaWikiTestCase {
* i.e. if the span element is generated right.
*/
public function testIntegration() {
global $wgLaTeXMLTimeout;
$wgLaTeXMLTimeout = 20;
global $wgMathLaTeXMLTimeout;
$wgMathLaTeXMLTimeout = 20;
$renderer = MathRenderer::getRenderer( "a+b", array(), MW_MATH_LATEXML );
$real = $renderer->render( true );
$expected = '<span class="tex" dir="ltr" id="a_b"><math xmlns="http://www.w3.org/1998/Math/MathML" id="p1.1.m1" class="ltx_Math" alttext="a+b" display="inline" xml:id="p1.1.m1.1" xref="p1.1.m1.1.cmml"> <semantics xml:id="p1.1.m1.1a" xref="p1.1.m1.1.cmml"> <mrow xml:id="p1.1.m1.1.4" xref="p1.1.m1.1.4.cmml"> <mi xml:id="p1.1.m1.1.1" xref="p1.1.m1.1.1.cmml">a</mi> <mo xml:id="p1.1.m1.1.2" xref="p1.1.m1.1.2.cmml">+</mo> <mi xml:id="p1.1.m1.1.3" xref="p1.1.m1.1.3.cmml">b</mi> </mrow> <annotation-xml encoding="MathML-Content" xml:id="p1.1.m1.1.cmml" xref="p1.1.m1.1"> <apply xml:id="p1.1.m1.1.4.cmml" xref="p1.1.m1.1.4"> <plus xml:id="p1.1.m1.1.2.cmml" xref="p1.1.m1.1.2"/> <ci xml:id="p1.1.m1.1.1.cmml" xref="p1.1.m1.1.1">a</ci> <ci xml:id="p1.1.m1.1.3.cmml" xref="p1.1.m1.1.3">b</ci> </apply> </annotation-xml> <annotation encoding="application/x-tex" xml:id="p1.1.m1.1b" xref="p1.1.m1.1.cmml">a+b</annotation> </semantics> </math></span>';