Jdlrobson has uploaded a new change for review. https://gerrit.wikimedia.org/r/219490
Change subject: Hygiene: Add API support for obtaining content sans lead section ...................................................................... Hygiene: Add API support for obtaining content sans lead section Needed to enable us to only serve the lead section Change-Id: I85f3321194073089d8833ef9baf04452190ff608 --- M includes/api/ApiMobileView.php M resources/mobile.startup/PageApi.js 2 files changed, 11 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/90/219490/1 diff --git a/includes/api/ApiMobileView.php b/includes/api/ApiMobileView.php index ffce1c0..011cfc5 100644 --- a/includes/api/ApiMobileView.php +++ b/includes/api/ApiMobileView.php @@ -356,7 +356,10 @@ $sectionCount = count( $data['sections'] ); if ( $str === 'all' ) { return range( 0, $sectionCount ); + } elseif ( $str === 'allbutlead' ) { + return array_slice( range( 0, $sectionCount ), 1, null, true ); } + $sections = array_map( 'trim', explode( '|', $str ) ); $ret = array(); foreach ( $sections as $sec ) { diff --git a/resources/mobile.startup/PageApi.js b/resources/mobile.startup/PageApi.js index f9f39f7..2f46fdb 100644 --- a/resources/mobile.startup/PageApi.js +++ b/resources/mobile.startup/PageApi.js @@ -100,10 +100,12 @@ * @method * @param {String} title the title of the page to be retrieved * @param {String} endpoint an alternative api url to retrieve the page from - * @param {Boolean} leadOnly When set only the lead section content is returned + * @param {String} sections keyword for sections api. Defaults to 'all' + * @param {Number} [cacheTime] to apply caching, defaults to no caching + * @param {String} [revisionid] the page's revisionid * @return {jQuery.Deferred} with parameter page data that can be passed to a Page view */ - getPage: function ( title, endpoint, leadOnly ) { + getPage: function ( title, endpoint, sections, cacheTime, revisionid ) { var page, timestamp, options = endpoint ? { url: endpoint, @@ -118,13 +120,16 @@ this.get( { action: 'mobileview', page: title, + revisionid: revisionid || '', // Invalid API parameter, used for caching purposes + smaxage: cacheTime || 0, + maxage: cacheTime || 0, variant: mw.config.get( 'wgPreferredVariant' ), redirect: 'yes', prop: 'id|sections|text|lastmodified|lastmodifiedby|languagecount|hasvariants|protection|displaytitle|revision', noheadings: 'yes', noimages: mw.config.get( 'wgImagesDisabled', false ) ? 1 : undefined, sectionprop: 'level|line|anchor', - sections: leadOnly ? 0 : 'all' + sections: sections ? sections : 'all' }, options ).done( function ( resp ) { var sections, lastModified, resolveObj, mv; -- To view, visit https://gerrit.wikimedia.org/r/219490 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I85f3321194073089d8833ef9baf04452190ff608 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