Bmansurov has uploaded a new change for review.

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

Change subject: Simplify the modules
......................................................................

Simplify the modules

There is only one module now: mw.cards.

Bug: T117108
Change-Id: I6cc1b6e904f24a7d187ba86176b1a80a5577b3ef
---
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
12 files changed, 31 insertions(+), 64 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cards 
refs/changes/19/252919/1

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 4d7a652..cf8ceb6 100644
--- a/includes/Cards.hooks.php
+++ b/includes/Cards.hooks.php
@@ -30,10 +30,10 @@
 
                $testModules['qunit']['ext.cards.models.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 66%
rename from resources/views/CardList.js
rename to resources/CardListView.js
index a8bf9e8..b230e0e 100644
--- a/resources/views/CardList.js
+++ b/resources/CardListView.js
@@ -2,16 +2,16 @@
        '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
+        * @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 || [];
 
@@ -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 97%
rename from resources/models/Card.js
rename to resources/CardModel.js
index eea309f..2a67149 100644
--- a/resources/models/Card.js
+++ b/resources/CardModel.js
@@ -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 78%
rename from resources/views/Card.js
rename to resources/CardView.js
index a69d3bf..4ec8ebb 100644
--- a/resources/views/Card.js
+++ b/resources/CardView.js
@@ -5,11 +5,11 @@
         * Renders a Card model and updates when it does.
         *
         * @class
-        * @param {mw.cards.models.Card} model
+        * @param {mw.cards.CardModel} model
         */
        function CardView( model ) {
                /**
-                * @property {mw.cards.models.Card}
+                * @property {mw.cards.CardModel}
                 */
                this.model = model;
 
@@ -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..2da6c18 100644
--- a/resources/CardsGateway.js
+++ b/resources/CardsGateway.js
@@ -6,9 +6,9 @@
         * @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
@@ -40,7 +40,7 @@
         * @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: newchange
Gerrit-Change-Id: I6cc1b6e904f24a7d187ba86176b1a80a5577b3ef
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cards
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to