jenkins-bot has submitted this change and it was merged. Change subject: Add pronunciation to lead response ......................................................................
Add pronunciation to lead response Provide a link to the audio file for the pronunciation of the article title when available. Bug: T108371 Change-Id: Ib7bdd26e71b58737982f7458b54f2506297eae27 --- M lib/transforms.js M routes/mobile-html-sections.js M spec.yaml M test/features/mobile-html-sections-lead/pagecontent.js 4 files changed, 37 insertions(+), 0 deletions(-) Approvals: BearND: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/transforms.js b/lib/transforms.js index 8aee968..3311096 100644 --- a/lib/transforms.js +++ b/lib/transforms.js @@ -54,6 +54,11 @@ return mUtil.defaultVal(mUtil.filterEmpty(table)); } +function parsePronunciation(doc) { + var anchor = doc.querySelector('span.IPA a[href]'); + return anchor && { 'url': anchor.href }; +} + function moveFirstParagraphUpInLeadSection(text) { var doc = domino.createDocument(text); // TODO: mhurd: feel free to add your lead section magic here @@ -95,6 +100,7 @@ runDomTransforms: runDomTransforms, moveFirstParagraphUpInLeadSection: moveFirstParagraphUpInLeadSection, parseInfobox: parseInfobox, + parsePronunciation: parsePronunciation, // visible for testing only: _rmBracketSpans: rmBracketSpans diff --git a/routes/mobile-html-sections.js b/routes/mobile-html-sections.js index 00f501e..e0f8ebe 100644 --- a/routes/mobile-html-sections.js +++ b/routes/mobile-html-sections.js @@ -98,6 +98,7 @@ })), media: input.media, infobox: transforms.parseInfobox(lead), + pronunciation: transforms.parsePronunciation(lead), sections: buildLeadSections(input.page.sections) }; } diff --git a/spec.yaml b/spec.yaml index 18450c2..372dc20 100644 --- a/spec.yaml +++ b/spec.yaml @@ -151,6 +151,28 @@ items: [ /.+/ ] infobox: [ [ /.+/ ] ] sections: [ /.+/ ] + - title: retrieve lead section of en.wp Barack Obama page via mobile-html-sections-lead + request: + params: + title: Barack_Obama + response: + status: 200 + headers: + content-type: application/json + body: + id: /.+/ + revision: /.+/ + lastmodified: /.+/ + displaytitle: /.+/ + protection: /.+/ + editable: /.+/ + languagecount: /.+/ + media: + items: [ /.+/ ] + infobox: [ [ /.+/ ] ] + pronunciation: + url: /.+/ + sections: [ /.+/ ] /{domain}/v1/page/mobile-html-sections-remaining/{title}: get: tags: diff --git a/test/features/mobile-html-sections-lead/pagecontent.js b/test/features/mobile-html-sections-lead/pagecontent.js index b66548f..876ef73 100644 --- a/test/features/mobile-html-sections-lead/pagecontent.js +++ b/test/features/mobile-html-sections-lead/pagecontent.js @@ -78,6 +78,14 @@ assert.ok(lead.media.items.length > 3, 'Expected many media items'); }); }); + it('Barack Obama should have a pronunciation', function() { + return preq.get({ uri: server.config.uri + 'en.wikipedia.org/v1/page/mobile-html-sections-lead/Barack_Obama' }) + .then(function(res) { + var lead = res.body; + assert.deepEqual(res.status, 200); + assert.deepEqual(lead.pronunciation.url, '/wiki/File:En-us-Barack-Hussein-Obama.ogg'); + }); + }); it('en Main page should have at least one image', function() { return preq.get({ uri: server.config.uri + 'en.wikipedia.org/v1/page/mobile-html-sections-lead/Main_Page' }) .then(function(res) { -- To view, visit https://gerrit.wikimedia.org/r/234682 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib7bdd26e71b58737982f7458b54f2506297eae27 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/services/mobileapps Gerrit-Branch: master Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org> Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org> Gerrit-Reviewer: Bgerstle <bgers...@wikimedia.org> Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org> Gerrit-Reviewer: Fjalapeno <cfl...@wikimedia.org> Gerrit-Reviewer: GWicke <gwi...@wikimedia.org> Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org> Gerrit-Reviewer: Mhurd <mh...@wikimedia.org> Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits