Kaldari has uploaded a new change for review.
https://gerrit.wikimedia.org/r/163956
Change subject: Using same API data for wikigrokeval and askWikidataQuestion
......................................................................
Using same API data for wikigrokeval and askWikidataQuestion
This is a custom backport of change I93ceb1e for 1.24wmf22
Bug: 71335
Change-Id: Ie8a6eaf299fb8b3eb934ad7c5334f81d8b9e79ef
---
M javascripts/modules/wikigrok/wikigrokeval.js
1 file changed, 11 insertions(+), 32 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/56/163956/1
diff --git a/javascripts/modules/wikigrok/wikigrokeval.js
b/javascripts/modules/wikigrok/wikigrokeval.js
index a8f7188..2fef97d 100644
--- a/javascripts/modules/wikigrok/wikigrokeval.js
+++ b/javascripts/modules/wikigrok/wikigrokeval.js
@@ -1,45 +1,24 @@
( function( M, $ ) {
var wikidataID = mw.config.get( 'wgWikibaseItemId' );
- // Get existing Wikidata claims about this page so we can decide if
it's appropriate
- // to display the WikiGrok interface.
+ // See if there are potential occupation claims about this person so we
can decide if
+ // it's appropriate to display the WikiGrok interface.
$.ajax( {
type: 'get',
- url: 'https://www.wikidata.org/w/api.php',
+ // https://github.com/kaldari/WikiGrokAPI
+ url: 'https://tools.wmflabs.org/wikigrok/api.php',
data: {
- 'action': 'wbgetentities',
- 'ids': wikidataID,
- 'props': 'claims',
- 'format': 'json'
+ 'action': 'get_potential_occupations',
+ // Strip the Q out of the Wikibase item ID
+ 'item': wikidataID.replace( 'Q' , '' )
},
- // Using JSONP so we aren't restricted by cross-site rules.
This isn't
- // strictly needed on the Wikimedia cluster since it has CORS
exceptions
- // for requests from other Wikimedia sites, but this makes it
easy to
- // test locally.
dataType: 'jsonp',
success: function( data ) {
- var instanceClaims,
- loadWikiGrokDialog = false,
- WikiGrokDialog;
+ var WikiGrokDialog;
- // See if the page has any 'instance of' claims.
- if ( data.entities !== undefined &&
data.entities[wikidataID].claims.P31 !== undefined ) {
- instanceClaims =
data.entities[wikidataID].claims.P31;
- $.each( instanceClaims, function( id, claim ) {
- // See if any of the claims state that
the topic is a human.
- if (
claim.mainsnak.datavalue.value['numeric-id'] === 5 ) {
- // Make sure there are no
existing occupation claims.
- if (
data.entities[wikidataID].claims.P106 === undefined ) {
- loadWikiGrokDialog =
true;
- }
- // Break each loop.
- return false;
- }
- } );
- if ( loadWikiGrokDialog ) {
- WikiGrokDialog = M.require(
'modules/wikigrok/WikiGrokDialog' );
- new WikiGrokDialog( { itemId:
wikidataID } );
- }
+ if ( data.occupations !== undefined && data.occupations
) {
+ WikiGrokDialog = M.require(
'modules/wikigrok/WikiGrokDialog' );
+ new WikiGrokDialog( { itemId: wikidataID } );
}
}
} );
--
To view, visit https://gerrit.wikimedia.org/r/163956
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie8a6eaf299fb8b3eb934ad7c5334f81d8b9e79ef
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: wmf/1.24wmf22
Gerrit-Owner: Kaldari <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits