jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/389584 )
Change subject: Summary 2.0: Add mobile content URLs
......................................................................
Summary 2.0: Add mobile content URLs
We want to avoid making clients redirect to the pages they need. This
adds content URLs specially formatted for mobile clients in order to
accomplish that.
NOTE: The mobile URL bits are commented out of the spec for now so the
CI tests continue to pass, but should be uncommented once the change
adding the base mobile URL to siteinfo is deployed (this week).
Bug: T170692
Change-Id: I3c4131596f2c22c998fe5802752ae93478b94c03
---
M lib/mobile-util.js
M lib/mwapi.js
M spec.yaml
3 files changed, 35 insertions(+), 15 deletions(-)
Approvals:
BearND: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index 84b4a94..1ebe27f 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -262,7 +262,7 @@
title: meta.normalizedtitle,
displaytitle: meta.displaytitle,
namespace_id: meta.ns,
- namespace_text: meta.ns_text,
+ namespace_text: meta.nsText,
titles: mUtil.buildTitleDictionary(title, meta),
pageid: meta.id,
thumbnail: meta.thumbnail,
@@ -283,11 +283,20 @@
};
mUtil.buildContentUrls = function(domain, title, meta) {
+ const mobileBaseUrl = meta.mobileHost;
return {
- page: `https://${domain}/wiki/${title.getPrefixedDBKey()}`,
- revisions:
`https://${domain}/wiki/${title.getPrefixedDBKey()}?action=history`,
- edit: `https://${domain}/wiki/${title.getPrefixedDBKey()}?action=edit`,
- talk: meta.talk_ns_text ?
`https://${domain}/wiki/${meta.talk_ns_text}:${title.getKey()}` : undefined,
+ desktop: {
+ page: `https://${domain}/wiki/${title.getPrefixedDBKey()}`,
+ revisions:
`https://${domain}/wiki/${title.getPrefixedDBKey()}?action=history`,
+ edit:
`https://${domain}/wiki/${title.getPrefixedDBKey()}?action=edit`,
+ talk: meta.talkNsText &&
`https://${domain}/wiki/${meta.talkNsText}:${title.getKey()}`
+ },
+ mobile: mobileBaseUrl && {
+ page: `${mobileBaseUrl}/wiki/${title.getPrefixedDBKey()}`,
+ revisions:
`${mobileBaseUrl}/wiki/Special:History/${title.getPrefixedDBKey()}`,
+ edit:
`${mobileBaseUrl}/wiki/${title.getPrefixedDBKey()}?action=edit`,
+ talk: meta.talkNsText &&
`${mobileBaseUrl}/wiki/${meta.talkNsText}:${title.getKey()}`
+ }
};
};
@@ -300,7 +309,7 @@
// references:
`https://${domain}/api/rest_v1/page/references/${title.getPrefixedDBKey()}`,
// media:
`https://${domain}/api/rest_v1/page/media/${title.getPrefixedDBKey()}`,
edit_html:
`https://${domain}/api/rest_v1/page/html/${title.getPrefixedDBKey()}`,
- talk_page_html: meta.talk_ns_text ?
`https://${domain}/api/rest_v1/page/html/${meta.talk_ns_text}:${title.getKey()}`
: undefined,
+ talk_page_html: meta.talkNsText &&
`https://${domain}/api/rest_v1/page/html/${meta.talkNsText}:${title.getKey()}`
};
};
diff --git a/lib/mwapi.js b/lib/mwapi.js
index ad987df..7bb49ca 100644
--- a/lib/mwapi.js
+++ b/lib/mwapi.js
@@ -220,6 +220,7 @@
const mainpage = res.siteinfo.general.mainpage === title ? true :
undefined;
const talkNsText = page.ns % 2 === 0 ? res.siteinfo.namespaces[page.ns
+ 1]
&& new Namespace(page.ns + 1, res.siteinfo).getNormalizedText() :
undefined;
+ const mobileHost = res.siteinfo.general.mobileserver;
return {
geo,
@@ -239,14 +240,15 @@
thumbnail: page.thumbnail,
originalimage: page.original,
ns: page.ns,
- ns_text: res.siteinfo.namespaces[page.ns].name,
- talk_ns: talkNsText ? page.ns + 1 : undefined,
- talk_ns_text: talkNsText,
+ nsText: res.siteinfo.namespaces[page.ns].name,
+ talkNs: talkNsText ? page.ns + 1 : undefined,
+ talkNsText,
protection,
editable: !protection.edit,
mainpage,
revision: revision && revision.revid,
- description: page.terms && page.terms.description[0]
+ description: page.terms && page.terms.description[0],
+ mobileHost
};
});
}
diff --git a/spec.yaml b/spec.yaml
index e12008f..a477d0c 100644
--- a/spec.yaml
+++ b/spec.yaml
@@ -701,10 +701,16 @@
timestamp: /.+/
description: /.+/
content_urls:
- page: /.+/
- revisions: /.+/
- edit: /.+/
- talk: /.+/
+ desktop:
+ page: /.+/
+ revisions: /.+/
+ edit: /.+/
+ talk: /.+/
+# mobile:
+# page: /.+/
+# revisions: /.+/
+# edit: /.+/
+# talk: /.+/
api_urls:
summary: /.+/
# read_html: /.+/
@@ -917,7 +923,10 @@
description: Wikidata description for the page
example: American poet
content_urls:
- $ref: '#/definitions/content_urls'
+ desktop:
+ $ref: '#/definitions/content_urls'
+# mobile:
+# $ref: '#/definitions/content_urls'
api_urls:
$ref: '#/definitions/api_urls'
coordinates:
--
To view, visit https://gerrit.wikimedia.org/r/389584
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3c4131596f2c22c998fe5802752ae93478b94c03
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Fjalapeno <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: Mhurd <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Ppchelko <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits