Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/181201

Change subject: WIP: Make infobox experiment configurable.
......................................................................

WIP: Make infobox experiment configurable.

Change-Id: If555a897e4743e93a968f6125c4b677d7bd0034a
---
M MobileFrontend.php
A includes/config/Wikidata.php
M includes/skins/SkinMinervaAlpha.php
M javascripts/modules/infobox/Infobox.js
A javascripts/modules/wikigrok/untitled.php
5 files changed, 343 insertions(+), 276 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/01/181201/1

diff --git a/MobileFrontend.php b/MobileFrontend.php
index e1891a5..59fdccc 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -599,6 +599,8 @@
        'instanceOf' => 'P31',
 );
 
+require_once __DIR__ . "/includes/config/Wikidata.php";
+
 /**
  * If set to true, main page HTML will receive special massaging that removes 
everything
  * but a few select pieces.
diff --git a/includes/config/Wikidata.php b/includes/config/Wikidata.php
new file mode 100644
index 0000000..9b84d63
--- /dev/null
+++ b/includes/config/Wikidata.php
@@ -0,0 +1,170 @@
+<?php
+// Needs to be called within MediaWiki; not standalone
+if ( !defined( 'MEDIAWIKI' ) ) {
+       echo "This is a MediaWiki extension and cannot run standalone.\n";
+       die( -1 );
+}
+
+/**
+ * Configuration for Infobox experiment
+ */
+$wgMFInfoboxConfig = array(
+       // movie
+       11424 => array(
+               'rows' => array(
+                               // Director
+                               'P57',
+                               // Produced by
+                               'P162',
+                               // Story by
+                               'P58',
+                               // Based on
+                               'P144',
+                               // Starring
+                               'P161',
+                               // Music by
+                               'P86',
+                               // Cinematography
+                               'P344',
+                               // Film editor
+                               'P1040',
+                               // Production company
+                               'P272',
+                               // Distributor
+                               'P750',
+                               // Released'
+                               'P577',
+                       // FIXME=> running time is not available on Wikidata
+                               //Country of origin
+                               'P495',
+                               //Original language
+                               'P364',
+                       // FIXME=> budget is not available on Wikidata
+                       // FIXME=> box office is not available on Wikidata
+               ),
+       ),
+       16521 => array(
+               'rows' => array(
+                               // Conservation status
+                               'P141',
+                               // Genus
+                               'P171',
+                               // Species
+                               'P225',
+                               // Geographic distribution
+                               'P181',
+               ),
+       ),
+       // country
+       6256 => array(
+               'rows' => array(
+                               // Flag
+                               'P41',
+                               // Coat of arms
+                               'P94',
+                       // FIXME=> add motto
+                               // Anthem
+                               'P85',
+                               // Location
+                               'P242',
+                               // Languages
+                               'P37',
+                               // Capital
+                               'P36',
+                               // FIXME=> Add ethnic groups
+                               // Basic form of government
+                               'P122',
+                               // Legislature
+                               'P194',
+                               // FIXME=> Add Area
+                               // Population
+                               'P1082',
+                               // FIXME: Add GDP
+                               // Currency
+                               'P38',
+                               // Timezone
+                               'P421',
+                               // FIXME=> add Date format
+                               // FIXME=> add Drives on the (left/right)
+                               // Country calling code
+                               'P474',
+                               // ISO 3166 code
+                               'P297',
+                               // Internet TLD
+                               'P78',
+               ),
+       ),
+       // city
+       515 => array(
+               'rows' => array(
+                               // Flag
+                               'P41',
+                               // Coat of arms
+                               'P94',
+                               // Coordinates
+                               'P625',
+                               // State
+                               'P131',
+                               // Country
+                               'P17',
+                               // Founded
+                               'P571',
+                               // Population
+                               'P1082',
+                               // Timezone
+                               'P421',
+                               // Born
+                               'P569',
+
+               ),
+       ),
+       // human
+       5 => array(
+               'rows' => array(
+                               // Born
+                               'P569',
+                               // Birthplace
+                               'P19',
+                               // Died
+                               'P570',
+                               // Place of death
+                               'P20',
+                               // Country of citizenship
+                               'P27',
+                       // FIXME=> Add political party
+                               // Spouse(s)
+                               'P26',
+                               // Mother(s)
+                               'P25',
+                               // Father(s)
+                               'P22',
+                               //FIXME=> Add Stepfather(s) (P43) and step 
mothers?
+                               // Sister(s)
+                               'P9',
+                               // Brother(s)
+                               'P7',
+                               // Child(ren)
+                               'P40',
+                               // FIXME=> add residence?
+                               // Alma mater
+                               'P69',
+                               // Occupation
+                               'P106',
+                               // Employer(s)
+                               'P108',
+                               // Religion
+                               'P140',
+                               // FIXME=> add awards?
+                               // Signature
+                               'P109',
+                               // Official website
+                               'P856',
+               ),
+       ),
+       'default' => array(
+               'rows' => array(
+                               // Official website
+                               'P856',
+               ),
+       ),
+);
diff --git a/includes/skins/SkinMinervaAlpha.php 
b/includes/skins/SkinMinervaAlpha.php
index af9f337..883e115 100644
--- a/includes/skins/SkinMinervaAlpha.php
+++ b/includes/skins/SkinMinervaAlpha.php
@@ -101,12 +101,13 @@
         * @return array
         */
        public function getSkinConfigVariables() {
-               global $wgWikiBasePropertyConfig;
+               global $wgWikiBasePropertyConfig, $wgMFInfoboxConfig;
 
                $vars = parent::getSkinConfigVariables();
                $vars['wgMFAnonymousEditing'] = true;
                $vars['wgMFDescription'] = $this->getOutput()->getProperty( 
'wgMFDescription' );
                $vars['wgWikiBasePropertyConfig'] = $wgWikiBasePropertyConfig;
+               $vars['wgMFInfoboxConfig'] = $wgMFInfoboxConfig;
 
                return $vars;
        }
diff --git a/javascripts/modules/infobox/Infobox.js 
b/javascripts/modules/infobox/Infobox.js
index 3d99c65..339fd2d 100644
--- a/javascripts/modules/infobox/Infobox.js
+++ b/javascripts/modules/infobox/Infobox.js
@@ -47,280 +47,7 @@
                                'A Wikipedia page in need of a description.',
                        rows: []
                },
-               typeDefaults: {
-                       // FIXME: In future this should be configurable by 
Wikipedia admins
-                       // movie
-                       11424: {
-                               rows: [
-                                       {
-                                               // Director
-                                               id: 'P57'
-                                       },
-                                       {
-                                               // Produced by
-                                               id: 'P162'
-                                       },
-                                       {
-                                               // Story by
-                                               id: 'P58'
-                                       },
-                                       {
-                                               // Based on
-                                               id: 'P144'
-                                       },
-                                       {
-                                               // Starring
-                                               id: 'P161'
-                                       },
-                                       {
-                                               // Music by
-                                               id: 'P86'
-                                       },
-                                       {
-                                               // Cinematography
-                                               id: 'P344'
-                                       },
-                                       {
-                                               // Film editor
-                                               id: 'P1040'
-                                       },
-                                       {
-                                               // Production company
-                                               id: 'P272'
-                                       },
-                                       {
-                                               // Distributor
-                                               id: 'P750'
-                                       },
-                                       {
-                                               // Released'
-                                               id: 'P577'
-                                       },
-                                       // FIXME: running time is not available 
on Wikidata
-                                       {
-                                               //Country of origin
-                                               id: 'P495'
-                                       },
-                                       {
-                                               //Original language
-                                               id: 'P364'
-                                       }
-                                       // FIXME: budget is not available on 
Wikidata
-                                       // FIXME: box office is not available 
on Wikidata
-                               ]
-                       },
-                       16521: {
-                               rows: [
-                                       {
-                                               // Conservation status
-                                               id: 'P141'
-                                       },
-                                       {
-                                               // Genus
-                                               id: 'P171'
-                                       },
-                                       {
-                                               // Species
-                                               id: 'P225'
-                                       },
-                                       {
-                                               // Geographic distribution
-                                               id: 'P181'
-                                       }
-                               ]
-                       },
-                       // country
-                       6256: {
-                               rows: [
-                                       {
-                                               // Flag
-                                               id: 'P41'
-                                       },
-                                       {
-                                               // Coat of arms
-                                               id: 'P94'
-                                       },
-                                       // FIXME: add motto
-                                       {
-                                               // Anthem
-                                               id: 'P85'
-                                       },
-                                       {
-                                               // Location
-                                               id: 'P242'
-                                       },
-                                       {
-                                               // Languages
-                                               id: 'P37'
-                                       },
-                                       {
-                                               // Capital
-                                               id: 'P36'
-                                       },
-                                       // FIXME: Add ethnic groups
-                                       {
-                                               // Basic form of government
-                                               id: 'P122'
-                                       },
-                                       {
-                                               // Legislature
-                                               id: 'P194'
-                                       },
-                                       // FIXME: Add Area
-                                       {
-                                               // Population
-                                               id: 'P1082'
-                                       },
-                                       // GDP
-                                       {
-                                               // Currency
-                                               id: 'P38'
-                                       },
-                                       {
-                                               // Timezone
-                                               id: 'P421'
-                                       },
-                                       // FIXME: add Date format
-                                       // FIXME: add Drives on the (left/right)
-                                       {
-                                               // Country calling code
-                                               id: 'P474'
-                                       },
-                                       {
-                                               // ISO 3166 code
-                                               id: 'P297'
-                                       },
-                                       {
-                                               // Internet TLD
-                                               id: 'P78'
-                                       }
-                               ]
-                       },
-                       // city
-                       515: {
-                               rows: [
-                                       {
-                                               // Flag
-                                               id: 'P41'
-                                       },
-                                       {
-                                               // Coat of arms
-                                               id: 'P94'
-                                       },
-                                       {
-                                               // Coordinates
-                                               id: 'P625'
-                                       },
-                                       {
-                                               // State
-                                               id: 'P131'
-                                       },
-                                       {
-                                               // Country
-                                               id: 'P17'
-                                       },
-                                       {
-                                               // Founded
-                                               id: 'P571'
-                                       },
-                                       {
-                                               // Population
-                                               id: 'P1082'
-                                       },
-                                       {
-                                               // Timezone
-                                               id: 'P421'
-                                       },
-                                       {
-                                               // Born
-                                               id: 'P569'
-                                       }
-                               ]
-                       },
-                       // human
-                       5: {
-                               rows: [
-                                       {
-                                               // Born
-                                               id: 'P569'
-                                       },
-                                       {
-                                               // Birthplace
-                                               id: 'P19'
-                                       },
-                                       {
-                                               // Died
-                                               id: 'P570'
-                                       },
-                                       {
-                                               // Place of death
-                                               id: 'P20'
-                                       },
-                                       {
-                                               // Country of citizenship
-                                               id: 'P27'
-                                       },
-                                       // FIXME: Add political party
-                                       {
-                                               // Spouse(s)
-                                               id: 'P26'
-                                       }, {
-                                               // Mother(s)
-                                               id: 'P25'
-                                       }, {
-                                               // Father(s)
-                                               id: 'P22'
-                                       },
-                                       //FIXME: Add Stepfather(s) (P43) and 
step mothers?
-                                       {
-                                               // Sister(s)
-                                               id: 'P9'
-                                       },
-                                       {
-                                               // Brother(s)
-                                               id: 'P7'
-                                       },
-                                       {
-                                               // Child(ren)
-                                               id: 'P40'
-                                       },
-                                       // FIXME: add residence?
-                                       {
-                                               // Alma mater
-                                               id: 'P69'
-                                       },
-                                       {
-                                               // Occupation
-                                               id: 'P106'
-                                       },
-                                       {
-                                               // Employer(s)
-                                               id: 'P108'
-                                       },
-                                       {
-                                               // Religion
-                                               id: 'P140'
-                                       },
-                                       // FIXME: add awards?
-                                       {
-                                               // Signature
-                                               id: 'P109'
-                                       },
-                                       {
-                                               // Official website
-                                               id: 'P856'
-                                       }
-                               ]
-                       },
-                       default: {
-                               rows: [
-                                       {
-                                               // Official website
-                                               id: 'P856'
-                                       }
-                               ]
-                       }
-               },
+               typeDefaults: mw.config.get( 'wgMFInfoboxConfig' ),
                /**
                 * Given a title work out the url to the thumbnail for that 
image
                 * FIXME: This should not make its way into stable.
@@ -421,7 +148,8 @@
                        // work out what they all mean
                        return this.api.getExpandedItemsData( labelIds ).then( 
function ( labels ) {
                                // map the property id to the actual label.
-                               $.each( rows, function ( i, row ) {
+                               $.each( rows, function ( i, id ) {
+                                       var row = { id: id };
                                        row.label = labels[ row.id ];
                                        $.each( row.values, function ( j, value 
) {
                                                var item = labels[ value.id ];
diff --git a/javascripts/modules/wikigrok/untitled.php 
b/javascripts/modules/wikigrok/untitled.php
new file mode 100644
index 0000000..66a62f9
--- /dev/null
+++ b/javascripts/modules/wikigrok/untitled.php
@@ -0,0 +1,166 @@
+<?php
+
+$wgInfoboxConfig = array(
+                       // FIXME=> In future this should be configurable by 
Wikipedia admins
+                       // movie
+                       11424 => array(
+                               'rows' => array(
+                                               // Director
+                                               'P57',
+                                               // Produced by
+                                               'P162',
+                                               // Story by
+                                               'P58',
+                                               // Based on
+                                               'P144',
+                                               // Starring
+                                               'P161',
+                                               // Music by
+                                               'P86',
+                                               // Cinematography
+                                               'P344',
+                                               // Film editor
+                                               'P1040',
+                                               // Production company
+                                               'P272',
+                                               // Distributor
+                                               'P750',
+                                               // Released'
+                                               'P577',
+                                       // FIXME=> running time is not 
available on Wikidata
+                                               //Country of origin
+                                               'P495',
+                                               //Original language
+                                               'P364',
+                                       // FIXME=> budget is not available on 
Wikidata
+                                       // FIXME=> box office is not available 
on Wikidata
+                               ),
+                       ),
+                       16521=> array(
+                               'rows' => array(
+                                               // Conservation status
+                                               'P141',
+                                               // Genus
+                                               'P171',
+                                               // Species
+                                               'P225',
+                                               // Geographic distribution
+                                               'P181',
+                               ),
+                       ),
+                       // country
+                       6256=> array(
+                               'rows' => array(
+                                               // Flag
+                                               'P41',
+                                               // Coat of arms
+                                               'P94',
+                                       // FIXME=> add motto
+                                               // Anthem
+                                               'P85',
+                                               // Location
+                                               'P242',
+                                               // Languages
+                                               'P37',
+                                               // Capital
+                                               'P36',
+                                               // FIXME=> Add ethnic groups
+                                               // Basic form of government
+                                               'P122',
+                                               // Legislature
+                                               'P194',
+                                               // FIXME=> Add Area
+                                               // Population
+                                               'P1082',
+                                               // FIXME: Add GDP
+                                               // Currency
+                                               'P38',
+                                               // Timezone
+                                               'P421',
+                                               // FIXME=> add Date format
+                                               // FIXME=> add Drives on the 
(left/right)
+                                               // Country calling code
+                                               'P474',
+                                               // ISO 3166 code
+                                               'P297',
+                                               // Internet TLD
+                                               'P78',
+                               ),
+                       ),
+                       // city
+                       515 => array(
+                               'rows' => array(
+                                               // Flag
+                                               'P41',
+                                               // Coat of arms
+                                               'P94',
+                                               // Coordinates
+                                               'P625',
+                                               // State
+                                               'P131',
+                                               // Country
+                                               'P17',
+                                               // Founded
+                                               'P571',
+                                               // Population
+                                               'P1082',
+                                               // Timezone
+                                               'P421',
+                                               // Born
+                                               'P569',
+
+                               ),
+                       ),
+                       // human
+                       5=> array(
+                               'rows' => array(
+                                               // Born
+                                               'P569',
+                                               // Birthplace
+                                               'P19',
+                                               // Died
+                                               'P570',
+                                               // Place of death
+                                               'P20',
+                                               // Country of citizenship
+                                               'P27',
+                                       // FIXME=> Add political party
+                                               // Spouse(s)
+                                               'P26',
+                                               // Mother(s)
+                                               'P25',
+                                               // Father(s)
+                                               'P22',
+                                               //FIXME=> Add Stepfather(s) 
(P43) and step mothers?
+                                               // Sister(s)
+                                               'P9',
+                                               // Brother(s)
+                                               'P7',
+                                               // Child(ren)
+                                               'P40',
+                                               // FIXME=> add residence?
+                                               // Alma mater
+                                               'P69',
+                                               // Occupation
+                                               'P106',
+                                               // Employer(s)
+                                               'P108',
+                                               // Religion
+                                               'P140',
+                                               // FIXME=> add awards?
+                                               // Signature
+                                               'P109',
+                                               // Official website
+                                               'P856'
+
+                               ),
+                       ),
+                       default=> array(
+                               rows=> array(
+
+                                               // Official website
+                                               'P856'
+
+                               ),
+                       ),
+               );
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/181201
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If555a897e4743e93a968f6125c4b677d7bd0034a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

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

Reply via email to