From dca7580757092a1a5b3764b5a530a3894292e6b4 Mon Sep 17 00:00:00 2001 From: Jon Robson Date: Thu, 14 Apr 2022 17:03:00 -0700 Subject: [PATCH] [Development] Allow us to pull RelatedArticles from production APIs useful for testing real world data Suggested test config: ``` $wgRelatedArticlesUseCirrusSearchApiUrl = "https://en.wikipedia.org/w/api.php"; $wgRelatedArticlesUseCirrusSearch = true; $wgRelatedArticlesDescriptionSource = 'wikidata'; ``` This will allow us to enable on patchdemo with production content. Change-Id: I73c0d73d3369f27ed2fd74b37ae71bfc12b6ee57 --- extension.json | 5 +++++ .../RelatedPagesGateway.js | 1 + resources/ext.relatedArticles.readMore.bootstrap/index.js | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/extension.json b/extension.json index cfa9ef1a..6e724d4e 100644 --- a/extension.json +++ b/extension.json @@ -61,6 +61,7 @@ { "name": "data.json", "config": { + "searchUrl": "RelatedArticlesUseCirrusSearchApiUrl", "useCirrusSearch": "RelatedArticlesUseCirrusSearch", "onlyUseCirrusSearch": "RelatedArticlesOnlyUseCirrusSearch", "descriptionSource": "RelatedArticlesDescriptionSource" @@ -122,6 +123,10 @@ ] }, "config": { + "RelatedArticlesUseCirrusSearchApiUrl": { + "description": "During development use a different API for sourcing related articles.", + "value": "/w/api.php" + }, "RelatedArticlesCardLimit": { "description": "Maximum number of articles that should be shown in RelatedArticles widget. This limit is derived from limits in TextExtracts and PageImages extensions. Number should be between 1 and 20.", "value": 3 diff --git a/resources/ext.relatedArticles.readMore.bootstrap/RelatedPagesGateway.js b/resources/ext.relatedArticles.readMore.bootstrap/RelatedPagesGateway.js index 33c6df70..7cf04cf6 100644 --- a/resources/ext.relatedArticles.readMore.bootstrap/RelatedPagesGateway.js +++ b/resources/ext.relatedArticles.readMore.bootstrap/RelatedPagesGateway.js @@ -63,6 +63,7 @@ RelatedPagesGateway.prototype.getForCurrentPage = function ( limit ) { var parameters = { action: 'query', formatversion: 2, + origin: '*', prop: 'pageimages', piprop: 'thumbnail', pithumbsize: 160 // FIXME: Revert to 80 once pithumbmode is implemented diff --git a/resources/ext.relatedArticles.readMore.bootstrap/index.js b/resources/ext.relatedArticles.readMore.bootstrap/index.js index d5f65dc4..1f1768dd 100644 --- a/resources/ext.relatedArticles.readMore.bootstrap/index.js +++ b/resources/ext.relatedArticles.readMore.bootstrap/index.js @@ -3,7 +3,11 @@ var data = require( './data.json' ), RelatedPagesGateway = require( './RelatedPagesGateway.js' ), relatedPages = new RelatedPagesGateway( - new mw.Api(), + new mw.Api( { + ajax: { + url: data.searchUrl + } + } ), mw.config.get( 'wgPageName' ), mw.config.get( 'wgRelatedArticles' ), data.useCirrusSearch,