jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/366587 )
Change subject: Expose disambiguation flag on pages
......................................................................
Expose disambiguation flag on pages
This will be needed by web as part of the page preview service.
Additional changes:
* pageprop wikibase_item was previously obtained via an unsupported
way (not even sure how that works) - the mobileview API uses
pageprops not ppprops
Bug: T151241
Change-Id: Ie368fe7ad9c1d667a77a3af6d744ba157c2658c1
---
M lib/mwapi.js
M routes/mobile-sections.js
M test/features/mobile-sections-lead/pagecontent.js
3 files changed, 27 insertions(+), 1 deletion(-)
Approvals:
BearND: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/mwapi.js b/lib/mwapi.js
index 1709de5..d092d2b 100644
--- a/lib/mwapi.js
+++ b/lib/mwapi.js
@@ -131,7 +131,7 @@
formatversion: 2,
page: req.params.title,
prop: props.join('|'),
- ppprop: 'wikibase_item',
+ pageprops: 'wikibase_item|disambiguation',
thumbwidth: mwapi.LEAD_IMAGE_XL
};
return api.mwApiGet(app, req.params.domain, query)
diff --git a/routes/mobile-sections.js b/routes/mobile-sections.js
index 9b8f720..e6ceb23 100644
--- a/routes/mobile-sections.js
+++ b/routes/mobile-sections.js
@@ -100,6 +100,10 @@
let intro;
let sections;
let text;
+ let disambiguation;
+ if (input.meta.pageprops && input.meta.pageprops.disambiguation !==
undefined) {
+ disambiguation = true;
+ }
if (!legacy) {
if (input.page.sections.length > 1) {
@@ -112,6 +116,7 @@
sections = buildLeadSections(input.page.sections);
input.page.sections[0].text = lead.body.innerHTML;
}
+
return {
ns: input.meta.ns,
@@ -126,6 +131,7 @@
normalizedtitle: input.meta.normalizedtitle,
redirected: input.meta.redirected,
wikibase_item: input.meta.pageprops &&
input.meta.pageprops.wikibase_item,
+ disambiguation,
description: input.meta.description,
protection: input.meta.protection,
editable: input.meta.editable,
diff --git a/test/features/mobile-sections-lead/pagecontent.js
b/test/features/mobile-sections-lead/pagecontent.js
index af6cae3..95a612f 100644
--- a/test/features/mobile-sections-lead/pagecontent.js
+++ b/test/features/mobile-sections-lead/pagecontent.js
@@ -264,4 +264,24 @@
assert.ok(res.body.issues === undefined, err);
});
});
+ it('Disambiguation pages are flagged.', () => {
+ const title = 'Barack_(disambiguation)';
+ const uri =
`${server.config.uri}en.wikipedia.org/v1/page/mobile-sections-lead/${title}`;
+ return preq.get({ uri })
+ .then((res) => {
+ assert.deepEqual(res.status, 200);
+ assert.ok(res.body.disambiguation,
+ 'Disambiguation flag is present in meta data.');
+ });
+ });
+ it('Most pages are not flagged as disambiguation.', () => {
+ const title = 'Barack Obama';
+ const uri =
`${server.config.uri}en.wikipedia.org/v1/page/mobile-sections-lead/${title}`;
+ return preq.get({ uri })
+ .then((res) => {
+ assert.deepEqual(res.status, 200);
+ assert.ok(res.body.disambiguation === undefined,
+ 'Disambiguation flag is missing in meta data.');
+ });
+ });
});
--
To view, visit https://gerrit.wikimedia.org/r/366587
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie368fe7ad9c1d667a77a3af6d744ba157c2658c1
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits