Mholloway has uploaded a new change for review. ( 
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 that the mobile edit URL is still under discussion.

Bug: T170692
Change-Id: I3c4131596f2c22c998fe5802752ae93478b94c03
---
M lib/mobile-util.js
M spec.yaml
2 files changed, 21 insertions(+), 5 deletions(-)


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

diff --git a/lib/mobile-util.js b/lib/mobile-util.js
index dd73585..7c30d75 100644
--- a/lib/mobile-util.js
+++ b/lib/mobile-util.js
@@ -100,6 +100,10 @@
     return domain.replace('.m.', '.');
 };
 
+mUtil.canonicalToMobile = function(domain) {
+    return domain.replace('.', '.m.');
+};
+
 /**
  * Remove the top-level domain from a domain string, e.g., 'en.wikipedia.org' 
->
  * 'en.wikipedia'.
@@ -266,11 +270,20 @@
 };
 
 mUtil.buildContentUrls = function(domain, title, lead) {
+    const mDomain = mUtil.canonicalToMobile(domain);
     return {
-        page: `https://${domain}/wiki/${title.getPrefixedDBKey()}`,
-        revisions: 
`https://${domain}/wiki/${title.getPrefixedDBKey()}?action=history`,
-        edit: `https://${domain}/wiki/${title.getPrefixedDBKey()}?action=edit`,
-        talk: lead.talk_ns_text ? 
`https://${domain}/wiki/${lead.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: lead.talk_ns_text ? 
`https://${domain}/wiki/${lead.talk_ns_text}:${title.getKey()}` : undefined,
+        },
+        mobile: {
+            page: `https://${mDomain}/wiki/${title.getPrefixedDBKey()}`,
+            revisions: 
`https://${mDomain}/wiki/Special:History/${title.getPrefixedDBKey()}`,
+            edit: 
`https://${mDomain}/wiki/${title.getPrefixedDBKey()}?action=edit`,
+            talk: lead.talk_ns_text ? 
`https://${mDomain}/wiki/${lead.talk_ns_text}:${title.getKey()}` : undefined,
+        }
     };
 };
 
diff --git a/spec.yaml b/spec.yaml
index c009d74..3807f88 100644
--- a/spec.yaml
+++ b/spec.yaml
@@ -895,7 +895,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: newchange
Gerrit-Change-Id: I3c4131596f2c22c998fe5802752ae93478b94c03
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <mhollo...@wikimedia.org>

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

Reply via email to