Jhobs has uploaded a new change for review.
https://gerrit.wikimedia.org/r/253054
Change subject: [Hygiene] Rename internal uses of "article" to "page"
......................................................................
[Hygiene] Rename internal uses of "article" to "page"
Leave all public-facing uses of "article" (including classes) because
the extension is remaining named RelatedArticles. Replace all other
instances with "page" for consistency with other extensions.
Bug: T117908
Change-Id: Ib0f258f26b0d11cfe8a598dbd90ff37afbbe36ac
---
M includes/Hooks.php
M resources/ext.relatedArticles.readMore.bootstrap/index.js
M resources/ext.relatedArticles.readMore.minerva/eventLogging.js
M resources/ext.relatedArticles.readMore/RelatedPagesGateway.js
M tests/phpunit/HooksTest.php
M tests/qunit/ext.relatedArticles.readMore/test_RelatedPagesGateway.js
6 files changed, 66 insertions(+), 66 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RelatedArticles
refs/changes/54/253054/1
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 714df5a..49fde85 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -44,19 +44,19 @@
*/
public static function onFuncRelated( Parser $parser ) {
$parserOutput = $parser->getOutput();
- $relatedArticles = $parserOutput->getExtensionData(
'RelatedArticles' );
- if ( !$relatedArticles ) {
- $relatedArticles = array();
+ $relatedPages = $parserOutput->getExtensionData(
'RelatedArticles' );
+ if ( !$relatedPages ) {
+ $relatedPages = array();
}
$args = func_get_args();
array_shift( $args );
- // Add all the related articles passed by the parser function
+ // Add all the related pages passed by the parser function
// {{#related:Test with read more|Foo|Bar}}
- foreach ( $args as $relatedArticle ) {
- $relatedArticles[] = $relatedArticle;
+ foreach ( $args as $relatedPage ) {
+ $relatedPages[] = $relatedPage;
}
- $parserOutput->setExtensionData( 'RelatedArticles',
$relatedArticles );
+ $parserOutput->setExtensionData( 'RelatedArticles',
$relatedPages );
return '';
}
@@ -64,7 +64,7 @@
/**
* Handler for the <code>ParserClearState</code> hook.
*
- * Empties the internal list so that related articles are not passed on
to future
+ * Empties the internal list so that related pages are not passed on to
future
* ParserOutput's - note that {{#related:Foo}} appends and can be used
multiple times
* in the page.
*
@@ -83,10 +83,10 @@
}
/**
- * Passes the related articles list from the cached parser output
+ * Passes the related pages list from the cached parser output
* object to the output page for rendering.
*
- * The list of related articles will be retrieved using
+ * The list of related pages will be retrieved using
* <code>ParserOutput#getExtensionData</code>.
*
* @param OutputPage $out
@@ -104,37 +104,37 @@
}
/**
- * Generates anchor element attributes for each entry in list of
articles.
+ * Generates anchor element attributes for each entry in list of pages.
*
* The attributes that are generated are: <code>href</code>,
* <code>text</code>, and <code>class</code>, with the latter always
* set to <code>"interwiki-relart"</code>.
*
- * If the the article is of the form <code>"Foo && Bar"</code>, then
+ * If the the page is of the form <code>"Foo && Bar"</code>, then
* the <code>text</code> attribute will be set to "Bar", otherwise the
- * article's {@see Title::getPrefixedText prefixed text} will be used.
+ * page's {@see Title::getPrefixedText prefixed text} will be used.
*
- * @param array[string] $relatedArticles
+ * @param array[string] $relatedPages
* @return array An array of maps, each with <code>href</code>,
* <code>text</code>, and <code>class</code> entries.
*/
- private static function getRelatedArticlesUrls( array $relatedArticles
) {
- $relatedArticlesUrls = array();
+ private static function getRelatedPagesUrls( array $relatedPages ) {
+ $relatedPagesUrls = array();
- foreach ( $relatedArticles as $article ) {
+ foreach ( $relatedPages as $page ) {
// Tribute to Evan
- $article = urldecode( $article );
+ $page = urldecode( $page );
$altText = '';
- if ( preg_match( '/\&\&/', $article ) ) {
- $parts = array_map( 'trim', explode( '&&',
$article, 2 ) );
- $article = $parts[0];
+ if ( preg_match( '/\&\&/', $page ) ) {
+ $parts = array_map( 'trim', explode( '&&',
$page, 2 ) );
+ $page = $parts[0];
$altText = $parts[1];
}
- $title = Title::newFromText( $article );
+ $title = Title::newFromText( $page );
if ( $title ) {
- $relatedArticlesUrls[] = array(
+ $relatedPagesUrls[] = array(
'href' => $title->getLocalURL(),
'text' => $altText ?:
$title->getPrefixedText(),
'class' => 'interwiki-relart'
@@ -142,13 +142,13 @@
}
};
- return $relatedArticlesUrls;
+ return $relatedPagesUrls;
}
/**
* Handler for the <code>SkinBuildSidebar</code> hook.
*
- * Retrieves the list of related articles
+ * Retrieves the list of related pages
* and adds its HTML representation to the sidebar.
*
* @param Skin $skin
@@ -157,18 +157,18 @@
*/
public static function onSkinBuildSidebar( Skin $skin, &$bar ) {
$out = $skin->getOutput();
- $relatedArticles = $out->getProperty( 'RelatedArticles' );
+ $relatedPages = $out->getProperty( 'RelatedArticles' );
- if ( !$relatedArticles ) {
+ if ( !$relatedPages ) {
return true;
}
- $relatedArticlesUrls = self::getRelatedArticlesUrls(
$relatedArticles );
+ $relatedPagesUrls = self::getRelatedPagesUrls( $relatedPages );
// build relatedarticles <li>'s
- $relatedArticles = array();
- foreach ( (array) $relatedArticlesUrls as $url ) {
- $relatedArticles[] =
+ $relatedPages = array();
+ foreach ( (array) $relatedPagesUrls as $url ) {
+ $relatedPages[] =
Html::rawElement( 'li', array( 'class' =>
htmlspecialchars( $url['class'] ) ),
Html::element( 'a', array( 'href' =>
htmlspecialchars( $url['href'] ) ),
$url['text']
@@ -179,7 +179,7 @@
// build complete html
$bar[$skin->msg( 'relatedarticles-title' )->text()] =
Html::rawElement( 'ul', array(),
- implode( '', $relatedArticles )
+ implode( '', $relatedPages )
);
return true;
@@ -188,25 +188,25 @@
/**
* Handler for the <code>SkinTemplateToolboxEnd</code> hook.
*
- * Retrieves the list of related articles from the template and
+ * Retrieves the list of related pages from the template and
* <code>echo</code>s its HTML representation to the sidebar.
*
* @param SkinTemplate $skinTpl
* @return boolean Always <code>true</code>
*/
public static function onSkinTemplateToolboxEnd( BaseTemplate &$skinTpl
) {
- $relatedArticles =
$skinTpl->getSkin()->getOutput()->getProperty( 'RelatedArticles' );
+ $relatedPages = $skinTpl->getSkin()->getOutput()->getProperty(
'RelatedArticles' );
- if ( !$relatedArticles ) {
+ if ( !$relatedPages ) {
return true;
}
- $relatedArticlesUrls = self::getRelatedArticlesUrls(
$relatedArticles );
+ $relatedPagesUrls = self::getRelatedPagesUrls( $relatedPages );
// build relatedarticles <li>'s
- $relatedArticles = array();
- foreach ( (array) $relatedArticlesUrls as $url ) {
- $relatedArticles[] =
+ $relatedPages = array();
+ foreach ( (array) $relatedPagesUrls as $url ) {
+ $relatedPages[] =
Html::rawElement( 'li', array( 'class' =>
htmlspecialchars( $url['class'] ) ),
Html::element( 'a', array( 'href' =>
htmlspecialchars( $url['href'] ) ),
$url['text']
@@ -227,7 +227,7 @@
Html::element( 'h3', array(), wfMessage(
'relatedarticles-title' )->text() ) .
Html::openElement( 'div', array( 'class' => 'body' ) ) .
Html::openElement( 'ul' ) .
- implode( '', $relatedArticles );
+ implode( '', $relatedPages );
return true;
}
diff --git a/resources/ext.relatedArticles.readMore.bootstrap/index.js
b/resources/ext.relatedArticles.readMore.bootstrap/index.js
index 32eea38..dd936ed 100644
--- a/resources/ext.relatedArticles.readMore.bootstrap/index.js
+++ b/resources/ext.relatedArticles.readMore.bootstrap/index.js
@@ -1,7 +1,7 @@
( function ( $ ) {
var config = mw.config.get( [ 'skin', 'wgNamespaceNumber', 'wgMFMode',
'wgIsMainPage' ] ),
- relatedPages = new mw.relatedArticles.RelatedPagesGateway(
+ relatedPages = new mw.relatedPages.RelatedPagesGateway(
new mw.Api(),
mw.config.get( 'wgPageName' ),
mw.config.get( 'wgRelatedArticles' ),
diff --git a/resources/ext.relatedArticles.readMore.minerva/eventLogging.js
b/resources/ext.relatedArticles.readMore.minerva/eventLogging.js
index 8dc048e..58f4b11 100644
--- a/resources/ext.relatedArticles.readMore.minerva/eventLogging.js
+++ b/resources/ext.relatedArticles.readMore.minerva/eventLogging.js
@@ -1,7 +1,7 @@
// See https://meta.wikimedia.org/wiki/Schema:RelatedArticles
( function ( $ ) {
var $readMore,
- schemaRelatedArticles,
+ schemaRelatedPages,
skin = mw.config.get( 'skin' ),
$window = $( window );
@@ -34,12 +34,12 @@
function logReadMoreSeen() {
if ( isElementInViewport( $readMore ) ) {
$window.off( 'scroll', logReadMoreSeen );
- schemaRelatedArticles.log( { eventName: 'seen' } );
+ schemaRelatedPages.log( { eventName: 'seen' } );
}
}
mw.trackSubscribe( 'ext.relatedArticles.logReady', function ( _, data )
{
- schemaRelatedArticles = new mw.eventLog.Schema(
+ schemaRelatedPages = new mw.eventLog.Schema(
'RelatedArticles',
// not sampled if the config variable is not set
mw.config.get( 'wgRelatedArticlesLoggingSamplingRate',
0 ),
@@ -56,7 +56,7 @@
$readMore = data.$readMore;
// log ready
- schemaRelatedArticles.log( { eventName: 'ready' } );
+ schemaRelatedPages.log( { eventName: 'ready' } );
// log when ReadMore is seen by the user
$window.on(
@@ -70,7 +70,7 @@
$readMore.on( 'click', 'a', function () {
var index = $( this ).parents( 'li' ).index();
- schemaRelatedArticles.log( {
+ schemaRelatedPages.log( {
eventName: 'clicked',
clickIndex: index + 1
} );
diff --git a/resources/ext.relatedArticles.readMore/RelatedPagesGateway.js
b/resources/ext.relatedArticles.readMore/RelatedPagesGateway.js
index 0eb2d9e..6008c64 100644
--- a/resources/ext.relatedArticles.readMore/RelatedPagesGateway.js
+++ b/resources/ext.relatedArticles.readMore/RelatedPagesGateway.js
@@ -1,20 +1,20 @@
( function ( $ ) {
// FIXME: Move into separate file as this module becomes larger.
- mw.relatedArticles = {};
+ mw.relatedPages = {};
/**
* @class RelatedPagesGateway
* @param {mw.Api} api
- * @param {string} currentPage the page that the editorCuratedArticles
relate to
- * @param {Array} editorCuratedArticles a list of articles curated by
editors for the current page
- * @param {boolean} useCirrusSearch whether to hit the API when no
editor-curated articles are available
- * @param {boolean} [onlyUseCirrusSearch=false] whether to ignore the
list of editor-curated articles
+ * @param {string} currentPage the page that the editorCuratedPages
relate to
+ * @param {Array} editorCuratedPages a list of pages curated by editors
for the current page
+ * @param {boolean} useCirrusSearch whether to hit the API when no
editor-curated pages are available
+ * @param {boolean} [onlyUseCirrusSearch=false] whether to ignore the
list of editor-curated pages
*/
function RelatedPagesGateway(
api,
currentPage,
- editorCuratedArticles,
+ editorCuratedPages,
useCirrusSearch,
onlyUseCirrusSearch
) {
@@ -23,10 +23,10 @@
this.useCirrusSearch = useCirrusSearch;
if ( onlyUseCirrusSearch ) {
- editorCuratedArticles = [];
+ editorCuratedPages = [];
}
- this.editorCuratedArticles = editorCuratedArticles || [];
+ this.editorCuratedPages = editorCuratedPages || [];
}
OO.initClass( RelatedPagesGateway );
@@ -50,7 +50,7 @@
* * The Wikidata description, if any
*
* @method
- * @param {number} limit of articles to get
+ * @param {number} limit of pages to get
* @return {jQuery.Promise}
*/
RelatedPagesGateway.prototype.getForCurrentPage = function ( limit ) {
@@ -62,13 +62,13 @@
pithumbsize: 80,
wbptterms: 'description'
},
- relatedArticles = ( this.editorCuratedArticles ).slice(
0, limit );
+ relatedPages = ( this.editorCuratedPages ).slice( 0,
limit );
- if ( relatedArticles.length ) {
- parameters.pilimit = relatedArticles.length;
+ if ( relatedPages.length ) {
+ parameters.pilimit = relatedPages.length;
parameters[ 'continue' ] = ''; // jscs:ignore
requireDotNotation
- parameters.titles = relatedArticles;
+ parameters.titles = relatedPages;
} else if ( this.useCirrusSearch ) {
parameters.pilimit = limit;
@@ -117,5 +117,5 @@
} );
}
- mw.relatedArticles.RelatedPagesGateway = RelatedPagesGateway;
+ mw.relatedPages.RelatedPagesGateway = RelatedPagesGateway;
}( jQuery ) );
diff --git a/tests/phpunit/HooksTest.php b/tests/phpunit/HooksTest.php
index f3331b7..d34e9d3 100644
--- a/tests/phpunit/HooksTest.php
+++ b/tests/phpunit/HooksTest.php
@@ -12,23 +12,23 @@
public function test_onParserClearState() {
$parser = new Parser();
$parserOutput = $parser->mOutput = new ParserOutput();
- $relatedArticles = array( 'Maybeshewill' );
+ $relatedPages = array( 'Maybeshewill' );
- $parserOutput->setExtensionData( 'RelatedArticles',
$relatedArticles );
- $parserOutput->setProperty( 'RelatedArticles', $relatedArticles
);
+ $parserOutput->setExtensionData( 'RelatedArticles',
$relatedPages );
+ $parserOutput->setProperty( 'RelatedArticles', $relatedPages );
Hooks::onParserClearState( $parser );
$this->assertEquals(
array(),
$parserOutput->getExtensionData( 'RelatedArticles' ),
- 'It clears the list of related articles.'
+ 'It clears the list of related pages.'
);
$this->assertEquals(
false,
$parserOutput->getProperty( 'RelatedArticles' ),
- '[T115698] It unsets the list of related articles that
were set as a property.'
+ '[T115698] It unsets the list of related pages that
were set as a property.'
);
}
}
diff --git
a/tests/qunit/ext.relatedArticles.readMore/test_RelatedPagesGateway.js
b/tests/qunit/ext.relatedArticles.readMore/test_RelatedPagesGateway.js
index ea49d08..5f39240 100644
--- a/tests/qunit/ext.relatedArticles.readMore/test_RelatedPagesGateway.js
+++ b/tests/qunit/ext.relatedArticles.readMore/test_RelatedPagesGateway.js
@@ -1,5 +1,5 @@
( function ( M, $ ) {
- var RelatedPagesGateway = mw.relatedArticles.RelatedPagesGateway,
+ var RelatedPagesGateway = mw.relatedPages.RelatedPagesGateway,
relatedPages = {
query: {
pages: {
--
To view, visit https://gerrit.wikimedia.org/r/253054
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib0f258f26b0d11cfe8a598dbd90ff37afbbe36ac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/RelatedArticles
Gerrit-Branch: dev
Gerrit-Owner: Jhobs <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits