Legoktm has uploaded a new change for review.

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

Change subject: linter: Use already-configured MW API URL
......................................................................

linter: Use already-configured MW API URL

Parsoid already knows the MediaWiki API URL for the current wiki, so use
that instead of hardcoding it in the configuration. Instead, have a
"linterSendAPI" variable that controls whether lint errors are sent to
the API or not.

Change-Id: I85fde69ac712ec04f6a3ea73669c06200638df6f
---
M config.example.yaml
M lib/config/MWParserEnvironment.js
M lib/config/ParsoidConfig.js
M lib/logger/linter.js
M lib/utils/Util.js
M tests/mocha/apitest.localsettings.js
M tests/rttest.localsettings.js
7 files changed, 15 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/15/316215/1

diff --git a/config.example.yaml b/config.example.yaml
index daafcc8..7bd7f26 100644
--- a/config.example.yaml
+++ b/config.example.yaml
@@ -81,8 +81,8 @@
         #serverPort: 8000
         #serverInterface: '127.0.0.1'
 
-        # The URL of your LintBridge API endpoint
-        #linterAPI: 'http://lintbridge.wmflabs.org/add'
+        # Send lint errors to MW API
+        #linterSendAPI: false
 
         # Require SSL certificates to be valid (default true)
         # Set to false when using self-signed SSL certificates
diff --git a/lib/config/MWParserEnvironment.js 
b/lib/config/MWParserEnvironment.js
index d25f2e7..6e88edd 100644
--- a/lib/config/MWParserEnvironment.js
+++ b/lib/config/MWParserEnvironment.js
@@ -259,7 +259,7 @@
                "fatal", "error", "warning", "info",
        ];
 
-       if (this.conf.parsoid.linting && !this.conf.parsoid.linterAPI) {
+       if (this.conf.parsoid.linting && !this.conf.parsoid.linterSendAPI) {
                defaultLogLevels.push("lint");
        }
 
diff --git a/lib/config/ParsoidConfig.js b/lib/config/ParsoidConfig.js
index 337923c..66e291a 100644
--- a/lib/config/ParsoidConfig.js
+++ b/lib/config/ParsoidConfig.js
@@ -226,10 +226,12 @@
 ParsoidConfig.prototype.linting = false;
 
 /**
- * @property {String|null} linterAPI
- * The URL for LintBridge API endpoint
+ * @property {boolean} linterSendAPI
+ * Whether to send lint errors to the MW API
+ * Requires the MW Linter extension to be installed
+ * and configured.
  */
-ParsoidConfig.prototype.linterAPI = null;
+ParsoidConfig.prototype.linterSendAPI = false;
 
 /**
  * @property {number} linterSampling
diff --git a/lib/logger/linter.js b/lib/logger/linter.js
index 32d97bc..c86d640 100644
--- a/lib/logger/linter.js
+++ b/lib/logger/linter.js
@@ -33,12 +33,12 @@
        }
 
        try {
-               if (env.conf.parsoid.linterAPI) {
+               if (env.conf.parsoid.linterSendAPI) {
                        // Only send the request if it is
                        // the latest revision
                        if (env.page.meta.revision.revid === env.page.latest) {
                                request.post(
-                                       env.conf.parsoid.linterAPI,
+                                       env.conf.wiki.apiURI,
                                        { form: {
                                                data: 
JSON.stringify(enabledBuffer),
                                                page: env.page.name,
diff --git a/lib/utils/Util.js b/lib/utils/Util.js
index bcdfb93..e08430a 100644
--- a/lib/utils/Util.js
+++ b/lib/utils/Util.js
@@ -223,7 +223,7 @@
                }
                if (opts.lint) {
                        parsoidConfig.linting = true;
-                       parsoidConfig.linterAPI = null;
+                       parsoidConfig.linterSendAPI = false;
                }
                if (opts.useBatchAPI !== null) {
                        parsoidConfig.useBatchAPI = 
Util.booleanOption(opts.useBatchAPI);
diff --git a/tests/mocha/apitest.localsettings.js 
b/tests/mocha/apitest.localsettings.js
index 0a45c19..d99ee0f 100644
--- a/tests/mocha/apitest.localsettings.js
+++ b/tests/mocha/apitest.localsettings.js
@@ -39,8 +39,8 @@
        //  parsoidConfig.serverPort = 8000;
        //  parsoidConfig.serverInterface = '127.0.0.1';
 
-       // The URL of your LintBridge API endpoint
-       //  parsoidConfig.linterAPI = 'http://lintbridge.wmflabs.org/add';
+       // Send lint errors to MW API
+       //  parsoidConfig.linterSendAPI = false;
 
        // Require SSL certificates to be valid (default true)
        // Set to false when using self-signed SSL certificates
diff --git a/tests/rttest.localsettings.js b/tests/rttest.localsettings.js
index 4a92840..133f848 100644
--- a/tests/rttest.localsettings.js
+++ b/tests/rttest.localsettings.js
@@ -42,8 +42,8 @@
        //  parsoidConfig.serverPort = 8000;
        //  parsoidConfig.serverInterface = '127.0.0.1';
 
-       // The URL of your LintBridge API endpoint
-       //  parsoidConfig.linterAPI = 'http://lintbridge.wmflabs.org/add';
+       // Send lint errors to MW API
+       //  parsoidConfig.linterSendAPI = false;
 
        // Require SSL certificates to be valid (default true)
        // Set to false when using self-signed SSL certificates

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I85fde69ac712ec04f6a3ea73669c06200638df6f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to