Physikerwelt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/189233
Change subject: Add special-page to display topics and mquery tag
......................................................................
Add special-page to display topics and mquery tag
* Adds a the special page Special:DisplayTopics
* Introduces a new tag <mquery> that displays
LaTeXML and MWS queries
Change-Id: Idf9729a5aaef5c3dad1de1d60f5a55d707efe21e
---
M MathSearch.hooks.php
M MathSearch.php
M includes/special/SpecialDisplayTopics.php
3 files changed, 59 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch
refs/changes/33/189233/1
diff --git a/MathSearch.hooks.php b/MathSearch.hooks.php
index 77574ab..b68c4d5 100644
--- a/MathSearch.hooks.php
+++ b/MathSearch.hooks.php
@@ -230,4 +230,45 @@
) );
} );
}
+
+ /**
+ * Register the <mquery> tag with the Parser.
+ *
+ * @param $parser Parser instance of Parser
+ * @return Boolean: true
+ */
+ static function onParserFirstCallInit( $parser ) {
+ $parser->setHook( 'mquery', array( 'MathSearchHooks',
'mQueryTagHook' ) );
+ wfDebugLog('MathSearch','mquery tag registered');
+ return true;
+ }
+
+ /**
+ * Callback function for the <mquery> parser hook.
+ *
+ * @param $content (the LaTeX+MWS query input)
+ * @param $attributes
+ * @param Parser $parser
+ * @return array
+ */
+ static function mQueryTagHook( $content, $attributes, $parser ) {
+ global $wgMathDefaultLaTeXMLSetting;
+ if ( trim( $content ) === '' ) { // bug 8372
+ return '';
+ }
+ wfDebugLog('MathSearch','Render mquery tag.');
+ wfProfileIn( __METHOD__ );
+ //TODO: Report %\n problem to LaTeXML upstream
+ $content = preg_replace( '/%\n/', '', $content );
+ $renderer = new MathLaTeXML( $content );
+ $mQuerySettings = $wgMathDefaultLaTeXMLSetting;
+ $mQuerySettings['preload'][] = 'mws.sty';
+ $renderer->setLaTeXMLSettings($mQuerySettings);
+ $renderer->render( );
+ $renderedMath = $renderer->getHtmlOutput();
+ wfProfileOut( __METHOD__ );
+
+ return array( $renderedMath, "markerType" => 'nowiki' );
+ }
+
}
diff --git a/MathSearch.php b/MathSearch.php
index 8a2ffa1..9499fbf 100644
--- a/MathSearch.php
+++ b/MathSearch.php
@@ -48,7 +48,7 @@
$wgAutoloadClasses['GetEquationsByQuery'] = $dir . 'GetEquationsByQuery.php';
$wgAutoloadClasses['SpecialMathDebug'] = $dir . 'SpecialMathDebug.php';
$wgAutoloadClasses['SpecialMathIndex'] = $dir . 'SpecialMathIndex.php';
-$wgAutoloadClasses['SpecialDisplayTopic'] = $dir .
'/includes/special/SpecialDisplayTopic.php';
+$wgAutoloadClasses['SpecialDisplayTopics'] = $dir .
'/includes/special/SpecialDisplayTopics.php';
$wgAutoloadClasses['MathEngineMws'] = $dir .
'/includes/engines/MathEngineMws.php';
$wgAutoloadClasses['MathEngineDB2'] = $dir .
'/includes/engines/MathEngineDB2.php';
$wgAutoloadClasses['MathEngineBaseX'] = $dir .
'/includes/engines/MathEngineBaseX.php';
@@ -67,20 +67,21 @@
$wgSpecialPageGroups['XQueryGenerator'] = 'mathsearch';
$wgSpecialPageGroups['MathDebug'] = 'mathsearch';
$wgSpecialPageGroups['MathIndex'] = 'mathsearch';
-$wgSpecialPageGroups['DisplayTopic'] = 'mathsearch';
+$wgSpecialPageGroups['DisplayTopics'] = 'mathsearch';
$wgSpecialPages['MathSearch'] = 'SpecialMathSearch';
$wgSpecialPages['FormulaInfo'] = 'FormulaInfo';
$wgSpecialPages['GetEquationsByQuery'] = 'GetEquationsByQuery';
$wgSpecialPages['MathDebug'] = 'SpecialMathDebug';
$wgSpecialPages['MathIndex'] = 'SpecialMathIndex';
-$wgSpecialPages['DisplayTopic'] = 'SpecialDisplayTopic';
+$wgSpecialPages['DisplayTopics'] = 'SpecialDisplayTopics';
$wgAPIModules['mathquery'] = 'MathSearchApi';
$wgHooks['LoadExtensionSchemaUpdates'][] =
'MathSearchHooks::onLoadExtensionSchemaUpdates';
$wgHooks['MathFormulaRendered']['updateIndex'] =
'MathSearchHooks::updateMathIndex';
$wgHooks['MathFormulaRendered']['addLink'] =
'MathSearchHooks::addLinkToFormulaInfoPage';
$wgHooks['UnitTestsList'][] = 'MathSearchHooks::onRegisterUnitTests';
+$wgHooks['ParserFirstCallInit'][] = 'MathSearchHooks::onParserFirstCallInit';
$wgGroupPermissions['user']['MathDebug'] = true;
diff --git a/includes/special/SpecialDisplayTopics.php
b/includes/special/SpecialDisplayTopics.php
index a4f51b1..9460827 100644
--- a/includes/special/SpecialDisplayTopics.php
+++ b/includes/special/SpecialDisplayTopics.php
@@ -29,12 +29,22 @@
throw new PermissionsError( 'mathwmcsubmit' );
}
- $this->getOutput()->addWikiText( wfMessage(
'math-wmc-Introduction' )->text() );
+ $this->getOutput()->addWikiText( wfMessage( 'math-wmc-Queries'
)->text() );
$dbw = wfGetDB( DB_MASTER );
- $cols = arraay('qId','fId');
- $res = $dbw->query( 'select * from math_wmc_query_summary ' );
+ $cols = array('#','fId','query','inputtex');
+ $res = $dbw->query( <<<'SQL'
+SELECT
+ qId,
+ concat('[[Special:Permalink/', oldId, '#math.', oldId, '.', fId, '|',
p.page_title, '-',fId, ']]'),
+ concat('<mquery>', texQuery, '</mquery>' ),
+ concat('<math>', math_inputtex, '</math>')
+FROM math_wmc_ref ref
+ NATURAL JOIN mathlatexml L
+ JOIN revision rev ON ref.oldId = rev.rev_id
+ JOIN page p on rev.rev_page = p.page_id
+SQL
+);
$this->getOutput()->addWikiText(
MathSearchUtils::dbRowToWikiTable($res,$cols) );
-
}
}
--
To view, visit https://gerrit.wikimedia.org/r/189233
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idf9729a5aaef5c3dad1de1d60f5a55d707efe21e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits