Physikerwelt has submitted this change and it was merged.
Change subject: Little improvements in MathDebug
......................................................................
Little improvements in MathDebug
Change-Id: I7a9859d3fee140138bf287d859b27ade0cdbd4b9
---
M .gitignore
M MathSearch.i18n.php
M MathSearch.php
M SpecialMathDebug.php
M db/mathobservation.sql
M db/mathpagestat.sql
M db/mathsearch.sql
M db/mathvarstat.sql
8 files changed, 111 insertions(+), 85 deletions(-)
Approvals:
Physikerwelt: Verified; Looks good to me, approved
diff --git a/.gitignore b/.gitignore
index 98b092a..60f70f7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,7 @@
*~
*.kate-swp
.*.swp
+.project
+.settings
+.buildpath
+nbproject
diff --git a/MathSearch.i18n.php b/MathSearch.i18n.php
index bbb7309..14fd2e4 100644
--- a/MathSearch.i18n.php
+++ b/MathSearch.i18n.php
@@ -18,6 +18,15 @@
'getequationsbyquery' => 'Get equations by query', // Special page
'xquerygenerator' => 'X-query generator', // Special page
'mathdebug' => 'Test Renderer', // Special page
+ 'mathmode_0' => 'MW_MATH_PNG',
+ 'mathmode_1' => 'MW_MATH_SIMPLE',
+ 'mathmode_2' => 'MW_MATH_HTML',
+ 'mathmode_3' => 'MW_MATH_SOURCE',
+ 'mathmode_4' => 'MW_MATH_MODERN',
+ 'mathmode_5' => 'MW_MATH_MATHML',
+ 'mathmode_6' => 'MW_MATH_MATHJAX',
+ 'mathmode_7' => 'MW_MATH_LATEXML',
+ 'mathmode_7+' => 'MW_MATH_LATEXML_JAX', //TODO: Remove that construct
);
/** Message documentation (Message documentation)
diff --git a/MathSearch.php b/MathSearch.php
index 39a880f..75613de 100644
--- a/MathSearch.php
+++ b/MathSearch.php
@@ -57,4 +57,6 @@
$wgSpecialPages['MathIndex'] = 'SpecialMathIndex';
$wgHooks['LoadExtensionSchemaUpdates'][] =
'MathSearchHooks::onLoadExtensionSchemaUpdates';
-$wgHooks['MathFormulaRendered'][] = 'MathSearchHooks::onMathFormulaRendered';
\ No newline at end of file
+$wgHooks['MathFormulaRendered'][] = 'MathSearchHooks::onMathFormulaRendered';
+
+$wgGroupPermissions['user']['MathDebug'] = true;
\ No newline at end of file
diff --git a/SpecialMathDebug.php b/SpecialMathDebug.php
index e5f7d6f..4d1bb1d 100644
--- a/SpecialMathDebug.php
+++ b/SpecialMathDebug.php
@@ -3,7 +3,7 @@
function __construct() {
- parent::__construct( 'MathDebug', 'edit', true );
+ parent::__construct( 'MathDebug', 'MathDebug', true );
}
/**
* Sets headers - this should be called from the execute() method of
all derived classes!
@@ -111,19 +111,24 @@
global $wgUseMathJax, $wgUseLaTeXML, $wgTexvc;
$out = $this->getOutput();
$out->addModules( array( 'ext.math.mathjax.enabler' ) );
+ $out->addModules( array( 'ext.math.mathjax.enabler.mml' ) );
// die('END');
$i = 0;
foreach ( array_slice( self::getMathTagsFromPage( $page ),
$offset, $length, true ) as $key => $t ) {
$out->addWikiText( "=== Test #" . ( $offset + $i++ ) .
": $key === " );
$out->addHTML( self::render( $t, MW_MATH_SOURCE ) );
$out->addHTML( self::render( $t, MW_MATH_PNG ) );
- $out->addWikiText( '<source lang="latex">' .
$this->getTexvcTex( $t ) . '</source>' );
+ $out->addWikiText( 'Texvc`s TeX output:<source
lang="latex">' . $this->getTexvcTex( $t ) . '</source>');
if ( $wgUseLaTeXML ) {
$out->addHTML( self::render( $t,
MW_MATH_LATEXML ) );
}
if ( $wgUseMathJax ) {
$out->addHTML( self::render( $t,
MW_MATH_MATHJAX, false ) );
}
+ if ( $wgUseMathJax && $wgUseMathJax) {
+ $out->addHTML( self::render( $t, '7+', false )
); //TODO: Update the name
+ }
+
}
}
@@ -155,11 +160,13 @@
return true;
}
private static function render( $t, $mode, $aimJax = true ) {
- $renderer = MathRenderer::getRenderer( $t, array(), $mode );
+ $modeInt= (int) substr($mode, 0,1);
+ $renderer = MathRenderer::getRenderer( $t, array(), $modeInt );
$renderer->setPurge( true );
$fragment = $renderer->render();
- $res = $mode . ':' . $fragment;
- wfDebugLog( 'MathSearch', 'rendered:' . $res );
+ $modeStr = wfMessage('mathmode_'.$mode)->inContentLanguage();
+ $res = $modeStr . ':' . $fragment;
+ wfDebugLog( 'MathSearch', 'rendered:' . $res . ' in mode '.
$modeStr . '('.$mode.')');
if ( $aimJax ) {
self::aimHTMLFromJax( $res );
}
@@ -172,6 +179,7 @@
private static function getMathTagsFromPage( $titleString = 'Testpage'
) {
$title = Title::newFromText( $titleString );
+ if ($title->exists()){
$article = new Article( $title );
// TODO: find a better way to extract math elements from a page
$wikiText = $article->getPage()->getContent()->getNativeData();
@@ -180,7 +188,10 @@
$matches = preg_match_all( "#<math>(.*?)</math>#s", $wikiText,
$math );
// TODO: Find a way to specify a key e.g
'\nRenderTest:(.?)#<math>(.*?)</math>#s\n'
// leads to array('\1'->'\2') with \1 eg Bug 2345 and \2 the
math content
- return $math[1];
+ return $math[1];}
+ else {
+ return 'Page does not exist';
+ }
}
private function getTexvcTex( $tex ) {
$tmpDir = wfTempDir();
diff --git a/db/mathobservation.sql b/db/mathobservation.sql
index b4bb747..21db97e 100644
--- a/db/mathobservation.sql
+++ b/db/mathobservation.sql
@@ -1,22 +1,22 @@
---
--- Used by the math search module to analyse the variables in the equations.
---
-CREATE TABLE /*_*/mathobservation (
-
- -- Reference to
- -- Binary MD5 hash of the latex fragment, used as an identifier key.
- mathobservation_inputhash varbinary(16) NOT NULL,
-
- --Type of the feature e.g. mo, mi
- mathobservation_featuretype varchar(10) NOT NULL,
-
- --Name of the feature. eg name of the variable
- mathobservation_featurename varchar(10) NOT NULL,
-
- -- Timestamp. Is set by the database autmatically
- mathobservation_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP
-
-) /*$wgDBTableOptions*/;
-
- CREATE INDEX /*i*/mathobservation_inputhash ON mathobservation
(mathobservation_inputhash);
- CREATE INDEX /*i*/mathobservation_featurename ON mathobservation
(mathobservation_featurename);
+--
+-- Used by the math search module to analyse the variables in the equations.
+--
+CREATE TABLE /*_*/mathobservation (
+
+ -- Reference to
+ -- Binary MD5 hash of the latex fragment, used as an identifier key.
+ mathobservation_inputhash varbinary(16) NOT NULL,
+
+ --Type of the feature e.g. mo, mi
+ mathobservation_featuretype varchar(10) NOT NULL,
+
+ --Name of the feature. eg name of the variable
+ mathobservation_featurename varchar(10) NOT NULL,
+
+ -- Timestamp. Is set by the database autmatically
+ mathobservation_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON
UPDATE CURRENT_TIMESTAMP
+
+) /*$wgDBTableOptions*/;
+
+ CREATE INDEX /*i*/mathobservation_inputhash ON mathobservation
(mathobservation_inputhash);
+ CREATE INDEX /*i*/mathobservation_featurename ON mathobservation
(mathobservation_featurename);
diff --git a/db/mathpagestat.sql b/db/mathpagestat.sql
index a4ab835..d54e779 100644
--- a/db/mathpagestat.sql
+++ b/db/mathpagestat.sql
@@ -1,11 +1,11 @@
---
--- Used by the math search module to analyse the variables in the equations.
---
-CREATE TABLE /*_*/mathpagestat (
- pagestat_pageid int(10) NOT NULL,
- pagestat_featureid int(6) NOT NULL,
- pagestat_featurecount int(11) NOT NULL,
- PRIMARY KEY (pagestat_pageid,pagestat_featureid),
- KEY `pagestat_pageid` (`pagestat_pageid`)
-) /*$wgDBTableOptions*/;
-
+--
+-- Used by the math search module to analyse the variables in the equations.
+--
+CREATE TABLE /*_*/mathpagestat (
+ pagestat_pageid int(10) NOT NULL,
+ pagestat_featureid int(6) NOT NULL,
+ pagestat_featurecount int(11) NOT NULL,
+ PRIMARY KEY (pagestat_pageid,pagestat_featureid),
+ KEY `pagestat_pageid` (`pagestat_pageid`)
+) /*$wgDBTableOptions*/;
+
diff --git a/db/mathsearch.sql b/db/mathsearch.sql
index 931aec6..9037048 100644
--- a/db/mathsearch.sql
+++ b/db/mathsearch.sql
@@ -1,35 +1,35 @@
---
--- Used by the math module to keep track
--- of previously-rendered items.
---
-CREATE TABLE /*_*/mathindex (
-
- -- Page id where the equation was found.
- mathindex_page_id int(10) unsigned NOT NULL,
-
- -- Position of the equation on the page
- -- Starting from 0 at the top of the page
- mathindex_anchor int(6) unsigned NOT NULL,
-
- -- Reference to
- -- Binary MD5 hash of the latex fragment, used as an identifier key.
- mathindex_inputhash varbinary(16) NOT NULL,
-
- -- Timestamp. Is set by the database autmatically
- mathindex_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP,
-
- PRIMARY KEY (mathindex_page_id,mathindex_anchor)
-
-
-) /*$wgDBTableOptions*/;
-
- CREATE INDEX /*i*/mathindex_inputhash ON mathindex (mathindex_inputhash);
- CREATE INDEX /*i*/mathindex_page_id ON mathindex (mathindex_page_id);
-
---
--- RELATIONEN DER TABELLE `mathindex`:
--- `inputhash`
--- `math` -> `math_inputhash`
--- `pageid`
--- `page` -> `page_id`
+--
+-- Used by the math module to keep track
+-- of previously-rendered items.
+--
+CREATE TABLE /*_*/mathindex (
+
+ -- Page id where the equation was found.
+ mathindex_page_id int(10) unsigned NOT NULL,
+
+ -- Position of the equation on the page
+ -- Starting from 0 at the top of the page
+ mathindex_anchor int(6) unsigned NOT NULL,
+
+ -- Reference to
+ -- Binary MD5 hash of the latex fragment, used as an identifier key.
+ mathindex_inputhash varbinary(16) NOT NULL,
+
+ -- Timestamp. Is set by the database autmatically
+ mathindex_timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP,
+
+ PRIMARY KEY (mathindex_page_id,mathindex_anchor)
+
+
+) /*$wgDBTableOptions*/;
+
+ CREATE INDEX /*i*/mathindex_inputhash ON mathindex (mathindex_inputhash);
+ CREATE INDEX /*i*/mathindex_page_id ON mathindex (mathindex_page_id);
+
+--
+-- RELATIONEN DER TABELLE `mathindex`:
+-- `inputhash`
+-- `math` -> `math_inputhash`
+-- `pageid`
+-- `page` -> `page_id`
--
\ No newline at end of file
diff --git a/db/mathvarstat.sql b/db/mathvarstat.sql
index d30d06b..daeb61c 100644
--- a/db/mathvarstat.sql
+++ b/db/mathvarstat.sql
@@ -1,11 +1,11 @@
---
--- Used by the math search module to analyse the variables in the equations.
---
-CREATE TABLE /*_*/mathvarstat (
- varstat_id smallint(6) NOT NULL AUTO_INCREMENT,
- varstat_featurename varchar(10) NOT NULL,
- varstat_featuretype varchar(10) NOT NULL,
- varstat_featurecount int(11) NOT NULL,
- PRIMARY KEY (`varstat_id`),
- UNIQUE KEY `varstat_featurename`
(`varstat_featurename`,`varstat_featuretype`)
-) /*$wgDBTableOptions*/;
+--
+-- Used by the math search module to analyse the variables in the equations.
+--
+CREATE TABLE /*_*/mathvarstat (
+ varstat_id smallint(6) NOT NULL AUTO_INCREMENT,
+ varstat_featurename varchar(10) NOT NULL,
+ varstat_featuretype varchar(10) NOT NULL,
+ varstat_featurecount int(11) NOT NULL,
+ PRIMARY KEY (`varstat_id`),
+ UNIQUE KEY `varstat_featurename`
(`varstat_featurename`,`varstat_featuretype`)
+) /*$wgDBTableOptions*/;
--
To view, visit https://gerrit.wikimedia.org/r/74153
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7a9859d3fee140138bf287d859b27ade0cdbd4b9
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits