jenkins-bot has submitted this change and it was merged.
Change subject: Simplify the modules
......................................................................
Simplify the modules
There is only one module now: mw.cards.
Bug: T117108
Change-Id: I6cc1b6e904f24a7d187ba86176b1a80a5577b3ef
---
M Gruntfile.js
M extension.json
M includes/Cards.hooks.php
R resources/CardListView.js
R resources/CardModel.js
R resources/CardView.js
M resources/CardsGateway.js
R resources/card.hogan
R resources/cards.hogan
R resources/noimage.png
R resources/noimage.svg
R resources/styles.less
R tests/qunit/CardModel.js
13 files changed, 44 insertions(+), 75 deletions(-)
Approvals:
Phuedx: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Gruntfile.js b/Gruntfile.js
index d8ff958..670881c 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -40,7 +40,9 @@
title: 'Cards',
external: [
'mw.Api',
- 'jQuery.Deferred'
+ 'jQuery.Deferred',
+ 'jQuery',
+ 'OO.EventEmitter'
],
warnings: [
'-nodoc(class,public)',
diff --git a/extension.json b/extension.json
index cdf3d66..6e3789b 100644
--- a/extension.json
+++ b/extension.json
@@ -26,29 +26,7 @@
"remoteExtPath": "Cards"
},
"ResourceModules": {
- "ext.cards.init": {
- "targets": [
- "mobile"
- ],
- "group": "other",
- "scripts": [
- "resources/init.js"
- ]
- },
- "ext.cards.models": {
- "targets": [
- "mobile"
- ],
- "group": "other",
- "dependencies": [
- "oojs",
- "ext.cards.init"
- ],
- "scripts": [
- "resources/models/Card.js"
- ]
- },
- "ext.cards.views": {
+ "ext.cards": {
"targets": [
"mobile"
],
@@ -56,33 +34,22 @@
"dependencies": [
"oojs",
"mediawiki.Title",
- "mediawiki.template.hogan",
- "ext.cards.init"
+ "mediawiki.template.hogan"
],
"scripts": [
- "resources/views/Card.js",
- "resources/views/CardList.js"
+ "resources/init.js",
+ "resources/CardModel.js",
+ "resources/CardView.js",
+ "resources/CardListView.js",
+ "resources/CardsGateway.js"
],
"styles": [
- "resources/views/styles.less"
+ "resources/styles.less"
],
"templates": {
- "card.hogan": "resources/views/card.hogan",
- "cards.hogan": "resources/views/cards.hogan"
+ "card.hogan": "resources/card.hogan",
+ "cards.hogan": "resources/cards.hogan"
}
- },
- "ext.cards.gateway": {
- "targets": [
- "mobile"
- ],
- "group": "other",
- "dependencies": [
- "ext.cards.models",
- "ext.cards.views"
- ],
- "scripts": [
- "resources/CardsGateway.js"
- ]
}
},
"manifest_version": 1
diff --git a/includes/Cards.hooks.php b/includes/Cards.hooks.php
index 3daad43..1431d8e 100644
--- a/includes/Cards.hooks.php
+++ b/includes/Cards.hooks.php
@@ -28,12 +28,12 @@
'targets' => array( 'mobile' ),
);
- $testModules['qunit']['ext.cards.models.tests'] = array(
+ $testModules['qunit']['ext.cards.tests'] = array(
'dependencies' => array(
- 'ext.cards.models'
+ 'ext.cards'
),
'scripts' => array(
- 'models/Card.js'
+ 'CardModel.js'
)
) + $resourceFileModulePaths;
diff --git a/resources/views/CardList.js b/resources/CardListView.js
similarity index 61%
rename from resources/views/CardList.js
rename to resources/CardListView.js
index a8bf9e8..7a54cc1 100644
--- a/resources/views/CardList.js
+++ b/resources/CardListView.js
@@ -2,21 +2,21 @@
'use strict';
/**
- * View that renders multiple {@link mw.cards.views.Card cards}
+ * View that renders multiple {@link mw.cards.CardView cards}
*
- * @class
- * @param {mw.cards.views.Card[]} cardViews
+ * @class mw.cards.CardListView
+ * @param {mw.cards.CardView[]} cardViews
*/
function CardListView( cardViews ) {
var self = this;
/**
- * @property {mw.cards.views.Card[]|Array}
+ * @property {mw.cards.CardView[]|Array}
*/
this.cardViews = cardViews || [];
/**
- * @property {jQuery.Object}
+ * @property {jQuery}
*/
this.$el = $( this.template.render() );
@@ -31,7 +31,7 @@
/**
* @property {Object} compiled template
*/
- CardListView.prototype.template = mw.template.get( 'ext.cards.views',
'cards.hogan' );
+ CardListView.prototype.template = mw.template.get( 'ext.cards',
'cards.hogan' );
- mw.cards.views.CardList = CardListView;
+ mw.cards.CardListView = CardListView;
} )( jQuery );
diff --git a/resources/models/Card.js b/resources/CardModel.js
similarity index 93%
rename from resources/models/Card.js
rename to resources/CardModel.js
index 49fa84d..9008654 100644
--- a/resources/models/Card.js
+++ b/resources/CardModel.js
@@ -7,8 +7,8 @@
* of a wiki article. It emits a 'change' event when its attribute
changes.
* A View can listen to this event and update the UI accordingly.
*
- * @class
- * @inherits OO.EventEmitter
+ * @class mw.cards.CardModel
+ * @extends OO.EventEmitter
* @param {Object} attributes article data, such as title, url, etc.
about
* an article
*/
@@ -52,5 +52,5 @@
return this.attributes[ key ];
};
- mw.cards.models.Card = CardModel;
+ mw.cards.CardModel = CardModel;
} )();
diff --git a/resources/views/Card.js b/resources/CardView.js
similarity index 73%
rename from resources/views/Card.js
rename to resources/CardView.js
index a69d3bf..6519bf0 100644
--- a/resources/views/Card.js
+++ b/resources/CardView.js
@@ -4,12 +4,12 @@
/**
* Renders a Card model and updates when it does.
*
- * @class
- * @param {mw.cards.models.Card} model
+ * @class mw.cards.CardView
+ * @param {mw.cards.CardModel} model
*/
function CardView( model ) {
/**
- * @property {mw.cards.models.Card}
+ * @property {mw.cards.CardModel}
*/
this.model = model;
@@ -17,7 +17,7 @@
this.model.on( 'change', this.render.bind( this ) );
/**
- * @property {jQuery.Object}
+ * @property {jQuery}
*/
this.$el = $( this.template.render( this.model.attributes ) );
}
@@ -26,7 +26,7 @@
/**
* @property {Object} compiled template
*/
- CardView.prototype.template = mw.template.get( 'ext.cards.views',
'card.hogan' );
+ CardView.prototype.template = mw.template.get( 'ext.cards',
'card.hogan' );
/**
* Replace the html of this.$el with a newly rendered html using the
model
@@ -36,5 +36,5 @@
this.$el.replaceWith( this.template.render(
this.model.attributes ) );
};
- mw.cards.views.Card = CardView;
+ mw.cards.CardView = CardView;
} )( jQuery );
diff --git a/resources/CardsGateway.js b/resources/CardsGateway.js
index 2b2cdb3..e6ea45d 100644
--- a/resources/CardsGateway.js
+++ b/resources/CardsGateway.js
@@ -6,16 +6,16 @@
* @readonly
*/
var THUMB_WIDTH = 50,
- CardModel = mw.cards.models.Card,
- CardView = mw.cards.views.Card,
- CardListView = mw.cards.views.CardList;
+ CardModel = mw.cards.CardModel,
+ CardView = mw.cards.CardView,
+ CardListView = mw.cards.CardListView;
/**
* Gateway for interacting with an API
* It can be used to retrieve information about article(s). In the
future
* it can also be used to update that information in the server.
*
- * @class
+ * @class mw.cards.CardsGateway
* @param {Object} options
* @param {mw.Api} options.api an Api to use.
*/
@@ -27,20 +27,20 @@
/**
* Fetch information about articleTitles from the API
* How to use:
- * <code>
+ *
+ * @example
* var gateway = new mw.cards.CardsGateway( { api: new mw.Api() } );
*
* // '1' and '2' are page titles, while 200 is the desired
thumbnail width
* gateway.getCards( ['1', '2'], 200 ).done( function( cards ) {
* $( '#bodyContent' ).append( cards.$el );
* } );
- * </code>
*
* @param {String[]} articleTitles array of article titles
* @param {Number} [thumbWidth] Thumbnail width in pixels. Defaults to
* {@link THUMB_WIDTH}
* @return {jQuery.Deferred} the result resolves with a
- * {@link mw.cards.views.CardList card list}
+ * {@link mw.cards.CardListView card list}
*/
CardsGateway.prototype.getCards = function ( articleTitles, thumbWidth
) {
var article,
diff --git a/resources/views/card.hogan b/resources/card.hogan
similarity index 100%
rename from resources/views/card.hogan
rename to resources/card.hogan
diff --git a/resources/views/cards.hogan b/resources/cards.hogan
similarity index 100%
rename from resources/views/cards.hogan
rename to resources/cards.hogan
diff --git a/resources/views/noimage.png b/resources/noimage.png
similarity index 100%
rename from resources/views/noimage.png
rename to resources/noimage.png
Binary files differ
diff --git a/resources/views/noimage.svg b/resources/noimage.svg
similarity index 100%
rename from resources/views/noimage.svg
rename to resources/noimage.svg
diff --git a/resources/views/styles.less b/resources/styles.less
similarity index 100%
rename from resources/views/styles.less
rename to resources/styles.less
diff --git a/tests/qunit/models/Card.js b/tests/qunit/CardModel.js
similarity index 78%
rename from tests/qunit/models/Card.js
rename to tests/qunit/CardModel.js
index a6c14f1..e4e7c8e 100644
--- a/tests/qunit/models/Card.js
+++ b/tests/qunit/CardModel.js
@@ -1,12 +1,12 @@
( function () {
'use strict';
- var Card = mw.cards.models.Card;
+ var CardModel = mw.cards.CardModel;
- QUnit.module( 'ext.cards.models.Card' );
+ QUnit.module( 'ext.cards.CardModel' );
QUnit.test( '#set', 1, function ( assert ) {
- var model = new Card( {} );
+ var model = new CardModel( {} );
model.on( 'change', function ( attributes ) {
assert.strictEqual(
@@ -17,7 +17,7 @@
} );
model.set( 'foo', 'bar' );
- model = new Card( {} );
+ model = new CardModel( {} );
model.on( 'change', function () {
assert.ok( false, 'It doesn\'t emit an event when
silenced.' );
} );
@@ -26,7 +26,7 @@
} );
QUnit.test( '#get', 2, function ( assert ) {
- var model = new Card( {} );
+ var model = new CardModel( {} );
model.set( 'foo', 'bar' );
assert.strictEqual( model.get( 'foo' ), 'bar', 'Got the correct
value.' );
--
To view, visit https://gerrit.wikimedia.org/r/252919
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6cc1b6e904f24a7d187ba86176b1a80a5577b3ef
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Cards
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits