Paladox has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/228273

Change subject: Update MathSearch tests
......................................................................

Update MathSearch tests

Uses the new npm test

Adds composer test. ( I Will do a follow up with php code sniffer )

Change-Id: Ib530ea6ae0dfe3ee48cc544508ce7522007e3961
---
A .jscsrc
A .jshintignore
A .jshintrc
A Gruntfile.js
M MathSearch.hooks.php
M MathSearch.php
A composer.json
A extension.json
A package.json
M runTestsOnVagrant
M tests/MwsDumpWriterTest.php
11 files changed, 190 insertions(+), 95 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch 
refs/changes/73/228273/1

diff --git a/.jscsrc b/.jscsrc
new file mode 100644
index 0000000..9d22e3f
--- /dev/null
+++ b/.jscsrc
@@ -0,0 +1,3 @@
+{
+       "preset": "wikimedia"
+}
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..66e3d48
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,24 @@
+{
+       // Enforcing
+       "bitwise": true,
+       "eqeqeq": true,
+       "freeze": true,
+       "latedef": true,
+       "noarg": true,
+       "nonew": true,
+       "undef": true,
+       "unused": true,
+       "strict": false,
+
+       // Relaxing
+       "es5": false,
+
+       // Environment
+       "browser": true,
+       "jquery": true,
+
+       "globals": {
+               "mediaWiki": false,
+               "OO": false
+       }
+}
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..6e443b1
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,19 @@
+/*jshint node:true */
+module.exports = function ( grunt ) {
+       grunt.loadNpmTasks( 'grunt-jsonlint' );
+       grunt.loadNpmTasks( 'grunt-banana-checker' );
+       var conf = grunt.file.readJSON( 'extension.json' );
+
+       grunt.initConfig( {
+               banana: conf.MessagesDirs,
+               jsonlint: {
+                       all: [
+                               '**/*.json',
+                               '!node_modules/**'
+                       ]
+               }
+       } );
+
+       grunt.registerTask( 'test', [ 'jsonlint', 'banana' ] );
+       grunt.registerTask( 'default', 'test' );
+};
diff --git a/MathSearch.hooks.php b/MathSearch.hooks.php
index ced14cb..73dd743 100644
--- a/MathSearch.hooks.php
+++ b/MathSearch.hooks.php
@@ -10,6 +10,12 @@
 class MathSearchHooks {
        static $nextID = 0;
 
+       public static function registerExtension() {
+               global $wgHooks;
+
+               $wgHooks['LoadExtensionSchemaUpdates'][] = 
'MathSearchHooks::onLoadExtensionSchemaUpdates';
+       }
+
        /**
         * @return int
         */
diff --git a/MathSearch.php b/MathSearch.php
index bb72851..aacbc2f 100644
--- a/MathSearch.php
+++ b/MathSearch.php
@@ -1,95 +1,13 @@
 <?php
-/**
- * MediaWiki math search extension
- *
- * @file
- * @ingroup Extensions
- * @author Moritz Schubotz
- * @author Brion Vibber
- * @copyright © 2002-2012 various MediaWiki contributors
- * @license GPLv2 license; info in main package.
- * @link http://www.mediawiki.org/wiki/Extension:MathSearch Documentation
- */
 
-# Alert the user that this is not a valid entry point to MediaWiki if they try 
to access the special pages file directly.
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( 'This is not a valid entry point to MediaWiki.\n'
-               . 'To install my extension, put the following line in 
LocalSettings.php:\n'
-               . 'require_once( \"\$IP/extensions/MathSearch/MathSearch.php\" 
);' );
-}
-
-$wgExtensionCredits['specialpage'][] = array(
-       'path' => __FILE__,
-       'name' => 'MathSearch',
-       'author' => 'Moritz Schubotz',
-       'url' => 'https://www.mediawiki.org/wiki/Extension:MathSearch',
-       'descriptionmsg' => 'mathsearch-desc',
-       'version' => '0.2.0',
-);
-/** @var String URL of MathWebSearch instance */
-$wgMathSearchMWSUrl = 'http://localhost:9090/';
-/** @var boolean if true the observation is updated everytime the SpecialPage 
formulainfo is shown. */
-$wgMathUpdateObservations = false;
-/** @var string $wgMathAnalysisTableName mathoid or mathlatexml */
-$wgMathAnalysisTableName = 'mathlatexml';
-
-$wgAutoloadClasses['MathSearchHooks'] = __DIR__ . '/MathSearch.hooks.php';
-$wgAutoloadClasses['SpecialMathSearch'] = __DIR__ . 
'/includes/special/SpecialMathSearch.php';
-$wgAutoloadClasses['FormulaInfo'] = __DIR__ . '/FormulaInfo.php';
-$wgAutoloadClasses['MathObject'] = __DIR__ . '/MathObject.php';
-$wgAutoloadClasses['MathQueryObject'] = __DIR__ . '/MathQueryObject.php';
-$wgAutoloadClasses['GetEquationsByQuery'] = __DIR__ . 
'/GetEquationsByQuery.php';
-$wgAutoloadClasses['SpecialMathDebug'] = __DIR__ . '/SpecialMathDebug.php';
-$wgAutoloadClasses['SpecialMathIndex'] = __DIR__ . '/SpecialMathIndex.php';
-$wgAutoloadClasses['SpecialDisplayTopics'] = __DIR__ . 
'/includes/special/SpecialDisplayTopics.php';
-$wgAutoloadClasses['MathEngineMws'] = __DIR__ . 
'/includes/engines/MathEngineMws.php';
-$wgAutoloadClasses['MathEngineBaseX'] = __DIR__ . 
'/includes/engines/MathEngineBaseX.php';
-$wgAutoloadClasses['MathEngineRest'] = __DIR__ . 
'/includes/engines/MathEngineRest.php';
-$wgAutoloadClasses['ImportCsv'] = __DIR__ . '/includes/ImportCsv.php';
-$wgAutoloadClasses['MathSearchUtils'] = __DIR__ . 
'/includes/MathSearchUtils.php';
-$wgAutoloadClasses['MathSearchTerm'] = __DIR__ . 
'/includes/MathSearchTerm.php';
-$wgAutoloadClasses['MwsDumpWriter'] = __DIR__ . '/includes/MwsDumpWriter.php';
-$wgAutoloadClasses['SpecialLaTeXTranslator'] = __DIR__ . 
'/includes/special/SpecialLaTeXTranslator.php';
-$wgAutoloadClasses['LaTeXTranslator'] = __DIR__ . 
'/includes/LaTeXTranslator.php';
-
-$wgMessagesDirs['MathSearch'] = __DIR__ . '/i18n';
-$wgExtensionMessagesFiles['MathSearchAlias'] = __DIR__ . 
'/MathSearch.alias.php';
-
-$wgSpecialPages['MathSearch'] = 'SpecialMathSearch';
-$wgSpecialPages['FormulaInfo'] = 'FormulaInfo';
-$wgSpecialPages['GetEquationsByQuery'] = 'GetEquationsByQuery';
-$wgSpecialPages['MathDebug'] = 'SpecialMathDebug';
-$wgSpecialPages['MathIndex'] = 'SpecialMathIndex';
-$wgSpecialPages['DisplayTopics'] = 'SpecialDisplayTopics';
-$wgSpecialPages['LaTeXTranslator'] = 'SpecialLaTeXTranslator';
-
-$wgHooks['LoadExtensionSchemaUpdates'][] = 
'MathSearchHooks::onLoadExtensionSchemaUpdates';
-$wgHooks['MathFormulaPostRender']['updateIndex'] = 
'MathSearchHooks::updateMathIndex';
-$wgHooks['MathFormulaPostRender']['addLink'] = 
'MathSearchHooks::addLinkToFormulaInfoPage';
-$wgHooks['UnitTestsList'][] = 'MathSearchHooks::onRegisterUnitTests';
-$wgHooks['ParserFirstCallInit'][] = 'MathSearchHooks::onParserFirstCallInit';
-$wgHooks['ArticleDeleteComplete'][] = 
'MathSearchHooks::onArticleDeleteComplete';
-$wgHooks['PageContentSaveComplete'][] = 
'MathSearchHooks::onPageContentSaveComplete';
-
-$wgMathSearchBaseXBackendUrl = 'http://localhost:10043/';
-
-/* Optional stuff for math search competetion server */
-$wgMathWmcServer = false;
-$wgGroupPermissions['sysop']['mathwmcsubmit'] = true;
-$wgAvailableRights[] = 'mathwmcsubmit';
-/** @var boolean $MathSearchWmcServer set true if you offer a math search 
competition server */
-$wgMathWmcMaxResults = 10000;
-$wgAutoloadClasses['SpecialUploadResult'] = __DIR__ . 
'/SpecialUploadResult.php';
-$wgSpecialPages['MathUpload'] = 'SpecialUploadResult';
-$wgMathUploadEnabled = false;
-$wgAutoloadClasses['SpecialMathDownloadResult'] = __DIR__ . 
'/SpecialMathDownloadResult.php';
-$wgSpecialPages['MathDownload'] = 'SpecialMathDownloadResult';
-/** Stores debug information in the database and provides more detailed debug 
output */
-$wgMathDebug = false;
-
-$wgResourceModules['ext.mathsearch.styles'] = array(
-       'localBasePath' => __DIR__ ,
-       'remoteExtPath' => 'MathSearch/',
-       'styles' => 'ext.mathsearch.css',
-       'targets' => array( 'desktop', 'mobile' ),
-);
+if ( function_exists( 'wfLoadExtension' ) ) {
+       wfLoadExtension( 'MathSearch' );
+       // Keep i18n globals so mergeMessageFileList.php doesn't break
+       $wgMessagesDirs['MathSearch'] = __DIR__ . '/i18n';
+       $wgExtensionMessagesFiles['MathSearchAlias'] = __DIR__ . 
'/MathSearch.alias.php';
+       /* wfWarn(
+               'Deprecated PHP entry point used for MathSearch extension. 
Please use wfLoadExtension instead, ' .
+               'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
+       ); */
+       return;
+}
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..3d55a97
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,10 @@
+{
+       "require-dev": {
+               "jakub-onderka/php-parallel-lint": "0.9.*"
+       },
+       "scripts": {
+               "test": [
+                       "parallel-lint . --exclude vendor"
+               ]
+       }
+}
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..2c63396
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,103 @@
+{
+       "name": "MathSearch",
+       "version": "0.2.0",
+       "author": "Moritz Schubotz",
+       "url": "https://www.mediawiki.org/wiki/Extension:MathSearch";,
+       "descriptionmsg": "mathsearch-desc",
+       "type": "specialpage",
+       "callback": "MathSearchHooks::registerExtension",
+       "AutoloadClasses": {
+               "MathSearchHooks": "MathSearch.hooks.php",
+               "SpecialMathSearch": "includes/special/SpecialMathSearch.php",
+               "FormulaInfo": "FormulaInfo.php",
+               "MathObject": "MathObject.php",
+               "MathQueryObject": "MathQueryObject.php",
+               "GetEquationsByQuery": "GetEquationsByQuery.php",
+               "SpecialMathDebug": "SpecialMathDebug.php",
+               "SpecialMathIndex": "SpecialMathIndex.php",
+               "SpecialDisplayTopics": 
"includes/special/SpecialDisplayTopics.php",
+               "MathEngineMws": "includes/engines/MathEngineMws.php",
+               "MathEngineBaseX": "includes/engines/MathEngineBaseX.php",
+               "MathEngineRest": "includes/engines/MathEngineRest.php",
+               "ImportCsv": "includes/ImportCsv.php",
+               "MathSearchUtils": "includes/MathSearchUtils.php",
+               "MathSearchTerm": "includes/MathSearchTerm.php",
+               "MwsDumpWriter": "includes/MwsDumpWriter.php",
+               "SpecialLaTeXTranslator": 
"includes/special/SpecialLaTeXTranslator.php",
+               "LaTeXTranslator": "includes/LaTeXTranslator.php",
+               "SpecialUploadResult": "SpecialUploadResult.php",
+               "SpecialMathDownloadResult": "SpecialMathDownloadResult.php"
+       },
+       "AvailableRights": [
+               "mathwmcsubmit"
+       ],
+       "ExtensionMessagesFiles": {
+               "MathSearchAlias": "MathSearch.alias.php"
+       },
+       "GroupPermissions": {
+               "sysop": {
+                       "mathwmcsubmit": true
+               }
+       },
+       "Hooks": {
+               "LoadExtensionSchemaUpdates": [
+                       "MathSearchHooks::onLoadExtensionSchemaUpdates"
+               ],
+               "MathFormulaPostRender": {
+                       "updateIndex": "MathSearchHooks::updateMathIndex",
+                       "addLink": "MathSearchHooks::addLinkToFormulaInfoPage"
+               },
+               "UnitTestsList": [
+                       "MathSearchHooks::onRegisterUnitTests"
+               ],
+               "ParserFirstCallInit": [
+                       "MathSearchHooks::onParserFirstCallInit"
+               ],
+               "ArticleDeleteComplete": [
+                       "MathSearchHooks::onArticleDeleteComplete"
+               ],
+               "PageContentSaveComplete": [
+                       "MathSearchHooks::onPageContentSaveComplete"
+               ]
+       },
+       "config": {
+               "MathAnalysisTableName": "mathlatexml",
+               "MathDebug": false,
+               "MathSearchBaseXBackendUrl": "http://localhost:10043/";,
+               "MathSearchMWSUrl": "http://localhost:9090/";,
+               "MathUpdateObservations": false,
+               "MathUploadEnabled": false,
+               "MathWmcMaxResults": 10000,
+               "MathWmcServer": false
+       },
+       "MessagesDirs": {
+               "MathSearch": [
+                       "i18n"
+               ]
+       },
+       "ResourceModules": {
+               "ext.mathsearch.styles": {
+                       "styles": "ext.mathsearch.css",
+                       "targets": [
+                               "desktop",
+                               "mobile"
+                       ]
+               }
+       },
+       "ResourceFileModulePaths": {
+               "localBasePath": "",
+               "remoteExtPath": "MathSearch/"
+       },
+       "SpecialPages": {
+               "MathSearch": "SpecialMathSearch",
+               "FormulaInfo": "FormulaInfo",
+               "GetEquationsByQuery": "GetEquationsByQuery",
+               "MathDebug": "SpecialMathDebug",
+               "MathIndex": "SpecialMathIndex",
+               "DisplayTopics": "SpecialDisplayTopics",
+               "LaTeXTranslator": "SpecialLaTeXTranslator",
+               "MathUpload": "SpecialUploadResult",
+               "MathDownload": "SpecialMathDownloadResult"
+       },
+       "manifest_version": 1
+}
\ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..e74f430
--- /dev/null
+++ b/package.json
@@ -0,0 +1,11 @@
+{
+  "scripts": {
+    "test": "grunt test"
+  },
+  "devDependencies": {
+    "grunt": "0.4.5",
+    "grunt-cli": "0.1.13",
+    "grunt-banana-checker": "0.2.2",
+    "grunt-jsonlint": "1.0.4"
+  }
+}
diff --git a/runTestsOnVagrant b/runTestsOnVagrant
old mode 100644
new mode 100755
diff --git a/tests/MwsDumpWriterTest.php b/tests/MwsDumpWriterTest.php
index bd41645..f844953 100644
--- a/tests/MwsDumpWriterTest.php
+++ b/tests/MwsDumpWriterTest.php
@@ -165,7 +165,7 @@
                $dw = new MwsDumpWriter();
                MathSearchHooks::resetId();
                $this->setMwGlobals( array(
-                       'wgMathValidModes' => array( MW_MATH_LATEXML ) ,
+                       'wgMathValidModes' => array( 'latexml' ) ,
                        'wgMathDefaultLaTeXMLSetting' => array(
                                'format' => 'xhtml',
                                'whatsin' => 'math',
@@ -189,7 +189,7 @@
                        $id = null;
                        $content = $tag[1];
                        $attributes = $tag[2];
-                       $renderer = MathRenderer::getRenderer( $content, 
$attributes, MW_MATH_LATEXML );
+                       $renderer = MathRenderer::getRenderer( $content, 
$attributes, 'latexml' );
                        $renderer->render( true );
                        MathSearchHooks::setMathId( $id, $renderer, $revId );
                        $dw->addMwsExpression( $renderer->getMathml(), $revId, 
$id );

-- 
To view, visit https://gerrit.wikimedia.org/r/228273
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib530ea6ae0dfe3ee48cc544508ce7522007e3961
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Paladox <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to