Physikerwelt has uploaded a new change for review.

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

Change subject: New endpoint: fast
......................................................................

New endpoint: fast

* This endpoints returns all the informatin needed by the math extension
at the first place

Change-Id: Ie45ae3738b57269fc4444af2e32571fc5b2d0836
---
M config.dev.yaml
A config.nolog.yaml
M config.prod.yaml
M routes/mathoid.js
M test/features/math/simple.js
5 files changed, 70 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mathoid 
refs/changes/44/267544/1

diff --git a/config.dev.yaml b/config.dev.yaml
index e7f26e9..ab3cd86 100644
--- a/config.dev.yaml
+++ b/config.dev.yaml
@@ -67,3 +67,4 @@
       texvcinfo: true
       speechOn: true
       chem: true
+      fast: true
diff --git a/config.nolog.yaml b/config.nolog.yaml
new file mode 100644
index 0000000..b3513f0
--- /dev/null
+++ b/config.nolog.yaml
@@ -0,0 +1,37 @@
+
+# Number of worker processes to spawn.
+# Set to 0 to run everything in a single process without clustering.
+# Use 'ncpu' to run as many workers as there are CPU units
+num_workers: ncpu
+
+# Log error messages and gracefully restart a worker if v8 reports that it
+# uses more heap (note: not RSS) than this many mb.
+worker_heap_limit_mb: 500
+
+# Logger info
+logging:
+  level: warn
+
+# Statsd metrics reporter
+metrics:
+  type: log
+  #host: localhost
+  #port: 8125
+
+services:
+  - name: mathoid
+    # a relative path or the name of an npm package, if different from name
+    module: ./app.js
+    # optionally, a version constraint of the npm package
+    # version: ^0.4.0
+    # per-service config
+    conf:
+      port: 10042
+      # interface: localhost # uncomment to only listen on localhost
+      # more per-service config settings
+      svg: true
+      img: true
+      texvcinfo: true
+      speech: true
+      speechOn: false
+      fast: true
\ No newline at end of file
diff --git a/config.prod.yaml b/config.prod.yaml
index 8144b32..5671771 100644
--- a/config.prod.yaml
+++ b/config.prod.yaml
@@ -9,7 +9,7 @@
 
 # Logger info
 logging:
-  level: warn
+  level: debug
   streams:
   # Use gelf-stream -> logstash
   - type: gelf
@@ -37,4 +37,5 @@
       img: true
       texvcinfo: true
       speech: true
-      sppechOn: false
+      speechOn: false
+      fast: true
diff --git a/routes/mathoid.js b/routes/mathoid.js
index 27138f5..274b257 100644
--- a/routes/mathoid.js
+++ b/routes/mathoid.js
@@ -53,10 +53,10 @@
 function handleRequest(res, q, type, outFormat, features) {
     var sanitizedTex, feedback;
     var svg = app.conf.svg && /^svg|json|complete$/.test(outFormat);
-    var mml = (type !== "MathML") && /^mml|json|complete$/.test(outFormat);
+    var mml = (type !== "MathML") && 
/^mml|json|complete|fast$/.test(outFormat);
     var png = app.conf.png && /^png|json|complete$/.test(outFormat);
-    var img = app.conf.img && /^json|complete$/.test(outFormat);
-    var speech = (outFormat !== "png") && features.speech || outFormat === 
"speech";
+    var mathoidStyle = app.conf.img && /^json|complete|fast$/.test(outFormat);
+    var speech = (!/^png|fast$/.test(outFormat) && features.speech ) || 
outFormat === "speech";
     var chem = app.conf.chem && (type === "chem");
 
     if (chem) {
@@ -85,7 +85,7 @@
         math: q,
         format: type,
         svg: svg,
-        mathoidStyle: img,
+        mathoidStyle: mathoidStyle,
         mml: mml,
         speakText: speech,
         png: png
@@ -108,6 +108,11 @@
             data.speech = data.speakText;
         }
         switch (outFormat) {
+            case 'fast':
+                feedback.mml = data.mml;
+                feedback.mathoidStyle = data.mathoidStyle;
+                res.json(feedback).end();
+                break;
             case 'json':
                 res.json(data).end();
                 break;
@@ -178,6 +183,9 @@
 
     if (req.params.outformat) {
         switch (req.params.outformat.toLowerCase()) {
+            case 'fast':
+                setOutFormat('fast');
+                break;
             case "svg":
                 setOutFormat('svg');
                 break;
diff --git a/test/features/math/simple.js b/test/features/math/simple.js
index ea0cf31..94bdda1 100644
--- a/test/features/math/simple.js
+++ b/test/features/math/simple.js
@@ -289,6 +289,23 @@
                 assert.deepEqual(res.body, "upper E equals m c squared");
             });
         });
+        it("get fast response", function () {
+            return preq.post({
+                uri: baseURL + "fast",
+                body: {q: "E=mc^2"}
+            }).then(function (res) {
+                assert.status(res, 200);
+                assert.deepEqual(res.body, {
+                    "success": true,
+                    "checked": "E=mc^{2}",
+                    "requiredPackages": [],
+                    "identifiers": ["E", "m", "c"],
+                    "endsWithDot": false,
+                    "mml": "<math xmlns=\"http://www.w3.org/1998/Math/MathML\"; 
display=\"block\">\n  <semantics>\n    <mrow>\n      <mi>E</mi>\n      
<mo>=</mo>\n      <mi>m</mi>\n      <msup>\n        <mi>c</mi>\n        <mrow 
class=\"MJX-TeXAtom-ORD\">\n          <mn>2</mn>\n        </mrow>\n      
</msup>\n    </mrow>\n    <annotation 
encoding=\"application/x-tex\">E=mc^{2}</annotation>\n  </semantics>\n</math>",
+                    "mathoidStyle": "vertical-align: -0.338ex; width:9.025ex; 
height:2.676ex;"
+                });
+            });
+        });
     });
 
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie45ae3738b57269fc4444af2e32571fc5b2d0836
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mathoid
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>

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

Reply via email to