[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: fix diff tests

2018-01-23 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/406015 )

Change subject: Hygiene: fix diff tests
..

Hygiene: fix diff tests

mw-redirect classes were added to a few links.

Change-Id: Ife970e33459b64e3af7175deb355d03fbdf838a8
---
M 
test/diff/results/page_formatted-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_Frankenstein.json
M 
test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_Frankenstein.json
2 files changed, 4 insertions(+), 4 deletions(-)


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

diff --git 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
index 3dc7cf4..11b309d 100644
--- 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
+++ 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
@@ -82,14 +82,14 @@
   },
   {
 "id": 9,
-"text": "\n\n\n\n\n\nAnvil of Crom 
(sample)\nhttps://upload.wikimedia.org/wikipedia/en/0/0d/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg\;
 type=\"audio/ogg; codecs=vorbis\" data-title=\"Original Ogg file 
(65 kbps)\" data-shorttitle=\"Ogg source\">https://upload.wikimedia.org/wikipedia/en/transcoded/0/0d/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg.mp3\;
 type=\"audio/mpeg\" data-title=\"MP3\" 
data-shorttitle=\"MP3\">\n\nProblems playing this file? See media 
help.\n\n",
+"text": "\n\n\n\n\n\nAnvil of Crom 
(sample)\nhttps://upload.wikimedia.org/wikipedia/en/0/0d/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg\;
 type=\"audio/ogg; codecs=vorbis\" data-title=\"Original Ogg file 
(65 kbps)\" data-shorttitle=\"Ogg source\">https://upload.wikimedia.org/wikipedia/en/transcoded/0/0d/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg.mp3\;
 type=\"audio/mpeg\" data-title=\"MP3\" 
data-shorttitle=\"MP3\">\n\nProblems playing this file? See media help.\n\n",
 "toclevel": 1,
 "line": "Audio",
 "anchor": "Audio"
   },
   {
 "id": 10,
-"text": "\n\n\n\n\n\nThe Dilbert 
Principle\nhttps://upload.wikimedia.org/wikipedia/commons/6/6d/The_Dilbert_Principle.ogg\;
 type=\"audio/ogg; codecs=vorbis\" data-title=\"Original Ogg file 
(56 kbps)\" data-shorttitle=\"Ogg source\">https://upload.wikimedia.org/wikipedia/commons/transcoded/6/6d/The_Dilbert_Principle.ogg/The_Dilbert_Principle.ogg.mp3\;
 type=\"audio/mpeg\" data-title=\"MP3\" 
data-shorttitle=\"MP3\">\n\nProblems playing this file? See media 
help.\n\n",
+"text": "\n\n\n\n\n\nThe Dilbert 
Principle\nhttps://upload.wikimedia.org/wikipedia/commons/6/6d/The_Dilbert_Principle.ogg\;
 type=\"audio/ogg; codecs=vorbis\" data-title=\"Original Ogg file 
(56 kbps)\" data-shorttitle=\"Ogg source\">https://upload.wikimedia.org/wikipedia/commons/transcoded/6/6d/The_Dilbert_Principle.ogg/The_Dilbert_Principle.ogg.mp3\;
 type=\"audio/mpeg\" data-title=\"MP3\" 
data-shorttitle=\"MP3\">\n\nProblems playing this file? See media help.\n\n",
 "toclevel": 1,
 "line": "Spoken Wikipedia",
 "anchor": "Spoken_Wikipedia"
diff --git 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
index 3cd4804..b7fc1cf 100644
--- 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
+++ 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
@@ -236,14 +236,14 @@
   },
   {
 "id": 9,
-"text": "\n\n\n\n\n\nAnvil of Crom 
(sample)\nhttps://upload.wikimedia.org/wikipedia/en/0/0d/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg\;
 type=\"audio/ogg; codecs=vorbis\" data-title=\"Original Ogg file 
(65 kbps)\" data-shorttitle=\"Ogg source\">https://upload.wikimedia.org/wikipedia/en/transcoded/0/0d/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg.mp3\;
 type=\"audio/mpeg\" data-title=\"MP3\" 
data-shorttitle=\"MP3\">\n\nProblems playing this file? See media 
help.\n\n",
+"text": "\n\n\n\n\n\nAnvil of Crom 
(sample)\nhttps://upload.wikimedia.org/wikipedia/en/0/0d/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg\;
 type=\"audio/ogg; codecs=vorbis\" data-title=\"Original Ogg file 
(65 kbps)\" data-shorttitle=\"Ogg source\">https://upload.wikimedia.org/wikipedia/en/transcoded/0/0d/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg/Anvil_of_Crom_%28sample%29_by_Basil_Poledouris.ogg.mp3\;
 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: fix jsdoc in extractLeadIntroduction

2018-01-19 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405351 )

Change subject: Hygiene: fix jsdoc in extractLeadIntroduction
..

Hygiene: fix jsdoc in extractLeadIntroduction

Change-Id: I1268821bfcf65470202ca76ff21143236772f63a
---
M lib/transformations/extractLeadIntroduction.js
1 file changed, 6 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/51/405351/1

diff --git a/lib/transformations/extractLeadIntroduction.js 
b/lib/transformations/extractLeadIntroduction.js
index 7661b2c..0157f73 100644
--- a/lib/transformations/extractLeadIntroduction.js
+++ b/lib/transformations/extractLeadIntroduction.js
@@ -3,22 +3,22 @@
 const NodeType = require('../nodeType');
 const _ = require('underscore');
 
-/*
+/**
  * Check whether a node has any content.
- * @param {!DOMElement} node
- * @return {!Boolean} whether the node is empty after all whitespace is 
stripped.
+ * @param {!Element} node
+ * @return {!boolean} whether the node is empty after all whitespace is 
stripped.
  */
 function isEmpty(node) {
 return node.textContent.trim().length === 0;
 }
 
-/*
+/**
  * Extracts the first non-empty paragraph from an article and any
  * nodes that follow it that are not themselves paragraphs.
  * @param {!Document} doc representing article
- * @param {Boolean} removeNodes when set the lead introduction will
+ * @param {boolean} removeNodes when set the lead introduction will
  *  be removed from the input DOM tree.
- * @return {String} representing article introduction
+ * @return {string} representing article introduction
  */
 function extractLeadIntroduction(doc, removeNodes) {
 let p = '';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1268821bfcf65470202ca76ff21143236772f63a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Use underscore's implementation of escape

2018-01-19 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405350 )

Change subject: Use underscore's implementation of escape
..

Use underscore's implementation of escape

The underscore implementation handles a few more characters than ours
did.

Change-Id: Ic029bae9f8f9ad10b35bdbc41fb8a2346b0d6bf8
---
M lib/transformations/extractLeadIntroduction.js
1 file changed, 2 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/50/405350/1

diff --git a/lib/transformations/extractLeadIntroduction.js 
b/lib/transformations/extractLeadIntroduction.js
index f586951..7661b2c 100644
--- a/lib/transformations/extractLeadIntroduction.js
+++ b/lib/transformations/extractLeadIntroduction.js
@@ -1,6 +1,7 @@
 'use strict';
 
 const NodeType = require('../nodeType');
+const _ = require('underscore');
 
 /*
  * Check whether a node has any content.
@@ -10,24 +11,6 @@
 function isEmpty(node) {
 return node.textContent.trim().length === 0;
 }
-
-/*
- * HTML escape a string.
- * @param {!String} s
- * @return {!String}
- */
-function escape(s) {
-return s.replace(/[&<>"']/g, (c) => {
-switch (c) {
-case '&': return '';
-case '<': return '';
-case '>': return '';
-case '"': return '';
-default: return;
-}
-});
-}
-
 
 /*
  * Extracts the first non-empty paragraph from an article and any
@@ -56,7 +39,7 @@
 // Deal with text nodes
 if (nextSibling.nodeType === NodeType.TEXT_NODE) {
 if (!isEmpty(nextSibling)) {
-p += escape(nextSibling.textContent);
+p += _.escape(nextSibling.textContent);
 }
 } else {
 p += nextSibling.outerHTML;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic029bae9f8f9ad10b35bdbc41fb8a2346b0d6bf8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: WIP: Get ready for Parsoid change of references wrappers

2018-01-19 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405317 )

Change subject: WIP: Get ready for Parsoid change of references wrappers
..

WIP: Get ready for Parsoid change of references wrappers

Parsoid's I2b5c7ff55 moves the typeof="mw:Extension/references"
attribute from the  to the parent .

TODO: probably need some auto-detection, potentially similar to what we
did for section parsing.

Change-Id: Ie9cfd8969f571a8a13f0338a71b3118c0420e40a
---
M lib/references/extractReferenceLists.js
M lib/references/stripReferenceListContent.js
M lib/references/structureReferenceListContent.js
M test/lib/references/extractReferenceLists.test.js
M test/lib/references/stripReferenceListContent-test.js
M test/lib/references/structureReferenceListContent.test.js
6 files changed, 61 insertions(+), 29 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/17/405317/1

diff --git a/lib/references/extractReferenceLists.js 
b/lib/references/extractReferenceLists.js
index 04a8546..10fa537 100644
--- a/lib/references/extractReferenceLists.js
+++ b/lib/references/extractReferenceLists.js
@@ -11,7 +11,7 @@
 function extractReferenceLists(document, logger) {
 const structure = [];
 let references = {};
-const refListElements = 
document.querySelectorAll('ol[typeof=\'mw:Extension/references\']');
+const refListElements = 
document.querySelectorAll('div[typeof=\'mw:Extension/references\']');
 refListElements.forEach((refListElement) => {
 const result = 
structureReferenceSections.buildReferenceList(refListElement, logger);
 structure.push({
diff --git a/lib/references/stripReferenceListContent.js 
b/lib/references/stripReferenceListContent.js
index b5442b1..b7e9e97 100644
--- a/lib/references/stripReferenceListContent.js
+++ b/lib/references/stripReferenceListContent.js
@@ -5,7 +5,7 @@
  * @param {!Document} doc to scan for references
  */
 function stripReferenceListContent(doc) {
-const refLists = 
doc.querySelectorAll('ol[typeof=\'mw:Extension/references\']');
+const refLists = 
doc.querySelectorAll('div[typeof=\'mw:Extension/references\']');
 for (const refList of refLists) {
 const placeholder = doc.createElement('DIV');
 placeholder.classList.add('mw-references-placeholder');
diff --git a/lib/references/structureReferenceListContent.js 
b/lib/references/structureReferenceListContent.js
index e3c6de6..731b5b7 100644
--- a/lib/references/structureReferenceListContent.js
+++ b/lib/references/structureReferenceListContent.js
@@ -138,27 +138,32 @@
 
 /**
  * Builds an object structure for a single reference list.
- * @param {!Element} refListElement a DOM element with content for one 
reference list
+ * @param {!Element} refListDivWrapperElement a DOM element with content for 
one reference list
  * @param {!Logger} logger a logger instance associated with the request
  * @return {Object} an object with order (an array of reference ids) and 
references
  */
-const buildReferenceList = (refListElement, logger) => {
+const buildReferenceList = (refListDivWrapperElement, logger) => {
 const orderArray = [];
 const references = {};
-const children = refListElement.children;
-for (let i = 0; i < children.length; i++) {
-const node = children[i];
-if (node.tagName === 'LI') {
-const referenceItem = buildOneReferenceItem(node, logger);
-orderArray.push(referenceItem.id);
-references[referenceItem.id] = referenceItem;
-delete referenceItem.id;
-} else if (hasOnlyWhitespace(node)) {
-// ignore white space
-logger.log('warn', `ignore white space: ${node.outerHTML}`);
-} else {
-logger.log('warn', `unexpected child tag: ${node.tagName}`);
+const olElement = refListDivWrapperElement.firstElementChild;
+if (olElement.tagName === 'OL') {
+const children = olElement.children;
+for (let i = 0; i < children.length; i++) {
+const node = children[i];
+if (node.tagName === 'LI') {
+const referenceItem = buildOneReferenceItem(node, logger);
+orderArray.push(referenceItem.id);
+references[referenceItem.id] = referenceItem;
+delete referenceItem.id;
+} else if (hasOnlyWhitespace(node)) {
+// ignore white space
+logger.log('warn', `ignore white space: ${node.outerHTML}`);
+} else {
+logger.log('warn', `unexpected child tag: ${node.tagName}`);
+}
 }
+} else {
+logger.log('warn', `expected ol element but got ${olElement.tagName}`);
 }
 return { order: orderArray, references };
 };
diff --git a/test/lib/references/extractReferenceLists.test.js 
b/test/lib/references/extractReferenceLists.test.js
index 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: update unit tests: refs changed from span to sup

2018-01-18 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405243 )

Change subject: Hygiene: update unit tests: refs changed from span to sup
..

Hygiene: update unit tests: refs changed from span to sup

Updates unit tests to account for Parsoid ref change from span to sup.

Bug: T185138
Change-Id: I2e8499f28621c647ed9ec1a8c0cdf306c9ab4298
---
M test/lib/transformations/summarize.js
M test/lib/transforms/transforms-test.js
2 files changed, 14 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/43/405243/1

diff --git a/test/lib/transformations/summarize.js 
b/test/lib/transformations/summarize.js
index ec25458..6190945 100644
--- a/test/lib/transformations/summarize.js
+++ b/test/lib/transformations/summarize.js
@@ -55,7 +55,7 @@
 ],
 // references are stripped
 [
-'France is a country with territory status in 
western Europe and several overseas regions and territories.[upper-roman 13]',
+'France is a country with territory status in 
western Europe and several overseas regions and territories.[upper-roman 13]',
 'France is a country with territory status in 
western Europe and several overseas regions and territories.'
 ],
 // Any element with .reference class is stripped (T176519)
@@ -159,7 +159,7 @@
 ],
 // Full stops do not impact the summary length (T173640)
 [
-'Arm. 
gen. Ing. Petr Pavel, M.A., (*1.listopadu 1961 Planá) je český voják, generál Armády České 
republiky aod června 2015 předseda vojenského výboru NATO. Jako první zástupce zemí bývalé Varšavské smlouvy tak 
nastoupil do nejvyšší vojenské funkce Severoatlantické aliance.[1][2]',
+'Arm. 
gen. Ing. Petr Pavel, M.A., (*1.listopadu 1961 Planá) je český voják, generál Armády České 
republiky aod června 2015 předseda vojenského výboru NATO. Jako první zástupce zemí bývalé Varšavské smlouvy tak 
nastoupil do nejvyšší vojenské funkce Severoatlantické aliance.[1][2]',
 'Arm. gen. Ing. Petr Pavel, M.A., je český voják, generál Armády České republiky 
aod června 2015 předseda vojenského výboru NATO. Jako první 
zástupce zemí bývalé Varšavské smlouvy tak nastoupil do nejvyšší vojenské 
funkce Severoatlantické aliance.'
 ],
 // Bold tags are retained
diff --git a/test/lib/transforms/transforms-test.js 
b/test/lib/transforms/transforms-test.js
index 049a5a8..8440d11 100644
--- a/test/lib/transforms/transforms-test.js
+++ b/test/lib/transforms/transforms-test.js
@@ -7,29 +7,29 @@
 describe('lib:size-transforms', () => {
 const buildHtml = (title) => {
 return domino.createDocument(''
-+ ''
++ ''
 + `[1]`
-+ ''
-+ ''
++ ''
++ ''
 + `[2]`
-+ ''
-+ ''
++ ''
++ ''
 + `[2]`
-+ ''
++ ''
 + '');
 };
 
 const buildHtml2 = () => {
 return domino.createDocument(''
-+ ''
++ ''
 + `[1]`
-+ ''
-+ ''
++ ''
++ ''
 + `[2]`
-+ ''
-+ ''
++ ''
++ ''
 + `[2]`
-+ ''
++ ''
 + '');
 };
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e8499f28621c647ed9ec1a8c0cdf306c9ab4298
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: remove unused addSectionTags for the section case

2018-01-18 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405242 )

Change subject: Hygiene: remove unused addSectionTags for the section case
..

Hygiene: remove unused addSectionTags for the section case

This has not been used since Parsoid started providing section tags.
Removed also unused parsoid-dom-utils package.

Change-Id: I2cb59493dcb1b88110e6b717b364a05b572c89c2
---
M lib/parsoidSectionsUsingSectionTags.js
M package.json
2 files changed, 0 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/42/405242/1

diff --git a/lib/parsoidSectionsUsingSectionTags.js 
b/lib/parsoidSectionsUsingSectionTags.js
index aab9cd3..96c2efb 100644
--- a/lib/parsoidSectionsUsingSectionTags.js
+++ b/lib/parsoidSectionsUsingSectionTags.js
@@ -1,21 +1,7 @@
 'use strict';
 
 const domino = require('domino');
-const parsoidDomUtils = require('parsoid-dom-utils');
 const NodeType = require('./nodeType');
-
-/**
- * @deprecated wait for Parsoid to implement this.
- * New sectioning code: wraps sections in  tags. Will likely
- * be replaced by code in Parsoid.
- * @param {!document} doc the parsed DOM Document of the Parsoid output
- */
-function addSectionTags(doc) {
-// in case this is already handled by Parsoid don't try again
-if (!doc.querySelector('section')) {
-parsoidDomUtils.sections.wrap(doc);
-}
-}
 
 /**
  * Gets the section number from Parsoid.
@@ -141,7 +127,6 @@
 }
 
 module.exports = {
-addSectionTags,
 getSectionsText,
 justLeadSection,
 testing: {
diff --git a/package.json b/package.json
index 91b5d2b..3800874 100644
--- a/package.json
+++ b/package.json
@@ -55,7 +55,6 @@
 "express": "^4.16.2",
 "js-yaml": "^3.10.0",
 "mediawiki-title": "^0.6.5",
-"parsoid-dom-utils": "^0.1.3",
 "preq": "^0.5.3",
 "service-runner": "^2.4.2",
 "swagger-router": "^0.7.1",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cb59493dcb1b88110e6b717b364a05b572c89c2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Include H1 heading tags to old section parsing

2018-01-18 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405241 )

Change subject: Include H1 heading tags to old section parsing
..

Include H1 heading tags to old section parsing

While not encouraged, pages could also have H1 section headings.

Change-Id: Icf01f5dfe3cddcdc906f85582b88cf72fa832f55
---
M lib/parsoidSectionsUsingDivs.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/41/405241/1

diff --git a/lib/parsoidSectionsUsingDivs.js b/lib/parsoidSectionsUsingDivs.js
index 5d11837..982ea26 100644
--- a/lib/parsoidSectionsUsingDivs.js
+++ b/lib/parsoidSectionsUsingDivs.js
@@ -13,7 +13,7 @@
 let node = startingNode;
 
 while (node) {
-if (!(/^H[2-6]$/.test(node.tagName))) {
+if (!(/^H[1-6]$/.test(node.tagName))) {
 nextNode = node.nextSibling;
 sectionDiv.appendChild(node);
 node = nextNode;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf01f5dfe3cddcdc906f85582b88cf72fa832f55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Dev: debug log for MW API requests when debug is true in config

2018-01-18 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405239 )

Change subject: Dev: debug log for MW API requests when debug is true in config
..

Dev: debug log for MW API requests when debug is true in config

The config.dev.yaml file already has a debug setting of true. This is
more convenient since then all developers get this debug info by
default.

Change-Id: If119f3fd173aabbe458d874b439a9b870e5f2f45
---
M lib/api-util.js
1 file changed, 1 insertion(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/39/405239/1

diff --git a/lib/api-util.js b/lib/api-util.js
index fe1cd78..b2f8b7c 100644
--- a/lib/api-util.js
+++ b/lib/api-util.js
@@ -8,7 +8,6 @@
 const HTTPError = sUtil.HTTPError;
 
 const MAX_BATCH_SIZE = 50;
-const DEBUG = process.env.DEBUG_MW_REQUESTS;
 
 function prettyMwApiReq(request) {
 // formatting it as GET request even though we use POST requests for MW 
API,
@@ -35,7 +34,7 @@
 }
 });
 
-if (DEBUG) {
+if (app.conf.debug) {
 app.logger.log(`trace/mwApiGet`, { msg: 'outgoing request', to: 
prettyMwApiReq(request) });
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If119f3fd173aabbe458d874b439a9b870e5f2f45
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Dev: debug log for RESTBase requests, too

2018-01-18 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405240 )

Change subject: Dev: debug log for RESTBase requests, too
..

Dev: debug log for RESTBase requests, too

Change-Id: I2cb1d4299a15c87274544f2dc3ae66b8cc2d21f2
---
M lib/api-util.js
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/40/405240/1

diff --git a/lib/api-util.js b/lib/api-util.js
index b2f8b7c..8ba63f0 100644
--- a/lib/api-util.js
+++ b/lib/api-util.js
@@ -14,6 +14,7 @@
 // just because GETs are easier to run from commandline or see it in a 
browser
 return `${request.uri}?${querystring.stringify(request.body)}`;
 }
+
 /**
  * Calls the MW API with the supplied query as its body
  * @param {!Object} app the application object
@@ -110,6 +111,10 @@
 }
 });
 
+if (app.conf.debug) {
+app.logger.log(`trace/restApiGet`, { msg: 'outgoing request', to: 
request.uri });
+}
+
 return preq(request);
 
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cb1d4299a15c87274544f2dc3ae66b8cc2d21f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: Update diff results for -wrapped references, p...

2018-01-18 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405234 )

Change subject: Hygiene: Update diff results for -wrapped references, part 
2
..

Hygiene: Update diff results for -wrapped references, part 2

Follow-up of I0bdde822. Looks like ChangeProp has progressed to another
page.

Change-Id: I25c0cedb7563999600c458d1da1de43fb9dd1de3
---
M test/diff/results/page_media-enwiki-Hummingbird.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/34/405234/1

diff --git a/test/diff/results/page_media-enwiki-Hummingbird.json 
b/test/diff/results/page_media-enwiki-Hummingbird.json
index 1f3aabb..cdb4fdf 100644
--- a/test/diff/results/page_media-enwiki-Hummingbird.json
+++ b/test/diff/results/page_media-enwiki-Hummingbird.json
@@ -265,7 +265,7 @@
   "section_id": 17,
   "type": "image",
   "caption": {
-"html": "A trail of wake vortices generated by a hummingbird's flight 
discovered after training a bird to fly through a cloud of neutrally buoyant, 
helium-filled soap bubbles and recording airflows in the wake with stereo photography.[65]",
+"html": "A trail of wake vortices generated by a hummingbird's flight 
discovered after training a bird to fly through a cloud of neutrally buoyant, 
helium-filled soap bubbles and recording airflows in the wake with stereo photography.[65]",
 "text": "A trail of wake vortices generated by a hummingbird's flight 
discovered after training a bird to fly through a cloud of neutrally buoyant, 
helium-filled soap bubbles and recording airflows in the wake with stereo 
photography.[65]"
   },
   "titles": {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25c0cedb7563999600c458d1da1de43fb9dd1de3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Dev: Make sure we tag the correct commit in the src repo

2018-01-18 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405210 )

Change subject: Dev: Make sure we tag the correct commit in the src repo
..

Dev: Make sure we tag the correct commit in the src repo

Get the corresponding commit in the src submodule
Gets the corresponding commit from the src repo via the submodule
and use that for tagging.
This will avoid tagging a commit that has been merged since deployment.
Yes, unfortunately, sometimes I've done the tagging a bit later than I
should have.

Change-Id: If5879fae9ac874de6f13e89fbc7530de1963abe3
---
M scripts/tag-deploy.sh
1 file changed, 7 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/10/405210/1

diff --git a/scripts/tag-deploy.sh b/scripts/tag-deploy.sh
index 53f4464..8614587 100755
--- a/scripts/tag-deploy.sh
+++ b/scripts/tag-deploy.sh
@@ -28,11 +28,16 @@
   fi
 fi
 
+# Get the corresponding commit in the src submodule
+cd src
+src_commit_id="$( git log --format="%h" -n 1 )"
+cd ..
+
 # Build the deployment tag
 deploy_commit_date="$( git show -s --format=%ci | awk '{print $1;}' )"
 deploy_commit_id="$( git rev-parse --short HEAD )"
 tag="deploy/$deploy_commit_date/$deploy_commit_id"
 
-# Tag the latest code repo commit with it & push tags
+# Tag the correct commit in the src repo with & push tags
 cd "$repo_dir"
-git tag -s "$tag" -m "deployed" && git push origin "$tag" && printf "Applied 
new tag: $tag\n"
+git tag -s "$tag" -m "deployed" $src_commit_id && git push origin "$tag" && 
printf "Applied new tag: $tag\n"

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If5879fae9ac874de6f13e89fbc7530de1963abe3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: fix api-util-test

2018-01-17 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404744 )

Change subject: Hygiene: fix api-util-test
..

Hygiene: fix api-util-test

Should not have reused the list between tests.

Bug: T182738
Change-Id: I1736624e52e00b1e0279fe1ddf1733f978e479f3
---
M test/lib/api-util/api-util-test.js
1 file changed, 2 insertions(+), 4 deletions(-)


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

diff --git a/test/lib/api-util/api-util-test.js 
b/test/lib/api-util/api-util-test.js
index 5059c18..3e22755 100644
--- a/test/lib/api-util/api-util-test.js
+++ b/test/lib/api-util/api-util-test.js
@@ -12,8 +12,6 @@
 
 logger.log = function(a, b) {};
 
-const list = [0, 1, 2, 3, 4];
-
 describe('lib:apiUtil', () => {
 
 it('checkForQueryPagesInResponse should return 504 when query.pages are 
absent', () => {
@@ -27,7 +25,7 @@
 });
 
 it('batching works correctly', () => {
-const batches = api._batch(list, 2);
+const batches = api._batch([0, 1, 2, 3, 4], 2);
 assert.deepEqual(batches.length, 3);
 assert.deepEqual(batches[0].length, 2);
 assert.deepEqual(batches[1].length, 2);
@@ -35,7 +33,7 @@
 });
 
 it('order is preserved when Array.reduce is called on resolved 
BBPromise.all batches', () => {
-const batches = api._batch(list, 2);
+const batches = api._batch([0, 1, 2, 3, 4], 2);
 const promises = BBPromise.all(batches.map((batch) => {
 return new BBPromise(resolve => setTimeout(() => resolve(batch), 
batch.length * 10));
 }));

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1736624e52e00b1e0279fe1ddf1733f978e479f3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: remove unnecessary PREQ_CONNECT_TIMEOUT for unit te...

2018-01-17 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404742 )

Change subject: Hygiene: remove unnecessary PREQ_CONNECT_TIMEOUT for unit test 
run
..

Hygiene: remove unnecessary PREQ_CONNECT_TIMEOUT for unit test run

Our unit tests are not supposed to use the internet anyways.

Change-Id: I3208ca378e48fa64450cd5fad3678e608f6fcd32
---
M package.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/42/404742/1

diff --git a/package.json b/package.json
index adb9e56..91b5d2b 100644
--- a/package.json
+++ b/package.json
@@ -6,7 +6,7 @@
   "scripts": {
 "start": "service-runner",
 "test": "PREQ_CONNECT_TIMEOUT=15 mocha && nsp check",
-"test:unit": "PREQ_CONNECT_TIMEOUT=15 mocha test/lib",
+"test:unit": "mocha test/lib",
 "lint": "eslint --cache --max-warnings 0 --ext .js --ext .json .",
 "docker-start": "service-runner docker-start",
 "docker-test": "service-runner docker-test",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3208ca378e48fa64450cd5fad3678e608f6fcd32
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Skip beta cluster test

2018-01-16 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404622 )

Change subject: Skip beta cluster test
..

Skip beta cluster test

Beta cluster API is having some issues:
PHP fatal error: Stack overflow

Change-Id: I2292be3d5caae18eba6e0eb6a4d993c6f7659a39
Related: T185055
---
M test/features/mobile-sections/pagecontent.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/22/404622/1

diff --git a/test/features/mobile-sections/pagecontent.js 
b/test/features/mobile-sections/pagecontent.js
index dc072f4..67923d1 100644
--- a/test/features/mobile-sections/pagecontent.js
+++ b/test/features/mobile-sections/pagecontent.js
@@ -109,7 +109,7 @@
 });
 });
 
-it('Beta cluster request should load successfully', () => {
+it.skip('Beta cluster request should load successfully', () => {
 const uri = localUri('Foobar', 'en.wikipedia.beta.wmflabs.org');
 return preq.get({ uri })
 .then((res) => {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2292be3d5caae18eba6e0eb6a4d993c6f7659a39
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: summary: reorder summarizer transforms

2018-01-16 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404514 )

Change subject: summary: reorder summarizer transforms
..

summary: reorder summarizer transforms

Doing the regex manipulations first, then the DOM transformations to
make sure no attributes we don't want get through.

Bug: T184557
Change-Id: Ic273b63bc43e0841892a215a49b23d93099b228c
---
M lib/transformations/summarize.js
1 file changed, 11 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/14/404514/1

diff --git a/lib/transformations/summarize.js b/lib/transformations/summarize.js
index 2b70ece..6b0cff7 100644
--- a/lib/transformations/summarize.js
+++ b/lib/transformations/summarize.js
@@ -106,17 +106,6 @@
  * @return {!object} html summary
  */
 module.exports = function(html) {
-const doc = domino.createDocument(html);
-flattenElements(doc, 'a');
-removeAttributes(doc, '*', ['data-mw']);
-rmElementsWithSelector(doc, '.mw-ref, .reference');
-rmElementsWithSelector(doc, '.noexcerpt');
-rmElementsWithSelector(doc, '.noprint');
-rmElementsWithSelector(doc, 'math');
-rmElementsWithSelector(doc, 'span:empty,b:empty,i:empty,p:empty');
-removeUnwantedNodes(doc);
-
-html = doc.body.innerHTML;
 html = removeNestedParentheticals(html);
 // 1. Replace any parentheticals which have at least one space inside
 html = html.replace(/\([^)]+ [^)]+\)/g, ' ');
@@ -139,9 +128,18 @@
 // 6. Same as 5 but for non-latin comma and no space afterwards
 html = html.replace(/ ,/g, ',');
 
-doc.body.innerHTML = html;
+const doc = domino.createDocument(html);
+flattenElements(doc, 'a');
+removeAttributes(doc, '*', ['data-mw']);
+rmElementsWithSelector(doc, '.mw-ref, .reference');
+rmElementsWithSelector(doc, '.noexcerpt');
+rmElementsWithSelector(doc, '.noprint');
+rmElementsWithSelector(doc, 'math');
+rmElementsWithSelector(doc, 'span:empty,b:empty,i:empty,p:empty');
+removeUnwantedNodes(doc);
+
 return {
 extract: doc.body.textContent,
-extract_html: html
+extract_html: doc.body.innerHTML
 };
 };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic273b63bc43e0841892a215a49b23d93099b228c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: summary: skip removing data-mw attributes

2018-01-16 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404515 )

Change subject: summary: skip removing data-mw attributes
..

summary: skip removing data-mw attributes

Skip removing data-mw attributes in the summary endpoint since we later
remove all attributes which are not whitelisted anyways.

Change-Id: Idc7b4a4e9f269ea49c2e4ec7a27ea0d0daf34f7a
---
M lib/transformations/summarize.js
1 file changed, 2 insertions(+), 4 deletions(-)


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

diff --git a/lib/transformations/summarize.js b/lib/transformations/summarize.js
index 6b0cff7..832cf2e 100644
--- a/lib/transformations/summarize.js
+++ b/lib/transformations/summarize.js
@@ -3,7 +3,6 @@
 const domino = require('domino');
 const flattenElements = require('./flattenElements');
 const rmElementsWithSelector = require('./rmElementsWithSelector');
-const removeAttributes = require('./removeAttributes');
 const NodeType = require('../nodeType');
 
 const DISALLOWED_ELEMENTS = ['OBJECT', 'SCRIPT', 'STYLE'];
@@ -79,7 +78,7 @@
  * Removes unwanted nodes and element attributes.
  * @param {!Document} document the DOM document
  */
-function removeUnwantedNodes(document) {
+function removeUnwantedNodesAndAttributes(document) {
 traverseDF(document.body);
 }
 
@@ -130,13 +129,12 @@
 
 const doc = domino.createDocument(html);
 flattenElements(doc, 'a');
-removeAttributes(doc, '*', ['data-mw']);
 rmElementsWithSelector(doc, '.mw-ref, .reference');
 rmElementsWithSelector(doc, '.noexcerpt');
 rmElementsWithSelector(doc, '.noprint');
 rmElementsWithSelector(doc, 'math');
 rmElementsWithSelector(doc, 'span:empty,b:empty,i:empty,p:empty');
-removeUnwantedNodes(doc);
+removeUnwantedNodesAndAttributes(doc);
 
 return {
 extract: doc.body.textContent,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc7b4a4e9f269ea49c2e4ec7a27ea0d0daf34f7a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: summary: fix mainpage handling

2018-01-16 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404510 )

Change subject: summary: fix mainpage handling
..

summary: fix mainpage handling

The issue was that several non-English main pages are not in the
main name space. In those cases we were returning a 204 HTTP code and
no content.

Change-Id: Ie15487184a7f9fc08603fc42cfad3aeac6642dcc
---
M lib/summary.js
M test/features/summary/pagecontent.js
2 files changed, 37 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/10/404510/1

diff --git a/lib/summary.js b/lib/summary.js
index 24a9e4a..62c57ce 100644
--- a/lib/summary.js
+++ b/lib/summary.js
@@ -7,6 +7,7 @@
 
 const NS_MAIN = 0;
 const SUMMARY_NS_WHITELIST = [ NS_MAIN ];
+const EMPTY_EXTRACTS = { extract: '', extract_html: '' };
 
 /**
  * Builds a dictionary containing the various forms of a page title that a 
client may need.
@@ -64,7 +65,7 @@
 }
 
 /**
- * Get the page summary type.
+ * Gets the page summary type.
  * @param {!Object} meta page metadata from MW API
  * return {!String} the summary type (one of 'standard', 'disambiguation', or 
'mainpage')
  */
@@ -80,6 +81,26 @@
 return 'standard';
 }
 
+/**
+ * Builds the extract values.
+ * @param {!Document} doc a DOM Document with the page content
+ * @param {!boolean} isMainPage if the page is a main page
+ * return {!Object {extract, extract_html} } the extract values
+ */
+function buildExtracts(doc, isMainPage) {
+if (isMainPage) {
+return EMPTY_EXTRACTS;
+} else {
+const leadSectionDoc = parsoidSections.justLeadSection(doc);
+const intro = transforms.extractLeadIntroduction(leadSectionDoc);
+if (intro.length) {
+return transforms.summarize(intro);
+} else {
+return EMPTY_EXTRACTS;
+}
+}
+}
+
 /*
  * Build a page summary
  * @param {!String} domain the request domain
@@ -90,18 +111,16 @@
  * @return {!Object} a summary 2.0 spec-compliant page summary object
  */
 function buildSummary(domain, title, html, revTid, meta) {
-if (shouldReturn204(meta)) {
+if (!meta.mainpage && shouldReturn204(meta)) {
 return { code: 204 };
 }
 
 const doc = domino.createDocument(html);
-const leadSectionDoc = parsoidSections.justLeadSection(doc);
-const intro = transforms.extractLeadIntroduction(leadSectionDoc);
-const summary = intro.length ? transforms.summarize(intro) : { extract: 
'', extract_html: '' };
+const extracts = buildExtracts(doc, meta.mainpage);
 
 return Object.assign({
 code: 200,
-type : getSummaryType(meta),
+type: getSummaryType(meta),
 title: meta.normalizedtitle,
 displaytitle: meta.displaytitle,
 namespace: { id: meta.ns, text: meta.nsText },
@@ -121,7 +140,7 @@
 },
 content_urls: buildContentUrls(domain, title, meta),
 api_urls: buildApiUrls(domain, title, meta),
-}, summary);
+}, extracts);
 }
 
 module.exports = {
diff --git a/test/features/summary/pagecontent.js 
b/test/features/summary/pagecontent.js
index 3ffa217..35933b8 100644
--- a/test/features/summary/pagecontent.js
+++ b/test/features/summary/pagecontent.js
@@ -57,6 +57,17 @@
 });
 });
 
+it('main page in non-mainspace should also return type: \'mainpage\'', () 
=> {
+const uri = localUri('Wikipedia:Hauptseite', 'de.wikipedia.org');
+return preq.get({ uri })
+.then((res) => {
+assert.deepEqual(res.status, 200);
+assert.deepEqual(res.body.type, 'mainpage', 'type should be 
\'mainpage\'');
+assert.deepEqual(res.body.extract, '', 'should send empty 
plaintext extract');
+assert.deepEqual(res.body.extract_html, '', 'should send empty 
html extract');
+});
+});
+
 function should204(uri) {
 return preq.get({ uri })
 .then((res) => {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie15487184a7f9fc08603fc42cfad3aeac6642dcc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: extract method for when to return 204

2018-01-16 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404509 )

Change subject: Hygiene: extract method for when to return 204
..

Hygiene: extract method for when to return 204

Change-Id: I97a3464f5f9f1eccef2831f6189fa2c4c450846f
---
M lib/summary.js
1 file changed, 28 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/09/404509/1

diff --git a/lib/summary.js b/lib/summary.js
index 9549204..24a9e4a 100644
--- a/lib/summary.js
+++ b/lib/summary.js
@@ -22,23 +22,6 @@
 };
 }
 
-/**
- * Get the page summary type.
- * @param {!Object} meta page metadata from MW API
- * return {!String} the summary type (one of 'standard', 'disambiguation', or 
'mainpage')
- */
-function getSummaryType(meta) {
-const isDisambiguationPage = meta.pageprops
-&& {}.hasOwnProperty.call(meta.pageprops, 'disambiguation');
-if (meta.mainpage) {
-return 'mainpage';
-}
-if (isDisambiguationPage) {
-return 'disambiguation';
-}
-return 'standard';
-}
-
 function buildContentUrls(domain, title, meta) {
 const mobileBaseUrl = meta.mobileHost;
 return {
@@ -70,6 +53,33 @@
 };
 }
 
+/**
+ * @param {!Object} meta page metadata from MW API
+ * return {!boolean} true if a '204: No Content' should be returned, false 
otherwise
+ */
+function shouldReturn204(meta) {
+return !SUMMARY_NS_WHITELIST.includes(meta.ns)
+|| meta.redirect
+|| meta.contentmodel !== 'wikitext';
+}
+
+/**
+ * Get the page summary type.
+ * @param {!Object} meta page metadata from MW API
+ * return {!String} the summary type (one of 'standard', 'disambiguation', or 
'mainpage')
+ */
+function getSummaryType(meta) {
+const isDisambiguationPage = meta.pageprops
+&& {}.hasOwnProperty.call(meta.pageprops, 'disambiguation');
+if (meta.mainpage) {
+return 'mainpage';
+}
+if (isDisambiguationPage) {
+return 'disambiguation';
+}
+return 'standard';
+}
+
 /*
  * Build a page summary
  * @param {!String} domain the request domain
@@ -80,15 +90,7 @@
  * @return {!Object} a summary 2.0 spec-compliant page summary object
  */
 function buildSummary(domain, title, html, revTid, meta) {
-if (!SUMMARY_NS_WHITELIST.includes(meta.ns)) {
-return { code: 204 };
-}
-
-if (meta.redirect) {
-return { code: 204 };
-}
-
-if (meta.contentmodel !== 'wikitext') {
+if (shouldReturn204(meta)) {
 return { code: 204 };
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97a3464f5f9f1eccef2831f6189fa2c4c450846f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Also keep style attributes when flattening elements

2018-01-16 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404496 )

Change subject: Also keep style attributes when flattening elements
..

Also keep style attributes when flattening elements

See comment https://phabricator.wikimedia.org/T177007#3899976.

Bug: T177007
Change-Id: I3703875bcf1cc924c0ec9bb5a4aa165efbb35d0d
---
M lib/transformations/flattenElements.js
M test/lib/transformations/flattenElements.test.js
2 files changed, 31 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/96/404496/1

diff --git a/lib/transformations/flattenElements.js 
b/lib/transformations/flattenElements.js
index f3d917f..0ee39fc 100644
--- a/lib/transformations/flattenElements.js
+++ b/lib/transformations/flattenElements.js
@@ -1,24 +1,41 @@
 'use strict';
 
-const KEEP_ATTRIBUTE = 'class';
+const KEEP_ATTRIBUTES = [ 'class', 'style' ];
+
+/**
+ * @param {!Element} element the element to copy attributes from
+ * @param {!Array} nameArray an array of attribute names
+ * @return {boolean} true if at least one of the attribute names exist
+ * on the element false otherwise.
+ */
+function hasAttribute(element, nameArray) {
+for (let i = 0; i < nameArray.length; i++) {
+if (element.getAttribute(nameArray[i])) {
+return true;
+}
+}
+return false;
+}
 
 /**
  * Copies only select attributes from one DOM element to another.
  * @param {!Element} oldElement the element to copy attributes from
  * @param {!Element} newElement the element to copy attributes to
- * @param {!String} name the name of the attribute
+ * @param {!Array} nameArray an array of attribute names
  */
-function copyAttribute(oldElement, newElement, name) {
-if (oldElement.getAttribute(name)) {
-newElement.setAttribute(name, oldElement.getAttribute(name));
-}
+function copyAttributes(oldElement, newElement, nameArray) {
+nameArray.forEach((name) => {
+if (oldElement.getAttribute(name)) {
+newElement.setAttribute(name, oldElement.getAttribute(name));
+}
+});
 }
 
 function createReplacementNode(oldElement, document) {
-if (oldElement.getAttribute(KEEP_ATTRIBUTE)) {
+if (hasAttribute(oldElement, KEEP_ATTRIBUTES)) {
 const spanElement = document.createElement('span');
 spanElement.innerHTML = oldElement.innerHTML;
-copyAttribute(oldElement, spanElement, KEEP_ATTRIBUTE);
+copyAttributes(oldElement, spanElement, KEEP_ATTRIBUTES);
 return spanElement;
 } else {
 return document.createTextNode(oldElement.innerHTML);
diff --git a/test/lib/transformations/flattenElements.test.js 
b/test/lib/transformations/flattenElements.test.js
index 4bd1726..3bc1c6c 100644
--- a/test/lib/transformations/flattenElements.test.js
+++ b/test/lib/transformations/flattenElements.test.js
@@ -11,6 +11,12 @@
 assert.deepEqual(document.body.innerHTML, 'foo');
 });
 
+it('replaces a with span, keeps style attribute', () => {
+const document = domino.createDocument('foo');
+flattenElements(document, 'a');
+assert.deepEqual(document.body.innerHTML, 'foo');
+});
+
 it('replaces a tag with plain text if no attributes to keep', () => {
 const document = domino.createDocument('foo');
 flattenElements(document, 'a');

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3703875bcf1cc924c0ec9bb5a4aa165efbb35d0d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: move summary library functions to own lib file

2018-01-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404245 )

Change subject: Hygiene: move summary library functions to own lib file
..

Hygiene: move summary library functions to own lib file

There were a lot of summary functions residing in the general
mobile-util.js. I moved them all to a new library module.
Same for the currently single unit test. I hope the new structure will
make it more conducive to write more.

Change-Id: Ic3ade779bd059231e654c49046118ace20eb8e59
---
M lib/mobile-util.js
A lib/summary.js
M routes/summary.js
M test/lib/mobile-util/mobile-util-test.js
A test/lib/summary/summary.test.js
5 files changed, 151 insertions(+), 130 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/45/404245/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index ad68b28..8537433 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -1,13 +1,9 @@
 'use strict';
 
-const domino = require('domino');
 const underscore = require('underscore');
 const uuid = require('cassandra-uuid').TimeUuid;
 const HTTPError = require('./util').HTTPError;
-const transforms = require('./transforms');
 const mUtil = {};
-
-const NS_MAIN = 0;
 
 mUtil.CONTENT_TYPES = {
 mobileSections: { name: 'mobile-sections', version: '0.13.1' },
@@ -22,8 +18,6 @@
 onthisday: { name: 'onthisday', version: '0.3.3' },
 unpublished: { name: 'unpublished', version: '0.0.0' }
 };
-
-mUtil.SUMMARY_NS_WHITELIST = [ NS_MAIN ];
 
 mUtil.setContentType = function(res, spec, mainType = 'application/json') {
 if (!spec.name || !spec.version) {
@@ -143,122 +137,6 @@
 }
 });
 return request.uri;
-};
-
-/**
- * Builds a dictionary containing the various forms of a page title that a 
client may need.
- * @param {!Object} title a mediawiki-title Title object constructed from a 
page title string
- * @param {!Object} meta page metadata
- * @return {!Object} a set of useful page title strings
- */
-mUtil.buildTitleDictionary = function(title, meta) {
-return {
-canonical: title.getPrefixedDBKey(),
-normalized: meta.normalizedtitle,
-display: meta.displaytitle,
-};
-};
-
-/**
- * Get the page summary type.
- * @param {!Object} meta page metadata from MW API
- * return {!String} the summary type (one of 'standard', 'disambiguation', or 
'mainpage')
- */
-mUtil.getSummaryType = function(meta) {
-const isDisambiguationPage = meta.pageprops
-  && {}.hasOwnProperty.call(meta.pageprops, 'disambiguation');
-if (meta.mainpage) {
-return 'mainpage';
-}
-if (isDisambiguationPage) {
-return 'disambiguation';
-}
-return 'standard';
-};
-
-/*
- * Build a page summary
- * @param {!String} domain the request domain
- * @param {!Object} title a mediawiki-title object for the page title
- * @param {!Object} page page content and metadata from Parsoid
- * @param {!Object} meta metadata from MW API
- * @return {!Object} a summary 2.0 spec-compliant page summary object
- */
-mUtil.buildSummary = function(domain, title, page, meta) {
-const isContentModelWikitext = meta.contentmodel === 'wikitext';
-const isWhiteListedNamespace = 
mUtil.SUMMARY_NS_WHITELIST.includes(meta.ns);
-const isRedirect = meta.redirect;
-
-if (!isContentModelWikitext) {
-return { code: 204 };
-}
-
-if (!isWhiteListedNamespace) {
-return { code: 204 };
-}
-
-if (isRedirect) {
-return { code: 204 };
-}
-
-const leadText = domino.createDocument(page.sections[0].text);
-const intro = transforms.extractLeadIntroduction(leadText);
-const summary = intro.length ? transforms.summarize(intro) : { extract: 
'', extract_html: '' };
-
-return Object.assign({
-code: 200,
-type : mUtil.getSummaryType(meta),
-title: meta.normalizedtitle,
-displaytitle: meta.displaytitle,
-namespace: { id: meta.ns, text: meta.nsText },
-titles: mUtil.buildTitleDictionary(title, meta),
-pageid: meta.id,
-thumbnail: meta.thumbnail,
-originalimage: meta.originalimage,
-lang: meta.lang,
-dir: meta.dir,
-revision: page.revision,
-tid: page.tid,
-timestamp: page.lastmodified,
-description: meta.description,
-coordinates: meta.geo && {
-lat: meta.geo.latitude,
-lon: meta.geo.longitude
-},
-content_urls: mUtil.buildContentUrls(domain, title, meta),
-api_urls: mUtil.buildApiUrls(domain, title, meta),
-}, summary);
-};
-
-mUtil.buildContentUrls = function(domain, title, meta) {
-const mobileBaseUrl = meta.mobileHost;
-return {
-desktop: {
-page: `https://${domain}/wiki/${title.getPrefixedDBKey()}`,
-revisions: 
`https://${domain}/wiki/${title.getPrefixedDBKey()}?action=history`,
-edit: 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: summary: inline 204 checks

2018-01-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404248 )

Change subject: summary: inline 204 checks
..

summary: inline 204 checks

The three checks for when to return 204 are simple enough that we could
inline them.

Change-Id: I4dd52a63c3bc438066c9d715e955f526c3c79255
---
M lib/summary.js
1 file changed, 3 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/48/404248/1

diff --git a/lib/summary.js b/lib/summary.js
index 37e5450..9549204 100644
--- a/lib/summary.js
+++ b/lib/summary.js
@@ -80,19 +80,15 @@
  * @return {!Object} a summary 2.0 spec-compliant page summary object
  */
 function buildSummary(domain, title, html, revTid, meta) {
-const isContentModelWikitext = meta.contentmodel === 'wikitext';
-const isWhiteListedNamespace = SUMMARY_NS_WHITELIST.includes(meta.ns);
-const isRedirect = meta.redirect;
-
-if (!isContentModelWikitext) {
+if (!SUMMARY_NS_WHITELIST.includes(meta.ns)) {
 return { code: 204 };
 }
 
-if (!isWhiteListedNamespace) {
+if (meta.redirect) {
 return { code: 204 };
 }
 
-if (isRedirect) {
+if (meta.contentmodel !== 'wikitext') {
 return { code: 204 };
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4dd52a63c3bc438066c9d715e955f526c3c79255
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: summary: just parse the lead section

2018-01-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404247 )

Change subject: summary: just parse the lead section
..

summary: just parse the lead section

No need to try to parse other sections for the summary endpoint.

Change-Id: I02828100fd1a81c94e1a842c3264caba51c634ed
---
M lib/parsoidSections.js
M lib/parsoidSectionsUsingDivs.js
M lib/parsoidSectionsUsingSectionTags.js
M lib/summary.js
M routes/summary.js
M test/lib/parsoid/parsoid-sections-div-element-test.js
M test/lib/parsoid/parsoid-sections-section-elements-tests.js
7 files changed, 69 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/47/404247/1

diff --git a/lib/parsoidSections.js b/lib/parsoidSections.js
index f8e21d6..f785685 100644
--- a/lib/parsoidSections.js
+++ b/lib/parsoidSections.js
@@ -38,8 +38,23 @@
 }
 }
 
+/**
+ * Reduces the input Parsoid document to a new Document containing
+ * just the first section.
+ * @param {!document} doc the parsed DOM Document of the Parsoid output
+ * @return {!Document} a new DOM Document containing only the lead section
+ */
+function justLeadSection(doc) {
+if (!hasParsoidSections(doc)) {
+return parsoidSectionsUsingDivs.justLeadSection(doc);
+} else {
+return parsoidSectionsUsingSectionTags.justLeadSection(doc);
+}
+}
+
 module.exports = {
 hasParsoidSections,
 addSectionDivs,
-getSectionsText
+getSectionsText,
+justLeadSection
 };
diff --git a/lib/parsoidSectionsUsingDivs.js b/lib/parsoidSectionsUsingDivs.js
index a5886dd..5d11837 100644
--- a/lib/parsoidSectionsUsingDivs.js
+++ b/lib/parsoidSectionsUsingDivs.js
@@ -1,11 +1,11 @@
 'use strict';
 
 /*
-  This is an old way of doing sectioning, which is preserved only for the 
definitions endpoint.
-  TODO: We should move the definition parsing implementation to the new way
-  (parsoidSectionsUsingSectionTags.js) soon since when Parsoid deploys adding 
 tags the
-  definitions code may be negatively affected by that.
+  This is an old way of doing sectioning, which is preserved only just in case
+  we encounter a payload from an older Parsoid version.
 */
+
+const domino = require('domino');
 
 function parseNextSection(sectionDiv, startingNode) {
 let nextNode;
@@ -96,7 +96,18 @@
 return sections;
 }
 
+/**
+ * @param {!document} doc the parsed DOM Document of the Parsoid output
+ * @return {!Document} a new DOM Document containing only the lead section
+ */
+function justLeadSection(doc) {
+const sectionDiv = doc.createElement('div');
+parseNextSection(sectionDiv, doc.body.firstChild);
+return domino.createDocument(sectionDiv.innerHTML);
+}
+
 module.exports = {
 addSectionDivs,
-getSectionsText
+getSectionsText,
+justLeadSection
 };
diff --git a/lib/parsoidSectionsUsingSectionTags.js 
b/lib/parsoidSectionsUsingSectionTags.js
index a30d537..aab9cd3 100644
--- a/lib/parsoidSectionsUsingSectionTags.js
+++ b/lib/parsoidSectionsUsingSectionTags.js
@@ -1,5 +1,6 @@
 'use strict';
 
+const domino = require('domino');
 const parsoidDomUtils = require('parsoid-dom-utils');
 const NodeType = require('./nodeType');
 
@@ -18,7 +19,7 @@
 
 /**
  * Gets the section number from Parsoid.
- * @param {!DOMElement} sectionElement a  DOM element
+ * @param {!Element} sectionElement a  DOM element
  * @return {int} the section number as reported by Parsoid
  */
 function getSectionNumber(sectionElement) {
@@ -66,7 +67,7 @@
  * In this case, starts a new section object when a  tag is 
encountered that is a
  * direct descendant
  * @param {!Logger} logger the app's bunyan logger
- * @param {!DOMNode} node the node to visit
+ * @param {!Node} node the node to visit
  * @param {!Object[]} allSections the array containing the results
  * @param {!Object} state some state to pass around
  */
@@ -103,7 +104,7 @@
  * descending so we don't duplicate content since elsewhere outerHTML is used 
(which contains
  * content of sub-nodes).
  * @param {!Logger} logger the app's bunyan logger
- * @param {!DOMElement} rootElement the root of the DOM tree which needs to be 
traversed
+ * @param {!Element} rootElement the root of the DOM tree which needs to be 
traversed
  * @param {!Object[]} allSections holds the results
  */
 function traverseDF(logger, rootElement, allSections) {
@@ -130,9 +131,19 @@
 return allSections;
 }
 
+/**
+ * @param {!document} doc the parsed DOM Document of the Parsoid output
+ * @return {!Document} a new DOM Document containing only the lead section
+ */
+function justLeadSection(doc) {
+const currentSectionElement = 
doc.querySelector('section[data-mw-section-id]');
+return domino.createDocument(currentSectionElement.innerHTML);
+}
+
 module.exports = {
 addSectionTags,
 getSectionsText,
+justLeadSection,
 testing: {
 parseSections: traverseDF,
 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Initial streamlining getting the summary HTML

2018-01-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404246 )

Change subject: Initial streamlining getting the summary HTML
..

Initial streamlining getting the summary HTML

* Replace pageJsonPromise with getParsoidHtml
pageJsonPromise does too many things we don't need:
** parsePronunciation
** parseSpokenWikipedia
** stripUnneededMarkup
** addSectionDivs (only need the first section), maybe tackle later

We also don't need them this early because if we return early in the 204
cases all this computation is thrown away.

Change-Id: I6a1a31aa5a1e5e608a37b0e8722c1c26b6ea4411
---
M lib/parsoid-access.js
M lib/summary.js
M routes/summary.js
3 files changed, 22 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/46/404246/1

diff --git a/lib/parsoid-access.js b/lib/parsoid-access.js
index 8633db3..15eeb8a 100644
--- a/lib/parsoid-access.js
+++ b/lib/parsoid-access.js
@@ -221,6 +221,7 @@
 getParsoidHtml,
 getRevisionFromEtag,
 getRevAndTidFromEtag,
+getModified,
 
 // VisibleForTesting
 _getBaseUri: getBaseUri,
diff --git a/lib/summary.js b/lib/summary.js
index 59db23b..6e18df5 100644
--- a/lib/summary.js
+++ b/lib/summary.js
@@ -1,6 +1,8 @@
 'use strict';
 
 const domino = require('domino');
+const parsoid = require('./parsoid-access');
+const parsoidSections = require('./parsoidSections');
 const transforms = require('./transforms');
 
 const NS_MAIN = 0;
@@ -72,11 +74,13 @@
  * Build a page summary
  * @param {!String} domain the request domain
  * @param {!Object} title a mediawiki-title object for the page title
- * @param {!Object} page page content and metadata from Parsoid
+ * @param {!String} html page content and metadata from Parsoid
+ * @param {!Object} revTid revision and tid from Parsoid
  * @param {!Object} meta metadata from MW API
+ * @param {!Logger} logger a bunyan logger
  * @return {!Object} a summary 2.0 spec-compliant page summary object
  */
-function buildSummary(domain, title, page, meta) {
+function buildSummary(domain, title, html, revTid, meta, logger) {
 const isContentModelWikitext = meta.contentmodel === 'wikitext';
 const isWhiteListedNamespace = SUMMARY_NS_WHITELIST.includes(meta.ns);
 const isRedirect = meta.redirect;
@@ -93,8 +97,12 @@
 return { code: 204 };
 }
 
-const leadText = domino.createDocument(page.sections[0].text);
-const intro = transforms.extractLeadIntroduction(leadText);
+const doc = domino.createDocument(html);
+parsoidSections.addSectionDivs(doc);
+const sections = parsoidSections.getSectionsText(doc, logger);
+
+const leadSectionDoc = domino.createDocument(sections[0].text);
+const intro = transforms.extractLeadIntroduction(leadSectionDoc);
 const summary = intro.length ? transforms.summarize(intro) : { extract: 
'', extract_html: '' };
 
 return Object.assign({
@@ -109,9 +117,9 @@
 originalimage: meta.originalimage,
 lang: meta.lang,
 dir: meta.dir,
-revision: page.revision,
-tid: page.tid,
-timestamp: page.lastmodified,
+revision: revTid.revision,
+tid: revTid.tid,
+timestamp: parsoid.getModified(doc),
 description: meta.description,
 coordinates: meta.geo && {
 lat: meta.geo.latitude,
diff --git a/routes/summary.js b/routes/summary.js
index 21ad57b..07577e3 100644
--- a/routes/summary.js
+++ b/routes/summary.js
@@ -19,22 +19,24 @@
 let app;
 
 /**
- * GET {domain}/v1/page/summary/{title}/{revision?}/{tid?}
+ * GET {domain}/v1/page/summary/{title}{/revision?}{/tid?}
  * Extracts a summary of a given wiki page limited to one paragraph of text
  */
 router.get('/summary/:title/:revision?/:tid?', (req, res) => {
 return BBPromise.props({
-page: parsoid.pageJsonPromise(app, req, false),
+html: parsoid.getParsoidHtml(app, req),
 meta: mwapi.getMetadata(app, req),
 title: mwapi.getTitleObj(app, req),
 siteinfo: mwapi.getSiteInfo(app, req)
 }).then((response) => {
+const revTid = parsoid.getRevAndTidFromEtag(response.html.headers);
 const title = Title.newFromText(req.params.title, response.siteinfo);
-const summary = lib.buildSummary(req.params.domain, title, 
response.page, response.meta);
+const summary = lib.buildSummary(req.params.domain, title,
+response.html.body, revTid, response.meta, req.logger);
 res.status(summary.code);
 if (summary.code === 200) {
 delete summary.code;
-mUtil.setETag(res, summary.revision, summary.tid);
+mUtil.setETag(res, revTid.revision, revTid.tid);
 mUtil.setContentType(res, mUtil.CONTENT_TYPES.summary);
 res.send(summary);
 }

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

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: remove extraneous disambig code

2018-01-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404242 )

Change subject: Hygiene: remove extraneous disambig code
..

Hygiene: remove extraneous disambig code

The disambig flag gets determined inside the mUtil.getSummaryType()
method anyways.

Change-Id: I8a747be6351a7d70acb77252dda5269291b56a83
---
M routes/mobile-sections.js
1 file changed, 1 insertion(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/42/404242/1

diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index f8ed15a..b34d9f7 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -365,9 +365,7 @@
 siteinfo: mwapi.getSiteInfo(app, req)
 }).then((response) => {
 const title = Title.newFromText(req.params.title, response.siteinfo);
-const pageProps = response.pageData.meta && 
response.pageData.meta.pageprops;
-const disambig = pageProps && {}.hasOwnProperty.call(pageProps, 
'disambiguation');
-const summary = mUtil.buildSummary(req.params.domain, title, 
response.pageData, disambig);
+const summary = mUtil.buildSummary(req.params.domain, title, 
response.pageData);
 res.status(summary.code);
 if (summary.code === 200) {
 delete summary.code;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8a747be6351a7d70acb77252dda5269291b56a83
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: move summary route to own file

2018-01-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404244 )

Change subject: Hygiene: move summary route to own file
..

Hygiene: move summary route to own file

Change-Id: I3f1c11331d4b1ecbc19fa6d5b1a039aa67fee1ec
---
M routes/mobile-sections.js
A routes/summary.js
2 files changed, 51 insertions(+), 25 deletions(-)


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

diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index 979e2c8..9584add 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -8,7 +8,6 @@
 const parsoid = require('../lib/parsoid-access');
 const sUtil = require('../lib/util');
 const transforms = require('../lib/transforms');
-const Title = require('mediawiki-title').Title;
 
 /**
  * The main router object
@@ -352,30 +351,6 @@
 mUtil.setETag(res, response.page.revision, response.page.tid);
 mUtil.setContentType(res, mUtil.CONTENT_TYPES.mobileSections);
 res.json(buildRemaining(response)).end();
-});
-});
-
-/**
-* GET {domain}/v1/page/summary/{title}/{revision?}/{tid?}
-* Extracts a summary of a given wiki page limited to one paragraph of text
-*/
-router.get('/summary/:title/:revision?/:tid?', (req, res) => {
-return BBPromise.props({
-page: parsoid.pageJsonPromise(app, req, false),
-meta: mwapi.getMetadata(app, req),
-title: mwapi.getTitleObj(app, req),
-siteinfo: mwapi.getSiteInfo(app, req)
-}).then((response) => {
-const title = Title.newFromText(req.params.title, response.siteinfo);
-const summary = mUtil.buildSummary(req.params.domain, title, 
response.page, response.meta);
-res.status(summary.code);
-if (summary.code === 200) {
-delete summary.code;
-mUtil.setETag(res, summary.revision, summary.tid);
-mUtil.setContentType(res, mUtil.CONTENT_TYPES.summary);
-res.send(summary);
-}
-res.end();
 });
 });
 
diff --git a/routes/summary.js b/routes/summary.js
new file mode 100644
index 000..8a3b058
--- /dev/null
+++ b/routes/summary.js
@@ -0,0 +1,51 @@
+'use strict';
+
+const BBPromise = require('bluebird');
+const mwapi = require('../lib/mwapi');
+const mUtil = require('../lib/mobile-util');
+const parsoid = require('../lib/parsoid-access');
+const sUtil = require('../lib/util');
+const Title = require('mediawiki-title').Title;
+
+/**
+ * The main router object
+ */
+const router = sUtil.router();
+
+/**
+ * The main application object reported when this module is require()d
+ */
+let app;
+
+/**
+ * GET {domain}/v1/page/summary/{title}/{revision?}/{tid?}
+ * Extracts a summary of a given wiki page limited to one paragraph of text
+ */
+router.get('/summary/:title/:revision?/:tid?', (req, res) => {
+return BBPromise.props({
+page: parsoid.pageJsonPromise(app, req, false),
+meta: mwapi.getMetadata(app, req),
+title: mwapi.getTitleObj(app, req),
+siteinfo: mwapi.getSiteInfo(app, req)
+}).then((response) => {
+const title = Title.newFromText(req.params.title, response.siteinfo);
+const summary = mUtil.buildSummary(req.params.domain, title, 
response.page, response.meta);
+res.status(summary.code);
+if (summary.code === 200) {
+delete summary.code;
+mUtil.setETag(res, summary.revision, summary.tid);
+mUtil.setContentType(res, mUtil.CONTENT_TYPES.summary);
+res.send(summary);
+}
+res.end();
+});
+});
+
+module.exports = function(appObj) {
+app = appObj;
+return {
+path: '/page',
+api_version: 1,
+router
+};
+};

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f1c11331d4b1ecbc19fa6d5b1a039aa67fee1ec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: inline the summary call to _collectRawPageData

2018-01-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404243 )

Change subject: Hygiene: inline the summary call to _collectRawPageData
..

Hygiene: inline the summary call to _collectRawPageData

This makes it easier to move things around.

Change-Id: Ie5a28f7110b374d043adb8d876561c4e3b4134af
---
M lib/mobile-util.js
M routes/mobile-sections.js
2 files changed, 7 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/43/404243/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index 52ba34b..ad68b28 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -180,12 +180,11 @@
  * Build a page summary
  * @param {!String} domain the request domain
  * @param {!Object} title a mediawiki-title object for the page title
- * @param {!Object} pageData raw page data for the page
+ * @param {!Object} page page content and metadata from Parsoid
+ * @param {!Object} meta metadata from MW API
  * @return {!Object} a summary 2.0 spec-compliant page summary object
  */
-mUtil.buildSummary = function(domain, title, pageData) {
-const page = pageData.page;
-const meta = pageData.meta;
+mUtil.buildSummary = function(domain, title, page, meta) {
 const isContentModelWikitext = meta.contentmodel === 'wikitext';
 const isWhiteListedNamespace = 
mUtil.SUMMARY_NS_WHITELIST.includes(meta.ns);
 const isRedirect = meta.redirect;
diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index b34d9f7..979e2c8 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -361,11 +361,13 @@
 */
 router.get('/summary/:title/:revision?/:tid?', (req, res) => {
 return BBPromise.props({
-pageData: _collectRawPageData(req, false),
+page: parsoid.pageJsonPromise(app, req, false),
+meta: mwapi.getMetadata(app, req),
+title: mwapi.getTitleObj(app, req),
 siteinfo: mwapi.getSiteInfo(app, req)
 }).then((response) => {
 const title = Title.newFromText(req.params.title, response.siteinfo);
-const summary = mUtil.buildSummary(req.params.domain, title, 
response.pageData);
+const summary = mUtil.buildSummary(req.params.domain, title, 
response.page, response.meta);
 res.status(summary.code);
 if (summary.code === 200) {
 delete summary.code;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5a28f7110b374d043adb8d876561c4e3b4134af
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: add more summary tests

2018-01-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404241 )

Change subject: Hygiene: add more summary tests
..

Hygiene: add more summary tests

Change-Id: I245cb3b3715cb67b7c589f42079f34203c25d32d
---
M test/features/summary/pagecontent.js
1 file changed, 17 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/41/404241/1

diff --git a/test/features/summary/pagecontent.js 
b/test/features/summary/pagecontent.js
index 9d5d999..3ffa217 100644
--- a/test/features/summary/pagecontent.js
+++ b/test/features/summary/pagecontent.js
@@ -57,13 +57,24 @@
 });
 });
 
-it('204 should be returned for redirect page', () => {
-const uri = localUri('Barack');
+function should204(uri) {
 return preq.get({ uri })
-.then((res) => {
-assert.deepEqual(res.status, 204);
-assert.ok(!res.body);
-});
+.then((res) => {
+assert.deepEqual(res.status, 204);
+assert.deepEqual(res.body, undefined, 'no content');
+});
+}
+
+it('204 should be returned for a file page', () => {
+should204(localUri('File:En-Alliterative_verse-article.ogg', 
'commons.wikimedia.org'));
+});
+
+it('204 should be returned for a talk page', () => {
+should204(localUri('Talk:Foobar'));
+});
+
+it('204 should be returned for a redirected page', () => {
+should204(localUri('Barack'));
 });
 
 it('timestamp should refer to the requested revision, not the latest 
revision', () => {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I245cb3b3715cb67b7c589f42079f34203c25d32d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Flatten DOM anchors if no attributes kept

2018-01-12 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403977 )

Change subject: Flatten DOM anchors if no attributes kept
..

Flatten DOM anchors if no attributes kept

The flattenElements method previously did not really flatten in a DOM
sense because it changed the  tags to another element ().
This patch proposes to really flatten the  tags to plain text,
but only if there is no (class) attribute to be retained.

Bug: T177007
Change-Id: Ib2e63e665d62e8a80215c456c7832a8e965caad1
---
M lib/transformations/flattenElements.js
A test/lib/transformations/flattenElements.test.js
M test/lib/transformations/summarize.js
3 files changed, 62 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/77/403977/1

diff --git a/lib/transformations/flattenElements.js 
b/lib/transformations/flattenElements.js
index 42f9ea9..f3d917f 100644
--- a/lib/transformations/flattenElements.js
+++ b/lib/transformations/flattenElements.js
@@ -1,21 +1,45 @@
 'use strict';
 
+const KEEP_ATTRIBUTE = 'class';
+
 /**
- * Replace all elements in Document `content` that match the
- * css selector, replacing them with span tags.
- * @param {!Document} content
+ * Copies only select attributes from one DOM element to another.
+ * @param {!Element} oldElement the element to copy attributes from
+ * @param {!Element} newElement the element to copy attributes to
+ * @param {!String} name the name of the attribute
+ */
+function copyAttribute(oldElement, newElement, name) {
+if (oldElement.getAttribute(name)) {
+newElement.setAttribute(name, oldElement.getAttribute(name));
+}
+}
+
+function createReplacementNode(oldElement, document) {
+if (oldElement.getAttribute(KEEP_ATTRIBUTE)) {
+const spanElement = document.createElement('span');
+spanElement.innerHTML = oldElement.innerHTML;
+copyAttribute(oldElement, spanElement, KEEP_ATTRIBUTE);
+return spanElement;
+} else {
+return document.createTextNode(oldElement.innerHTML);
+}
+}
+
+/**
+ * Replaces all elements in the given Document which match the
+ * CSS selector, replacing them with span tags or text.
+ * If the resulting span tag doesn't have any attributes then
+ * the element is replaced with a TextNode of the same content.
+ * The main purpose of this is to disable certain  tags.
+ * @param {!Document} document
  * @param {string} selector
  */
-function flattenElements(content, selector) {
-const elements = content.querySelectorAll(selector);
+function flattenElements(document, selector) {
+const elements = document.querySelectorAll(selector);
 for (let i = 0; i < elements.length; i++) {
-const element = elements[i];
-const replacementSpan = content.createElement('span');
-replacementSpan.innerHTML = element.innerHTML;
-if (element.getAttribute('class')) {
-replacementSpan.setAttribute('class', 
element.getAttribute('class'));
-}
-element.parentNode.replaceChild(replacementSpan, element);
+const oldElement = elements[i];
+const newNode = createReplacementNode(oldElement, document);
+oldElement.parentNode.replaceChild(newNode, oldElement);
 }
 }
 
diff --git a/test/lib/transformations/flattenElements.test.js 
b/test/lib/transformations/flattenElements.test.js
new file mode 100644
index 000..4bd1726
--- /dev/null
+++ b/test/lib/transformations/flattenElements.test.js
@@ -0,0 +1,19 @@
+"use strict";
+
+const domino = require('domino');
+const assert = require('./../../utils/assert.js');
+const flattenElements = 
require('./../../../lib/transformations/flattenElements');
+
+describe('lib:flattenElements', () => {
+it('replaces a with span, keeps class attribute', () => {
+const document = domino.createDocument('foo');
+flattenElements(document, 'a');
+assert.deepEqual(document.body.innerHTML, 'foo');
+});
+
+it('replaces a tag with plain text if no attributes to keep', () => {
+const document = domino.createDocument('foo');
+flattenElements(document, 'a');
+assert.deepEqual(document.body.innerHTML, 'foo');
+});
+});
diff --git a/test/lib/transformations/summarize.js 
b/test/lib/transformations/summarize.js
index fe90123..ec25458 100644
--- a/test/lib/transformations/summarize.js
+++ b/test/lib/transformations/summarize.js
@@ -36,7 +36,7 @@
 // Should flatten links
 [
 'This is some content with a link.',
-'This is some content with a link.'
+'This is some content with a link.'
 ],
 // Should strip .noexcerpt
 [
@@ -125,22 +125,22 @@
 // Content inside Cantonese parentheticals are also stripped
 [
 '蔡英文(Tsai 
Ing-wen,1956年8月31號—)係現任中華民國總統,臺灣學者同埋政治人,民主進步黨主席。',
-

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Summary: flattened anchors stay anchors

2018-01-11 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403882 )

Change subject: Summary: flattened anchors stay anchors
..

Summary: flattened anchors stay anchors

We can remove the flattenElements call for anchors if we accept to just
remove the attributes and keep the element  instead of making them
s.

Change-Id: Id5b9a76090369a044b82d99d7fe17bb1f34fac14
---
M lib/transformations/summarize.js
M test/lib/transformations/summarize.js
2 files changed, 11 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/82/403882/1

diff --git a/lib/transformations/summarize.js b/lib/transformations/summarize.js
index 2b70ece..750bac2 100644
--- a/lib/transformations/summarize.js
+++ b/lib/transformations/summarize.js
@@ -1,7 +1,6 @@
 "use strict";
 
 const domino = require('domino');
-const flattenElements = require('./flattenElements');
 const rmElementsWithSelector = require('./rmElementsWithSelector');
 const removeAttributes = require('./removeAttributes');
 const NodeType = require('../nodeType');
@@ -107,7 +106,6 @@
  */
 module.exports = function(html) {
 const doc = domino.createDocument(html);
-flattenElements(doc, 'a');
 removeAttributes(doc, '*', ['data-mw']);
 rmElementsWithSelector(doc, '.mw-ref, .reference');
 rmElementsWithSelector(doc, '.noexcerpt');
diff --git a/test/lib/transformations/summarize.js 
b/test/lib/transformations/summarize.js
index fe90123..f5f563a 100644
--- a/test/lib/transformations/summarize.js
+++ b/test/lib/transformations/summarize.js
@@ -36,7 +36,7 @@
 // Should flatten links
 [
 'This is some content with a link.',
-'This is some content with a link.'
+'This is some content with a link.'
 ],
 // Should strip .noexcerpt
 [
@@ -124,23 +124,23 @@
 ],
 // Content inside Cantonese parentheticals are also stripped
 [
-'蔡英文(Tsai 
Ing-wen,1956年8月31號—)係現任中華民國總統,臺灣學者同埋政治人,民主進步黨主席。',
-'蔡英文 
係現任中華民國總統,臺灣學者同埋政治人,民主進步黨主席。'
+'蔡英文(Tsai Ing-wen,1956年8月31號—)係現任中華民國總統,臺灣學者同埋政治人,民主進步黨主席。',
+'蔡英文 
係現任中華民國總統,臺灣學者同埋政治人,民主進步黨主席。'
 ],
 // Content inside parentheticals written in `wuu` language variant 
are also stripped
 [
-'东亚(日文:東アジア ‧ 東亜,韩文:東아시아,西文:Asia 
Oriental)是一个比较笼统个地理概念,立在弗同个语境当中有弗一样个含义。东亚个概念来自欧洲人对东方个定位,拿博斯普鲁斯海峡、乌拉尔山脉东面个广大欧亚大陆地区侪通称亚洲,拿西太平洋沿岸、欧亚大陆东端个地区就叫做东亚。',
-'东亚 
是一个比较笼统个地理概念,立在弗同个语境当中有弗一样个含义。东亚个概念来自欧洲人对东方个定位,拿博斯普鲁斯海峡、乌拉尔山脉东面个广大欧亚大陆地区侪通称亚洲,拿西太平洋沿岸、欧亚大陆东端个地区就叫做东亚。'
+'东亚(日文:東アジア ‧ 東亜,韩文:東아시아,西文:Asia 
Oriental)是一个比较笼统个地理概念,立在弗同个语境当中有弗一样个含义。东亚个概念来自欧洲人对东方个定位,拿博斯普鲁斯海峡、乌拉尔山脉东面个广大欧亚大陆地区侪通称亚洲,拿西太平洋沿岸、欧亚大陆东端个地区就叫做东亚。',
+'东亚 
是一个比较笼统个地理概念,立在弗同个语境当中有弗一样个含义。东亚个概念来自欧洲人对东方个定位,拿博斯普鲁斯海峡、乌拉尔山脉东面个广大欧亚大陆地区侪通称亚洲,拿西太平洋沿岸、欧亚大陆东端个地区就叫做东亚。'
 ],
 // Content inside parentheticals written in `gan` language variant 
are also stripped
 [
-
'亞細亞洲(古希臘文:Ασία),又簡稱亞洲,絕大部分都位到北半球,係全世界上最大,最多人嗰一隻洲。佢東頭一徑到白令海峽嗰傑日尼奧夫角(西經169度40分,北緯60度5分),南頭一徑到努沙登加拉群島(東經103度30分,南緯11度7分),西頭一徑到巴巴角(東經26度3分,北緯39度27分),北頭一徑到切柳斯金角(東經104度18分,北緯77度43分),最高嗰山係珠穆朗瑪峰。亞洲東西嗰時差係11小時。佢西首連到歐洲,箇就係世界上最大嗰大陸-歐亞大陸。',
-'亞細亞洲,又簡稱亞洲,絕大部分都位到北半球,係全世界上最大,最多人嗰一隻洲。佢東頭一徑到白令海峽嗰傑日尼奧夫角,南頭一徑到努沙登加拉群島,西頭一徑到巴巴角,北頭一徑到切柳斯金角,最高嗰山係珠穆朗瑪峰。亞洲東西嗰時差係11小時。佢西首連到歐洲,箇就係世界上最大嗰大陸-歐亞大陸。'
+
'亞細亞洲(古希臘文:Ασία),又簡稱亞洲,絕大部分都位到北半球,係全世界上最大,最多人嗰一隻洲。佢東頭一徑到白令海峽嗰傑日尼奧夫角(西經169度40分,北緯60度5分),南頭一徑到努沙登加拉群島(東經103度30分,南緯11度7分),西頭一徑到巴巴角(東經26度3分,北緯39度27分),北頭一徑到切柳斯金角(東經104度18分,北緯77度43分),最高嗰山係珠穆朗瑪峰。亞洲東西嗰時差係11小時。佢西首連到歐洲,箇就係世界上最大嗰大陸-歐亞大陸。',
+'亞細亞洲,又簡稱亞洲,絕大部分都位到北半球,係全世界上最大,最多人嗰一隻洲。佢東頭一徑到白令海峽嗰傑日尼奧夫角,南頭一徑到努沙登加拉群島,西頭一徑到巴巴角,北頭一徑到切柳斯金角,最高嗰山係珠穆朗瑪峰。亞洲東西嗰時差係11小時。佢西首連到歐洲,箇就係世界上最大嗰大陸-歐亞大陸。'
 ],
 // Content inside parentheticals is not stripped if it doesn't 
include any spaces
 [
-'Der Deutsche Orden, auch Deutschherrenorden 
oder Deutschritterorden genannt, ist eine römisch-katholische 
Ordensgemeinschaft. Mit dem Johanniter- und dem 
Malteserorden steht er in der (Rechts-)Nachfolge der Ritterorden 
aus der Zeit der Kreuzzüge. Die Mitglieder des Ordens sind seit der 
Reform der Ordensregel 1929 regulierte Chorherren. Der Orden hat 
gegenwärtig 1100 Mitglieder, darunter 100 Priester und 200 
Ordensschwestern, die sich vorwiegend karitativen Aufgaben widmen. Der 
Hauptsitz befindet sich heute in Wien.',
-'Der Deutsche Orden, auch Deutschherrenorden 
oder Deutschritterorden genannt, ist eine römisch-katholische 
Ordensgemeinschaft. Mit dem Johanniter- und dem 
Malteserorden steht er in der (Rechts-)Nachfolge der 
Ritterorden aus der Zeit der Kreuzzüge. Die 
Mitglieder des Ordens sind seit der Reform 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Summary: update regex for non-ASCII parentheses

2018-01-11 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403880 )

Change subject: Summary: update regex for non-ASCII parentheses
..

Summary: update regex for non-ASCII parentheses

The previous version created character classes of three times the same
characters each.

((( -> \uFF08\uFF08\uFF08
))) -> \uFF09\uFF09\uFF09

This is redundant. Since there is only one character left we don't need
the character class for that anymore.

Change-Id: I5ece83d2d5bde8cfe3afc6694c26683dddae2e78
---
M lib/transformations/summarize.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/80/403880/1

diff --git a/lib/transformations/summarize.js b/lib/transformations/summarize.js
index 9bdb1d5..c5775f4 100644
--- a/lib/transformations/summarize.js
+++ b/lib/transformations/summarize.js
@@ -125,7 +125,7 @@
 
 // 3. Remove content inside any other non-latin parentheticals. The 
behaviour is
 // the same as 1 but for languages that are not latin based
-html = html.replace(/[(((].+ .+[)))]/g, ' ');
+html = html.replace(/(.+ .+)/g, ' ');
 
 // 4. remove all double spaces created by the above
 html = html.replace(/ +/g, ' ');

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ece83d2d5bde8cfe3afc6694c26683dddae2e78
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Summary: update regex for finding parentheticals

2018-01-11 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403881 )

Change subject: Summary: update regex for finding parentheticals
..

Summary: update regex for finding parentheticals

For the latin character case (stays the same):
Parentheticals which have at least one space inside should be removed.
I removed the useless escaping of parentheses in the latin variant.

For the non-latin character case:
Parentheticals which have at least a space, colon, or comma inside
should be removed.
Updated expected results for a couple of Asian test cases to be less
aggressive in removing parentheticals.

Change-Id: I39a62342456a214a341f2694ed32edc01eed6597
---
M lib/transformations/summarize.js
M test/lib/transformations/summarize.js
2 files changed, 11 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/81/403881/1

diff --git a/lib/transformations/summarize.js b/lib/transformations/summarize.js
index c5775f4..2b70ece 100644
--- a/lib/transformations/summarize.js
+++ b/lib/transformations/summarize.js
@@ -119,20 +119,26 @@
 html = doc.body.innerHTML;
 html = removeNestedParentheticals(html);
 // 1. Replace any parentheticals which have at least one space inside
-html = html.replace(/\([^\)]+ [^\)]+\)/g, ' '); // eslint-disable-line 
no-useless-escape
+html = html.replace(/\([^)]+ [^)]+\)/g, ' ');
 // 2. Remove any empty parentheticals due to transformations
 html = html.replace(/\(\)/g, ' ');
 
 // 3. Remove content inside any other non-latin parentheticals. The 
behaviour is
-// the same as 1 but for languages that are not latin based
-html = html.replace(/(.+ .+)/g, ' ');
+// the same as 1 but for languages that are not latin based. The other 
difference
+// to #1 is that in addition to a space the non-latin colon or comma could 
also
+// trigger the removal of parentheticals.
+html = html.replace(/([^)]+[ :,][^)]+)/g, ' ');
 
 // 4. remove all double spaces created by the above
 html = html.replace(/ +/g, ' ');
 
 // 5. Replace any leading whitespace before commas
+// (which could be the result of earlier transformations)
 html = html.replace(/ , /g, ', ');
 
+// 6. Same as 5 but for non-latin comma and no space afterwards
+html = html.replace(/ ,/g, ',');
+
 doc.body.innerHTML = html;
 return {
 extract: doc.body.textContent,
diff --git a/test/lib/transformations/summarize.js 
b/test/lib/transformations/summarize.js
index abe6348..fe90123 100644
--- a/test/lib/transformations/summarize.js
+++ b/test/lib/transformations/summarize.js
@@ -115,7 +115,7 @@
 // Content inside Chinese parentheticals are also stripped
 [
 '台北101(TAIPEI 
101)是位於的,樓高509.2米(1,671英尺),樓層共有101層、另有5層,總樓地板面積37萬4千,由設計,團隊、韩国等承造,於1999年動工,2004年12月31日完工啟用;最初名稱為台北國際金融中心(Taipei World Financial 
Center),2003年改為現名,亦俗稱為101大樓。興建與經營機構為。其為,曾於2004年12月31日至2010年1月4日間擁有的紀錄,目前為以及環最高,完工以來即成為重要之一。此外,大樓內擁有全球第二大的(僅次)、全球唯二開放遊客觀賞的巨型阻尼器(另一個為上海中心之「上海慧眼」),以及全球起降速度第四快的,僅次於、與。',
-'台北101 ,以及全球起降速度第四快的,僅次於、與。'
+'台北101 
是位於的,樓高509.2米(1,671英尺),樓層共有101層、另有5層,總樓地板面積37萬4千,由設計,團隊、韩国等承造,於1999年動工,2004年12月31日完工啟用;最初名稱為台北國際金融中心,2003年改為現名,亦俗稱為101大樓。興建與經營機構為。其為,曾於2004年12月31日至2010年1月4日間擁有的紀錄,目前為以及環最高,完工以來即成為重要之一。此外,大樓內擁有全球第二大的(僅次)、全球唯二開放遊客觀賞的巨型阻尼器(另一個為上海中心之「上海慧眼」),以及全球起降速度第四快的,僅次於、與。',
 ],
 // Content inside Japanese parentheticals are also stripped
 [
@@ -135,7 +135,7 @@
 // Content inside parentheticals written in `gan` language variant 
are also stripped
 [
 
'亞細亞洲(古希臘文:Ασία),又簡稱亞洲,絕大部分都位到北半球,係全世界上最大,最多人嗰一隻洲。佢東頭一徑到白令海峽嗰傑日尼奧夫角(西經169度40分,北緯60度5分),南頭一徑到努沙登加拉群島(東經103度30分,南緯11度7分),西頭一徑到巴巴角(東經26度3分,北緯39度27分),北頭一徑到切柳斯金角(東經104度18分,北緯77度43分),最高嗰山係珠穆朗瑪峰。亞洲東西嗰時差係11小時。佢西首連到歐洲,箇就係世界上最大嗰大陸-歐亞大陸。',
-'亞細亞洲 
,最高嗰山係珠穆朗瑪峰。亞洲東西嗰時差係11小時。佢西首連到歐洲,箇就係世界上最大嗰大陸-歐亞大陸。'
+'亞細亞洲,又簡稱亞洲,絕大部分都位到北半球,係全世界上最大,最多人嗰一隻洲。佢東頭一徑到白令海峽嗰傑日尼奧夫角,南頭一徑到努沙登加拉群島,西頭一徑到巴巴角,北頭一徑到切柳斯金角,最高嗰山係珠穆朗瑪峰。亞洲東西嗰時差係11小時。佢西首連到歐洲,箇就係世界上最大嗰大陸-歐亞大陸。'
 ],
 // Content inside parentheticals is not stripped if it doesn't 
include any spaces
 [

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I39a62342456a214a341f2694ed32edc01eed6597
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Fix another lint issue

2018-01-11 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403770 )

Change subject: Fix another lint issue
..

Fix another lint issue

I ran into these when trying to commit my patches. I run the pre-commit
hook, which runs lint automatically.

Change-Id: Icb8b88f6b69837703b0c293d5596871aeafa2337
---
M test/diff/diff.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/70/403770/1

diff --git a/test/diff/diff.js b/test/diff/diff.js
index 85ff7d9..994486b 100644
--- a/test/diff/diff.js
+++ b/test/diff/diff.js
@@ -50,7 +50,7 @@
 for (const spec of testSpec.TEST_SPECS) {
 it(`${spec.testName()}`, () => {
 return preq.get({ uri: buildUri(spec.uriPath()),
-  headers: 'cache-control: no-cache' })
+headers: 'cache-control: no-cache' })
.then((rsp) => {
const content = 
fs.readFileSync(spec.filePath(), 'utf8');
spec.postProcessing(rsp);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icb8b88f6b69837703b0c293d5596871aeafa2337
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: WIP: Remove parentheses using state machine instead of regex

2018-01-11 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403725 )

Change subject: WIP: Remove parentheses using state machine instead of regex
..

WIP: Remove parentheses using state machine instead of regex

Do not merge!

Bug: T184557
Change-Id: Ia135df4eb6fbb26064eb95764d1529f294ea4dbe
---
M lib/transformations/summarize.js
M test/lib/transformations/summarize.js
2 files changed, 245 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/25/403725/1

diff --git a/lib/transformations/summarize.js b/lib/transformations/summarize.js
index 06c777b..1072f0f 100644
--- a/lib/transformations/summarize.js
+++ b/lib/transformations/summarize.js
@@ -34,31 +34,229 @@
 }
 }
 
+// Non-ASCII examples of parentheses are taken from
+// https://www.mediawiki.org/wiki/Topic:Tn0k9fjn0g8e9fpe.
+// They were all the same in the Asian languages.
+const TOKEN = {
+Open: { ASCII:  '(', NON_ASCII: '(' }, // %28, %uFF08
+Close: { ASCII:  ')', NON_ASCII: ')' }, // %29, %uFF09
+Space: { NORMAL:  ' ' }
+};
+
+class Range {
+constructor(startNode, startNodeIndex, startCharacterIndex) {
+this._startNode = startNode;
+this._startNodeIndex = startNodeIndex;
+this._startCharacterIndex = startCharacterIndex;
+}
+
+endRange(endNode, endNodeIndex, endCharacterIndex) {
+this._endNode = endNode;
+this._endNodeIndex = endNodeIndex;
+this._endCharacterIndex = endCharacterIndex;
+}
+
+getStartNode() {
+return this._startNode;
+}
+
+getStartNodeIndex() {
+return this._startNodeIndex;
+}
+
+getStartCharacterIndex() {
+return this._startCharacterIndex;
+}
+
+getEndNode() {
+return this._endNode;
+}
+
+getEndNodeIndex() {
+return this._endNodeIndex;
+}
+
+getEndIndex() {
+return this._endCharacterIndex;
+}
+
+startsBefore(nextRange) {
+return this._startNodeIndex < nextRange._startNodeIndex
+|| (
+this._startNodeIndex === nextRange._startNodeIndex
+&& this._startCharacterIndex < nextRange._startCharacterIndex
+);
+}
+
+endsBefore(nextRange) {
+return this._endNodeIndex < nextRange._endNodeIndex
+|| (
+this._endNodeIndex === nextRange._endNodeIndex
+&& this._endCharacterIndex < nextRange._endCharacterIndex
+);
+}
+
+setSpace() {
+this._hasSpace = true;
+}
+
+hasSpaces() {
+return this._hasSpace;
+}
+
+debug() {
+if (this._startNode === this._endNode) {
+const text = this._startNode.textContent;
+return `${text.slice(this._startCharacterIndex, 
this._endCharacterIndex + 1)}`;
+} else {
+const startText = 
this._startNode.textContent.slice(this._startCharacterIndex);
+const endText = this._endNode.textContent.slice(0, 
this._endCharacterIndex + 1);
+return `'${startText}' to '${endText}'`;
+}
+}
+}
+
+function markParentheses(node, state) {
+const text = node.textContent;
+for (let i = 0; i < text.length; i++) {
+const char = text[i];
+if (char === TOKEN.Open.ASCII || char === TOKEN.Open.NON_ASCII) {
+const range = new Range(node, node._nid, i);
+state.ranges.push(range);
+state.stack.push(range);
+} else if (char === TOKEN.Close.ASCII || char === 
TOKEN.Close.NON_ASCII) {
+const range = state.stack[state.stack.length - 1];
+if (range) {
+range.endRange(node, node._nid, i);
+state.stack.pop();
+}
+} else if (char === TOKEN.Space.NORMAL) {
+// TODO: do for all in stack???
+const range = state.stack[state.stack.length - 1];
+if (range && !range.hasSpaces()) {
+range.setSpace();
+}
+}
+}
+}
+
+// '(d e)'
+function discardIneligibleRanges(ranges) {
+for (let i = 0; i < ranges.length; i++) {
+const currentRange = ranges[i];
+if (!currentRange.hasSpaces()) {
+ranges.splice(i, 1); // remove current range
+}
+}
+}
+
+// 'a(b'
+function discardUnclosedRanges(ranges) {
+for (let i = 0; i < ranges.length; i++) {
+const currentRange = ranges[i];
+if (!currentRange.getEndNode()) {
+ranges.splice(i, 1); // remove current range
+}
+}
+}
+
+// 'a(b (d e) f)g'
+function discardNestedRanges(ranges) {
+for (let i = 0; i < ranges.length - 1; i++) {
+const currentRange = ranges[i];
+const nextRange = ranges[i + 1];
+if (currentRange.startsBefore(nextRange)
+&& nextRange.endsBefore(currentRange)
+&& 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Fix lint issues

2018-01-10 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403578 )

Change subject: Fix lint issues
..

Fix lint issues

Change-Id: I5dbf10b3479856a9e35d2fa32895373f63b577f4
---
M test/lib/mobile-util/mobile-util-test.js
1 file changed, 3 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/78/403578/1

diff --git a/test/lib/mobile-util/mobile-util-test.js 
b/test/lib/mobile-util/mobile-util-test.js
index bbc000b..0665cf1 100644
--- a/test/lib/mobile-util/mobile-util-test.js
+++ b/test/lib/mobile-util/mobile-util-test.js
@@ -31,8 +31,9 @@
 });
 
 it('getSummaryType identifies main and disambig pages, defaults to 
\'standard\'', () => {
-assert.deepEqual(mUtil.getSummaryType({"mainpage":true}), 'mainpage');
-
assert.deepEqual(mUtil.getSummaryType({"pageprops":{"disambiguation":""}}), 
'disambiguation');
+assert.deepEqual(mUtil.getSummaryType({ "mainpage": true }), 
'mainpage');
+assert.deepEqual(mUtil.getSummaryType({ "pageprops": { 
"disambiguation": "" } }),
+'disambiguation');
 assert.deepEqual(mUtil.getSummaryType({}), 'standard');
 });
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5dbf10b3479856a9e35d2fa32895373f63b577f4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Remove unwanted nodes and attributes from summary

2018-01-10 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403568 )

Change subject: Remove unwanted nodes and attributes from summary
..

Remove unwanted nodes and attributes from summary

Bug: T184557
Change-Id: Ib4f21f5f68913fa10b9005d10de23b94616dcc94
---
M lib/transformations/summarize.js
M test/lib/transformations/summarize.js
2 files changed, 88 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/68/403568/1

diff --git a/lib/transformations/summarize.js b/lib/transformations/summarize.js
index e0becc8..f558d86 100644
--- a/lib/transformations/summarize.js
+++ b/lib/transformations/summarize.js
@@ -4,6 +4,77 @@
 const flattenElements = require('./flattenElements');
 const rmElementsWithSelector = require('./rmElementsWithSelector');
 const removeAttributes = require('./removeAttributes');
+const NodeType = require('../nodeType');
+
+const ALLOWED_ATTRIBUTES = ['class', 'style'];
+const DISALLOWED_ELEMENTS = ['object', 'script', 'style'];
+
+/**
+ * Removes blacklisted elements.
+ * @param {!Node} node the node to visit
+ */
+function rmDisallowedElements(node) {
+if (DISALLOWED_ELEMENTS.includes(node.tagName)) {
+node.remove();
+}
+}
+
+/**
+ * Removes attributes except white-listed ones.
+ * @param {!Node} node the node to visit
+ */
+function rmUnwantedAttributes(node) {
+if (node.tagName !== 'IMG') {
+const attrs = node.attributes;
+for (let i = attrs.length - 1; i >= 0; i--) {
+const attribute = attrs.item(i);
+if (attribute && attribute.localName
+&& !ALLOWED_ATTRIBUTES.includes(attribute.localName)) {
+node.removeAttribute(attribute.localName);
+}
+}
+}
+}
+
+/**
+ * Visits one DOM node. Do the stuff that needs to be done when a single DOM 
node is handled.
+ * In this case, remove DOM nodes and their children we don't want to keep.
+ * @param {!Node} node the node to visit
+ */
+function visitor(node) {
+if (node.nodeType === NodeType.TEXT_NODE) {
+// keep as is for now
+} else if (node.nodeType === NodeType.ELEMENT_NODE) {
+rmDisallowedElements(node);
+rmUnwantedAttributes(node);
+} else {
+node.remove();
+}
+}
+
+/**
+ * Traverses DOM tree iteratively (depth first).
+ * @param {!Element} rootElement the root of the DOM tree which needs to be 
traversed
+ */
+function traverseDF(rootElement) {
+let nodesToVisit = [ rootElement ];
+while (nodesToVisit.length > 0) {
+const currentNode = nodesToVisit.shift();
+visitor(currentNode);
+nodesToVisit = [
+...(currentNode.childNodes || []), // depth first
+...nodesToVisit,
+];
+}
+}
+
+/**
+ * Removes unwanted nodes and element attributes.
+ * @param {!Document} document the DOM document
+ */
+function removeUnwantedNodes(document) {
+traverseDF(document.body);
+}
 
 /**
  * Recursively discard any parentheticals that themselves are inside 
parentheticals
@@ -36,6 +107,7 @@
 rmElementsWithSelector(doc, '.noprint');
 rmElementsWithSelector(doc, 'math');
 rmElementsWithSelector(doc, 'span:empty,b:empty,i:empty,p:empty');
+removeUnwantedNodes(doc);
 
 html = doc.body.innerHTML;
 html = removeNestedParentheticals(html);
diff --git a/test/lib/transformations/summarize.js 
b/test/lib/transformations/summarize.js
index 6c9f3cf..7031bf4 100644
--- a/test/lib/transformations/summarize.js
+++ b/test/lib/transformations/summarize.js
@@ -8,6 +8,21 @@
 describe('summarize', () => {
 it('matches the spec', () => {
 const testCases = [
+// Should remove unwanted attributes
+[
+'foo',
+'foo'
+],
+// Should keep white-listed attributes
+[
+'foo',
+'foo'
+],
+// Should remove comments
+[
+'foobar',
+'foobar'
+],
 // Should flatten empty nodes
 [
 'f',
@@ -46,7 +61,7 @@
 // math tags are stripped but any math images are shown
 [
 'The Planck–Einstein relation connects the particulate 
photon energy E with its associated wave 
frequency f:\n\nhttp://www.w3.org/1998/Math/MathML;>\n  \n\n  \n  
  E\n=\nh\nf\n  
\n\n{\\displaystyle E=hf}\n  
\nhttps://wikimedia.org/api/rest_v1/media/math/render/svg/f39fac3593bb1e2dec0282c112c4dff7a99007f6;
 class="mwe-math-fallback-image-inline" aria-hidden="true" 
style="vertical-align: -0.671ex; width:7.533ex; 
height:2.509ex;">',
-'The Planck–Einstein relation connects the particulate 
photon energy E with its associated wave 
frequency 

[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to d20915c

2018-01-08 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402984 )

Change subject: Update mobileapps to d20915c
..

Update mobileapps to d20915c

List of changes:
94845db Show MW API requests when debug is true
2fc6c01 Restore diff tests
835257d Update read-html tests to use new 'section' selector
978a550 Revert "Skip some tests because of upstream issues"
5eb3f42 Hygiene: Update diff results to fix tests
25df32d Update tests to allow for testing arbitrary RESTBase installations
afb6ab3 Hygiene: Move test request from enwiki beta to testwiki
9b9de8b Summary: return type=mainpage for project main pages
c220bf6 Revert "Stop getting dc:lastmodified"
d06b090 Summary: Make timestamp refer to the requested revision
65fd0a9 Further cleanup of lib/most-read
d20915c Show MW API requests when env var DEBUG_MW_REQUESTS is set
xxx Update node module dependencies

Change-Id: I87aeaa3e93732faa852467bf5247a5cc2df3a007
---
M node_modules/kad/package.json
M node_modules/pinkie/package.json
M node_modules/swagger-ui/package.json
M src
4 files changed, 10 insertions(+), 11 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps/deploy 
refs/changes/84/402984/1

diff --git a/node_modules/kad/package.json b/node_modules/kad/package.json
index 20a5480..8281d61 100644
--- a/node_modules/kad/package.json
+++ b/node_modules/kad/package.json
@@ -49,7 +49,7 @@
 "/limitation"
   ],
   "_resolved": 
"git+https://github.com/gwicke/kad.git#936c91652d757ea6f9dd30e44698afb0daaa1d17;,
-  "_shasum": "0be082c35b1022209607b4521984b00bb5361541",
+  "_shasum": "4d538ea742189c07f4b62c9319ebe5cf97afb16d",
   "_shrinkwrap": null,
   "_spec": "kad@git+https://github.com/gwicke/kad.git#master;,
   "_where": "/opt/service/node_modules/limitation",
diff --git a/node_modules/pinkie/package.json b/node_modules/pinkie/package.json
index 0e88c78..7aaf31b 100644
--- a/node_modules/pinkie/package.json
+++ b/node_modules/pinkie/package.json
@@ -17,12 +17,12 @@
   "_id": "pinkie@2.0.4",
   "_inCache": true,
   "_location": "/pinkie",
-  "_nodeVersion": "4.2.4",
+  "_nodeVersion": "0.0.0-fake",
   "_npmUser": {
-"name": "floatdrop",
-"email": "floatd...@gmail.com"
+"name": "npm",
+"email": "supp...@npmjs.com"
   },
-  "_npmVersion": "2.14.12",
+  "_npmVersion": "0.0.0-fake",
   "_phantomChildren": {},
   "_requested": {
 "raw": "pinkie@^2.0.0",
@@ -70,8 +70,7 @@
   "files": [
 "index.js"
   ],
-  "gitHead": "8d4a92447a5c62bff9f89756caeb4c9c8770579b",
-  "homepage": "https://github.com/floatdrop/pinkie;,
+  "homepage": "https://github.com/floatdrop/pinkie#readme;,
   "keywords": [
 "promise",
 "promises",
@@ -81,8 +80,8 @@
   "license": "MIT",
   "maintainers": [
 {
-  "name": "floatdrop",
-  "email": "floatd...@gmail.com"
+  "name": "puradox",
+  "email": "sambalana...@gmail.com"
 }
   ],
   "name": "pinkie",
diff --git a/node_modules/swagger-ui/package.json 
b/node_modules/swagger-ui/package.json
index 6d63165..32853bc 100644
--- a/node_modules/swagger-ui/package.json
+++ b/node_modules/swagger-ui/package.json
@@ -49,7 +49,7 @@
 "/"
   ],
   "_resolved": 
"git+https://github.com/wikimedia/swagger-ui.git#b9b40dc8e00caeb24c19fe636b93250a7e335541;,
-  "_shasum": "1807391ceb86fb1b72c76ff0b81a5f2ca012bc5a",
+  "_shasum": "5849854953a6fc495915c229f6ae0264dd7aa825",
   "_shrinkwrap": null,
   "_spec": "swagger-ui@git+https://github.com/wikimedia/swagger-ui.git#master;,
   "_where": "/opt/service",
diff --git a/src b/src
index a4ba9fd..d20915c 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit a4ba9fd9059f64a6d8aac4a2cb8bb251ce757c8e
+Subproject commit d20915c1975c0d5792fdb030631a2d11b5d4f40e

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I87aeaa3e93732faa852467bf5247a5cc2df3a007
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps/deploy
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Add revision and tid to references output

2018-01-08 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402914 )

Change subject: Add revision and tid to references output
..

Add revision and tid to references output

Bug: T184328
Change-Id: I6b055ccc09f38eead74e549bee58603b5e07efea
---
M routes/references.js
1 file changed, 5 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/14/402914/1

diff --git a/routes/references.js b/routes/references.js
index d4a6d47..ba9e7fd 100644
--- a/routes/references.js
+++ b/routes/references.js
@@ -17,12 +17,13 @@
 
 /*
  * Build a response which contains a structure of reference sections
- * @param {!Document} document the page content DOM Document
+ * @param {!object} meta metadata from Parsoid ETag header with revision and 
tid
+ * @param {!Document} document the page content DOM Document (for the other 
properties)
  * @param {!Logger} logger a Bunyan logger
  * @return { structure, references } an Object containing structured data of 
references
  */
-function buildReferences(document, logger) {
-return transforms.extractReferenceLists(document, logger);
+function buildReferences(meta, document, logger) {
+return Object.assign(meta, transforms.extractReferenceLists(document, 
logger));
 }
 
 /**
@@ -35,7 +36,7 @@
 res.status(200);
 mUtil.setETag(res, response.meta.revision);
 mUtil.setContentType(res, mUtil.CONTENT_TYPES.references);
-res.json(buildReferences(response.doc, req.logger)).end();
+res.json(buildReferences(response.meta, response.doc, 
req.logger)).end();
 });
 });
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b055ccc09f38eead74e549bee58603b5e07efea
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: extract references endpoint into new module

2018-01-08 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402913 )

Change subject: Hygiene: extract references endpoint into new module
..

Hygiene: extract references endpoint into new module

Also fixed/clarified some jsdoc there.

Change-Id: Ia64ab51b1e13be8d06fe2e97d668dd620d2b0b2b
---
M lib/references/extractReferenceLists.js
M routes/mobile-sections.js
A routes/references.js
M test/features/featured/pagecontent.js
4 files changed, 53 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/13/402913/1

diff --git a/lib/references/extractReferenceLists.js 
b/lib/references/extractReferenceLists.js
index 0ff37b2..04a8546 100644
--- a/lib/references/extractReferenceLists.js
+++ b/lib/references/extractReferenceLists.js
@@ -4,8 +4,9 @@
 
 /**
  * Scan the DOM document for reference lists
- * @param {!String} document DOM document
+ * @param {!Document} document DOM document
  * @param {!Logger} logger a logger instance associated with the request
+ * @return { structure, references }
  */
 function extractReferenceLists(document, logger) {
 const structure = [];
diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index 75fb024..f8ed15a 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -156,16 +156,6 @@
 }
 
 /*
- * Build a response which contains a structure of reference sections
- * @param {!Object} input
- * @param {!Logger} logger
- * @return {!Object}
- */
-function buildReferences(html, logger) {
-return transforms.extractReferenceLists(html, logger);
-}
-
-/*
  * @param {!Object} input
  * @param {?Boolean} [legacy] whether to perform legacy transformations
  * @return {!Object}
@@ -362,20 +352,6 @@
 mUtil.setETag(res, response.page.revision, response.page.tid);
 mUtil.setContentType(res, mUtil.CONTENT_TYPES.mobileSections);
 res.json(buildRemaining(response)).end();
-});
-});
-
-/**
- * GET {domain}/v1/page/references/{title}{/revision}{/tid}
- * Gets any sections which are part of a reference sections for a given wiki 
page.
- */
-router.get('/references/:title/:revision?/:tid?', (req, res) => {
-return parsoid.pageHtmlPromiseForReferences(app, req)
-.then((response) => {
-res.status(200);
-mUtil.setETag(res, response.meta.revision);
-mUtil.setContentType(res, mUtil.CONTENT_TYPES.references);
-res.json(buildReferences(response.doc, req.logger)).end();
 });
 });
 
diff --git a/routes/references.js b/routes/references.js
new file mode 100644
index 000..d4a6d47
--- /dev/null
+++ b/routes/references.js
@@ -0,0 +1,49 @@
+'use strict';
+
+const mUtil = require('../lib/mobile-util');
+const parsoid = require('../lib/parsoid-access');
+const sUtil = require('../lib/util');
+const transforms = require('../lib/transforms');
+
+/**
+ * The main router object
+ */
+const router = sUtil.router();
+
+/**
+ * The main application object reported when this module is require()d
+ */
+let app;
+
+/*
+ * Build a response which contains a structure of reference sections
+ * @param {!Document} document the page content DOM Document
+ * @param {!Logger} logger a Bunyan logger
+ * @return { structure, references } an Object containing structured data of 
references
+ */
+function buildReferences(document, logger) {
+return transforms.extractReferenceLists(document, logger);
+}
+
+/**
+ * GET {domain}/v1/page/references/{title}{/revision}{/tid}
+ * Gets any sections which are part of a reference sections for a given wiki 
page.
+ */
+router.get('/references/:title/:revision?/:tid?', (req, res) => {
+return parsoid.pageHtmlPromiseForReferences(app, req)
+.then((response) => {
+res.status(200);
+mUtil.setETag(res, response.meta.revision);
+mUtil.setContentType(res, mUtil.CONTENT_TYPES.references);
+res.json(buildReferences(response.doc, req.logger)).end();
+});
+});
+
+module.exports = function(appObj) {
+app = appObj;
+return {
+path: '/page',
+api_version: 1,
+router
+};
+};
diff --git a/test/features/featured/pagecontent.js 
b/test/features/featured/pagecontent.js
index 17c3fc7..e44233b 100644
--- a/test/features/featured/pagecontent.js
+++ b/test/features/featured/pagecontent.js
@@ -30,7 +30,8 @@
 return preq.get({ uri: 
`${server.config.uri}en.wikipedia.org/v1/page/featured/2016/04/15` })
 .then((res) => {
 assert.status(res, 200);
-assert.contains(res.body.$merge[0], 
'v1/page/summary/Cosmic_Stories_and_Stirring_Science_Stories');
+assert.contains(res.body.$merge[0],
+
'v1/page/summary/Cosmic_Stories_and_Stirring_Science_Stories');
 });
 });
 

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

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Show MW API requests when env var DEBUG_MW_REQUESTS is set

2018-01-08 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402891 )

Change subject: Show MW API requests when env var DEBUG_MW_REQUESTS is set
..

Show MW API requests when env var DEBUG_MW_REQUESTS is set

Even more convenient. Just set the environment variable
DEBUG_MW_REQUESTS on your machine or in the run configuration
of your IDE to have this always on on the dev machine.

Change-Id: I6d3b7be9d2cc3b040749308666e71a1e5c797460
---
M lib/api-util.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/91/402891/1

diff --git a/lib/api-util.js b/lib/api-util.js
index 3d053fc..fe1cd78 100644
--- a/lib/api-util.js
+++ b/lib/api-util.js
@@ -8,7 +8,7 @@
 const HTTPError = sUtil.HTTPError;
 
 const MAX_BATCH_SIZE = 50;
-const DEBUG = false;
+const DEBUG = process.env.DEBUG_MW_REQUESTS;
 
 function prettyMwApiReq(request) {
 // formatting it as GET request even though we use POST requests for MW 
API,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d3b7be9d2cc3b040749308666e71a1e5c797460
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Show MW API requests when debug is true

2018-01-04 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402129 )

Change subject: Show MW API requests when debug is true
..

Show MW API requests when debug is true

To make it easier to debug backend requests I think it is useful
to see the full query string made to the MW API.
There can be tons of query parameters, and it's quite tedious to
compile them manually.
To turn this on just set the DEBUG constant in api-util.js to true
and look for "outgoing request" messages in the log file.

Change-Id: Ibd8196b98d90e0431650b4fabc56ef006af16d10
---
M lib/api-util.js
1 file changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/29/402129/1

diff --git a/lib/api-util.js b/lib/api-util.js
index efb4686..3d053fc 100644
--- a/lib/api-util.js
+++ b/lib/api-util.js
@@ -2,13 +2,19 @@
 
 const BBPromise = require('bluebird');
 const preq = require('preq');
+const querystring = require('querystring');
 const sUtil = require('./util');
 const Template = require('swagger-router').Template;
 const HTTPError = sUtil.HTTPError;
 
 const MAX_BATCH_SIZE = 50;
+const DEBUG = false;
 
-
+function prettyMwApiReq(request) {
+// formatting it as GET request even though we use POST requests for MW 
API,
+// just because GETs are easier to run from commandline or see it in a 
browser
+return `${request.uri}?${querystring.stringify(request.body)}`;
+}
 /**
  * Calls the MW API with the supplied query as its body
  * @param {!Object} app the application object
@@ -29,6 +35,10 @@
 }
 });
 
+if (DEBUG) {
+app.logger.log(`trace/mwApiGet`, { msg: 'outgoing request', to: 
prettyMwApiReq(request) });
+}
+
 return preq(request).then((response) => {
 if (response.status < 200 || response.status > 399) {
 // there was an error when calling the upstream service, propagate 
that

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibd8196b98d90e0431650b4fabc56ef006af16d10
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to a4ba9fd

2018-01-04 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402096 )

Change subject: Update mobileapps to a4ba9fd
..

Update mobileapps to a4ba9fd

List of changes:
29fd37f References: add specific version number
6c7479e References: back_link as object
aa6af69 Fix CI
6f2ae66 Automatically end announcements after configured endTime
f9868c0 News: don't include empty stories
6e8fe5c Media: Mark items in MW galleries with gallery IDs
8eb90cc Media: Add video derivative sizes
ecfe7e9 random: fail early when MW API response has no query.pages
022c7a6 References: citation type
xxx Update node module dependencies

Change-Id: I67c62d7bcd225b43900b047f1cb23323939e64a6
---
M node_modules/ajv/dist/ajv.min.js
M node_modules/ajv/dist/ajv.min.js.map
M node_modules/ajv/dist/nodent.min.js
M node_modules/ajv/dist/regenerator.min.js
M node_modules/ajv/lib/ajv.d.ts
M node_modules/ajv/package.json
M node_modules/kad/package.json
M node_modules/moment/locale/af.js
M node_modules/moment/locale/ar-dz.js
M node_modules/moment/locale/ar-kw.js
M node_modules/moment/locale/ar-ly.js
M node_modules/moment/locale/ar-ma.js
M node_modules/moment/locale/ar-sa.js
M node_modules/moment/locale/ar-tn.js
M node_modules/moment/locale/ar.js
M node_modules/moment/locale/az.js
M node_modules/moment/locale/be.js
M node_modules/moment/locale/bg.js
M node_modules/moment/locale/bm.js
M node_modules/moment/locale/bn.js
M node_modules/moment/locale/bo.js
M node_modules/moment/locale/br.js
M node_modules/moment/locale/bs.js
M node_modules/moment/locale/ca.js
M node_modules/moment/locale/cs.js
M node_modules/moment/locale/cv.js
M node_modules/moment/locale/cy.js
M node_modules/moment/locale/da.js
M node_modules/moment/locale/de-at.js
M node_modules/moment/locale/de-ch.js
M node_modules/moment/locale/de.js
M node_modules/moment/locale/dv.js
M node_modules/moment/locale/el.js
M node_modules/moment/locale/en-au.js
M node_modules/moment/locale/en-ca.js
M node_modules/moment/locale/en-gb.js
M node_modules/moment/locale/en-ie.js
M node_modules/moment/locale/en-nz.js
M node_modules/moment/locale/eo.js
M node_modules/moment/locale/es-do.js
M node_modules/moment/locale/es-us.js
M node_modules/moment/locale/es.js
M node_modules/moment/locale/et.js
M node_modules/moment/locale/eu.js
M node_modules/moment/locale/fa.js
M node_modules/moment/locale/fi.js
M node_modules/moment/locale/fo.js
M node_modules/moment/locale/fr-ca.js
M node_modules/moment/locale/fr-ch.js
M node_modules/moment/locale/fr.js
M node_modules/moment/locale/fy.js
M node_modules/moment/locale/gd.js
M node_modules/moment/locale/gl.js
M node_modules/moment/locale/gom-latn.js
M node_modules/moment/locale/gu.js
M node_modules/moment/locale/he.js
M node_modules/moment/locale/hi.js
M node_modules/moment/locale/hr.js
M node_modules/moment/locale/hu.js
M node_modules/moment/locale/hy-am.js
M node_modules/moment/locale/id.js
M node_modules/moment/locale/is.js
M node_modules/moment/locale/it.js
M node_modules/moment/locale/ja.js
M node_modules/moment/locale/jv.js
M node_modules/moment/locale/ka.js
M node_modules/moment/locale/kk.js
M node_modules/moment/locale/km.js
M node_modules/moment/locale/kn.js
M node_modules/moment/locale/ky.js
M node_modules/moment/locale/lb.js
M node_modules/moment/locale/lo.js
M node_modules/moment/locale/lt.js
M node_modules/moment/locale/lv.js
M node_modules/moment/locale/me.js
M node_modules/moment/locale/mi.js
M node_modules/moment/locale/mk.js
M node_modules/moment/locale/ml.js
M node_modules/moment/locale/mr.js
M node_modules/moment/locale/ms-my.js
M node_modules/moment/locale/ms.js
A node_modules/moment/locale/mt.js
M node_modules/moment/locale/my.js
M node_modules/moment/locale/nb.js
M node_modules/moment/locale/ne.js
M node_modules/moment/locale/nl-be.js
M node_modules/moment/locale/nl.js
M node_modules/moment/locale/nn.js
M node_modules/moment/locale/pa-in.js
M node_modules/moment/locale/pl.js
M node_modules/moment/locale/pt.js
M node_modules/moment/locale/ro.js
M node_modules/moment/locale/ru.js
M node_modules/moment/locale/sd.js
M node_modules/moment/locale/se.js
M node_modules/moment/locale/si.js
M node_modules/moment/locale/sk.js
M node_modules/moment/locale/sl.js
M node_modules/moment/locale/sq.js
M node_modules/moment/locale/sr-cyrl.js
M node_modules/moment/locale/sr.js
M node_modules/moment/locale/ss.js
M node_modules/moment/locale/sv.js
M node_modules/moment/locale/sw.js
M node_modules/moment/locale/ta.js
M node_modules/moment/locale/te.js
M node_modules/moment/locale/tet.js
M node_modules/moment/locale/th.js
M node_modules/moment/locale/tl-ph.js
M node_modules/moment/locale/tlh.js
M node_modules/moment/locale/tr.js
M node_modules/moment/locale/tzl.js
M node_modules/moment/locale/tzm-latn.js
M node_modules/moment/locale/tzm.js
M node_modules/moment/locale/uk.js
M node_modules/moment/locale/ur.js
M node_modules/moment/locale/uz-latn.js
M node_modules/moment/locale/uz.js
M 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: News: don't include empty stories

2018-01-04 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402083 )

Change subject: News: don't include empty stories
..

News: don't include empty stories

Bug: T184198
Change-Id: Ia2e7c4cc61cbb99e2fa0f5af355ba5cf837f0401
---
M lib/feed/news.js
M test/features/news/news.js
2 files changed, 9 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/83/402083/1

diff --git a/lib/feed/news.js b/lib/feed/news.js
index eea1715..d81d261 100644
--- a/lib/feed/news.js
+++ b/lib/feed/news.js
@@ -25,7 +25,11 @@
 });
 
 story.story = storyHtml.innerHTML;
-return story;
+if (story.story.length > 0 && story.links.length > 0) {
+return story;
+} else {
+return undefined;
+}
 }
 
 function promise(app, req) {
@@ -55,8 +59,10 @@
 };
 
 Array.prototype.forEach.call(headlines, (storyHtml) => {
-result.payload.push(constructStory(app.restbase_tpl, 
req.params.domain, lang,
-storyHtml));
+const story = constructStory(app.restbase_tpl, req.params.domain, 
lang, storyHtml);
+if (story) {
+result.payload.push(story);
+}
 });
 
 return result;
diff --git a/test/features/news/news.js b/test/features/news/news.js
index d554811..36f9997 100644
--- a/test/features/news/news.js
+++ b/test/features/news/news.js
@@ -50,10 +50,6 @@
 before(() => { return server.start(); });
 
 for (const lang in NEWS_TEMPLATES) {
-if (lang === 'fr') {
-continue; // TODO: unskip testing french news today
-}
-
 if ({}.hasOwnProperty.call(NEWS_TEMPLATES, lang)) {
 it(`${lang}: should respond with expected headers, incl. CORS and 
CSP headers`, () => {
 return 
checkHeaders(`${server.config.uri}${lang}.wikipedia.org/v1/page/news`,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2e7c4cc61cbb99e2fa0f5af355ba5cf837f0401
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Temporarily skip testing of French news.

2018-01-04 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402077 )

Change subject: Temporarily skip testing of French news.
..

Temporarily skip testing of French news.

Will add a separate patch to fix adding empty stories to the output.

Bug: T184198
Change-Id: Iaf76009eb36ae7590b86807053d693f9228989ab
---
M test/features/news/news.js
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/77/402077/1

diff --git a/test/features/news/news.js b/test/features/news/news.js
index 36f9997..d554811 100644
--- a/test/features/news/news.js
+++ b/test/features/news/news.js
@@ -50,6 +50,10 @@
 before(() => { return server.start(); });
 
 for (const lang in NEWS_TEMPLATES) {
+if (lang === 'fr') {
+continue; // TODO: unskip testing french news today
+}
+
 if ({}.hasOwnProperty.call(NEWS_TEMPLATES, lang)) {
 it(`${lang}: should respond with expected headers, incl. CORS and 
CSP headers`, () => {
 return 
checkHeaders(`${server.config.uri}${lang}.wikipedia.org/v1/page/news`,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf76009eb36ae7590b86807053d693f9228989ab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: random: fail early when MW API response has no query.pages

2018-01-04 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402074 )

Change subject: random: fail early when MW API response has no query.pages
..

random: fail early when MW API response has no query.pages

Stack trace from log files (1001):
500: internal_error","stack":"
TypeError: Cannot read property 'pages' of undefined
at Request.api.mwApiGet.then 
(/srv/deployment/mobileapps/deploy-cache/revs/00e60b294482ec067dc48f5b9117bfcc347ac20e/src/lib/feed/random.js:113:50)
at Request.tryCatcher 
(/srv/deployment/mobileapps/deploy-cache/revs/00e60b294482ec067dc48f5b9117bfcc347ac20e/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler

Change-Id: I24c4c32a2c2180aca607c6dfee8745a1699f0e18
---
M lib/feed/random.js
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/74/402074/1

diff --git a/lib/feed/random.js b/lib/feed/random.js
index 659befa..3c28168 100644
--- a/lib/feed/random.js
+++ b/lib/feed/random.js
@@ -110,6 +110,7 @@
 prop: 'extracts|pageterms|pageimages|revisions',
 wbptterms: 'description'
 }).then((response) => {
+mwapi.checkForQueryPagesInResponse(req, response);
 const scoredResults = response.body.query.pages.map((result) => {
 result.score = relativeScoreForResult(result);
 return result;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24c4c32a2c2180aca607c6dfee8745a1699f0e18
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to ff74bb1

2017-12-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398304 )

Change subject: Update mobileapps to ff74bb1
..

Update mobileapps to ff74bb1

List of changes:
96eab05 Revert "Revert "Update section validation logic""
c28a1a4 Fix Logger usage
bc283f3 Include H1 tags when evaluating sections
10b3632 Add unit test for logging the warning if section validation fails
3578a6b Fix onthisday entries from day pages
ff74bb1 Bump onthisday version
xxx Update node module dependencies

Change-Id: I23e225e65eb4a2fa72e2ccb102326cd47888c86a
---
D node_modules/are-we-there-yet/CHANGES.md~
D node_modules/console-control-strings/README.md~
M node_modules/cryptiles/.npmignore
M node_modules/esprima/dist/esprima.js
M node_modules/hawk/.npmignore
M node_modules/json-schema/draft-00/hyper-schema
M node_modules/json-schema/draft-00/json-ref
M node_modules/json-schema/draft-00/links
M node_modules/json-schema/draft-00/schema
M node_modules/json-schema/draft-01/hyper-schema
M node_modules/json-schema/draft-01/json-ref
M node_modules/json-schema/draft-01/links
M node_modules/json-schema/draft-01/schema
M node_modules/json-schema/draft-02/hyper-schema
M node_modules/json-schema/draft-02/json-ref
M node_modules/json-schema/draft-02/links
M node_modules/json-schema/draft-02/schema
M node_modules/json-schema/draft-03/examples/address
M node_modules/json-schema/draft-03/examples/calendar
M node_modules/json-schema/draft-03/examples/card
M node_modules/json-schema/draft-03/examples/geo
M node_modules/json-schema/draft-03/examples/interfaces
M node_modules/json-schema/draft-03/hyper-schema
M node_modules/json-schema/draft-03/json-ref
M node_modules/json-schema/draft-03/links
M node_modules/json-schema/draft-03/schema
M node_modules/json-schema/draft-04/hyper-schema
M node_modules/json-schema/draft-04/links
M node_modules/json-schema/draft-04/schema
M node_modules/json-schema/draft-zyp-json-schema-03.xml
M node_modules/json-schema/draft-zyp-json-schema-04.xml
M node_modules/json-schema/lib/links.js
M node_modules/json-schema/lib/validate.js
M node_modules/json-schema/test/tests.js
M node_modules/kad/package.json
M node_modules/long/.npmignore
M node_modules/long/.travis.yml
M node_modules/long/LICENSE
M node_modules/long/bower.json
M node_modules/long/dist/Long.js
M node_modules/long/externs/Long.js
M node_modules/long/index.js
M node_modules/long/jsdoc.json
M node_modules/long/scripts/build.js
M node_modules/long/src/Long.js
M node_modules/long/src/bower.json
M node_modules/long/src/wrap.js
M node_modules/long/tests/goog.math.long.js
M node_modules/long/tests/suite.js
M node_modules/merge/LICENSE
M node_modules/merge/merge.js
M node_modules/merge/merge.min.js
M node_modules/sntp/.npmignore
M node_modules/swagger-ui/dist/swagger-ui.js
M node_modules/swagger-ui/package.json
M src
56 files changed, 14,912 insertions(+), 15,079 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps/deploy 
refs/changes/04/398304/1


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23e225e65eb4a2fa72e2ccb102326cd47888c86a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps/deploy
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Bump onthisday version

2017-12-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398300 )

Change subject: Bump onthisday version
..

Bump onthisday version

... since we fixed the section heading id selector strings,
see previous commit.

Change-Id: If218da0a29a00382d7ebef1c745a6009a22fd7ac
---
M lib/mobile-util.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/00/398300/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index c088707..0c413f8 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -18,7 +18,7 @@
 random: { name: 'random', version: '0.6.0' },
 announcements: { name: 'announcements', version: '0.1.0' },
 compilations: { name: 'compilations', version: '0.1.0' },
-onthisday: { name: 'onthisday', version: '0.3.2' },
+onthisday: { name: 'onthisday', version: '0.3.3' },
 unpublished: { name: 'unpublished', version: '0.0.0' }
 };
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If218da0a29a00382d7ebef1c745a6009a22fd7ac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Fix onthisday entries from day pages

2017-12-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398268 )

Change subject: Fix onthisday entries from day pages
..

Fix onthisday entries from day pages

Since HTML5 section ids were deployed,
onthisday entries from day pages (=everything except 'selected')
were missing.
Instead of using the anchorencoded ids we need to use the,
much more readable, Unicode characters.

Bug: T182868
Change-Id: I98b8456d12c5b3b827411229b82abfb644c78630
---
M lib/feed/on-this-day.languages.js
1 file changed, 21 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/68/398268/1

diff --git a/lib/feed/on-this-day.languages.js 
b/lib/feed/on-this-day.languages.js
index 2edf72f..f008d1f 100644
--- a/lib/feed/on-this-day.languages.js
+++ b/lib/feed/on-this-day.languages.js
@@ -46,8 +46,8 @@
 events: ['Ereignisse'],
 holidays: [
 'Feier-_und_Gedenktage',
-'Feier-.2C_Gedenk-_und_Aktionstage',
-'Feier-.2C_Aktions-_und_Gedenktage'
+'Feier-,_Gedenk-_und_Aktionstage',
+'Feier-,_Aktions-_und_Gedenktage'
 ]
 }
 },
@@ -78,9 +78,9 @@
 },
 headingIds: {
 births: ['Naissances'],
-deaths: ['D.C3.A9c.C3.A8s'],  // Décès
-events: ['.C3.89v.C3.A9nements', '.C3.89v.C3.A8nements'], // 
Événements + Évènements
-holidays: ['C.C3.A9l.C3.A9brations']  // Célébrations
+deaths: ['Décès'],
+events: ['Événements', 'Évènements'],
+holidays: ['Célébrations']
 }
 },
 selectedPage: {
@@ -111,10 +111,10 @@
 // https://sv.wikipedia.org/api/rest_v1/page/html/22_maj
 nameFormatter : (monthName, monthNumber, dayNumber) => 
`${dayNumber}_${monthName}`,
 headingIds: {
-births: ['F.C3.B6dda'],   // Födda
+births: ['Födda'],
 deaths: ['Avlidna'],
-events: ['H.C3.A4ndelser'],   // Händelser
-holidays: ['.C3.85terkommande_bem.C3.A4rkelsedagar'] // 
Återkommande bemärkelsedagar
+events: ['Händelser'],
+holidays: ['Återkommande bemärkelsedagar']
 }
 },
 selectedPage : {
@@ -139,8 +139,8 @@
 headingIds: {
 births: ['Nascimentos'],
 deaths: ['Mortes', 'Falecimentos'],
-events: ['Eventos', 'Eventos_hist.C3.B3ricos'],
-holidays: ['Feriados_e_eventos_c.C3.ADclicos']
+events: ['Eventos', 'Eventos_históricos'],
+holidays: ['Feriados_e_eventos_cíclicos']
 }
 },
 selectedPage : {
@@ -164,17 +164,14 @@
 // https://ru.wikipedia.org/api/rest_v1/page/html/22_мая
 nameFormatter : (monthName, monthNumber, dayNumber) => 
`${dayNumber}_${monthName}`,
 headingIds: {
-births: ['.D0.A0.D0.BE.D0.B4.D0.B8.D0.BB.D0.B8.D1.81.D1.8C'],
-deaths: 
['.D0.A1.D0.BA.D0.BE.D0.BD.D1.87.D0.B0.D0.BB.D0.B8.D1.81.D1.8C'],
-events: ['.D0.A1.D0.BE.D0.B1.D1.8B.D1.82.D0.B8.D1.8F'],
+births: ['Родились'],
+deaths: ['Скончались'],
+events: ['События'],
 holidays: [
-'.D0.9F.D1.80.D0.B0.D0.B7.D0.B4.D0.BD.D0.B8.D0.BA.D0.B8',
-// eslint-disable-next-line max-len
-
'.D0.9F.D1.80.D0.B0.D0.B7.D0.B4.D0.BD.D0.B8.D0.BA.D0.B8_.D0.B8_.D0.BF.D0.B0.D0.BC.D1.8F.D1.82.D0.BD.D1.8B.D0.B5_.D0.B4.D0.BD.D0.B8',
-// eslint-disable-next-line max-len
-
'.D0.9F.D1.80.D0.B0.D0.B7.D0.B4.D0.BD.D0.B8.D0.BA.D0.B8_.D0.B8_.D0.BF.D0.B0.D0.BC.D1.8F.D1.82.D0.BD.D1.8B.D0.B5_.D0.B4.D0.B0.D1.82.D1.8B',
-// eslint-disable-next-line max-len
-
'.D0.9F.D1.80.D0.B0.D0.B7.D0.B4.D0.BD.D0.B8.D0.BA.D0.B8.2C_.D0.BF.D0.B0.D0.BC.D1.8F.D1.82.D0.BD.D1.8B.D0.B5_.D0.B4.D0.B0.D1.82.D1.8B'
+'Праздники',
+'Праздники_и_памятные_дни',
+'Праздники_и_памятные_даты',
+'Праздники,_памятные_даты'
 ]
 }
 },
@@ -227,11 +224,10 @@
 // https://ar.wikipedia.org/api/rest_v1/page/html/22_مايو
 nameFormatter : (monthName, monthNumber, dayNumber) => 
`${dayNumber}_${monthName}`,
 headingIds: {
-births: ['.D9.85.D9.88.D8.A7.D9.84.D9.8A.D8.AF'],
-deaths: ['.D9.88.D9.81.D9.8A.D8.A7.D8.AA'],
-events: ['.D8.A3.D8.AD.D8.AF.D8.A7.D8.AB'],
-// eslint-disable-next-line max-len
-

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Automatically end announcements after configured endTime

2017-12-14 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398254 )

Change subject: Automatically end announcements after configured endTime
..

Automatically end announcements after configured endTime

No need to still serve any announcements after they ended.

Change-Id: Id27816938108f82f09f522702dede79d630b630a
---
M lib/feed/announcements.js
M test/lib/feed/announcements.js
2 files changed, 33 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/54/398254/1

diff --git a/lib/feed/announcements.js b/lib/feed/announcements.js
index 08fb116..5e3a956 100644
--- a/lib/feed/announcements.js
+++ b/lib/feed/announcements.js
@@ -82,10 +82,23 @@
 return domain === 'en.wikipedia.beta.wmflabs.org';
 }
 
+function hasEnded(now) {
+const endDate = Date.parse(config.endTime);
+if (isNaN(endDate)) {
+return true; // end right away if config.endTime is invalid
+}
+return now > endDate;
+}
+
+function isActive(domain, now) {
+return (isActiveWiki(domain) || isEnBetaClusterDomain(domain))
+&& !hasEnded(now);
+}
+
 function getAnnouncements(domain) {
 return {
 // eslint-disable-next-line multiline-ternary
-announce: isActiveWiki(domain) || isEnBetaClusterDomain(domain)
+announce: isActive(domain, new Date())
 ? getActiveAnnouncements() : []
 };
 }
@@ -97,6 +110,7 @@
 buildId,
 buildAndroidAnnouncement,
 buildIosAnnouncement,
-getActiveAnnouncements
+getActiveAnnouncements,
+hasEnded
 }
 };
diff --git a/test/lib/feed/announcements.js b/test/lib/feed/announcements.js
index f721f9f..0b6e243 100644
--- a/test/lib/feed/announcements.js
+++ b/test/lib/feed/announcements.js
@@ -90,6 +90,23 @@
 assert.deepEqual(id, id.toUpperCase());
 });
 
+describe('.hasEnded', () => {
+it('invalid endTime', () => {
+config.endTime = 'DISABLED';
+assert.ok(mut.testing.hasEnded());
+});
+
+it('endTime has passed', () => {
+config.endTime = '2017-12-20T23:59:00Z';
+assert.ok(mut.testing.hasEnded(new Date(Date.UTC(2017, 11, 21;
+});
+
+it('endTime has not passed yet', () => {
+config.endTime = '2017-12-20T23:59:00Z';
+assert.ok(!mut.testing.hasEnded(new Date(Date.UTC(2017, 11, 20;
+});
+});
+
 describe('announcements-unit-config', () => {
 const THIS_YEAR = new Date().getUTCFullYear();
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id27816938108f82f09f522702dede79d630b630a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Add unit test for logging the warning if section validation ...

2017-12-13 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398184 )

Change subject: Add unit test for logging the warning if section validation 
fails
..

Add unit test for logging the warning if section validation fails

Bug: T182774
Change-Id: I4d1711b7f49fd43ae54d0b6ee56e850f9d039017
---
M lib/parsoidSectionsUsingSectionTags.js
M test/lib/parsoid/parsoid-sections-section-elements-tests.js
2 files changed, 24 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/84/398184/1

diff --git a/lib/parsoidSectionsUsingSectionTags.js 
b/lib/parsoidSectionsUsingSectionTags.js
index 6fb3b72..39d53c9 100644
--- a/lib/parsoidSectionsUsingSectionTags.js
+++ b/lib/parsoidSectionsUsingSectionTags.js
@@ -135,6 +135,7 @@
 getSectionsText,
 testing: {
 parseSections: traverseDF,
-shouldLogInvalidSectionWarning
+shouldLogInvalidSectionWarning,
+validatePreviousSection
 }
 };
diff --git a/test/lib/parsoid/parsoid-sections-section-elements-tests.js 
b/test/lib/parsoid/parsoid-sections-section-elements-tests.js
index ecfb94c..36d8644 100644
--- a/test/lib/parsoid/parsoid-sections-section-elements-tests.js
+++ b/test/lib/parsoid/parsoid-sections-section-elements-tests.js
@@ -4,8 +4,10 @@
 
 const assert = require('../../utils/assert.js');
 const domino = require('domino');
+const sinon = require('sinon');
 const parsoidSectionsUsingSectionTags = 
require('../../../lib/parsoidSectionsUsingSectionTags');
 const shouldWarn = 
parsoidSectionsUsingSectionTags.testing.shouldLogInvalidSectionWarning;
+const validatePreviousSection = 
parsoidSectionsUsingSectionTags.testing.validatePreviousSection;
 
 describe('lib:parsoid-sections (section elements)', function() {
 
@@ -126,9 +128,9 @@
 assert.ok(!shouldWarn(allSections[0]));
 });
 
-it('should warn for non-lead section without heading tag', () => {
-const allSections = [ { id: 0 }, { id: 1 } ];
-assert.ok(shouldWarn(allSections[1]));
+it('should warn for non-lead section without heading properties', () => {
+const allSectionsWithoutHeadingProps = [ { id: 0 }, { id: 1 } ];
+assert.ok(shouldWarn(allSectionsWithoutHeadingProps[1]));
 });
 
 it('should not warn if id & anchor are found for all sections after the 
lead section', () => {
@@ -136,7 +138,7 @@
 assert.ok(!shouldWarn(allSections[1]));
 });
 
-it('should not warn for non-lead non-editable section without heading 
tag', () => {
+it('should not warn for non-lead non-editable section without heading 
properties', () => {
 const allSections = [ { id: 0 }, { id: -1 } ];
 assert.ok(!shouldWarn(allSections[1]));
 });
@@ -149,4 +151,20 @@
 it('should throw if sectionObj is invalid', () => {
 assert.throws(() => { shouldWarn(undefined); }, /TypeError/);
 });
+
+it('validatePreviousSection should log a warning if appropriate', () => {
+const logger = {
+log: sinon.stub()
+};
+const allSectionsWarn = [ { id: 0 }, { id: 1 } ];
+
+validatePreviousSection(logger, allSectionsWarn);
+assert.ok(logger.log.calledOnce);
+assert.deepEqual(logger.log.args,
+[[ 'warn', {
+warning: 'invalid_section',
+title: 'Found section without expected heading',
+detail: 'Cannot find heading for section number 1.'
+}]]);
+});
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4d1711b7f49fd43ae54d0b6ee56e850f9d039017
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Revert "Revert "Update section validation logic""

2017-12-13 Thread BearND (Code Review)
Hello jenkins-bot, Mholloway,

I'd like you to do a code review.  Please visit

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

to review the following change.


Change subject: Revert "Revert "Update section validation logic""
..

Revert "Revert "Update section validation logic""

This reverts commit ebb87374b3c69ff6a3a71dffaf4e1e64af9b.

It's easier to see what has changed from the previous solution
if we split up the changes into two commits. I'm also going to add
a unit test for the log call.

Change-Id: I2394ee5d14b7cb83f329c7f17e735a8f8d6342f9
---
M lib/parsoid-access.js
M lib/parsoidSections.js
M lib/parsoidSectionsUsingSectionTags.js
M test/lib/parsoid/parsoid-sections-section-elements-tests.js
4 files changed, 57 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/83/398183/1

diff --git a/lib/parsoid-access.js b/lib/parsoid-access.js
index 338ce33..3ae3308 100644
--- a/lib/parsoid-access.js
+++ b/lib/parsoid-access.js
@@ -119,7 +119,7 @@
 transforms.stripUnneededMarkup(doc, legacy);
 parsoidSections.addSectionDivs(doc);
 
-page.sections = parsoidSections.getSectionsText(doc);
+page.sections = parsoidSections.getSectionsText(doc, req.logger);
 return page;
 });
 }
diff --git a/lib/parsoidSections.js b/lib/parsoidSections.js
index dcdbb72..f8e21d6 100644
--- a/lib/parsoidSections.js
+++ b/lib/parsoidSections.js
@@ -27,13 +27,14 @@
  * Gets the sections array, including HTML string and metadata for all sections
  * (id, anchor, line, toclevel).
  * @param {!document} doc the parsed DOM Document of the Parsoid output
+ * @param {!Logger} logger the app's bunyan logger
  * @return {!sections[]} an array of section JSON elements
  */
-function getSectionsText(doc) {
+function getSectionsText(doc, logger) {
 if (!hasParsoidSections(doc)) {
 return parsoidSectionsUsingDivs.getSectionsText(doc);
 } else {
-return parsoidSectionsUsingSectionTags.getSectionsText(doc);
+return parsoidSectionsUsingSectionTags.getSectionsText(doc, logger);
 }
 }
 
diff --git a/lib/parsoidSectionsUsingSectionTags.js 
b/lib/parsoidSectionsUsingSectionTags.js
index 76e471d..ce27178 100644
--- a/lib/parsoidSectionsUsingSectionTags.js
+++ b/lib/parsoidSectionsUsingSectionTags.js
@@ -1,8 +1,6 @@
 'use strict';
 
 const parsoidDomUtils = require('parsoid-dom-utils');
-// const sUtil = require('./util');
-// const HTTPError = sUtil.HTTPError;
 const NodeType = require('./nodeType');
 
 /**
@@ -39,7 +37,13 @@
 }
 }
 
-/* function throwIfPreviousSectionIsIncomplete(allSections, sectionObj) {
+// skip lead sections since they don't have headings;
+// no line and no anchor means incomplete section
+function shouldLogInvalidSectionWarning(sectionObj) {
+return sectionObj.id >= 1 && !sectionObj.line && !sectionObj.anchor;
+}
+
+function validatePreviousSection(logger, allSections, sectionObj) {
 if (allSections.length === 0) {
 return;
 }
@@ -47,30 +51,29 @@
 if (!sectionObj) {
 sectionObj = allSections[allSections.length - 1];
 }
-// skip lead sections since they don't have headings;
-// no line and no anchor means incomplete section
-if (allSections.length > 1 && !sectionObj.line && !sectionObj.anchor) {
-throw new HTTPError({
-status: 502,
-type: 'unsupported_section',
-title: 'Section structure not supported',
+
+if (shouldLogInvalidSectionWarning(sectionObj)) {
+logger.warn({
+warning: 'invalid_section',
+title: 'Found section without expected heading',
 detail: `Cannot find heading for section number ${sectionObj.id}.`
 });
 }
-} */
+}
 
 /**
  * Visits one DOM node. Do the stuff that needs to be done when a single DOM 
node is handled.
  * In this case, starts a new section object when a  tag is 
encountered that is a
  * direct descendant
+ * @param {!Logger} logger the app's bunyan logger
  * @param {!DOMNode} node the node to visit
  * @param {!Object[]} allSections the array containing the results
  * @param {!Object} state some state to pass around
  */
-function visit(node, allSections, state) {
+function visit(logger, node, allSections, state) {
 let sectionObj = allSections.length > 0 ? allSections[allSections.length - 
1] : undefined;
 if (node.tagName === 'SECTION') {
-// throwIfPreviousSectionIsIncomplete(allSections, sectionObj);
+validatePreviousSection(logger, allSections, sectionObj);
 
 sectionObj = { id: getSectionNumber(node), text: '' };
 allSections.push(sectionObj);
@@ -99,16 +102,17 @@
  * This started out with a traditional iterative DFS algorithm but added a 
boolean to stop
  * descending so we don't duplicate content since elsewhere outerHTML is used 
(which contains
  * content 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Skip some tests because of upstream issues

2017-12-13 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398085 )

Change subject: Skip some tests because of upstream issues
..

Skip some tests because of upstream issues

This is related to T182770.

Change-Id: I9fc9c5360248e20949e0ff09d4c5ffd36dbe3944
---
M test/features/mobile-sections/shared.js
M test/features/read-html/pagecontent-base.js
M test/features/read-html/pagecontent.js
3 files changed, 3 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/85/398085/1

diff --git a/test/features/mobile-sections/shared.js 
b/test/features/mobile-sections/shared.js
index 59dfc83..c277306 100644
--- a/test/features/mobile-sections/shared.js
+++ b/test/features/mobile-sections/shared.js
@@ -69,7 +69,7 @@
 });
 });
 
-it('Check content of fresh revision', () => {
+it.skip('Check content of fresh revision', () => { // skipped because of 
issue T182770 (RB?)
 const title = 'Leonard_Cohen';
 const uri = localUri(title);
 return preq.get({ uri })
diff --git a/test/features/read-html/pagecontent-base.js 
b/test/features/read-html/pagecontent-base.js
index 2cb4abc..8cda184 100644
--- a/test/features/read-html/pagecontent-base.js
+++ b/test/features/read-html/pagecontent-base.js
@@ -21,7 +21,7 @@
 return headers.checkHeaders(uri, headers.HTML_CONTENT_TYPE_REGEX);
 });
 
-it('HTML should be sectioned', () => {
+it.skip('HTML should be sectioned', () => { // skipped because of issue 
T182770 (RB?)
 const uri = localUri('Foobar/788941783');
 return preq.get({ uri })
 .then((res) => {
diff --git a/test/features/read-html/pagecontent.js 
b/test/features/read-html/pagecontent.js
index e11dda3..a52535a 100644
--- a/test/features/read-html/pagecontent.js
+++ b/test/features/read-html/pagecontent.js
@@ -21,7 +21,7 @@
 return headers.checkHeaders(uri, headers.HTML_CONTENT_TYPE_REGEX);
 });
 
-it('HTML should be sectioned', () => {
+it.skip('HTML should be sectioned', () => { // skipped because of issue 
T182770 (RB?)
 const uri = localUri('Foobar/788941783');
 return preq.get({ uri })
 .then((res) => {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9fc9c5360248e20949e0ff09d4c5ffd36dbe3944
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Adjust end time for fundraising announcements

2017-12-13 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398080 )

Change subject: Adjust end time for fundraising announcements
..

Adjust end time for fundraising announcements

New end date it is December 20th 23:59UTC.

Bug: T182802
Change-Id: Ia40286139dbd41483c1a3f85c99acc5c513c00b2
---
M etc/feed/announcements.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/80/398080/1

diff --git a/etc/feed/announcements.js b/etc/feed/announcements.js
index dbe1743..0bdc7ea 100644
--- a/etc/feed/announcements.js
+++ b/etc/feed/announcements.js
@@ -8,7 +8,7 @@
 const type = AnnouncementType.FUNDRAISING;
 const activeWiki = 'en.wikipedia.org';
 const startTime = '2017-11-30T16:00:00Z';
-const endTime = '2017-12-31T00:00:00Z';
+const endTime = '2017-12-20T23:59:00Z';
 const idPrefix = 'EN1217';
 const androidDestinationUrl
 = 
'https://donate.wikimedia.org/?uselang=en_medium=WikipediaAppFeed_campaign=Android_source=app_201712_6C_control';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia40286139dbd41483c1a3f85c99acc5c513c00b2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Bump onthisday version.

2017-12-12 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397961 )

Change subject: Bump onthisday version.
..

Bump onthisday version.

Change-Id: I15a3dbb1337d56291a0e2bb85f2c043afe51
---
M lib/mobile-util.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/61/397961/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index 443dc01..3d9e28a 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -18,7 +18,7 @@
 random: { name: 'random', version: '0.6.0' },
 announcements: { name: 'announcements', version: '0.1.0' },
 compilations: { name: 'compilations', version: '0.1.0' },
-onthisday: { name: 'onthisday', version: '0.3.1' },
+onthisday: { name: 'onthisday', version: '0.3.2' },
 unpublished: { name: 'unpublished', version: '0.0.0' }
 };
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I15a3dbb1337d56291a0e2bb85f2c043afe51
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Fix onthisday with section tags

2017-12-12 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397928 )

Change subject: Fix onthisday with section tags
..

Fix onthisday with section tags

Onthisday was looking for direct children of body to look for the
elements, which is bad with the section tags deployed.

Change-Id: Iabc1e162ac106f0b5ff5ab6ca395b60cb9819201
---
M lib/feed/on-this-day.languages.js
1 file changed, 8 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/28/397928/1

diff --git a/lib/feed/on-this-day.languages.js 
b/lib/feed/on-this-day.languages.js
index 3df2f41..6da6dc2 100644
--- a/lib/feed/on-this-day.languages.js
+++ b/lib/feed/on-this-day.languages.js
@@ -23,7 +23,7 @@
 // 
https://en.wikipedia.org/api/rest_v1/page/html/Wikipedia:Selected_anniversaries%2FMay_22
 nameFormatter : (monthName, monthNumber, dayNumber) =>
 `Wikipedia:Selected_anniversaries/${monthName}_${dayNumber}`,
-listElementSelector: 'body > ul li'
+listElementSelector: 'section > ul li'
 },
 yearListElementRegEx :
   // eslint-disable-next-line max-len
@@ -55,7 +55,7 @@
 // 
https://de.wikipedia.org/api/rest_v1/page/html/Wikipedia:Hauptseite%2FJahrestage%2FMai%2F22
 nameFormatter : (monthName, monthNumber, dayNumber) =>
 `Wikipedia:Hauptseite/Jahrestage/${monthName}/${dayNumber}`,
-listElementSelector: 'body > ul li'
+listElementSelector: 'section > ul li'
 },
 yearListElementRegEx :
   new 
RegExp(String.raw`^\s*(\d+)\s*(v\.\s*Chr\.)?\s*(?::|[${dashChars}])\s*(.*\S.*)`,
 'i'),
@@ -93,7 +93,7 @@
 }
 return `Wikipédia:Éphéméride/${dayNumber}_${monthName}`;
 },
-listElementSelector: 'body > ul li'
+listElementSelector: 'section > ul li'
 },
 yearListElementRegEx :
   // eslint-disable-next-line max-len
@@ -120,7 +120,7 @@
 selectedPage : {
 // https://sv.wikipedia.org/api/rest_v1/page/html/Mall:22_maj
 nameFormatter : (monthName, monthNumber, dayNumber) => 
`Mall:${dayNumber}_${monthName}`,
-listElementSelector: 'body > ul li'
+listElementSelector: 'section > ul li'
 },
 yearListElementRegEx :
   new 
RegExp(String.raw`^\s*(\d+)\s*(f\.\s*Kr\.)?\s*[${dashChars}]\s*(.*\S.*)`, 'i'),
@@ -147,7 +147,7 @@
 // 
https://pt.wikipedia.org/api/rest_v1/page/html/Wikipédia:Efemérides%2F22_de_maio
 nameFormatter : (monthName, monthNumber, dayNumber) =>
 `Wikipédia:Efemérides/${dayNumber}_${monthName}`,
-listElementSelector: 'body > ul li'
+listElementSelector: 'section > ul li'
 },
 yearListElementRegEx :
   new 
RegExp(String.raw`^\s*(\d+)\s*(a\.\s*C\.)?\s*[${dashChars}]\s*(.*\S.*)`, 'i'),
@@ -182,7 +182,7 @@
 // 
https://ru.wikipedia.org/api/rest_v1/page/html/Шаблон:События_дня:05-30
 nameFormatter : (monthName, monthNo, dayNo) =>
 `Шаблон:События_дня:${monthNo < 10 ? `0${monthNo}` : 
monthNo}-${dayNo}`,
-listElementSelector: 'body > ul li'
+listElementSelector: 'section > ul li'
 },
 yearListElementRegEx :
   // eslint-disable-next-line max-len
@@ -210,7 +210,7 @@
 // 
https://es.wikipedia.org/api/rest_v1/page/html/Plantilla:Efemérides_-_22_de_mayo
 nameFormatter : (monthName, monthNumber, dayNumber) =>
 `Plantilla:Efemérides - ${dayNumber}_${monthName}`,
-listElementSelector: 'body > ul li'
+listElementSelector: 'section > ul li'
 },
 yearListElementRegEx :
   new 
RegExp(String.raw`^\s*(\d+)\s*(a\.\s*C\.)?\s*\.*[:${dashChars}]\s*(.*\S.*)`, 
'i'),
@@ -238,7 +238,7 @@
 // 
https://ar.wikipedia.org/api/rest_v1/page/html/%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7%3A%D9%81%D9%8A_%D9%87%D8%B0%D8%A7_%D8%A7%D9%84%D9%8A%D9%88%D9%85%2F22_%D9%85%D8%A7%D9%8A%D9%88
 nameFormatter : (monthName, monthNumber, dayNumber) =>
 `ويكيبيديا:في_هذا_اليوم/${dayNumber}_${monthName}`,
-listElementSelector: 'body > ul li'
+listElementSelector: 'section > ul li'
 },
 yearListElementRegEx :
   new 
RegExp(String.raw`^\s*(\d+)\s*(ق.م)?\s*[${dashChars}]\s*(.*\S.*)`, 'i'),

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iabc1e162ac106f0b5ff5ab6ca395b60cb9819201
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: References: citation type

2017-12-12 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397867 )

Change subject: References: citation type
..

References: citation type

Instead of an citations array we return a single value in the type
field.
We still collect all citation types in a set.
If there is exactly one type left and it's one of the known values
("web", "news", "journal", or "book") then that value is returned.
Else "generic" is returned.

Bug: T182652
Change-Id: Ic703fbdf642661481b53e3af21eba1a3583366a0
---
M lib/references/structureReferenceListContent.js
M test/lib/references/structureReferenceListContent.test.js
2 files changed, 34 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/67/397867/1

diff --git a/lib/references/structureReferenceListContent.js 
b/lib/references/structureReferenceListContent.js
index cbf6064..e6af549 100644
--- a/lib/references/structureReferenceListContent.js
+++ b/lib/references/structureReferenceListContent.js
@@ -6,6 +6,9 @@
 */
 
 const NodeType = require('../nodeType');
+const CITATION_TYPES = {
+'web': 1, 'news': 1, 'journal': 1, 'book': 1
+};
 
 const hasOnlyWhitespace = node =>
 node.nodeType === NodeType.TEXT_NODE && /^\s*$/.test(node.textContent);
@@ -65,6 +68,20 @@
 content.html = content.html ? content.html + html : html;
 };
 
+const isKnownCitationType = (type) => {
+return CITATION_TYPES[type];
+};
+
+const getCitationType = (citations) => {
+if (citations.size === 1) {
+const value = citations.values().next().value;
+if (isKnownCitationType(value)) {
+return value;
+}
+}
+return 'generic';
+};
+
 /**
  * Returns reference content in an html string and citations set.
  * @param {!Element} spanElement 'span.mw-reference-text'
@@ -85,12 +102,8 @@
 }
 }
 
-if (content.citations.size === 0) {
-delete content.citations;
-} else {
-content.citations = Array.from(content.citations);
-}
-
+content.type = getCitationType(content.citations);
+delete content.citations;
 return content;
 };
 
@@ -121,16 +134,12 @@
 element = element.nextElementSibling;
 }
 
-const result = {
+return {
 id: getCiteNoteId(listItemElement),
 back_links: backLinks,
 content: content.html,
-citations: content.citations
+type: content.type
 };
-if (!result.citations) {
-delete result.citations;
-}
-return result;
 };
 
 /**
diff --git a/test/lib/references/structureReferenceListContent.test.js 
b/test/lib/references/structureReferenceListContent.test.js
index e4e6b48..027a9d1 100644
--- a/test/lib/references/structureReferenceListContent.test.js
+++ b/test/lib/references/structureReferenceListContent.test.js
@@ -111,7 +111,8 @@
 const doc = createDocument(simpleDogRef);
 assert.deepEqual(
 
mut.unit.getReferenceContent(doc.querySelector('span.mw-reference-text')), {
-html: 'some HTML'
+html: 'some HTML',
+type: 'generic'
 });
 assert.ok(logger.log.notCalled);
 });
@@ -121,7 +122,7 @@
 assert.deepEqual(
 
mut.unit.getReferenceContent(doc.querySelector('span.mw-reference-text')), {
 html: 'cite 
1more HTML',
-citations: [ 'journal' ]
+type: 'journal'
 });
 assert.ok(logger.log.notCalled);
 });
@@ -131,10 +132,7 @@
 assert.deepEqual(
 
mut.unit.getReferenceContent(doc.querySelector('span.mw-reference-text')), {
 html: ulRefContent,
-citations: [
-'web',
-'book'
-]
+type: 'generic'
 });
 assert.ok(logger.log.notCalled);
 });
@@ -143,7 +141,8 @@
 const doc = createDocument(indianFilmsRef);
 assert.deepEqual(
 
mut.unit.getReferenceContent(doc.querySelector('span.mw-reference-text')), {
-html: indianFilmsRefContent
+html: indianFilmsRefContent,
+type: 'generic'
 });
 assert.ok(logger.log.notCalled);
 });
@@ -154,11 +153,12 @@
 const doc = createDocument(simpleDogRef);
 const result = 
mut.unit.buildOneReferenceItem(doc.querySelector('li'), logger);
 assert.deepEqual(result, {
-back_links: [ {
+back_links: [{
 "href": "./Dog#cite_ref-101",
 "text": "↑"
 }],
 content: 'some HTML',
+type: 'generic',
 id: '101'
 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: References: back_link as object

2017-12-11 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397737 )

Change subject: References: back_link as object
..

References: back_link as object

Instead of a single string a backlink is now an object with an href and
a text field.
The content of the text field is just returns what Parsoid gives us in
the DOM but spaces are trimmed on the beginning and the end.

Bug: T182647
Change-Id: Ie0c03e1695b291d6040252f66b6d3aa4319aa939
---
M lib/references/structureReferenceListContent.js
M test/lib/references/structureReferenceListContent.test.js
2 files changed, 37 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/37/397737/1

diff --git a/lib/references/structureReferenceListContent.js 
b/lib/references/structureReferenceListContent.js
index de1bee7..cbf6064 100644
--- a/lib/references/structureReferenceListContent.js
+++ b/lib/references/structureReferenceListContent.js
@@ -10,8 +10,11 @@
 const hasOnlyWhitespace = node =>
 node.nodeType === NodeType.TEXT_NODE && /^\s*$/.test(node.textContent);
 
-const buildBackLinkText = (element) => {
-return element.getAttribute('href');
+const buildBackLinkObject = (element) => {
+return {
+href: element.getAttribute('href'),
+text: element.textContent.trim()
+};
 };
 
 const structureBackLinks = (listItemElement, logger) => {
@@ -19,7 +22,7 @@
 const element = listItemElement.firstElementChild;
 if (element.tagName === 'A') {
 // single back link directly
-resultArray.push(buildBackLinkText(element));
+resultArray.push(buildBackLinkObject(element));
 } else if (element.tagName === 'SPAN') {
 // multiple back links inside a 
 
@@ -29,7 +32,7 @@
 for (let i = 0; i < spanChildElements.length; i++) {
 const spanChildEl = spanChildElements[i];
 if (spanChildEl.tagName === 'A') {
-resultArray.push(buildBackLinkText(spanChildEl));
+resultArray.push(buildBackLinkObject(spanChildEl));
 }
 }
 } else {
diff --git a/test/lib/references/structureReferenceListContent.test.js 
b/test/lib/references/structureReferenceListContent.test.js
index 6b8cbb4..e4e6b48 100644
--- a/test/lib/references/structureReferenceListContent.test.js
+++ b/test/lib/references/structureReferenceListContent.test.js
@@ -74,19 +74,23 @@
 it('one back link', () => {
 const doc = createDocument(simpleDogRef);
 assert.deepEqual(
-mut.unit.structureBackLinks(doc.querySelector('li'), logger), [
-'./Dog#cite_ref-101'
-]);
+mut.unit.structureBackLinks(doc.querySelector('li'), logger), 
[{
+href: './Dog#cite_ref-101',
+text: '↑'
+}]);
 assert.ok(logger.log.notCalled);
 });
 
 it('two back links', () => {
 const doc = createDocument(twoBacklinksDogRef);
 assert.deepEqual(
-mut.unit.structureBackLinks(doc.querySelector('li'), logger), [
-'./Dog#cite_ref-perri2016_13-0',
-'./Dog#cite_ref-perri2016_13-1'
-]
+mut.unit.structureBackLinks(doc.querySelector('li'), logger), 
[ {
+href: './Dog#cite_ref-perri2016_13-0',
+text: '1'
+}, {
+href: './Dog#cite_ref-perri2016_13-1',
+text: '2'
+}]
 );
 assert.ok(logger.log.notCalled);
 });
@@ -150,9 +154,10 @@
 const doc = createDocument(simpleDogRef);
 const result = 
mut.unit.buildOneReferenceItem(doc.querySelector('li'), logger);
 assert.deepEqual(result, {
-back_links: [
-'./Dog#cite_ref-101'
-],
+back_links: [ {
+"href": "./Dog#cite_ref-101",
+"text": "↑"
+}],
 content: 'some HTML',
 id: '101'
 });
@@ -163,11 +168,13 @@
 const doc = createDocument(twoBacklinksDogRef);
 const result = 
mut.unit.buildOneReferenceItem(doc.querySelector('li'), logger);
 assert.deepEqual(result, {
-back_links: [
-'./Dog#cite_ref-perri2016_13-0',
-'./Dog#cite_ref-perri2016_13-1'
-
-],
+back_links: [{
+"href": "./Dog#cite_ref-perri2016_13-0",
+"text": "1"
+}, {
+"href": "./Dog#cite_ref-perri2016_13-1",
+"text": "2"
+}],
 content: 'cite 
1more HTML',
 citations: [
 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: References: add specific version number

2017-12-11 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397640 )

Change subject: References: add specific version number
..

References: add specific version number

This will be part of PCS.

Change-Id: I2f7600ffc5c6254db99ee18063da35ab503ac777
---
M lib/mobile-util.js
M routes/mobile-sections.js
2 files changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/40/397640/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index 3e9b515..47b1257 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -13,6 +13,7 @@
 mobileSections: { name: 'mobile-sections', version: '0.13.1' },
 media: { name: 'Media', version: '1.0.0' },
 readHtml: { name: 'ReadHtml', version: '0.1.0' },
+references: { name: 'References', version: '1.0.0' },
 summary: { name: 'Summary', version: '1.3.0' },
 definition: { name: 'definition', version: '0.7.3' },
 random: { name: 'random', version: '0.6.0' },
diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index 278ecd2..75fb024 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -374,7 +374,7 @@
 .then((response) => {
 res.status(200);
 mUtil.setETag(res, response.meta.revision);
-mUtil.setContentType(res, mUtil.CONTENT_TYPES.mobileSections);
+mUtil.setContentType(res, mUtil.CONTENT_TYPES.references);
 res.json(buildReferences(response.doc, req.logger)).end();
 });
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f7600ffc5c6254db99ee18063da35ab503ac777
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Bump mobile-sections and definitions version

2017-12-11 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397633 )

Change subject: Bump mobile-sections and definitions version
..

Bump mobile-sections and definitions version

to hopefully follow shortly after the deployment of
Parsoid section tags.

Once Parsoid deploys the sectioning patch then we'll exercise
different code paths in MCS for the various mobile-sections and
definitions endpoints.

Change-Id: Ibb105cb3b7ab71a14c190fd59eadbe3462f6d429
---
M lib/mobile-util.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/33/397633/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index acbccc8..92034bb 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -10,7 +10,7 @@
 const NS_MAIN = 0;
 
 mUtil.CONTENT_TYPES = {
-mobileSections: { name: 'mobile-sections', version: '0.13.0' },
+mobileSections: { name: 'mobile-sections', version: '0.13.1' },
 media: { name: 'Media', version: '1.0.0' },
 readHtml: { name: 'ReadHtml', version: '0.1.0' },
 summary: { name: 'Summary', version: '1.3.0' },

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb105cb3b7ab71a14c190fd59eadbe3462f6d429
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: WIP: Dev: Replace Sepia with Replayer

2017-12-08 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/396428 )

Change subject: WIP: Dev: Replace Sepia with Replayer
..

WIP: Dev: Replace Sepia with Replayer

Unfortunately the Sepia project seems abandoned. This project was forked
to Replayer.[1]

Unfortunately some requests to RESTBase don't seem to work anymore:

```
HTTPError {name: HTTPError,
message: 504: internal_http_error,
status: 504,
body: ,
stack: Error: incorrect header check
at Gunzip.zlibOnError (zlib.js:153:15)}
```

[1] https://github.com/linkedin/sepia/issues/27

Bug: T152255
Change-Id: Ic1ee147e0767f414a11bacec5644ae21ee6beeec
---
M package.json
M test/utils/server.js
2 files changed, 9 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/28/396428/1

diff --git a/package.json b/package.json
index 9e916e9..bfff8b0 100644
--- a/package.json
+++ b/package.json
@@ -81,7 +81,7 @@
 "eslint-plugin-json": "^1.2.0",
 "eslint-plugin-jsdoc": "^3.0.0",
 "rss-parser": "^2.10.8",
-"sepia": "^2.0.2"
+"replayer": "^2.1.3"
   },
   "deploy": {
 "target": "debian",
diff --git a/test/utils/server.js b/test/utils/server.js
index ba33769..233146a 100644
--- a/test/utils/server.js
+++ b/test/utils/server.js
@@ -16,7 +16,7 @@
 const assert = require('./assert');
 const yaml = require('js-yaml');
 const extend = require('extend');
-const sepia = require('sepia');
+const replayer = require('replayer');
 
 
 // set up the configuration
@@ -40,8 +40,14 @@
 // make a deep copy of it for later reference
 const origConfig = extend(true, {}, config);
 
+// replayer.configure({
+// verbose: true,
+// debug: true,
+// // includeCookieNames: false,
+// // cookieWhitelist: []
+// });
 // Requests to our own service should always be live and not use the VCR 
facility.
-sepia.filter({
+replayer.filter({
 url: new RegExp(config.uri),
 forceLive: true
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1ee147e0767f414a11bacec5644ae21ee6beeec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Bring back Sepia request caching

2017-12-07 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/396297 )

Change subject: Bring back Sepia request caching
..

Bring back Sepia request caching

The key is to require sepia. This line got somehow deleted via a merge.
I'm a bit concerned that there haven't been any updates to this npm
package from linkedin in three years. So far it does seem to work, once
the require line is brought back.

Also added a filter so that requests to our own service (localhost:6927)
don't get recorded since that is what we actually want to test. This
makes this much more useful than before, where sometimes our code didn't
end up even being invoked. That was very bad.

Bug: T152255
Change-Id: Ic41c0308c8a74fa123a24372a4329b46a56789ab
---
M test/utils/server.js
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/97/396297/1

diff --git a/test/utils/server.js b/test/utils/server.js
index a1fb54f..71a464f 100644
--- a/test/utils/server.js
+++ b/test/utils/server.js
@@ -16,6 +16,7 @@
 const assert = require('./assert');
 const yaml = require('js-yaml');
 const extend = require('extend');
+const sepia = require('sepia');
 
 
 // set up the configuration
@@ -39,6 +40,13 @@
 // make a deep copy of it for later reference
 const origConfig = extend(true, {}, config);
 
+// Requests to our own service should always be live and not use the VCR 
facility.
+// See https://github.com/linkedin/sepia/blob/master/examples/forceLive.js#L133
+sepia.filter({
+url: new RegExp(config.uri),
+forceLive: true
+});
+
 module.exports.stop = () => { return BBPromise.resolve(); };
 let options = null;
 const runner = new ServiceRunner();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic41c0308c8a74fa123a24372a4329b46a56789ab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Version number for the media endpoint

2017-12-06 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395849 )

Change subject: Version number for the media endpoint
..

Version number for the media endpoint

Bug: T177430
Change-Id: I426d97e2c36b0071bc3a6191fb79e0ee48efec33
---
M lib/mobile-util.js
M routes/media.js
2 files changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/49/395849/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index 41f3e3c..e93e453 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -11,6 +11,7 @@
 
 mUtil.CONTENT_TYPES = {
 mobileSections: { name: 'mobile-sections', version: '0.13.0' },
+media: { name: 'Media', version: '1.0.0' },
 readHtml: { name: 'ReadHtml', version: '0.1.0' },
 summary: { name: 'Summary', version: '1.3.0' },
 definition: { name: 'definition', version: '0.7.2' },
diff --git a/routes/media.js b/routes/media.js
index fb39932..68c0c13 100644
--- a/routes/media.js
+++ b/routes/media.js
@@ -41,7 +41,7 @@
 });
 });
 mUtil.setETag(res, revTid.revision, revTid.tid);
-mUtil.setContentType(res, mUtil.CONTENT_TYPES.unpublished);
+mUtil.setContentType(res, mUtil.CONTENT_TYPES.media);
 res.send({ items: mediaList.filter(item => 
media.filterResult(item)) });
 });
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I426d97e2c36b0071bc3a6191fb79e0ee48efec33
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: tag-deploy: push only the created tag

2017-11-30 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394522 )

Change subject: tag-deploy: push only the created tag
..

tag-deploy: push only the created tag

git push --tags would push any local tags missing on the upstream repo
to it. Instead just push the single tag we just created.

Change-Id: If221f8faceab86f9ab3df61b18e27678a43cfda4
---
M scripts/tag-deploy.sh
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/22/394522/1

diff --git a/scripts/tag-deploy.sh b/scripts/tag-deploy.sh
index 8b63dab..53f4464 100755
--- a/scripts/tag-deploy.sh
+++ b/scripts/tag-deploy.sh
@@ -35,4 +35,4 @@
 
 # Tag the latest code repo commit with it & push tags
 cd "$repo_dir"
-git tag -s "$tag" -m "deployed" && git push --tags && printf "Applied new tag: 
$tag\n"
+git tag -s "$tag" -m "deployed" && git push origin "$tag" && printf "Applied 
new tag: $tag\n"

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If221f8faceab86f9ab3df61b18e27678a43cfda4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to 4317ea5

2017-11-30 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394479 )

Change subject: Update mobileapps to 4317ea5
..

Update mobileapps to 4317ea5

List of changes:
dad2788 Add figure-inline transformation
ffe7f95 Media: Add figure-inline selectors to media selector list
4317ea5 Update: exclude Canada from iOS countries list
xxx Update node module dependencies

Change-Id: I8820a03f4bbb2f6925199bedb1a8ffd1d4446abd
---
M node_modules/kad/package.json
M node_modules/swagger-ui/package.json
M src
3 files changed, 3 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps/deploy 
refs/changes/79/394479/1

diff --git a/node_modules/kad/package.json b/node_modules/kad/package.json
index 02a5b18..57b6238 100644
--- a/node_modules/kad/package.json
+++ b/node_modules/kad/package.json
@@ -49,7 +49,7 @@
 "/limitation"
   ],
   "_resolved": 
"git+https://github.com/gwicke/kad.git#936c91652d757ea6f9dd30e44698afb0daaa1d17;,
-  "_shasum": "204a27444e66a1d7a8699687da261a1fab223d33",
+  "_shasum": "7b42eaea96f809e59e8ef42179ade6971684cf91",
   "_shrinkwrap": null,
   "_spec": "kad@git+https://github.com/gwicke/kad.git#master;,
   "_where": "/opt/service/node_modules/limitation",
diff --git a/node_modules/swagger-ui/package.json 
b/node_modules/swagger-ui/package.json
index 4ddbc6e..ba42456 100644
--- a/node_modules/swagger-ui/package.json
+++ b/node_modules/swagger-ui/package.json
@@ -49,7 +49,7 @@
 "/"
   ],
   "_resolved": 
"git+https://github.com/wikimedia/swagger-ui.git#b9b40dc8e00caeb24c19fe636b93250a7e335541;,
-  "_shasum": "5902ff146b94ece492e879e33b2b64432d4554c1",
+  "_shasum": "33a7513b2bd76f5b641a1d0bcdafab15f7a11dd9",
   "_shrinkwrap": null,
   "_spec": "swagger-ui@git+https://github.com/wikimedia/swagger-ui.git#master;,
   "_where": "/opt/service",
diff --git a/src b/src
index dcea7d3..4317ea5 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit dcea7d3b58e0ad450297ac13cef0cd0b783a54d0
+Subproject commit 4317ea51751104ec8898a6f9f53c5bd06a970cd6

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8820a03f4bbb2f6925199bedb1a8ffd1d4446abd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps/deploy
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Add figure-inline transformation

2017-11-29 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394243 )

Change subject: Add figure-inline transformation
..

Add figure-inline transformation

Parsoid is going to change some img wrapper DOM elements from span to
figure-inline. This means we probably want to do the same DOM
transformations we do for spans to also the new, made-up figure-inline
tag.

TODO: Once it's live we'll have to update the expected diff
test results.

Change-Id: I45e54cc54c784eac2a215d6c84b1d3d19da1d8f5
---
M lib/transforms.js
1 file changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/43/394243/1

diff --git a/lib/transforms.js b/lib/transforms.js
index fae122c..341360f 100644
--- a/lib/transforms.js
+++ b/lib/transforms.js
@@ -201,8 +201,10 @@
 _rmAttributes(doc, 'li', ['about']);
 _rmAttributes(doc, 'img', ['about', 'alt', 'data-file-height', 
'data-file-width',
 'resource']);
-_rmAttributes(doc, 'span', ['about', 'data-file-type', 'data-mw', 
'itemscope',
-'itemtype', 'lang', 'rel', 'title', 'typeof']);
+const figureInlineAttributes = ['about', 'data-file-type', 'data-mw', 
'itemscope',
+'itemtype', 'lang', 'rel', 'title', 'typeof'];
+_rmAttributes(doc, 'figure-inline', figureInlineAttributes);
+_rmAttributes(doc, 'span', figureInlineAttributes);
 
 _rmMwIdAttributes(doc, 'a[href]');
 _rmMwIdAttributes(doc, 'b');

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I45e54cc54c784eac2a215d6c84b1d3d19da1d8f5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to dcea7d3

2017-11-29 Thread BearND (Code Review)
BearND has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/394227 )

Change subject: Update mobileapps to dcea7d3
..


Update mobileapps to dcea7d3

List of changes:
e5b73f3 Add .nsprc and update dependencies to resolve build issues
15bb29d Hygiene: Refine processing of media items in Parsoid HTML
149a6a6 Update to service-template-node v0.5.4
29bb698 Big English fundraiser announcements
350528b Tweak Big English fundraiser copy and start time
f3d91c3 Tweak Big English fundraiser copy some more
dcea7d3 Tweak Big English fundraiser copy and start time again
xxx Update node module dependencies

Change-Id: Idae8dc9484038e46309b154f0f5ea23059af5075
---
M node_modules/ajv/dist/ajv.bundle.js
M node_modules/ajv/dist/ajv.min.js
M node_modules/ajv/dist/ajv.min.js.map
M node_modules/ajv/lib/ajv.d.ts
M node_modules/ajv/lib/ajv.js
M node_modules/ajv/lib/keyword.js
M node_modules/ajv/package.json
D node_modules/are-we-there-yet/CHANGES.md~
D node_modules/console-control-strings/README.md~
M node_modules/core-js/package.json
M node_modules/cryptiles/.npmignore
M node_modules/domino/.travis.yml
M node_modules/domino/lib/CharacterData.js
M node_modules/domino/lib/ChildNode.js
M node_modules/domino/lib/Comment.js
A node_modules/domino/lib/ContainerNode.js
M node_modules/domino/lib/Document.js
M node_modules/domino/lib/DocumentFragment.js
M node_modules/domino/lib/DocumentType.js
M node_modules/domino/lib/Element.js
M node_modules/domino/lib/FilteredElementList.js
M node_modules/domino/lib/Leaf.js
A node_modules/domino/lib/LinkedList.js
M node_modules/domino/lib/Node.js
M node_modules/domino/lib/NonDocumentTypeChildNode.js
M node_modules/domino/lib/ProcessingInstruction.js
M node_modules/domino/lib/Text.js
M node_modules/domino/lib/utils.js
M node_modules/domino/package.json
M node_modules/domino/test/mocha.opts
M node_modules/esprima/dist/esprima.js
M node_modules/gc-stats/node_modules/cryptiles/.npmignore
M node_modules/gc-stats/node_modules/cryptiles/.travis.yml
M node_modules/gc-stats/node_modules/hawk/.npmignore
M node_modules/gc-stats/node_modules/hawk/.travis.yml
M node_modules/gc-stats/node_modules/hawk/bower.json
M node_modules/gc-stats/node_modules/hawk/component.json
M node_modules/gc-stats/node_modules/hawk/dist/client.js
M node_modules/gc-stats/node_modules/hawk/example/usage.js
M node_modules/gc-stats/node_modules/hawk/lib/browser.js
M node_modules/gc-stats/node_modules/hawk/lib/client.js
M node_modules/gc-stats/node_modules/hawk/lib/crypto.js
M node_modules/gc-stats/node_modules/hawk/lib/index.js
M node_modules/gc-stats/node_modules/hawk/lib/server.js
M node_modules/gc-stats/node_modules/hawk/lib/utils.js
M node_modules/gc-stats/node_modules/hawk/test/browser.js
M node_modules/gc-stats/node_modules/hawk/test/client.js
M node_modules/gc-stats/node_modules/hawk/test/crypto.js
M node_modules/gc-stats/node_modules/hawk/test/index.js
M node_modules/gc-stats/node_modules/hawk/test/readme.js
M node_modules/gc-stats/node_modules/hawk/test/server.js
M node_modules/gc-stats/node_modules/hawk/test/uri.js
M node_modules/gc-stats/node_modules/hawk/test/utils.js
M node_modules/hawk/.npmignore
M node_modules/json-schema/draft-00/hyper-schema
M node_modules/json-schema/draft-00/json-ref
M node_modules/json-schema/draft-00/links
M node_modules/json-schema/draft-00/schema
M node_modules/json-schema/draft-01/hyper-schema
M node_modules/json-schema/draft-01/json-ref
M node_modules/json-schema/draft-01/links
M node_modules/json-schema/draft-01/schema
M node_modules/json-schema/draft-02/hyper-schema
M node_modules/json-schema/draft-02/json-ref
M node_modules/json-schema/draft-02/links
M node_modules/json-schema/draft-02/schema
M node_modules/json-schema/draft-03/examples/address
M node_modules/json-schema/draft-03/examples/calendar
M node_modules/json-schema/draft-03/examples/card
M node_modules/json-schema/draft-03/examples/geo
M node_modules/json-schema/draft-03/examples/interfaces
M node_modules/json-schema/draft-03/hyper-schema
M node_modules/json-schema/draft-03/json-ref
M node_modules/json-schema/draft-03/links
M node_modules/json-schema/draft-03/schema
M node_modules/json-schema/draft-04/hyper-schema
M node_modules/json-schema/draft-04/links
M node_modules/json-schema/draft-04/schema
M node_modules/json-schema/draft-zyp-json-schema-03.xml
M node_modules/json-schema/draft-zyp-json-schema-04.xml
M node_modules/json-schema/lib/links.js
M node_modules/json-schema/lib/validate.js
M node_modules/json-schema/test/tests.js
M node_modules/kad/package.json
M node_modules/long/.npmignore
M node_modules/long/.travis.yml
M node_modules/long/LICENSE
M node_modules/long/bower.json
M node_modules/long/dist/Long.js
M node_modules/long/externs/Long.js
M node_modules/long/index.js
M node_modules/long/jsdoc.json
M node_modules/long/scripts/build.js
M node_modules/long/src/Long.js
M node_modules/long/src/bower.json
M node_modules/long/src/wrap.js

[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to dcea7d3

2017-11-29 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394227 )

Change subject: Update mobileapps to dcea7d3
..

Update mobileapps to dcea7d3

List of changes:
e5b73f3 Add .nsprc and update dependencies to resolve build issues
15bb29d Hygiene: Refine processing of media items in Parsoid HTML
149a6a6 Update to service-template-node v0.5.4
29bb698 Big English fundraiser announcements
350528b Tweak Big English fundraiser copy and start time
f3d91c3 Tweak Big English fundraiser copy some more
dcea7d3 Tweak Big English fundraiser copy and start time again
xxx Update node module dependencies

Change-Id: Idae8dc9484038e46309b154f0f5ea23059af5075
---
M node_modules/ajv/dist/ajv.bundle.js
M node_modules/ajv/dist/ajv.min.js
M node_modules/ajv/dist/ajv.min.js.map
M node_modules/ajv/lib/ajv.d.ts
M node_modules/ajv/lib/ajv.js
M node_modules/ajv/lib/keyword.js
M node_modules/ajv/package.json
D node_modules/are-we-there-yet/CHANGES.md~
D node_modules/console-control-strings/README.md~
M node_modules/core-js/package.json
M node_modules/cryptiles/.npmignore
M node_modules/domino/.travis.yml
M node_modules/domino/lib/CharacterData.js
M node_modules/domino/lib/ChildNode.js
M node_modules/domino/lib/Comment.js
A node_modules/domino/lib/ContainerNode.js
M node_modules/domino/lib/Document.js
M node_modules/domino/lib/DocumentFragment.js
M node_modules/domino/lib/DocumentType.js
M node_modules/domino/lib/Element.js
M node_modules/domino/lib/FilteredElementList.js
M node_modules/domino/lib/Leaf.js
A node_modules/domino/lib/LinkedList.js
M node_modules/domino/lib/Node.js
M node_modules/domino/lib/NonDocumentTypeChildNode.js
M node_modules/domino/lib/ProcessingInstruction.js
M node_modules/domino/lib/Text.js
M node_modules/domino/lib/utils.js
M node_modules/domino/package.json
M node_modules/domino/test/mocha.opts
M node_modules/esprima/dist/esprima.js
M node_modules/gc-stats/node_modules/cryptiles/.npmignore
M node_modules/gc-stats/node_modules/cryptiles/.travis.yml
M node_modules/gc-stats/node_modules/hawk/.npmignore
M node_modules/gc-stats/node_modules/hawk/.travis.yml
M node_modules/gc-stats/node_modules/hawk/bower.json
M node_modules/gc-stats/node_modules/hawk/component.json
M node_modules/gc-stats/node_modules/hawk/dist/client.js
M node_modules/gc-stats/node_modules/hawk/example/usage.js
M node_modules/gc-stats/node_modules/hawk/lib/browser.js
M node_modules/gc-stats/node_modules/hawk/lib/client.js
M node_modules/gc-stats/node_modules/hawk/lib/crypto.js
M node_modules/gc-stats/node_modules/hawk/lib/index.js
M node_modules/gc-stats/node_modules/hawk/lib/server.js
M node_modules/gc-stats/node_modules/hawk/lib/utils.js
M node_modules/gc-stats/node_modules/hawk/test/browser.js
M node_modules/gc-stats/node_modules/hawk/test/client.js
M node_modules/gc-stats/node_modules/hawk/test/crypto.js
M node_modules/gc-stats/node_modules/hawk/test/index.js
M node_modules/gc-stats/node_modules/hawk/test/readme.js
M node_modules/gc-stats/node_modules/hawk/test/server.js
M node_modules/gc-stats/node_modules/hawk/test/uri.js
M node_modules/gc-stats/node_modules/hawk/test/utils.js
M node_modules/hawk/.npmignore
M node_modules/json-schema/draft-00/hyper-schema
M node_modules/json-schema/draft-00/json-ref
M node_modules/json-schema/draft-00/links
M node_modules/json-schema/draft-00/schema
M node_modules/json-schema/draft-01/hyper-schema
M node_modules/json-schema/draft-01/json-ref
M node_modules/json-schema/draft-01/links
M node_modules/json-schema/draft-01/schema
M node_modules/json-schema/draft-02/hyper-schema
M node_modules/json-schema/draft-02/json-ref
M node_modules/json-schema/draft-02/links
M node_modules/json-schema/draft-02/schema
M node_modules/json-schema/draft-03/examples/address
M node_modules/json-schema/draft-03/examples/calendar
M node_modules/json-schema/draft-03/examples/card
M node_modules/json-schema/draft-03/examples/geo
M node_modules/json-schema/draft-03/examples/interfaces
M node_modules/json-schema/draft-03/hyper-schema
M node_modules/json-schema/draft-03/json-ref
M node_modules/json-schema/draft-03/links
M node_modules/json-schema/draft-03/schema
M node_modules/json-schema/draft-04/hyper-schema
M node_modules/json-schema/draft-04/links
M node_modules/json-schema/draft-04/schema
M node_modules/json-schema/draft-zyp-json-schema-03.xml
M node_modules/json-schema/draft-zyp-json-schema-04.xml
M node_modules/json-schema/lib/links.js
M node_modules/json-schema/lib/validate.js
M node_modules/json-schema/test/tests.js
M node_modules/kad/package.json
M node_modules/long/.npmignore
M node_modules/long/.travis.yml
M node_modules/long/LICENSE
M node_modules/long/bower.json
M node_modules/long/dist/Long.js
M node_modules/long/externs/Long.js
M node_modules/long/index.js
M node_modules/long/jsdoc.json
M node_modules/long/scripts/build.js
M node_modules/long/src/Long.js
M node_modules/long/src/bower.json
M node_modules/long/src/wrap.js
M 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Tweak Big English fundraiser copy and start time again

2017-11-29 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394205 )

Change subject: Tweak Big English fundraiser copy and start time again
..

Tweak Big English fundraiser copy and start time again

Updated start time and added '.' at end of disclaimer.

Bug: T181004
Change-Id: I9ee81fc634364dcca4ec30cd1a31b27d9527970f
---
M etc/feed/announcements.js
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/05/394205/1

diff --git a/etc/feed/announcements.js b/etc/feed/announcements.js
index 7e1f8d9..d761731 100644
--- a/etc/feed/announcements.js
+++ b/etc/feed/announcements.js
@@ -7,7 +7,7 @@
 
 const type = AnnouncementType.FUNDRAISING;
 const activeWiki = 'en.wikipedia.org';
-const startTime = '2017-12-06T16:00:00Z';
+const startTime = '2017-12-01T00:00:00Z';
 const endTime = '2017-12-31T00:00:00Z';
 const idPrefix = 'EN1217';
 const androidDestinationUrl
@@ -18,7 +18,7 @@
 // const imageUrl = undefined; // no image this time
 const buttonLabel = 'Donate now';
 const disclaimerHtml
-= 'By submitting, you are agreeing to our https://wikimediafoundation.org/wiki/Donor_policy/en;>donor privacy 
policy';
+= 'By submitting, you are agreeing to our https://wikimediafoundation.org/wiki/Donor_policy/en;>donor privacy 
policy.';
 
 const countryVariants = [ {
 countryCode: 'US',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9ee81fc634364dcca4ec30cd1a31b27d9527970f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Tweak Big English fundraiser copy some more

2017-11-29 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394152 )

Change subject: Tweak Big English fundraiser copy some more
..

Tweak Big English fundraiser copy some more

Removed the extra "Privacy disclaimer text: ".

Bug: T181004
Change-Id: Ib15453e03d37988e1d549f5ffdb9062c40737160
---
M etc/feed/announcements.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/52/394152/1

diff --git a/etc/feed/announcements.js b/etc/feed/announcements.js
index a02c414..7e1f8d9 100644
--- a/etc/feed/announcements.js
+++ b/etc/feed/announcements.js
@@ -18,7 +18,7 @@
 // const imageUrl = undefined; // no image this time
 const buttonLabel = 'Donate now';
 const disclaimerHtml
-= 'Privacy disclaimer text: By submitting, you are agreeing to our https://wikimediafoundation.org/wiki/Donor_policy/en;>donor privacy 
policy';
+= 'By submitting, you are agreeing to our https://wikimediafoundation.org/wiki/Donor_policy/en;>donor privacy 
policy';
 
 const countryVariants = [ {
 countryCode: 'US',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib15453e03d37988e1d549f5ffdb9062c40737160
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Tweak Big English fundraiser copy

2017-11-29 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394107 )

Change subject: Tweak Big English fundraiser copy
..

Tweak Big English fundraiser copy

Now with double the line breaks and updated button label.

Bug: T181004
Change-Id: Icc8485f603b8c1aae2b3af4d0e58a1b9e6c23854
---
M etc/feed/announcements.js
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/07/394107/1

diff --git a/etc/feed/announcements.js b/etc/feed/announcements.js
index 4af8fde..e4e2f4d 100644
--- a/etc/feed/announcements.js
+++ b/etc/feed/announcements.js
@@ -16,7 +16,7 @@
 = 
'https://donate.wikimedia.org/?uselang=en_medium=WikipediaAppFeed_campaign=iOS_source=app_201712_6C_control';
 // TODO: consider removing jshint
 // const imageUrl = undefined; // no image this time
-const buttonLabel = 'Donate today';
+const buttonLabel = 'Donate now';
 const disclaimerHtml
 = 'Privacy disclaimer text: By submitting, you are agreeing to our https://wikimediafoundation.org/wiki/Donor_policy/en;>donor privacy 
policy';
 
@@ -66,7 +66,9 @@
 // replaced %COUNTRY% with ${country}, ...
 /* eslint-disable max-len */
 return `Hi reader in ${country}, it seems you use Wikipedia a lot; I think 
that’s great and hope you find it useful.
+
 It’s a little awkward to ask, but today we need your help. We depend on 
donations averaging ${currency}${average}, but fewer than 1% of readers choose 
to give. If you donate just ${currency}${coffee}, you would help keep Wikipedia 
thriving for years. That’s right, the price of a cup of coffee is all I ask. 
Please take a minute to keep Wikipedia growing.
+
 Thank you. — Jimmy Wales, Wikipedia Founder`;
 /* eslint-enable max-len */
 };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc8485f603b8c1aae2b3af4d0e58a1b9e6c23854
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Big English fundraiser announcements

2017-11-29 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394013 )

Change subject: Big English fundraiser announcements
..

Big English fundraiser announcements

For the Big English fundraiser we need to have 12 announcements.
2 platforms as usual (Android + iOS) times
6 English speaking countries/currencies

To avoid copy/paste issues let's compile the announcements more
dynamically.

Restructured the code into route, lib and, config (under etc).
Also moved some integration tests to unit tests + added a bunch more.
The announcement configuration is now in the new etc file.

Bug: T181004
Change-Id: Ic3146fb637efa384539a3f0141367a8e242610d2
---
A etc/feed/announcements.js
A lib/feed/announcements.js
M lib/mobile-util.js
M routes/announcements.js
M spec.yaml
M test/features/announcements/announcements.js
A test/lib/feed/announcements.js
7 files changed, 337 insertions(+), 152 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/13/394013/1

diff --git a/etc/feed/announcements.js b/etc/feed/announcements.js
new file mode 100644
index 000..7224f5c
--- /dev/null
+++ b/etc/feed/announcements.js
@@ -0,0 +1,81 @@
+'use strict';
+
+const activeWiki = 'en.wikipedia.org';
+const startTime = '2017-11-30T16:00:00Z';
+const endTime = '2017-12-31T00:00:00Z';
+const idPrefix = 'EN1217';
+const type = 'fundraising'; // 'survey' or 'fundraising'
+const androidDestinationUrl
+= 
'https://donate.wikimedia.org/?uselang=en_medium=WikipediaAppFeed_campaign=Android_source=app_201712_6C_control';
+const iosDestinationUrl
+= 
'https://donate.wikimedia.org/?uselang=en_medium=WikipediaAppFeed_campaign=iOS_source=app_201712_6C_control';
+const imageUrl = undefined; // no image this time
+const buttonLabel = 'Donate today';
+const disclaimerHtml
+= 'Privacy disclaimer text: By submitting, you are agreeing to our https://wikimediafoundation.org/wiki/Donor_policy/en;>donor privacy 
policy';
+
+const variants = [ {
+countryCode: 'US',
+country: 'the U.S.',
+currency: '$',
+average: 15,
+coffee: 3
+}, {
+countryCode: 'GB',
+country: 'the UK',
+currency: '£',
+average: 10,
+coffee: 2
+}, {
+countryCode: 'AU',
+country: 'Australia',
+currency: '$',
+average: 15,
+coffee: 3
+}, {
+countryCode: 'CA',
+country: 'Canada',
+currency: '$',
+average: 15,
+coffee: 3
+}, {
+countryCode: 'NZ',
+country: 'New Zealand',
+currency: '$',
+average: 15,
+coffee: 3
+}, {
+countryCode: 'IE',
+country: 'Ireland',
+currency: '€',
+average: 10,
+coffee: 2
+}];
+
+/**
+ * Builds the body text. No HTML here since iOS doesn't support it.
+ * @param {!object} vars an Object holding the variables for text substitution
+ */
+const buildBaseBodyText = ({ country, currency, average, coffee }) => {
+// replaced %COUNTRY% with ${country}, ...
+/* eslint-disable max-len */
+return `Hi reader in ${country}, it seems you use Wikipedia a lot; I think 
that’s great and hope you find it useful.
+It’s a little awkward to ask, but today we need your help. We depend on 
donations averaging ${currency}${average}, but fewer than 1% of readers choose 
to give. If you donate just ${currency}${coffee}, you would help keep Wikipedia 
thriving for years. That’s right, the price of a cup of coffee is all I ask. 
Please take a minute to keep Wikipedia growing.
+Thank you. — Jimmy Wales, Wikipedia Founder`;
+/* eslint-enable max-len */
+};
+
+module.exports = {
+activeWiki,
+startTime,
+endTime,
+idPrefix,
+type,
+androidDestinationUrl,
+iosDestinationUrl,
+imageUrl,
+buttonLabel,
+disclaimerHtml,
+variants,
+buildBaseBodyText
+};
diff --git a/lib/feed/announcements.js b/lib/feed/announcements.js
new file mode 100644
index 000..dbb868c
--- /dev/null
+++ b/lib/feed/announcements.js
@@ -0,0 +1,102 @@
+'use strict';
+
+const config = require('../../etc/feed/announcements');
+
+/**
+ * Builds the body text for iOS. Note: HTML is not supported by iOS clients!
+ * @param {!object} vars an Object holding the variables for text substitution
+ */
+const buildIosBodyText = (vars) => {
+return config.buildBaseBodyText(vars);
+};
+
+/**
+ * Builds the body text for Android. Note: Android wants HTML here.
+ * @param {!object} vars an Object holding the variables for text substitution
+ */
+const buildAndroidBodyText = (vars) => {
+return config.buildBaseBodyText(vars).replace(/\n/g, '');
+};
+
+/**
+ * @param {!string} os operating system, uppercase ('IOS' or 'ANDROID')
+ * @param {!string} countryCode country code, uppercase (e.g. 'US', 'CA')
+ */
+const buildId = (os, countryCode) => {
+return `${config.idPrefix}${config.type.toUpperCase()}${os}${countryCode}`;
+};
+
+const buildIosAnnouncement = (variant) => {
+// Notes: for iOS 'text' and 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: featured-image: better diagnostics in error case

2017-11-13 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391157 )

Change subject: featured-image: better diagnostics in error case
..

featured-image: better diagnostics in error case

We don't want to have the promise return undefined if an error occurs.
Instead re-throw the error so it doesn't go into the then block.
Hopefully this will provide better diagnostics in the future if the same
thing happens again.

Bug: T180420
Change-Id: I607cf4be08a040de36e45ea531a4f0cb310a95c6
---
M lib/feed/featured-image.js
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/57/391157/1

diff --git a/lib/feed/featured-image.js b/lib/feed/featured-image.js
index 3d3b612..ba812dc 100644
--- a/lib/feed/featured-image.js
+++ b/lib/feed/featured-image.js
@@ -204,6 +204,8 @@
 title: 'No picture of the day for this date',
 detail: 'There is no picture of the day for this date.'
 });
+} else {
+throw err;
 }
 });
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I607cf4be08a040de36e45ea531a4f0cb310a95c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...trending-edits[master]: Hygiene: update simple node dependencies

2017-11-10 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/390545 )

Change subject: Hygiene: update simple node dependencies
..

Hygiene: update simple node dependencies

This is more to document the node dependency that get updated
automatically by npm install.

Change-Id: I21938ff2b901ce690dbf4fd85e64ee91a37a4f5e
---
M package.json
1 file changed, 11 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/trending-edits 
refs/changes/45/390545/1

diff --git a/package.json b/package.json
index ff5a63d..40b3d40 100644
--- a/package.json
+++ b/package.json
@@ -21,29 +21,29 @@
 "url": 
"https://phabricator.wikimedia.org/tag/reading_web_trending_service/;
   },
   "dependencies": {
-"bluebird": "^3.4.1",
-"body-parser": "^1.15.2",
-"bunyan": "^1.8.1",
+"bluebird": "^3.5.1",
+"body-parser": "^1.18.2",
+"bunyan": "^1.8.12",
 "cassandra-uuid": "^0.0.2",
-"compression": "^1.6.2",
-"core-js": "^2.4.1",
-"domino": "^1.0.25",
+"compression": "^1.7.1",
+"core-js": "^2.5.1",
+"domino": "^1.0.30",
 "express": "^4.14.0",
-"js-yaml": "^3.6.1",
+"js-yaml": "^3.10.0",
 "preq": "^0.4.10",
 "service-runner": "^2.2.5",
 "swagger-router": "^0.4.6",
 "node-rdkafka": "^1.0.6",
-"wikipedia-edits-scorer": "^1.4.0"
+"wikipedia-edits-scorer": "^1.5.7"
   },
   "devDependencies": {
-"extend": "^3.0.0",
+"extend": "^3.0.1",
 "istanbul": "^0.4.4",
-"jscs": "^3.0.3",
+"jscs": "^3.0.7",
 "mocha": "^2.5.3",
 "mocha-jscs": "^5.0.1",
 "mocha-jshint": "^2.3.1",
-"mocha-lcov-reporter": "^1.2.0",
+"mocha-lcov-reporter": "^1.3.0",
 "nsp": "^2.6.1"
   },
   "deploy": {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21938ff2b901ce690dbf4fd85e64ee91a37a4f5e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/trending-edits
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...trending-edits[master]: Update node-rdkafka dependency to 1.x

2017-11-10 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/390544 )

Change subject: Update node-rdkafka dependency to 1.x
..

Update node-rdkafka dependency to 1.x

Bug: T179786
Change-Id: If613179f95fbb2277be4c3675878bc00cb0183b5
---
M package.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/trending-edits 
refs/changes/44/390544/1

diff --git a/package.json b/package.json
index a46160a..ff5a63d 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
 "preq": "^0.4.10",
 "service-runner": "^2.2.5",
 "swagger-router": "^0.4.6",
-"node-rdkafka": "^0.8.0",
+"node-rdkafka": "^1.0.6",
 "wikipedia-edits-scorer": "^1.4.0"
   },
   "devDependencies": {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If613179f95fbb2277be4c3675878bc00cb0183b5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/trending-edits
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...trending-edits[master]: Update node-rdkafka dependency to 2.x

2017-11-10 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/390546 )

Change subject: Update node-rdkafka dependency to 2.x
..

Update node-rdkafka dependency to 2.x

Breaking Changes mentioned for 2.0.0 release[1]

1. Keys are now returned as buffers in delivery reports
2. Keys are now produced as buffers. If you pass one in as a string
   it will be converted.
3. Topic objects have been removed. You should use topic name strings
   to create topics.

Re 1) Probably not applicable here.
Re 2) Not applicable since it for producers only AFAIU.
Re 3) We already use strings for topics in our Consumer.

As a plus some deprecation warnings got removed when
running npm install.

[1] https://github.com/Blizzard/node-rdkafka/releases

Bug: T179786
Change-Id: Icd5d6183c0e7358287e4fc20da6210281f9692d9
---
M package.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/trending-edits 
refs/changes/46/390546/1

diff --git a/package.json b/package.json
index 40b3d40..c49303e 100644
--- a/package.json
+++ b/package.json
@@ -33,7 +33,7 @@
 "preq": "^0.4.10",
 "service-runner": "^2.2.5",
 "swagger-router": "^0.4.6",
-"node-rdkafka": "^1.0.6",
+"node-rdkafka": "^2.2.0",
 "wikipedia-edits-scorer": "^1.5.7"
   },
   "devDependencies": {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icd5d6183c0e7358287e4fc20da6210281f9692d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/trending-edits
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to 8e82983

2017-11-08 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/390096 )

Change subject: Update mobileapps to 8e82983
..

Update mobileapps to 8e82983

List of changes:
ad0b15a Exclude properties only needed for summary from lead response, pt. 2
xxx Update node module dependencies

Change-Id: I6dcde58d70b175e6c1a1195298724bea72e03040
---
M node_modules/kad/package.json
M src
2 files changed, 2 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps/deploy 
refs/changes/96/390096/1

diff --git a/node_modules/kad/package.json b/node_modules/kad/package.json
index 85ace01..34d5caf 100644
--- a/node_modules/kad/package.json
+++ b/node_modules/kad/package.json
@@ -49,7 +49,7 @@
 "/limitation"
   ],
   "_resolved": 
"git+https://github.com/gwicke/kad.git#936c91652d757ea6f9dd30e44698afb0daaa1d17;,
-  "_shasum": "02c183d0147c659a4dd89dbdeac0db26087592d0",
+  "_shasum": "335455782298b6f0d3a0bdafb789ea71e7e02250",
   "_shrinkwrap": null,
   "_spec": "kad@git+https://github.com/gwicke/kad.git#master;,
   "_where": "/opt/service/node_modules/limitation",
diff --git a/src b/src
index e86fb6c..8e82983 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit e86fb6c9b0ffc4cb9f829ce239c52ca690fb85e0
+Subproject commit 8e829839628f1722db80965ed86a1b299418c626

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6dcde58d70b175e6c1a1195298724bea72e03040
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps/deploy
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to e86fb6c

2017-11-08 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/390068 )

Change subject: Update mobileapps to e86fb6c
..

Update mobileapps to e86fb6c

List of changes:
0492af8 Remove unnecessary API call in unit test
44e42c2 Get section number from Parsoid
3245615 Hygiene: add tests for new Parsoid section elements
6e34857 Revert "Add fundraising test via announcement cards in France"
7bfbc5d Hygiene: create script to compare old and new sectioning code
6fbfedf Fix: Exclude private/compare-sections contents from eslint
3df101c Fix: Get the default set of pageprops in getMetadataActionApi
acf71ee Hygiene: Simplify image URL rewriting and set building
ac111cd Hygiene: Use parallel requests in getMetadataActionApi
3bbd70d Hygiene: Always use node type constants
c42b594 Augment MCS lead and summary responses with all existing RB summary 
fields
5c480ad Add 'titles' object to MCS summary output
fa69a2c Fail incomplete sections early
c4dfd9c Rewrite sectioning using section tags code
4395257 Hygiene: rename parseDefinitions to parseDefinitionsUsingDivs
27a0fc5 Hygiene: split up definitions parsing into two implementations
02fce34 Hygiene: replace data-section-number with data-mw-section-id
ba93e69 Hygiene: rename parsoid-sections-test
b2ed37f Improve Parsoid section detection
a4f1dcc Add swagger spec for summary endpoint
56a86ee Add summary 2.0 common titles object to swagger spec
aa19d64 Add common URLs to summary API
5c51c71 Add geo coordinates to summary 2.0 response
7e3bcd3 Hygiene: Bump mobile-sections content format minor version
597ed0b Hygiene: preserve response objects throughout special handling
c5fc9cf Add canonical title to mobile-sections lead
1e1baaa Next gen definitions parsing, using section tags
2d41d9d Sort media endpoint results in order of appearance
1865dbc Hygiene: Rename lib/gallery.js -> lib/media.js
40a2d1c Report filesize, and don't delete misc props from intermediate response
78d22be Simplify the media endpoint
2830d52 Update swagger spec with the media endpoint updates
910b7a7 Revert "Add canonical title to mobile-sections lead"
285ef96 Don't add lead properties only used for summary construction
xxx Update node module dependencies

Change-Id: I2aee440d329e3cbe8c6489cee8d1197bb17bcac2
---
M node_modules/ajv/dist/ajv.bundle.js
M node_modules/ajv/dist/ajv.min.js
M node_modules/ajv/dist/ajv.min.js.map
M node_modules/ajv/dist/nodent.min.js
M node_modules/ajv/dist/regenerator.min.js
M node_modules/ajv/lib/ajv.d.ts
M node_modules/ajv/lib/ajv.js
M node_modules/ajv/lib/compile/index.js
M node_modules/ajv/package.json
D node_modules/domino/.npmignore
M node_modules/domino/.travis.yml
M node_modules/domino/lib/Node.js
M node_modules/domino/lib/URLUtils.js
M node_modules/domino/lib/htmlelts.js
M node_modules/domino/package.json
D node_modules/domino/test/.npmignore
A node_modules/domino/tools/bump-version.js
A node_modules/domino/tools/update-changelog.js
A node_modules/fast-json-stable-stringify/.eslintrc.yml
A node_modules/fast-json-stable-stringify/.npmignore
A node_modules/fast-json-stable-stringify/.travis.yml
R node_modules/fast-json-stable-stringify/LICENSE
A node_modules/fast-json-stable-stringify/benchmark/index.js
A node_modules/fast-json-stable-stringify/benchmark/test.json
R node_modules/fast-json-stable-stringify/example/key_cmp.js
R node_modules/fast-json-stable-stringify/example/nested.js
R node_modules/fast-json-stable-stringify/example/str.js
R node_modules/fast-json-stable-stringify/example/value_cmp.js
A node_modules/fast-json-stable-stringify/index.js
A node_modules/fast-json-stable-stringify/package.json
R node_modules/fast-json-stable-stringify/test/cmp.js
R node_modules/fast-json-stable-stringify/test/nested.js
A node_modules/fast-json-stable-stringify/test/str.js
A node_modules/fast-json-stable-stringify/test/to-json.js
A node_modules/hot-shots/#CHANGES.md#
M node_modules/hot-shots/lib/statsd.js
A node_modules/hot-shots/package-lock.json
M node_modules/hot-shots/package.json
D node_modules/json-stable-stringify/.npmignore
D node_modules/json-stable-stringify/.travis.yml
D node_modules/json-stable-stringify/index.js
D node_modules/json-stable-stringify/package.json
D node_modules/json-stable-stringify/readme.markdown
D node_modules/json-stable-stringify/test/replacer.js
D node_modules/json-stable-stringify/test/space.js
D node_modules/json-stable-stringify/test/str.js
D node_modules/json-stable-stringify/test/to-json.js
D node_modules/jsonify/README.markdown
D node_modules/jsonify/index.js
D node_modules/jsonify/lib/parse.js
D node_modules/jsonify/lib/stringify.js
D node_modules/jsonify/package.json
D node_modules/jsonify/test/parse.js
D node_modules/jsonify/test/stringify.js
M node_modules/kad/package.json
D node_modules/msgpack5/.npmignore
M node_modules/msgpack5/lib/encoder.js
M node_modules/msgpack5/package.json
A node_modules/msgpack5/test/1-byte-length-uint8arrays.js
A 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Revert "Add canonical title to mobile-sections lead"

2017-11-08 Thread BearND (Code Review)
Hello Mobrovac, GWicke, Fjalapeno, Ppchelko, Mhurd, jenkins-bot, Jdlrobson, 
Mholloway,

I'd like you to do a code review.  Please visit

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

to review the following change.


Change subject: Revert "Add canonical title to mobile-sections lead"
..

Revert "Add canonical title to mobile-sections lead"

This reverts commit c5fc9cff8cb4c716980e9d5f7645722c38ea8191.

Change-Id: I1c82a3d55b9c402e9e47a2f6a51654c51f239612
---
M routes/mobile-sections.js
M 
test/diff/results/page_formatted-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_Frankenstein.json
M 
test/diff/results/page_formatted-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_TitleLinkEncoding.json
M 
test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_Frankenstein.json
M 
test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_TitleLinkEncoding.json
5 files changed, 0 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/47/390047/1

diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index 5dc1bb5..3d3fa02 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -138,7 +138,6 @@
 revision: input.page.revision,
 lastmodified: input.meta.lastmodified,
 lastmodifier: input.meta.lastmodifier,
-title: input.title.getPrefixedDBKey(),
 displaytitle: input.meta.displaytitle,
 normalizedtitle: input.meta.normalizedtitle,
 wikibase_item: input.meta.pageprops && 
input.meta.pageprops.wikibase_item,
diff --git 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
index 235c552..4e0c21d 100644
--- 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
+++ 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
@@ -6,7 +6,6 @@
 "talk_ns_text": "User_talk",
 "id": 53626841,
 "revision": "77813",
-"title": "User:BSitzmann_(WMF)/MCS/Test/Frankenstein",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "protection": {
diff --git 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
index 70a4dd3..2a42a7e 100644
--- 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
+++ 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
@@ -6,7 +6,6 @@
 "talk_ns_text": "User_talk",
 "id": 51184092,
 "revision": "743079682",
-"title": "User:BSitzmann_(WMF)/MCS/Test/TitleLinkEncoding",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/TitleLinkEncoding",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/TitleLinkEncoding",
 "protection": {},
diff --git 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
index d70f515..dc20754 100644
--- 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
+++ 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
@@ -6,7 +6,6 @@
 "talk_ns_text": "User_talk",
 "id": 53626841,
 "revision": "77813",
-"title": "User:BSitzmann_(WMF)/MCS/Test/Frankenstein",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "protection": {
diff --git 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
index 03db8a0..bb9de6e 100644
--- 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
+++ 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
@@ -6,7 +6,6 @@
 "talk_ns_text": "User_talk",
 "id": 51184092,
 "revision": "743079682",
-"title": "User:BSitzmann_(WMF)/MCS/Test/TitleLinkEncoding",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/TitleLinkEncoding",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/TitleLinkEncoding",
 "protection": {},

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: preserve response objects throughout special handling

2017-11-06 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389643 )

Change subject: Hygiene: preserve response objects throughout special handling
..

Hygiene: preserve response objects throughout special handling

In mobile-sections we sometimes rebuilt the response objects while
handling some special cases (Main/File/User page). This leaked the
details of the response objects to these many places and we needed
to take care to recreate all desired fields in the response objects.

With this patch this will change. Instead of recreating the object
it will modify or add new properties in those mentioned special cases
but not try to recreate the whole response object.
This leads to simpler code, and fewer changes when new properties are
introduced.

Change-Id: I23fd30fecd05e23f7ef9a1de2389e6993af504f6
---
M routes/mobile-sections.js
1 file changed, 10 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/43/389643/1

diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index 7309ca6..3d3fa02 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -69,7 +69,7 @@
 
 /*
  * Build the lead for the requested page.
- * @param {!Object} input
+ * @param {!Object} input (needs to have a meta, page, and title property)
  * @param {?Boolean} [legacy] whether to perform legacy transformations
  * @return {!Object} lead json
  */
@@ -215,10 +215,8 @@
 function mainPageFixPromise(req, response) {
 return pageContentForMainPagePromise(req)
 .then((mainPageContent) => {
-return {
-page: mainPageContent,
-meta: response.meta
-};
+response.page = mainPageContent;
+return response;
 });
 }
 
@@ -239,15 +237,10 @@
 })
 .then((resp) => {
 const body = resp.body;
-const meta = res.meta;
 if (body.query && body.query.globaluserinfo) {
-meta.userinfo = body.query.globaluserinfo;
+res.meta.userinfo = body.query.globaluserinfo;
 }
-return {
-page: res.page,
-meta,
-extract: res.extract
-};
+return res;
 });
 }
 
@@ -271,18 +264,11 @@
 })
 .then((resp) => {
 const body = resp.body;
-const meta = res.meta;
-let ii;
-
 if (body.query && body.query.pages && body.query.pages.length) {
-ii = body.query.pages[0].imageinfo;
-meta.imageinfo = ii ? ii[0] : ii;
+const ii = body.query.pages[0].imageinfo;
+res.meta.imageinfo = ii ? ii[0] : ii;
 }
-return {
-page: res.page,
-meta,
-extract: res.extract
-};
+return res;
 });
 }
 
@@ -321,7 +307,8 @@
 function _collectRawPageData(req, legacy) {
 return BBPromise.props({
 page: parsoid.pageJsonPromise(app, req, legacy),
-meta: mwapi.getMetadata(app, req)
+meta: mwapi.getMetadata(app, req),
+title: mwapi.getTitleObj(app, req)
 }).then((interimState) => {
 return _handleNamespaceAndSpecialCases(req, interimState);
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23fd30fecd05e23f7ef9a1de2389e6993af504f6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Add canonical title to mobile-sections lead

2017-11-06 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389644 )

Change subject: Add canonical title to mobile-sections lead
..

Add canonical title to mobile-sections lead

Bug: T179600
Change-Id: I003b491cb298d208fdd45acbae0fe926fd057144
---
M routes/mobile-sections.js
M 
test/diff/results/page_formatted-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_Frankenstein.json
M 
test/diff/results/page_formatted-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_TitleLinkEncoding.json
M 
test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_Frankenstein.json
M 
test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_TitleLinkEncoding.json
5 files changed, 5 insertions(+), 0 deletions(-)


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

diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index 3d3fa02..5dc1bb5 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -138,6 +138,7 @@
 revision: input.page.revision,
 lastmodified: input.meta.lastmodified,
 lastmodifier: input.meta.lastmodifier,
+title: input.title.getPrefixedDBKey(),
 displaytitle: input.meta.displaytitle,
 normalizedtitle: input.meta.normalizedtitle,
 wikibase_item: input.meta.pageprops && 
input.meta.pageprops.wikibase_item,
diff --git 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
index 4e0c21d..235c552 100644
--- 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
+++ 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
@@ -6,6 +6,7 @@
 "talk_ns_text": "User_talk",
 "id": 53626841,
 "revision": "77813",
+"title": "User:BSitzmann_(WMF)/MCS/Test/Frankenstein",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "protection": {
diff --git 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
index 2a42a7e..70a4dd3 100644
--- 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
+++ 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
@@ -6,6 +6,7 @@
 "talk_ns_text": "User_talk",
 "id": 51184092,
 "revision": "743079682",
+"title": "User:BSitzmann_(WMF)/MCS/Test/TitleLinkEncoding",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/TitleLinkEncoding",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/TitleLinkEncoding",
 "protection": {},
diff --git 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
index dc20754..d70f515 100644
--- 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
+++ 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
@@ -6,6 +6,7 @@
 "talk_ns_text": "User_talk",
 "id": 53626841,
 "revision": "77813",
+"title": "User:BSitzmann_(WMF)/MCS/Test/Frankenstein",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "protection": {
diff --git 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
index bb9de6e..03db8a0 100644
--- 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
+++ 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_TitleLinkEncoding.json"
@@ -6,6 +6,7 @@
 "talk_ns_text": "User_talk",
 "id": 51184092,
 "revision": "743079682",
+"title": "User:BSitzmann_(WMF)/MCS/Test/TitleLinkEncoding",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/TitleLinkEncoding",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/TitleLinkEncoding",
 "protection": {},

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I003b491cb298d208fdd45acbae0fe926fd057144
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: replace data-section-number with data-mw-section-id

2017-11-01 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387828 )

Change subject: Hygiene: replace data-section-number with data-mw-section-id
..

Hygiene: replace data-section-number with data-mw-section-id

The corresponding Parsoid patch[1] changes the attribute name
from data-section-number to data-mw-section-id

[1] https://gerrit.wikimedia.org/r/#/c/364933/30

Change-Id: Ia7d875a027ecf6271e40329de4911b64f018d7d5
---
M lib/parsoidSectionsUsingSectionTags.js
M test/lib/parsoid/parsoid-sections-section-elements-tests.js
2 files changed, 19 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/28/387828/1

diff --git a/lib/parsoidSectionsUsingSectionTags.js 
b/lib/parsoidSectionsUsingSectionTags.js
index c2a1d2d..7d20fdd 100644
--- a/lib/parsoidSectionsUsingSectionTags.js
+++ b/lib/parsoidSectionsUsingSectionTags.js
@@ -25,7 +25,7 @@
  */
 function getSectionNumber(sectionElement) {
 const sectionNumberString = sectionElement
-&& sectionElement.getAttribute('data-section-number');
+&& sectionElement.getAttribute('data-mw-section-id');
 return sectionNumberString ? parseInt(sectionNumberString, 10) : undefined;
 }
 
diff --git a/test/lib/parsoid/parsoid-sections-section-elements-tests.js 
b/test/lib/parsoid/parsoid-sections-section-elements-tests.js
index 3c91d84..4ba24df 100644
--- a/test/lib/parsoid/parsoid-sections-section-elements-tests.js
+++ b/test/lib/parsoid/parsoid-sections-section-elements-tests.js
@@ -40,15 +40,15 @@
 });
 
 it('getSectionsText() with just text should produce a lead section', () => 
{
-const doc = domino.createDocument('text0');
+const doc = domino.createDocument('text0');
 const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
 assert.deepEqual(sections.length, 1);
 assertSection0(sections);
 });
 
 it('getSectionsText() with one h2 should produce two sections', () => {
-const doc = domino.createDocument('text0' +
-'footext1');
+const doc = domino.createDocument('text0' +
+'footext1');
 const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
 assert.deepEqual(sections.length, 2);
 assertSection0(sections);
@@ -56,9 +56,9 @@
 });
 
 it('getSectionsText() with one h2 and h3 should produce three sections', 
() => {
-const doc = domino.createDocument('text0' +
-'footext1' +
-'' +
+const doc = domino.createDocument('text0' +
+'footext1' +
+'' +
 'Funny section 
!@#$%^&*()text2' +
 '');
 const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
@@ -71,9 +71,9 @@
 // From T175305 
http://localhost:8000/fy.wikipedia.org/v3/page/html/De_Kanto%27s
 it('getSectionsText() with one h2 inside div should not produce another 
section', () => {
 const sectionInDiv = '' +
-'bar';
-const doc = domino.createDocument('text0' +
-'footext1' + 
sectionInDiv +
+'bar';
+const doc = domino.createDocument('text0' +
+'footext1' + 
sectionInDiv +
 '');
 const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
 assert.deepEqual(sections.length, 2);
@@ -84,9 +84,9 @@
 // same as above but using h3 instead of h2 in extra 
 it('getSectionsText() with one h3 inside div should not produce another 
section', () => {
 const sectionInDiv = '' +
-'bar';
-const doc = domino.createDocument('text0' +
-'footext1' + 
sectionInDiv +
+'bar';
+const doc = domino.createDocument('text0' +
+'footext1' + 
sectionInDiv +
 '');
 const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
 assert.deepEqual(sections.length, 2);
@@ -95,9 +95,9 @@
 });
 
 it('section inside lead section should not be part of lead section', () => 
{
-const sectionNotInDiv = 'Footext1';
+const sectionNotInDiv = 'Footext1';
 const doc = domino.createDocument(
-'text0' +
+'text0' +
 sectionNotInDiv +
 ''
 );
@@ -108,9 +108,9 @@
 
 it('div/section inside lead section should be part of lead section', () => 
{
 const sectionInDiv = '' +
-'Footext1';
+'Footext1';
 const doc = domino.createDocument(
-'text0' +
+'text0' +
 sectionInDiv +
 ''
 );
@@ -121,8 +121,8 @@
 
 it('non-lead section without heading tag should throw error', () => {
 const doc = domino.createDocument(
-'text0' +
-'text1');
+'text0' +
+'text1');
 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Improve Parsoid section detection

2017-10-30 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387295 )

Change subject: Improve Parsoid section detection
..

Improve Parsoid section detection

Replaces individual implementations with a common function to detect
Parsoid section tags.
Section tag introduced by Parsoid must have the data-section-number
attribute.
Added unit test.

Change-Id: I478a94ca090ee69e2eb7f0ce3b8aa98f3f919474
---
M lib/parseDefinitions.js
M lib/parsoidSections.js
A test/lib/parsoid/parsoid-sections-test.js
3 files changed, 39 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/95/387295/1

diff --git a/lib/parseDefinitions.js b/lib/parseDefinitions.js
index e8c55f9..bd7dec5 100644
--- a/lib/parseDefinitions.js
+++ b/lib/parseDefinitions.js
@@ -3,6 +3,7 @@
 const parseDefinitionsUsingDivs = require('./parseDefinitionsUsingDivs');
 const parseDefinitionsUsingSectionTags = 
require('./parseDefinitionsUsingSectionTags');
 const parsoidSectionsUsingDivs = require('./parsoidSectionsUsingDivs');
+const parsoidSections = require('./parsoidSections');
 
 /**
  * Parses Wiktionary definitions. Delegates to the correct implementation.
@@ -14,7 +15,7 @@
  * Wiktionary page
  */
 function parseDefinitions(doc, domain, title) {
-if (doc.querySelector('section')) {
+if (parsoidSections.hasParsoidSections(doc)) {
 return parseDefinitionsUsingSectionTags(doc, domain, title);
 } else {
 parsoidSectionsUsingDivs.addSectionDivs(doc);
diff --git a/lib/parsoidSections.js b/lib/parsoidSections.js
index da1caa1..7db3b3f 100644
--- a/lib/parsoidSections.js
+++ b/lib/parsoidSections.js
@@ -4,13 +4,21 @@
 const parsoidSectionsUsingSectionTags = 
require('./parsoidSectionsUsingSectionTags');
 
 /**
+ * Determines if Parsoid added section tags. See T114072.
+ * @param {!document} doc the parsed DOM Document of the Parsoid output
+ * @return {boolean} true if Parsoid added section tags
+ */
+function hasParsoidSections(doc) {
+return Boolean(doc.querySelector('section[data-section-number]'));
+}
+
+/**
  * New sectioning code: wraps sections in  tags. Will likely
  * be replaced by code in Parsoid.
  * @param {!document} doc the parsed DOM Document of the Parsoid output
  */
 function addSectionDivs(doc) {
-// in case this is already handled by Parsoid (T114072) don't try again
-if (!doc.querySelector('section')) {
+if (!hasParsoidSections(doc)) {
 parsoidSectionsUsingDivs.addSectionDivs(doc);
 }
 }
@@ -22,7 +30,7 @@
  * @return {!sections[]} an array of section JSON elements
  */
 function getSectionsText(doc) {
-if (!doc.querySelector('section')) {
+if (!hasParsoidSections(doc)) {
 return parsoidSectionsUsingDivs.getSectionsText(doc);
 } else {
 return parsoidSectionsUsingSectionTags.getSectionsText(doc);
@@ -30,6 +38,7 @@
 }
 
 module.exports = {
+hasParsoidSections,
 addSectionDivs,
 getSectionsText
 };
diff --git a/test/lib/parsoid/parsoid-sections-test.js 
b/test/lib/parsoid/parsoid-sections-test.js
new file mode 100644
index 000..6025e66
--- /dev/null
+++ b/test/lib/parsoid/parsoid-sections-test.js
@@ -0,0 +1,25 @@
+'use strict';
+
+const assert = require('../../utils/assert.js');
+const domino = require('domino');
+const parsoid = require('../../../lib/parsoidSections');
+
+describe('lib:parsoid-sections', function() {
+
+this.timeout(2); // eslint-disable-line no-invalid-this
+
+it('hasParsoidSections(empty) should return false', () => {
+const doc = domino.createDocument('');
+assert.ok(parsoid.hasParsoidSections(doc) === false);
+});
+
+it('hasParsoidSections(section) should return false', () => {
+const doc = domino.createDocument('');
+assert.ok(parsoid.hasParsoidSections(doc) === false);
+});
+
+it('hasParsoidSections(section[data-section-number]) should return true', 
() => {
+const doc = domino.createDocument('');
+assert.ok(parsoid.hasParsoidSections(doc) === true);
+});
+});

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I478a94ca090ee69e2eb7f0ce3b8aa98f3f919474
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: rename parsoid-sections-test

2017-10-30 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387294 )

Change subject: Hygiene: rename parsoid-sections-test
..

Hygiene: rename parsoid-sections-test

Change-Id: I0bb5a3393f352876addb1f57235c2c863ae48e1b
---
R test/lib/parsoid/parsoid-sections-div-element-test.js
1 file changed, 0 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/94/387294/1

diff --git a/test/lib/parsoid/parsoid-sections-test.js 
b/test/lib/parsoid/parsoid-sections-div-element-test.js
similarity index 100%
rename from test/lib/parsoid/parsoid-sections-test.js
rename to test/lib/parsoid/parsoid-sections-div-element-test.js

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0bb5a3393f352876addb1f57235c2c863ae48e1b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Next gen definitions parsing, using section tags

2017-10-24 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386336 )

Change subject: Next gen definitions parsing, using section tags
..

Next gen definitions parsing, using section tags

Prep definitions parsing for Parsoid sections, part 3.

* Four nested loops instead of three:
  * one for language sections (NEW),
  * another for partsOfSpeech sections,
  * a third for definitions,
  * a fourth for examples
* Extracted a method for iterating over definitions
* Moved some variable definitions to places where they can be made const

Bug: T178708
Change-Id: Ia52db9e08252667af800d9cdf00f06ce132e1635
---
M lib/parseDefinitionsUsingSectionTags.js
1 file changed, 44 insertions(+), 52 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/36/386336/1

diff --git a/lib/parseDefinitionsUsingSectionTags.js 
b/lib/parseDefinitionsUsingSectionTags.js
index 5bca2e7..38f833c 100644
--- a/lib/parseDefinitionsUsingSectionTags.js
+++ b/lib/parseDefinitionsUsingSectionTags.js
@@ -4,7 +4,7 @@
  * English Wiktionary entry layout guide:
  * https://en.wiktionary.org/wiki/Wiktionary:Entry_layout
  *
- * V2: to be updated with new implementation (currently the same as V1)
+ * This version is for when Parsoid emits  tags.
  */
 
 'use strict';
@@ -68,36 +68,62 @@
  * actual definitions on a wiki-by-wiki basis and pluck them out; this is
  * usually at least *internally* consistent.
  */
-function getDefnList(doc, id, wikiLangCode) {
+function getDefnList(parentNode, wikiLangCode) {
 let defnList;
 if (wikiLangCode === 'en') {
-defnList = doc.querySelectorAll(`div[id=${id}] li`);
+defnList = parentNode.querySelectorAll('li');
 }
 return defnList;
 }
 
 function constructDefinition(element, wikiLangCode) {
 const currentDefinition = {};
-
-let example;
-let examples;
-let j;
-
 if (hasUsageExamples(element.innerHTML, wikiLangCode)) {
 const html = element.innerHTML;
 const selector = wikiLangCode === 'en' ? 'dd' : 'li';
 
 currentDefinition.definition = html.substring(0, 
html.indexOf('h3,section>h4');
+for (let j = 0; j < partsOfSpeechHeadings.length; j++) {
+const partsOfSpeechHeading = partsOfSpeechHeadings[j];
+const partsOfSpeechSection = partsOfSpeechHeading.parentNode;
+const header = partsOfSpeechHeading.textContent;
+
+/* Parse definitions from part-of-speech sections */
+if (partsOfSpeech[wikiLangCode].indexOf(header) > -1) {
+const definitionSection = {};
+definitionSection.partOfSpeech = header;
+definitionSection.language = currentLang;
+definitionSection.definitions = [];
+const defnList = getDefnList(partsOfSpeechSection, wikiLangCode);
+for (let i = 0; i < defnList.length; i++) {
+
definitionSection.definitions.push(constructDefinition(defnList[i], 
wikiLangCode));
+}
+
+if (!definitions[defnLangCode]) {
+definitions[defnLangCode] = [];
+}
+
+definitions[defnLangCode].push(definitionSection);
+}
+}
 }
 
 /**
@@ -109,18 +135,11 @@
  * for supported partOfSpeeches (Noun, Verb, ...) of all language headings 
found on the given
  * Wiktionary page
  */
-function parse(doc, domain, title) {
-// TODO: update once Parsoid emits section tags, see 
https://phabricator.wikimedia.org/T114072#1711063
-let currentLang;
-let currentSectionDiv;
+function iterateOverLanguageSections(doc, domain, title) {
 const definitions = {};
-let definitionSection;
-let defnList;
-let defnLangCode = null;
-let header;
-let i;
-let j;
-const sectionDivs = doc.querySelectorAll('div[id^="section_"]');
+
+// H2 headings are language names per the English Wiktionary style guide 
(link above)
+const languageHeadings = 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: rename parseDefinitions to parseDefinitionsUsingDivs

2017-10-24 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386334 )

Change subject: Hygiene: rename parseDefinitions to parseDefinitionsUsingDivs
..

Hygiene: rename parseDefinitions to parseDefinitionsUsingDivs

Prep definitions parsing for Parsoid sections, part 1.

Bug: T178708
Change-Id: I03dbd6aff94db7460c8c746f4f167972817edafb
---
R lib/parseDefinitionsUsingDivs.js
M lib/parsoid-access.js
2 files changed, 8 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/34/386334/1

diff --git a/lib/parseDefinition.js b/lib/parseDefinitionsUsingDivs.js
similarity index 93%
rename from lib/parseDefinition.js
rename to lib/parseDefinitionsUsingDivs.js
index 9b67809..1bf40d7 100644
--- a/lib/parseDefinition.js
+++ b/lib/parseDefinitionsUsingDivs.js
@@ -99,9 +99,13 @@
 }
 
 /**
+ * Parses Wiktionary definitions.
  * @param {!document} doc the parsed DOM Document of the Parsoid output
- * @return {!definitions[]} an array of objects, organized by part of speech,
- * containing definitions (with examples, where available) from Wiktionary
+ * @param {!string} domain the domain the request was directed to
+ * @param {!string} title the title of the page requested
+ * @return {Object} an object structure with definitions (with examples, where 
available)
+ * for supported partOfSpeeches (Noun, Verb, ...) of all language headings 
found on the given
+ * Wiktionary page
  */
 function parse(doc, domain, title) {
 // TODO: update once Parsoid emits section tags, see 
https://phabricator.wikimedia.org/T114072#1711063
diff --git a/lib/parsoid-access.js b/lib/parsoid-access.js
index 0f063e8..efea1ac 100644
--- a/lib/parsoid-access.js
+++ b/lib/parsoid-access.js
@@ -9,7 +9,7 @@
 const api = require('./api-util');
 const mwapi = require('./mwapi');
 const parseProperty = require('./parseProperty');
-const parseDefinition = require('./parseDefinition');
+const parseDefinitions = require('./parseDefinitionsUsingDivs');
 const parsoidSections = require('./parsoidSections');
 const parsoidSectionsForDefinitions = require('./parsoidSectionsUsingDivs');
 const transforms = require('./transforms');
@@ -184,7 +184,7 @@
 parsoidSectionsForDefinitions.addSectionDivs(doc);
 transforms.addRequiredMarkup(doc);
 return {
-payload: parseDefinition(doc, req.params.domain, 
req.params.title),
+payload: parseDefinitions(doc, req.params.domain, 
req.params.title),
 meta: {
 revision: getRevisionFromEtag(response.headers)
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I03dbd6aff94db7460c8c746f4f167972817edafb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: split up definitions parsing into two implementations

2017-10-24 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386335 )

Change subject: Hygiene: split up definitions parsing into two implementations
..

Hygiene: split up definitions parsing into two implementations

Prep definitions parsing for Parsoid sections, part 2.

Bug: T178708
Change-Id: I1be1128e6df351eefce41a355a20437c0da1c2ff
---
A lib/parseDefinitions.js
A lib/parseDefinitionsUsingSectionTags.js
M lib/parsoid-access.js
3 files changed, 201 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/35/386335/1

diff --git a/lib/parseDefinitions.js b/lib/parseDefinitions.js
new file mode 100644
index 000..e8c55f9
--- /dev/null
+++ b/lib/parseDefinitions.js
@@ -0,0 +1,25 @@
+'use strict';
+
+const parseDefinitionsUsingDivs = require('./parseDefinitionsUsingDivs');
+const parseDefinitionsUsingSectionTags = 
require('./parseDefinitionsUsingSectionTags');
+const parsoidSectionsUsingDivs = require('./parsoidSectionsUsingDivs');
+
+/**
+ * Parses Wiktionary definitions. Delegates to the correct implementation.
+ * @param {!document} doc the parsed DOM Document of the Parsoid output
+ * @param {!string} domain the domain the request was directed to
+ * @param {!string} title the title of the page requested
+ * @return {Object} an object structure with definitions (with examples, where 
available)
+ * for supported partOfSpeeches (Noun, Verb, ...) of all language headings 
found on the given
+ * Wiktionary page
+ */
+function parseDefinitions(doc, domain, title) {
+if (doc.querySelector('section')) {
+return parseDefinitionsUsingSectionTags(doc, domain, title);
+} else {
+parsoidSectionsUsingDivs.addSectionDivs(doc);
+return parseDefinitionsUsingDivs(doc, domain, title);
+}
+}
+
+module.exports = parseDefinitions;
diff --git a/lib/parseDefinitionsUsingSectionTags.js 
b/lib/parseDefinitionsUsingSectionTags.js
new file mode 100644
index 000..5bca2e7
--- /dev/null
+++ b/lib/parseDefinitionsUsingSectionTags.js
@@ -0,0 +1,175 @@
+/**
+ * Parse definitions from Wiktionary Parsoid HTML.
+ *
+ * English Wiktionary entry layout guide:
+ * https://en.wiktionary.org/wiki/Wiktionary:Entry_layout
+ *
+ * V2: to be updated with new implementation (currently the same as V1)
+ */
+
+'use strict';
+
+const sUtil = require('./util');
+const transforms = require('./transforms');
+const languageList = require('../private/languages_list.json');
+
+/* This list has expanded beyond parts of speech to something more like 
"whatever
+   categories of terms the Wiktionary editors decided to include", but we'll
+   retain the variable name/response field since this is now what the app 
expects
+   and changing it will require a coordinated service deployment/app 
release/RESTBase
+   cache purge. */
+const partsOfSpeech = {
+'en':['Abbreviation',
+'Acronym',
+'Adjective',
+'Adverb',
+'Article',
+'Conjunction',
+'Contraction',
+'Determiner',
+'Idiom',
+'Infix',
+'Initialism',
+'Interjection',
+'Letter',
+'Noun',
+'Numeral',
+'Participle',
+'Particle',
+'Phrase',
+'Prefix',
+'Preposition',
+'Prepositional phrase',
+'Pronoun',
+'Proper noun',
+'Proverb',
+'Punctuation mark',
+'Romanization',
+'Suffix',
+'Syllable',
+'Symbol',
+'Verb' ]
+};
+
+function hasUsageExamples(text, langCode) {
+return langCode === 'en' ? text.indexOf(' -1 : text.indexOf(' -1;
+}
+
+function getLanguageCode(langName, wikiLangCode) {
+if (langName === "Translingual") {
+return wikiLangCode;
+}
+return languageList[langName];
+}
+
+/**
+ * This is where the sausage is made.  It seems no two Wiktionaries are
+ * formatted the same way, so we'll figure out where they (usually) keep the
+ * actual definitions on a wiki-by-wiki basis and pluck them out; this is
+ * usually at least *internally* consistent.
+ */
+function getDefnList(doc, id, wikiLangCode) {
+let defnList;
+if (wikiLangCode === 'en') {
+defnList = doc.querySelectorAll(`div[id=${id}] li`);
+}
+return defnList;
+}
+
+function constructDefinition(element, wikiLangCode) {
+const currentDefinition = {};
+
+let example;
+let examples;
+let j;
+
+if (hasUsageExamples(element.innerHTML, wikiLangCode)) {
+const html = element.innerHTML;
+const selector = wikiLangCode === 'en' ? 'dd' : 'li';
+
+currentDefinition.definition = html.substring(0, 
html.indexOf('

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Revert "Add fundraising test via announcement cards in France"

2017-10-24 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386268 )

Change subject: Revert "Add fundraising test via announcement cards in France"
..

Revert "Add fundraising test via announcement cards in France"

The announcement period is over. No need to serve this anymore.

This reverts most of commit 5c32b64.
Left some of the test improvements and a useful comment in the route.

Bug: T177001
Change-Id: Ib32b954eff14779145877cbe9db98bd664482166
---
M lib/mobile-util.js
M routes/announcements.js
M spec.yaml
M test/features/announcements/announcements.js
4 files changed, 78 insertions(+), 66 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/68/386268/1

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index 1653a98..cee4c5d 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -119,10 +119,6 @@
 return (domain === 'en.wikipedia.org' || domain === 
'en.wikipedia.beta.wmflabs.org');
 };
 
-mUtil.isFrenchWikipedia = function(domain) {
-return (domain === 'fr.wikipedia.org');
-};
-
 mUtil.removeFragment = function(href) {
 if (href.indexOf('#') > -1) {
 return href.substring(0, href.indexOf('#'));
diff --git a/routes/announcements.js b/routes/announcements.js
index 7007029..f37b786 100644
--- a/routes/announcements.js
+++ b/routes/announcements.js
@@ -8,53 +8,63 @@
  */
 const router = sUtil.router();
 
-function getFrwikiAnnouncements() {
+/* eslint-disable max-len */
+function getEnwikiAnnouncements() {
 // Notes: for iOS 'text' and 'action.title': HTML is not supported.
 // iOS uses image_url instead of the image Android uses.
 // iOS caption_HTML should be wrapped in  tag.
-
-// image_url: 
"https://upload.wikimedia.org/wikipedia/commons/8/8f/Reading_list_survey_-_iOS.png;,
-// image: 
"https://upload.wikimedia.org/wikipedia/commons/5/52/Reading_list_survey.png;,
-
 return [
-{
-id: "FR1017FRIOS",
-type: "fundraising",
-start_time: "2017-10-05T00:00:00Z",
-end_time: "2017-10-19T00:00:00Z",
-platforms: [
-"iOSApp",
-],
-text: "Le moment est venu de faire appel à vous.\n\nChers lecteurs 
en France, nous irons droit au but : aujourd’hui, nous vous demandons d’aider 
Wikipédia. Afin de protéger notre indépendance, nous ne diffuserons jamais de 
publicité. Nous sommes soutenus par des dons d’environ 10 € en moyenne. Nos 
lecteurs sont très peu nombreux à faire des dons. Si chaque personne qui lit ce 
message donnait 2 €, cela permettrait à Wikipédia de continuer à prospérer de 
nombreuses années. Le prix d’un café, c’est tout ce dont nous avons besoin. Si 
Wikipédia vous est utile, prenez une minute afin de maintenir cette plate-forme 
en ligne et lui permettre de continuer de croître. Merci.", // 
eslint-disable-line max-len
-action: {
-title: "Continuer",
-url: 
"https://donate.wikimedia.org/?uselang=fr_medium=WikipediaAppFeed_campaign=iOS_source=app_201710_FR_control;
-},
-caption_HTML: "Un
 problème pour faire un don ? | Autres
 façons de donner | Questions
 fréquentes",
-countries: [
-"FR"
-]
-},
-{
-id: "FR1017FRANDROID",
-type: "fundraising",
-start_time: "2017-10-05T00:00:00Z",
-end_time: "2017-10-19T00:00:00Z",
-platforms: [
-"AndroidApp"
-],
-text: "Le moment est venu de faire appel à vous.Chers 
lecteurs en France, nous irons droit au but : aujourd’hui, nous vous demandons 
d’aider Wikipédia. Afin de protéger notre indépendance, nous ne diffuserons 
jamais de publicité. Nous sommes soutenus par des dons d’environ 10 € en 
moyenne. Nos lecteurs sont très peu nombreux à faire des dons. Si chaque 
personne qui lit ce message donnait 2 €, cela permettrait à Wikipédia de 
continuer à prospérer de nombreuses années. Le prix d’un café, c’est tout ce 
dont nous avons besoin. Si Wikipédia vous est utile, prenez une minute afin de 
maintenir cette plate-forme en ligne et lui permettre de continuer de croître. 
Merci.", // eslint-disable-line max-len
-action: {
-title: "Continuer",
-url: 
"https://donate.wikimedia.org/?uselang=fr_medium=WikipediaAppFeed_campaign=Android_source=app_201710_FR_control;
-},
-caption_HTML: "Un
 problème pour faire un don ? | Autres
 façons de donner | Questions
 fréquentes",
-countries: [
-"FR"
-]
-}
+// {
+// id: "EN0517SURVEYIOS",
+// type: "survey",
+// start_time: "2017-05-26T00:00:00Z",
+// end_time: "2017-05-29T00:00:00Z",
+// platforms: [
+// "iOSApp",
+ 

[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to 3628105

2017-10-23 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386045 )

Change subject: Update mobileapps to 3628105
..

Update mobileapps to 3628105

List of changes:
c330b3f Summary 2.0: Introduce namespace whitelisting
26e12a9 Hygiene: add tmp folder to eslintignore
b6b1843 Hygiene: Update diff test results
c132a94 Hygiene: Update media API calls to use formatversion=2
70422c4 Fix: Include MIME type and thumb URL in media endpoint responses
42d7ffa Media: Return all video derivatives
3a42c87 Hygiene: Simplify extmetadata collection
3628105 Fix pronunciation parsing
xxx Update node module dependencies

Change-Id: Ie1d800948d3a66a52815a65afbac0b6ad1ba9b2f
---
M node_modules/ajv/dist/ajv.min.js
M node_modules/ajv/dist/ajv.min.js.map
M node_modules/ajv/dist/nodent.min.js
M node_modules/ajv/dist/regenerator.min.js
M node_modules/ajv/lib/ajv.d.ts
M node_modules/ajv/package.json
M node_modules/compressible/package.json
A node_modules/express/node_modules/statuses/LICENSE
A node_modules/express/node_modules/statuses/codes.json
A node_modules/express/node_modules/statuses/index.js
A node_modules/express/node_modules/statuses/package.json
A node_modules/finalhandler/node_modules/statuses/LICENSE
A node_modules/finalhandler/node_modules/statuses/codes.json
A node_modules/finalhandler/node_modules/statuses/index.js
A node_modules/finalhandler/node_modules/statuses/package.json
M node_modules/kad/package.json
M node_modules/moment/min/moment-with-locales.js
M node_modules/moment/min/moment-with-locales.min.js
M node_modules/moment/min/moment.min.js
M node_modules/moment/moment.js
M node_modules/moment/package.json
M node_modules/moment/src/lib/locale/locales.js
M node_modules/moment/src/moment.js
A node_modules/send/node_modules/statuses/LICENSE
A node_modules/send/node_modules/statuses/codes.json
A node_modules/send/node_modules/statuses/index.js
A node_modules/send/node_modules/statuses/package.json
M node_modules/statuses/LICENSE
M node_modules/statuses/codes.json
M node_modules/statuses/index.js
M node_modules/statuses/package.json
M src
32 files changed, 1,141 insertions(+), 140 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps/deploy 
refs/changes/45/386045/1


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie1d800948d3a66a52815a65afbac0b6ad1ba9b2f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps/deploy
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Rewrite sectioning using section tags code

2017-10-20 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/385425 )

Change subject: Rewrite sectioning using section tags code
..

Rewrite sectioning using section tags code

For mobile-sections we only care about section tags which are direct
descendants of other sections.
The old implementation collected all section tags via
querySelectorAll('section'). This doesn't make it easy to find out
where a given section is and when to suppress a section.

The new implementation traverses the DOM and builds a sections array
recursively (depth-first, of course).

Bug: T178706
Change-Id: I297e070623e367cffb5404854c8af0a58a9ac5f6
---
M lib/parsoidSectionsUsingSectionTags.js
M test/lib/parsoid/parsoid-sections-section-elements-tests.js
2 files changed, 120 insertions(+), 71 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/25/385425/1

diff --git a/lib/parsoidSectionsUsingSectionTags.js 
b/lib/parsoidSectionsUsingSectionTags.js
index 96ba0ef..6873c7c 100644
--- a/lib/parsoidSectionsUsingSectionTags.js
+++ b/lib/parsoidSectionsUsingSectionTags.js
@@ -18,87 +18,110 @@
 }
 
 /**
- * Parse the next wiki section. A wiki section is contained inside a  
tag.
- * If there is a nested sub section it ends right before that next sub 
section's
- *  tag starts.
- * @param {!Node} startingNode the DOM node to start parsing
- * @return {string} the HTML text of the next wiki section
+ * Gets the section number from Parsoid.
+ * @param {!DOMElement} sectionElement a  DOM element
+ * @return {int} the section number as reported by Parsoid
  */
-function parseNextSection(startingNode) {
-let sectionText = '';
-let node = startingNode;
-
-while (node) {
-if (node.tagName !== 'SECTION') {
-if (node.outerHTML) {
-sectionText += node.outerHTML;
-} else if (node.nodeType === 3) {
-sectionText += node.textContent;
-}
-node = node.nextSibling;
-} else {
-return sectionText;
-}
-}
-return sectionText;
-}
-
-function getSectionNumber(currentSectionElement) {
-const sectionNumberString = currentSectionElement
-&& currentSectionElement.getAttribute('data-section-number');
+function getSectionNumber(sectionElement) {
+const sectionNumberString = sectionElement
+&& sectionElement.getAttribute('data-section-number');
 return sectionNumberString ? parseInt(sectionNumberString, 10) : undefined;
 }
 
-/**
- * Gets the sections array, including HTML string and metadata for all sections
- * (id, anchor, line, toclevel).
- * @param {!document} doc the parsed DOM Document of the Parsoid output
- * @return {!sections[]} an array of section JSON elements
- */
-function getSectionsText(doc) {
-const sections = [];
-const sectionElements = doc.querySelectorAll('section');
+function appendSectionText(node, currentSection, state) {
+// Deal with text nodes
+if (node.nodeType === 3) {
+currentSection.text += node.textContent;
+} else {
+currentSection.text += node.outerHTML;
+state.pauseDescent = true;
+}
+}
 
-const currentSectionElement = sectionElements[0];
-const currentSection = {};
-currentSection.id = 0;
-currentSection.text = currentSectionElement ? 
currentSectionElement.innerHTML : '';
-sections.push(currentSection);
-
-for (let i = 1; i < sectionElements.length; i++) {
-const currentSection = {};
-const currentSectionElement = sectionElements[i];
-currentSection.id = getSectionNumber(currentSectionElement);
-if (currentSection.id < 0) {
-continue; // pseudo section
-// See 
https://www.mediawiki.org/wiki/Parsing/Notes/Section_Wrapping#Pseudo-sections
-}
-
-const childEl = currentSectionElement.firstChild;
-
-if (childEl && /^H[1-6]$/.test(childEl.tagName)) {
-currentSection.text = parseNextSection(childEl.nextSibling); // 
text starts after H[1-6]
-currentSection.toclevel = parseInt(childEl.tagName.charAt(1), 10) 
- 1;
-currentSection.line = childEl.innerHTML.trim();
-currentSection.anchor = childEl.getAttribute('id');
-sections.push(currentSection);
-} else {
-throw new HTTPError({
-status: 502,
-type: 'unsupported_section',
-title: 'Section structure not supported',
-detail: `Cannot find heading for section number 
${currentSection.id}. ${childEl.tagName} not a heading.` // eslint-disable-line 
max-len
-});
-}
+function throwIfPreviousSectionIsIncomplete(allSections, sectionObj) {
+if (allSections.length === 0) {
+return;
 }
 
-return sections;
+if (!sectionObj) {
+sectionObj = 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Fail incomplete sections early

2017-10-20 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/385424 )

Change subject: Fail incomplete sections early
..

Fail incomplete sections early

To avoid issues with incomplete sections, which let to T175305,
the sectioning code now throws an 502 HTTP error code
("unsupported_section") when a section without heading is encountered.
The exception to this is the lead section, which never should have a
heading.

Change-Id: I6535f4884b2a77609338a5215f1ddf877d24f98d
---
M lib/parsoidSectionsUsingSectionTags.js
M test/lib/parsoid/parsoid-sections-section-elements-tests.js
2 files changed, 19 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/24/385424/1

diff --git a/lib/parsoidSectionsUsingSectionTags.js 
b/lib/parsoidSectionsUsingSectionTags.js
index 8b6a29f..96ba0ef 100644
--- a/lib/parsoidSectionsUsingSectionTags.js
+++ b/lib/parsoidSectionsUsingSectionTags.js
@@ -1,6 +1,8 @@
 'use strict';
 
 const parsoidDomUtils = require('parsoid-dom-utils');
+const sUtil = require('./util');
+const HTTPError = sUtil.HTTPError;
 
 /**
  * @deprecated wait for Parsoid to implement this.
@@ -79,9 +81,15 @@
 currentSection.toclevel = parseInt(childEl.tagName.charAt(1), 10) 
- 1;
 currentSection.line = childEl.innerHTML.trim();
 currentSection.anchor = childEl.getAttribute('id');
+sections.push(currentSection);
+} else {
+throw new HTTPError({
+status: 502,
+type: 'unsupported_section',
+title: 'Section structure not supported',
+detail: `Cannot find heading for section number 
${currentSection.id}. ${childEl.tagName} not a heading.` // eslint-disable-line 
max-len
+});
 }
-
-sections.push(currentSection);
 }
 
 return sections;
diff --git a/test/lib/parsoid/parsoid-sections-section-elements-tests.js 
b/test/lib/parsoid/parsoid-sections-section-elements-tests.js
index 3c94847..c511943 100644
--- a/test/lib/parsoid/parsoid-sections-section-elements-tests.js
+++ b/test/lib/parsoid/parsoid-sections-section-elements-tests.js
@@ -94,5 +94,14 @@
 assertSection1(sections, sectionInDiv);
 });
 
+it('non-lead section without heading tag should throw error', () => {
+const doc = domino.createDocument(
+'text0' +
+'text1');
+assert.throws(() => {
+parsoidSectionsUsingSectionTags.getSectionsText(doc);
+}, /unsupported_section/);
+});
+
 /* eslint-enable prefer-template */
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6535f4884b2a77609338a5215f1ddf877d24f98d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Get section number from Parsoid

2017-10-20 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/385422 )

Change subject: Get section number from Parsoid
..

Get section number from Parsoid

* Get section number from Parsoid's section element data-section-number
attribute.

* When a section number is < 0 consider it a pseudo section. We will
skip it since the content is assumed to be included in the previous section
already.

Bug: T158635
Change-Id: Ie6347bf3d75b76d8be09e7669dd45f97a55f2714
---
M lib/parsoidSectionsUsingSectionTags.js
1 file changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/22/385422/1

diff --git a/lib/parsoidSectionsUsingSectionTags.js 
b/lib/parsoidSectionsUsingSectionTags.js
index 20a1307..8b6a29f 100644
--- a/lib/parsoidSectionsUsingSectionTags.js
+++ b/lib/parsoidSectionsUsingSectionTags.js
@@ -41,6 +41,12 @@
 return sectionText;
 }
 
+function getSectionNumber(currentSectionElement) {
+const sectionNumberString = currentSectionElement
+&& currentSectionElement.getAttribute('data-section-number');
+return sectionNumberString ? parseInt(sectionNumberString, 10) : undefined;
+}
+
 /**
  * Gets the sections array, including HTML string and metadata for all sections
  * (id, anchor, line, toclevel).
@@ -60,7 +66,12 @@
 for (let i = 1; i < sectionElements.length; i++) {
 const currentSection = {};
 const currentSectionElement = sectionElements[i];
-currentSection.id = i;
+currentSection.id = getSectionNumber(currentSectionElement);
+if (currentSection.id < 0) {
+continue; // pseudo section
+// See 
https://www.mediawiki.org/wiki/Parsing/Notes/Section_Wrapping#Pseudo-sections
+}
+
 const childEl = currentSectionElement.firstChild;
 
 if (childEl && /^H[1-6]$/.test(childEl.tagName)) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6347bf3d75b76d8be09e7669dd45f97a55f2714
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: add tests for new Parsoid section elements

2017-10-20 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/385423 )

Change subject: Hygiene: add tests for new Parsoid section elements
..

Hygiene: add tests for new Parsoid section elements

To prepare for T114072.

Change-Id: I643641d557aa4bfa7cf037e8eb7ec28f0d3b19f9
---
A test/lib/parsoid/parsoid-sections-section-elements-tests.js
M test/lib/parsoid/parsoid-sections-test.js
2 files changed, 99 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/23/385423/1

diff --git a/test/lib/parsoid/parsoid-sections-section-elements-tests.js 
b/test/lib/parsoid/parsoid-sections-section-elements-tests.js
new file mode 100644
index 000..3c94847
--- /dev/null
+++ b/test/lib/parsoid/parsoid-sections-section-elements-tests.js
@@ -0,0 +1,98 @@
+'use strict';
+
+const assert = require('../../utils/assert.js');
+const domino = require('domino');
+const parsoidSectionsUsingSectionTags = 
require('../../../lib/parsoidSectionsUsingSectionTags');
+
+describe('lib:parsoid-sections (section elements)', function() {
+/* eslint-disable prefer-template */
+
+this.timeout(2); // eslint-disable-line no-invalid-this
+
+function assertSection0(sections) {
+assert.deepEqual(sections[0].id, 0);
+assert.deepEqual(sections[0].text, 'text0', 
JSON.stringify(sections[0], null, 2));
+}
+
+function assertSection1(sections, extraText = '') {
+assert.deepEqual(sections[1].id, 1);
+assert.deepEqual(sections[1].toclevel, 1);
+assert.deepEqual(sections[1].line, 'foo');
+assert.deepEqual(sections[1].anchor, 'foo');
+assert.deepEqual(sections[1].text, `text1${extraText}`);
+}
+
+function assertSection2(sections) {
+assert.deepEqual(sections[2].id, 2);
+assert.deepEqual(sections[2].toclevel, 2);
+// assert.deepEqual(sections[2].line, 'Funny section !@#$');
+assert.deepEqual(sections[2].anchor, 'Funny_section_.21.40.23.24');
+assert.deepEqual(sections[2].text, 'text2');
+}
+
+
+it('getSectionsText(empty) should produce an empty lead section', () => {
+const doc = domino.createDocument('');
+const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
+assert.deepEqual(sections.length, 1);
+assert.deepEqual(sections[0].id, 0);
+assert.deepEqual(sections[0].text, '');
+});
+
+it('getSectionsText() with just text should produce a lead section', () => 
{
+const doc = domino.createDocument('text0');
+const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
+assert.deepEqual(sections.length, 1);
+assertSection0(sections);
+});
+
+it('getSectionsText() with one h2 should produce two sections', () => {
+const doc = domino.createDocument('text0' +
+'footext1');
+const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
+assert.deepEqual(sections.length, 2);
+assertSection0(sections);
+assertSection1(sections);
+});
+
+it('getSectionsText() with one h2 and h3 should produce three sections', 
() => {
+const doc = domino.createDocument('text0' +
+'footext1' +
+'' +
+'Funny section 
!@#$%^&*()text2' +
+'');
+const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
+assert.deepEqual(sections.length, 3);
+assertSection0(sections);
+assertSection1(sections);
+assertSection2(sections);
+});
+
+// From T175305 
http://localhost:8000/fy.wikipedia.org/v3/page/html/De_Kanto%27s
+it('getSectionsText() with one h2 inside div should not produce another 
section', () => {
+const sectionInDiv = '' +
+'bar';
+const doc = domino.createDocument('text0' +
+'footext1' + 
sectionInDiv +
+'');
+const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
+assert.deepEqual(sections.length, 2);
+assertSection0(sections);
+assertSection1(sections, sectionInDiv);
+});
+
+// same as above but using h3 instead of h2 in extra 
+it('getSectionsText() with one h3 inside div should not produce another 
section', () => {
+const sectionInDiv = '' +
+'bar';
+const doc = domino.createDocument('text0' +
+'footext1' + 
sectionInDiv +
+'');
+const sections = parsoidSectionsUsingSectionTags.getSectionsText(doc);
+assert.deepEqual(sections.length, 2);
+assertSection0(sections);
+assertSection1(sections, sectionInDiv);
+});
+
+/* eslint-enable prefer-template */
+});
diff --git a/test/lib/parsoid/parsoid-sections-test.js 
b/test/lib/parsoid/parsoid-sections-test.js
index 26f1396..04622b9 100644
--- 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: create script to compare old and new sectioning code

2017-10-20 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/385420 )

Change subject: Hygiene: create script to compare old and new sectioning code
..

Hygiene: create script to compare old and new sectioning code

The output of this allows us to have more confidence when changing
the sectioning code. It could probably be used for other changes, too.
This script requires some extensive setup. See the comments at the
beginning of the script file.

Bug: T178707
Change-Id: I0a8116ec8fe9278a31e8dea781ee646251b83c94
(cherry picked from commit 29c0038523e01df0008b9881655a08c9b26eca41)
---
A scripts/compare-sections.js
1 file changed, 140 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/20/385420/1

diff --git a/scripts/compare-sections.js b/scripts/compare-sections.js
new file mode 100755
index 000..3695de1
--- /dev/null
+++ b/scripts/compare-sections.js
@@ -0,0 +1,140 @@
+#!/usr/bin/env node
+
+'use strict';
+
+/*
+  Setup notes before running this script:
+  * Start two local Parsoid instances on ports 8000 and 8001. The latter would 
get the new code.
+  * Start two local MCS instances on ports 6927 and 6928.
+  * Change the config also to hook up with the respective local Parsoid 
installations.
+  * E.g.
+  * v1) MCS:6927 -> Parsoid:8000
+  * v2) MCS:6928 -> Parsoid:8001
+  * Run the script from the script folder.
+
+  Arguments: provide a single argument which is the language code for the 
Wikipedia project.
+
+  Example:
+  $ cd scripts
+  $ ./compare-sections.js en
+
+  The output will be in the private/compare-sections folder. Since the output 
is much larger than
+  for text extracts each page gets it's own file.
+  Note: the output will be massaged to allow for easier diffing by reducing 
uninteresting variances
+  and by adding line breaks at strategic points.
+*/
+
+const BBPromise = require('bluebird');
+const fs = require('fs');
+const mkdir = require('mkdirp');
+const preq = require('preq');
+
+const DELAY = 10; // delay between requests in ms
+const topPagesDir = '../private/top-pages';
+const outDir = '../private/compare-sections';
+
+let lang;
+let topPages;
+
+let oldDirName;
+let newDirName;
+
+const uriForOldMobileSections = (title, rev, lang) => {
+return 
`http://localhost:6927/${lang}.wikipedia.org/v1/page/mobile-sections/${encodeURIComponent(title)}/${rev}`;
+};
+
+const uriForNewSections = (title, rev, lang) => {
+return 
`http://localhost:6928/${lang}.wikipedia.org/v1/page/mobile-sections/${encodeURIComponent(title)}/${rev}`;
+};
+
+/**
+ * Remove some values which vary between implementation but don't have 
anything to do with
+ * sectioning.
+ */
+const simplifyExtractValue = (value) => {
+return value && value
+.replace(/"revision": "\w+",/, '"revision": "ZZZ",')
+.replace(/"lastmodified": "\w+",/, '"lastmodified": "ZZZ",')
+.replace(/"user": "\w+",/, '"user": "ZZZ",')
+.replace(/"gender": "\w+",/, '"gender": "ZZZ",')
+.replace(/#ImageMap_\d+_\d+/g, '#ImageMap_0_000')
+.replace(/)/g, "$1\n")
+.replace(/()/g, "$1\n")
+.replace(/(.{50}[^<>]{0,50}>?)/g, "$1\n")
+// ^ keep lines to a reasonable width (try to break near HTML tags)
+;
+};
+
+const getExtractHtml = (response) => {
+if (response.status !== 200) {
+return `!! STATUS = ${response.status} !!\n`;
+}
+return simplifyExtractValue(JSON.stringify(response.body, null, 2));
+};
+
+const writeFile = (dir, title, rev, value) => {
+const file = 
fs.createWriteStream(`${dir}_${encodeURIComponent(title)}-${rev}.json`,
+{ flags: 'w' });
+file.write(`${value}\n`);
+file.end();
+};
+
+const compareExtracts = (filePrefix, oldExtract, newExtract, counter, title, 
rev) => {
+writeFile(`${oldDirName}/${filePrefix}`, title, rev, oldExtract);
+writeFile(`${newDirName}/${filePrefix}`, title, rev, newExtract);
+};
+
+const fetchExtract = (uri) => {
+return preq.get({ uri })
+.then((response) => {
+return BBPromise.delay(DELAY, getExtractHtml(response));
+}).catch((err) => {
+return BBPromise.resolve(`!!! ${err} "${uri}" !!!`);
+});
+};
+
+const fetchAndVerify = (filePrefix, title, rev, counter, lang) => {
+process.stdout.write('.');
+let newExtract;
+return fetchExtract(uriForNewSections(title, rev, lang))
+.then((response) => {
+newExtract = response;
+return fetchExtract(uriForOldMobileSections(title, rev, lang));
+}).then((oldExtract) => {
+compareExtracts(filePrefix, oldExtract, newExtract, counter, title, 
rev);
+});
+};
+
+const processOneLanguage = (lang) => {
+let counter = 0;
+BBPromise.each(topPages, (page) => {
+const filePrefix = (`${++counter}`).slice(-4); // 0-pad
+return 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: add tmp folder to eslintignore

2017-10-20 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/385419 )

Change subject: Hygiene: add tmp folder to eslintignore
..

Hygiene: add tmp folder to eslintignore

Change-Id: I77f5fb80ffda11c1fcafe5113d6a863536ac4d27
---
M .eslintignore
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/19/385419/1

diff --git a/.eslintignore b/.eslintignore
index 7d226e1..9065f89 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,4 @@
 private/top-pages/top-pages.*.json
 test/diff/results/page_definition-enwiktionary-*.json
-test/diff/results/page_*MCS_Test_Frankenstein.json
\ No newline at end of file
+test/diff/results/page_*MCS_Test_Frankenstein.json
+tmp/
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I77f5fb80ffda11c1fcafe5113d6a863536ac4d27
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to c045afc

2017-10-11 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383648 )

Change subject: Update mobileapps to c045afc
..

Update mobileapps to c045afc

List of changes:
6b7a264 Account for  instead of  for inline figures
ce12152 Hygiene: update diff test results + disable spokenWP test
93827da Hygiene: simplify assert.closeTo and assert.contains
7702d51 Hygiene: simplify assertions in onthisday test
468d4ef Fix Portuguese news selector
c045afc Hygiene: Update test fixtures
xxx Update node module dependencies

Change-Id: I47d9425d44e248ac5b56e949e069d0ced2f7261d
---
M node_modules/bluebird/js/browser/bluebird.core.js
M node_modules/bluebird/js/browser/bluebird.core.min.js
M node_modules/bluebird/js/browser/bluebird.js
M node_modules/bluebird/js/browser/bluebird.min.js
M node_modules/bluebird/js/release/debuggability.js
M node_modules/bluebird/js/release/promise.js
M node_modules/bluebird/js/release/util.js
M node_modules/bluebird/package.json
M node_modules/express/lib/request.js
M node_modules/express/lib/response.js
M node_modules/express/package.json
M node_modules/kad/package.json
M node_modules/moment/locale/ar-ly.js
M node_modules/moment/locale/ar.js
A node_modules/moment/locale/bm.js
M node_modules/moment/locale/ca.js
M node_modules/moment/locale/da.js
M node_modules/moment/locale/de-at.js
M node_modules/moment/locale/de-ch.js
M node_modules/moment/locale/de.js
M node_modules/moment/locale/el.js
M node_modules/moment/locale/es-do.js
A node_modules/moment/locale/es-us.js
M node_modules/moment/locale/es.js
A node_modules/moment/locale/gu.js
M node_modules/moment/locale/ko.js
M node_modules/moment/locale/nl-be.js
M node_modules/moment/locale/nl.js
M node_modules/moment/locale/pl.js
M node_modules/moment/locale/pt-br.js
M node_modules/moment/locale/pt.js
M node_modules/moment/locale/ru.js
M node_modules/moment/locale/tr.js
M node_modules/moment/min/locales.js
M node_modules/moment/min/locales.min.js
M node_modules/moment/min/moment-with-locales.js
M node_modules/moment/min/moment-with-locales.min.js
M node_modules/moment/min/moment.min.js
M node_modules/moment/moment.d.ts
M node_modules/moment/moment.js
M node_modules/moment/package.json
M node_modules/moment/src/lib/create/from-array.js
M node_modules/moment/src/lib/create/from-string.js
M node_modules/moment/src/lib/create/valid.js
A node_modules/moment/src/lib/duration/clone.js
M node_modules/moment/src/lib/duration/constructor.js
M node_modules/moment/src/lib/duration/create.js
M node_modules/moment/src/lib/duration/iso-string.js
M node_modules/moment/src/lib/duration/prototype.js
M node_modules/moment/src/lib/duration/valid.js
M node_modules/moment/src/lib/locale/locales.js
M node_modules/moment/src/lib/moment/add-subtract.js
M node_modules/moment/src/lib/moment/diff.js
M node_modules/moment/src/lib/moment/get-set.js
M node_modules/moment/src/lib/units/month.js
M node_modules/moment/src/lib/units/year.js
M node_modules/moment/src/lib/utils/is-object-empty.js
A node_modules/moment/src/lib/utils/mod.js
M node_modules/moment/src/locale/ar-ly.js
M node_modules/moment/src/locale/ar.js
A node_modules/moment/src/locale/bm.js
M node_modules/moment/src/locale/ca.js
M node_modules/moment/src/locale/da.js
M node_modules/moment/src/locale/de-at.js
M node_modules/moment/src/locale/de-ch.js
M node_modules/moment/src/locale/de.js
M node_modules/moment/src/locale/el.js
M node_modules/moment/src/locale/es-do.js
A node_modules/moment/src/locale/es-us.js
M node_modules/moment/src/locale/es.js
A node_modules/moment/src/locale/gu.js
M node_modules/moment/src/locale/ko.js
M node_modules/moment/src/locale/nl-be.js
M node_modules/moment/src/locale/nl.js
M node_modules/moment/src/locale/pl.js
M node_modules/moment/src/locale/pt-br.js
M node_modules/moment/src/locale/pt.js
M node_modules/moment/src/locale/ru.js
M node_modules/moment/src/locale/tr.js
M node_modules/moment/src/moment.js
M src
81 files changed, 2,565 insertions(+), 2,179 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps/deploy 
refs/changes/48/383648/1


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I47d9425d44e248ac5b56e949e069d0ced2f7261d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps/deploy
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: simplify assert.closeTo and assert.contains

2017-10-06 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382875 )

Change subject: Hygiene: simplify assert.closeTo and assert.contains
..

Hygiene: simplify assert.closeTo and assert.contains

This is to make failure output a bit nicer and more useful
when assertions fail by showing the actual result.

Change-Id: I64bb8e6839f343e8718234a542b5fc74a0718114
---
M test/utils/assert.js
1 file changed, 4 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/75/382875/1

diff --git a/test/utils/assert.js b/test/utils/assert.js
index ec10cee..fcdd736 100644
--- a/test/utils/assert.js
+++ b/test/utils/assert.js
@@ -115,24 +115,14 @@
  * @param {?string} message
 */
 function closeTo(result, expected, delta, message) {
-try {
-assert.ok(_.isNumber(result) && Math.abs(result - expected) <= delta, 
message);
-} catch (e) {
-console.log(`Result is ${result}; expected ${expected} ± ${delta}`);
-throw e;
-}
+assert.ok(_.isNumber(result) && Math.abs(result - expected) <= delta,
+message || `Result is ${result}; expected ${expected} ± ${delta}`);
 }
 
 
 function contains(result, sub, message) {
-try {
-assert.ok(result.indexOf(sub) > -1, message);
-} catch (e) {
-console.log(`Substring:\n${sub}`);
-console.log(`Not in result:\n${result}`);
-throw e;
-}
-
+assert.ok(result.indexOf(sub) > -1,
+message || `'${sub}' not in:\n${result}`);
 }
 
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64bb8e6839f343e8718234a542b5fc74a0718114
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: simplify assertions in onthisday test

2017-10-06 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382876 )

Change subject: Hygiene: simplify assertions in onthisday test
..

Hygiene: simplify assertions in onthisday test

This is to make failure output a bit nicer and more useful
when assertions fail by showing the actual result.

Change-Id: I6d974c59997e0efe318fdee62541b9af9d348736
---
M test/features/onthisday/on-this-day.js
1 file changed, 31 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/76/382876/1

diff --git a/test/features/onthisday/on-this-day.js 
b/test/features/onthisday/on-this-day.js
index f68585a..ec7e036 100644
--- a/test/features/onthisday/on-this-day.js
+++ b/test/features/onthisday/on-this-day.js
@@ -289,7 +289,7 @@
 return preq.get(january30uriForEndpointName(endpointName, lang));
 }
 function verifyNonZeroEndpointResults(response, endpointName) {
-assert.equal(response.status, 200);
+assert.deepEqual(response.status, 200);
 assert.ok(response.body[endpointName].length > 0,
 `${endpointName} should have fetched some results`);
 }
@@ -331,8 +331,8 @@
 });
 
 it('eventsForYearListElements returns a WMFEvent for only year list 
elements', () => {
-assert.ok(
-   
onThisDay.testing.eventsForYearListElements(MOCK_EVENT_LIST_ELEMENTS, 
'en').length === 4,
+assert.deepEqual(
+   
onThisDay.testing.eventsForYearListElements(MOCK_EVENT_LIST_ELEMENTS, 
'en').length, 4,
'Should return WMFEvent for each of 4 year list elements'
 );
 });
@@ -383,10 +383,10 @@
 assert.ok('4 CE – Bla bla'.match(regex)[2] === undefined);
 assert.ok('4CE – Bla bla'.match(regex)[2] === undefined);
 assert.ok('4 AD – Bla bla'.match(regex)[2] === undefined);
-assert.ok('1 BC – Bla bla'.match(regex)[2] === 'BC');
-assert.ok('1BC – Bla bla'.match(regex)[2] === 'BC');
-assert.ok('1bce – Bla bla'.match(regex)[2] === 'bce');
-assert.ok('1 bce – Bla bla'.match(regex)[2] === 'bce');
+assert.deepEqual('1 BC – Bla bla'.match(regex)[2], 'BC');
+assert.deepEqual('1BC – Bla bla'.match(regex)[2], 'BC');
+assert.deepEqual('1bce – Bla bla'.match(regex)[2], 'bce');
+assert.deepEqual('1 bce – Bla bla'.match(regex)[2], 'bce');
 assert.ok('AD 1 – Bla bla'.match(regex)[2] === undefined);
 });
 
@@ -411,10 +411,10 @@
 const sortedEvents =
 
onThisDay.testing.eventsForYearListElements(MOCK_EVENT_LIST_ELEMENTS, 'en')
 .sort(onThisDay.testing.reverseChronologicalWMFEventComparator);
-assert.ok(sortedEvents[0].year === 1948);
-assert.ok(sortedEvents[1].year === 1946);
-assert.ok(sortedEvents[2].year === -58);
-assert.ok(sortedEvents[3].year === -516);
+assert.deepEqual(sortedEvents[0].year, 1948);
+assert.deepEqual(sortedEvents[1].year, 1946);
+assert.deepEqual(sortedEvents[2].year, -58);
+assert.deepEqual(sortedEvents[3].year, -516);
 });
 
 it('Hydration should replace each \'title\' key with \'$merge\' key', () 
=> {
@@ -443,25 +443,25 @@
 }
 
 // Confirm expected number of pages exist post-hydration
-assert.ok(events[0].pages.length === 1);
-assert.ok(events[1].pages.length === 4);
-assert.ok(events[2].pages.length === 2);
-assert.ok(events[3].pages.length === 1);
-assert.ok(events[4].pages.length === 5);
+assert.deepEqual(events[0].pages.length, 1);
+assert.deepEqual(events[1].pages.length, 4);
+assert.deepEqual(events[2].pages.length, 2);
+assert.deepEqual(events[3].pages.length, 1);
+assert.deepEqual(events[4].pages.length, 5);
 });
 
 it('listElementsByHeadingID extracts expected number of births from DE 
fixture', () => {
 // https://de.wikipedia.org/api/rest_v1/page/html/1._Dezember
 const document = documentFromFixtureFile('de.1._Dezember.html');
 const listElements = 
onThisDay.testing.listElementsByHeadingID(document, ['Geboren'], 'de');
-assert.ok(listElements.length === 180);
+assert.deepEqual(listElements.length, 180);
 });
 
 it('listElementsByHeadingID extracts expected number of births from EN 
fixture', () => {
 // https://en.wikipedia.org/api/rest_v1/page/html/December_1
 const document = documentFromFixtureFile('en.December_1.html');
 const listElements = 
onThisDay.testing.listElementsByHeadingID(document, ['Births'], 'en');
-assert.ok(listElements.length === 208);
+assert.deepEqual(listElements.length, 208);
 });
 
 it('listElementsByHeadingID extracts expected number of births from AR 
fixture', () => {
@@ -469,7 +469,7 @@
 const document = 

[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: Update test fixtures

2017-10-06 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382878 )

Change subject: Hygiene: Update test fixtures
..

Hygiene: Update test fixtures

This is for news, onthisday, and a general test page.
This ia a followup of the comment in
https://gerrit.wikimedia.org/r/#/c/382035/1//COMMIT_MSG@9.

The updated content is based on an undeployed Parsoid version:
https://gerrit.wikimedia.org/r/#/c/370227/12
to make sure MCS is ready for this.

Using
const uri = 
`http://localhost:8000/${lang}.wikipedia.org/v3/page/pagebundle/${encodeURIComponent(NEWS_SITES[lang].title)}`;
Note: pagebundle instead of html in the path.
And used rsp.body.html.body instead of rsp.body when writing.

Change-Id: Ib50b702a37acf6cb481d5ffa731e48e6e8490303
---
M test/features/news/news-sites.js
M test/features/onthisday/fixtures/ar.January_1.html
M test/features/onthisday/fixtures/de.1._Dezember.html
M test/features/onthisday/fixtures/en.December_1.html
M test/features/onthisday/fixtures/sv.Augusti_25.html
M test/features/onthisday/on-this-day.js
A test/fixtures/news-site-da-2017-10-04.htm
A test/fixtures/news-site-de-2017-10-04.htm
A test/fixtures/news-site-el-2017-10-04.htm
A test/fixtures/news-site-en-2017-10-04.htm
A test/fixtures/news-site-es-2017-10-04.htm
A test/fixtures/news-site-fi-2017-10-04.htm
A test/fixtures/news-site-fr-2017-10-04.htm
A test/fixtures/news-site-he-2017-10-04.htm
A test/fixtures/news-site-ko-2017-10-04.htm
A test/fixtures/news-site-no-2017-10-04.htm
A test/fixtures/news-site-pl-2017-10-04.htm
A test/fixtures/news-site-pt-2017-10-04.htm
A test/fixtures/news-site-ru-2017-10-04.htm
A test/fixtures/news-site-sco-2017-10-04.htm
A test/fixtures/news-site-sv-2017-10-04.htm
A test/fixtures/news-site-vi-2017-10-04.htm
M test/fixtures/update-news-sites
M test/lib/bill-clinton.html
M test/lib/parseProperty/parse-infobox-test.js
25 files changed, 4,363 insertions(+), 3,013 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/78/382878/1


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib50b702a37acf6cb481d5ffa731e48e6e8490303
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Fix Portuguese news selector

2017-10-06 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382877 )

Change subject: Fix Portuguese news selector
..

Fix Portuguese news selector

The old version of the CSS selector for ptwiki news stories resulted in
too many news result (around 133 as of yesterday). Now it should only
pick from the top news table.

We had not noticed earlier since he had not updated the fixtures.
A subsequent commit will do so.

Change-Id: I165ec6056c10673a297ed407e427cc1697f1efc4
---
M etc/feed/news-sites.js
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/77/382877/1

diff --git a/etc/feed/news-sites.js b/etc/feed/news-sites.js
index 4bbe83e..7e6f627 100644
--- a/etc/feed/news-sites.js
+++ b/etc/feed/news-sites.js
@@ -62,7 +62,8 @@
 ko: new NewsSite('틀:새로_들어온_소식', 'body > ul > li', 
TOPIC_SELECTOR_BOLD_LINK),
 no: new NewsSite('Mal:Aktuelt', 'ul > li', TOPIC_SELECTOR_BOLD_LINK),
 pl: new NewsSite('Szablon:Aktualności', 'ul:last-of-type > li', 
TOPIC_SELECTOR_BOLD_LINK),
-pt: new NewsSite('Portal:Eventos_atuais', 'div > ul > li', 
TOPIC_SELECTOR_BOLD_LINK),
+pt: new NewsSite('Portal:Eventos_atuais', 'table:nth-child(3) ul > li',
+TOPIC_SELECTOR_BOLD_LINK),
 ru: new NewsSite('Шаблон:Актуальные_события', 'body > ul > li', 
TOPIC_SELECTOR_BOLD_LINK),
 sco: new NewsSite('Template:In_the_news', 'ul[id^=mw] li', 
TOPIC_SELECTOR_BOLD_LINK), // see en
 sv: new NewsSite('Portal:Huvudsida/Aktuella händelser', 'body > ul > li',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I165ec6056c10673a297ed407e427cc1697f1efc4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...mobileapps[master]: Hygiene: update diff test results

2017-10-05 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382628 )

Change subject: Hygiene: update diff test results
..

Hygiene: update diff test results

The Frankenstein test page has been protected.

Change-Id: Ic6397b0af7db09f19e7bb78b73baff815e14e31c
---
M 
test/diff/results/page_formatted-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_Frankenstein.json
M 
test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_(WMF)_MCS_Test_Frankenstein.json
2 files changed, 18 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/28/382628/1

diff --git 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
index 6b15353..b094f9d 100644
--- 
"a/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
+++ 
"b/test/diff/results/page_formatted-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
@@ -5,8 +5,15 @@
 "revision": "77813",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
-"protection": {},
-"editable": true,
+"protection": {
+  "edit": [
+"sysop"
+  ],
+  "move": [
+"sysop"
+  ]
+},
+"editable": false,
 "hatnotes": [],
 "intro": "Frankenstein Castle is a medieval fortification on a 
spur above the village of 
Frankenstein, Rhineland-Palatinate in the Palatinate Forest 
in Germany. Its name derives from 
the local House of Frankenstein.",
 "geo": {
diff --git 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
index 924b604..8ff0105 100644
--- 
"a/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
+++ 
"b/test/diff/results/page_mobile-sections-enwiki-User%3ABSitzmann_\050WMF\051_MCS_Test_Frankenstein.json"
@@ -5,8 +5,15 @@
 "revision": "77813",
 "displaytitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
 "normalizedtitle": "User:BSitzmann (WMF)/MCS/Test/Frankenstein",
-"protection": {},
-"editable": true,
+"protection": {
+  "edit": [
+"sysop"
+  ],
+  "move": [
+"sysop"
+  ]
+},
+"editable": false,
 "hatnotes": [],
 "geo": {
   "latitude": 49.4388,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6397b0af7db09f19e7bb78b73baff815e14e31c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update mobileapps to 5dc0c02

2017-10-03 Thread BearND (Code Review)
BearND has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382073 )

Change subject: Update mobileapps to 5dc0c02
..

Update mobileapps to 5dc0c02

List of changes:
7139e27 Add featured feed In the news entry for scowiki
949e7a5 Hygiene: update diff tests
43eb4e7 Don't try to get userinfo for subpages
4f80049 Strip any .reference elements
be6d9c7 Hygiene: Break out removeAttributes transformation
a4f603b Remove data-mw attributes before parsing summary
3dcc319 Fix definition of lead introduction
f492d7d Redirects return 204 inside MCS
41709cd Add multi-lang.js script
af6e6de Make top-pages script take language command line parameter
d6c03af More top-pages script improvements
26376f9 Add more top-pages lists
5e5056c Add compare script for old and new extracts
4ec0f04 Update express to 4.16.0
d76c3d9 Add test cases for summary endpoint
5c32b64 Add fundraising test via announcement cards in France
3bb95e8 Fix removeNestedParentheticals parenthetical handling
xxx Update node module dependencies

Change-Id: I4f77ba4519fc2d9dc0e7998f82615334fa6589a9
---
M node_modules/accepts/package.json
M node_modules/ajv/dist/ajv.min.js
M node_modules/ajv/package.json
M node_modules/body-parser/lib/read.js
M node_modules/body-parser/package.json
M node_modules/bytes/package.json
M node_modules/compressible/package.json
D node_modules/compression/node_modules/bytes/LICENSE
D node_modules/compression/node_modules/bytes/index.js
D node_modules/compression/node_modules/bytes/package.json
M node_modules/compression/package.json
M node_modules/debug/component.json
M node_modules/debug/package.json
A node_modules/debug/src/inspector-log.js
M node_modules/debug/src/node.js
M node_modules/etag/package.json
M node_modules/express/lib/application.js
M node_modules/express/lib/express.js
M node_modules/express/lib/response.js
M node_modules/express/lib/router/index.js
M node_modules/express/lib/router/route.js
M node_modules/express/lib/utils.js
M node_modules/express/lib/view.js
D node_modules/express/node_modules/qs/.editorconfig
D node_modules/express/node_modules/qs/.eslintignore
D node_modules/express/node_modules/qs/.eslintrc
D node_modules/express/node_modules/qs/LICENSE
D node_modules/express/node_modules/qs/dist/qs.js
D node_modules/express/node_modules/qs/lib/formats.js
D node_modules/express/node_modules/qs/lib/index.js
D node_modules/express/node_modules/qs/lib/parse.js
D node_modules/express/node_modules/qs/lib/stringify.js
D node_modules/express/node_modules/qs/lib/utils.js
D node_modules/express/node_modules/qs/package.json
D node_modules/express/node_modules/qs/test/.eslintrc
D node_modules/express/node_modules/qs/test/index.js
D node_modules/express/node_modules/qs/test/parse.js
D node_modules/express/node_modules/qs/test/stringify.js
D node_modules/express/node_modules/qs/test/utils.js
A node_modules/express/node_modules/setprototypeof/LICENSE
A node_modules/express/node_modules/setprototypeof/index.d.ts
A node_modules/express/node_modules/setprototypeof/index.js
A node_modules/express/node_modules/setprototypeof/package.json
M node_modules/express/package.json
M node_modules/finalhandler/index.js
M node_modules/finalhandler/package.json
M node_modules/forwarded/package.json
M node_modules/fresh/index.js
M node_modules/fresh/package.json
M node_modules/hot-shots/package.json
D node_modules/hot-shots/types.d.ts
M node_modules/ipaddr.js/LICENSE
M node_modules/ipaddr.js/bower.json
M node_modules/ipaddr.js/ipaddr.min.js
M node_modules/ipaddr.js/lib/ipaddr.js
M node_modules/ipaddr.js/package.json
M node_modules/ipaddr.js/src/ipaddr.coffee
M node_modules/ipaddr.js/test/ipaddr.test.coffee
M node_modules/kad/package.json
D node_modules/mime/.npmignore
M node_modules/mime/LICENSE
M node_modules/mime/build/test.js
M node_modules/mime/mime.js
M node_modules/mime/package.json
M node_modules/mime/types.json
M node_modules/parseurl/package.json
M node_modules/proxy-addr/index.js
M node_modules/proxy-addr/package.json
M node_modules/qs/package.json
M node_modules/request/package.json
M node_modules/safe-buffer/package.json
M node_modules/send/index.js
M node_modules/send/package.json
M node_modules/serve-static/index.js
M node_modules/serve-static/package.json
M node_modules/setprototypeof/package.json
M node_modules/tough-cookie/lib/cookie.js
M node_modules/tough-cookie/lib/pubsuffix.js
M node_modules/tough-cookie/package.json
A node_modules/utils-merge/.npmignore
D node_modules/utils-merge/.travis.yml
M node_modules/utils-merge/LICENSE
M node_modules/utils-merge/package.json
M node_modules/vary/index.js
M node_modules/vary/package.json
M src
86 files changed, 1,386 insertions(+), 3,688 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps/deploy 
refs/changes/73/382073/1


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


  1   2   3   4   5   6   7   8   9   10   >