jenkins-bot has submitted this change and it was merged.

Change subject: Add more languages to news feed
......................................................................


Add more languages to news feed

da, el, fi, fr, ko, no, pl, sv, vi

For some languages the code needed to be changed to be more
flexible in terms of selectors used to find the correct list of
news items. (fr, da, pl)

To test I added the following paths to my local RB instance config.yaml

    /{domain:ca.wikipedia.org}: *default_project
    /{domain:el.wikipedia.org}: *default_project
    /{domain:fi.wikipedia.org}: *default_project
    /{domain:ko.wikipedia.org}: *default_project
    /{domain:no.wikipedia.org}: *default_project
    /{domain:pl.wikipedia.org}: *default_project
    /{domain:vi.wikipedia.org}: *default_project

and in the Android app pointed to that local RB instance. After switching to
a new language in the app I ended up having to refresh the feed a couple of
times before the news items showed up.

Bug: T143808
Change-Id: Iac6c156a242b1cb545ed671338bf525a07e105b4
---
M lib/feed/news.js
M test/features/news/news.js
2 files changed, 20 insertions(+), 11 deletions(-)

Approvals:
  Mholloway: Looks good to me, approved
  jenkins-bot: Verified
  Niedzielski: Looks good to me, but someone else must approve



diff --git a/lib/feed/news.js b/lib/feed/news.js
index 4932193..55e9c5d 100644
--- a/lib/feed/news.js
+++ b/lib/feed/news.js
@@ -9,13 +9,23 @@
 var HTTPError = require('../util').HTTPError;
 
 var newsTemplates = {
-    en: 'Template:In_the_news',
-    de: 'Wikipedia:Hauptseite/Aktuelles',
-    es: 'Portal:Actualidad',
-    he: 'תבנית:חדשות_ואקטואליה',
-    pt: 'Portal:Eventos_atuais',
-    ru: 'Шаблон:Актуальные_события',
-    zh: 'Portal:新聞動態'
+    en: {title: 'Template:In_the_news', selector: 'ul[id^=mw]'},
+
+    da: {title: 'Skabelon:Forside_aktuelle_begivenheder', selector: 'div'},
+    de: {title: 'Wikipedia:Hauptseite/Aktuelles', selector: 'ul'},
+    el: {title: 'Πύλη:Τρέχοντα_γεγονότα/Επικεφαλίδες', selector: 'ul'},
+    es: {title: 'Portal:Actualidad', selector: 'ul'},
+    fi: {title: 'Malline:Uutisissa', selector: 'ul'},
+    fr: {title: 'Modèle:Accueil_actualité', selector: 'ul[id^=mw]'},
+    he: {title: 'תבנית:חדשות_ואקטואליה', selector: 'ul'},
+    ko: {title: '틀:새로_들어온_소식', selector: 'ul'},
+    no: {title: 'Mal:Aktuelt', selector: 'ul'},
+    pl: {title: 'Szablon:Aktualności', selector: 'ul:last-of-type'},
+    pt: {title: 'Portal:Eventos_atuais', selector: 'ul'},
+    ru: {title: 'Шаблон:Актуальные_события', selector: 'ul'},
+    sv: {title: 'Portal:Huvudsida/Aktuella händelser', selector: 'ul'},
+    vi: {title: 'Bản_mẫu:Tin_tức', selector: 'ul'},
+    zh: {title: 'Portal:新聞動態', selector: 'ul'}
 };
 
 function removeFragment(href) {
@@ -55,14 +65,14 @@
         payload: [],
         meta: {}
     };
-    req.params.title = newsTemplates[lang];
+    req.params.title = newsTemplates[lang].title;
     return parsoid.getParsoidHtml(app, req)
     .then(function (response) {
         result.meta.etag = parsoid.getRevisionFromEtag(response.headers);
 
         var linkTitles = [];
         var doc = domino.createDocument(response.body);
-        var newsList = doc.getElementsByTagName('ul')[0];
+        var newsList = doc.querySelector(newsTemplates[lang].selector);
         var stories = newsList.getElementsByTagName('li');
 
         for (var j = 0, m = stories.length; j < m; j++) {
diff --git a/test/features/news/news.js b/test/features/news/news.js
index a5eb076..f2478fc 100644
--- a/test/features/news/news.js
+++ b/test/features/news/news.js
@@ -40,8 +40,7 @@
     this.timeout(20000);
 
     before(function () { return server.start(); });
-
-    [ 'de', 'en', 'es', 'he', 'pt', 'ru', 'zh' ].forEach(function(lang) {
+    [ 'da', 'de', 'el', 'en', 'es', 'fi', 'fr', 'he', 'ko', 'no', 'pl', 'pt', 
'ru', 'sv', 'vi', 'zh' ].forEach(function(lang) {
         it(lang + ': should respond to GET request with expected headers, 
incl. CORS and CSP headers', function () {
             return headers.checkHeaders(server.config.uri + lang + 
'.wikipedia.org/v1/page/news',
                 'application/json');

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iac6c156a242b1cb545ed671338bf525a07e105b4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org>
Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org>
Gerrit-Reviewer: Fjalapeno <cfl...@wikimedia.org>
Gerrit-Reviewer: GWicke <gwi...@wikimedia.org>
Gerrit-Reviewer: Jhernandez <jhernan...@wikimedia.org>
Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org>
Gerrit-Reviewer: Mhurd <mh...@wikimedia.org>
Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org>
Gerrit-Reviewer: Niedzielski <sniedziel...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to