r114494 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114493‎ | r114494 | r114495 >
Date:21:14, 26 March 2012
Author:raindrift
Status:ok
Tags:
Comment:
fixed list view so it runs with debug=false too
Modified paths:
  • /trunk/extensions/PageTriage/PageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/SpecialPageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.js (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/SpecialPageTriage.php
@@ -57,10 +57,7 @@
5858 $out->setPageTitle( wfMessage( 'pagetriage' ) );
5959
6060 // load the JS
61 - $out->addModules( 'ext.pageTriage.init' );
62 - $out->addModules( 'ext.pageTriage.external' );
63 - $out->addModules( 'ext.pageTriage.models' );
64 - $out->addModules( 'ext.pageTriage.views' );
 61+ $out->addModules( array( 'ext.pageTriage.external', 'ext.pageTriage.models', 'ext.pageTriage.views' ) );
6562
6663 // This will hold the HTML for the triage interface
6764 $triageInterface = '';
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.articleListItem.js
@@ -1,103 +1,105 @@
2 -// view for the article list
 2+$( function() {
 3+ // view for the article list
34
45
5 -// TODO: find a way to insert these templates raw with RL instead of appending them to
6 -// the DOM with javascript later (which is lame)
 6+ // TODO: find a way to insert these templates raw with RL instead of appending them to
 7+ // the DOM with javascript later (which is lame)
78
8 -// This template is repeated many times for each element in list view
9 -// TODO there's some words in here which need to become wfMsg() calls
10 -$( "#backboneTemplates" ).append('<script type="text/template" id="listItemTemplate"> \
11 - <div class="mwe-pt-article-row"> \
12 - <div class="mwe-pt-status-icon"> \
13 - <% if ( afd_status == "1" || blp_prod_status == "1" || csd_status == "1" || prod_status == "1" ) { %> \
14 - [DEL] <!-- deleted --> \
15 - <% } else if ( patrol_status == "1" ) { %> \
16 - [PTR] <!-- patrolled --> \
17 - <% } else { %> \
18 - [NEW] <!-- not patrolled --> \
19 - <% } %> \
 9+ // This template is repeated many times for each element in list view
 10+ // TODO there's some words in here which need to become wfMsg() calls
 11+ $( "#backboneTemplates" ).append('<script type="text/template" id="listItemTemplate"> \
 12+ <div class="mwe-pt-article-row"> \
 13+ <div class="mwe-pt-status-icon"> \
 14+ <% if ( afd_status == "1" || blp_prod_status == "1" || csd_status == "1" || prod_status == "1" ) { %> \
 15+ [DEL] <!-- deleted --> \
 16+ <% } else if ( patrol_status == "1" ) { %> \
 17+ [PTR] <!-- patrolled --> \
 18+ <% } else { %> \
 19+ [NEW] <!-- not patrolled --> \
 20+ <% } %> \
 21+ </div> \
 22+ <div class="mwe-pt-info-pane"> \
 23+ <div> \
 24+ <span class="mwe-pt-page-title"><%= title %></span> \
 25+ <span class="mwe-pt-histlink">(hist)</span> \
 26+ <span class="mwe-pt-metadata"> \
 27+ &#xb7; \
 28+ bytes \
 29+ &#xb7; \
 30+ edits \
 31+ &#xb7; \
 32+ images \
 33+ &#xb7; \
 34+ categories \
 35+ </span> \
 36+ </div> \
 37+ <div class="mwe-pt-snippet"> \
 38+ <%= snippet %> \
 39+ </div> \
 40+ </div> \
2041 </div> \
21 - <div class="mwe-pt-info-pane"> \
22 - <div> \
23 - <span class="mwe-pt-page-title"><%= title %></span> \
24 - <span class="mwe-pt-histlink">(hist)</span> \
25 - <span class="mwe-pt-metadata"> \
26 - &#xb7; \
27 - bytes \
28 - &#xb7; \
29 - edits \
30 - &#xb7; \
31 - images \
32 - &#xb7; \
33 - categories \
34 - </span> \
35 - </div> \
36 - <div class="mwe-pt-snippet"> \
37 - <%= snippet %> \
38 - </div> \
39 - </div> \
40 - </div> \
41 - <br/> \
42 - </script>'
43 -);
 42+ <br/> \
 43+ </script>'
 44+ );
4445
45 -// instantiate the collection of articles
46 -var articles = new ArticleList;
 46+ // instantiate the collection of articles
 47+ var articles = new mw.pageTriage.ArticleList;
4748
48 -// single list item
49 -// TODO: move this into its own file?
50 -ListItem = Backbone.View.extend( {
51 - tagName: "div",
52 - template: _.template( $( "#listItemTemplate" ).html() ),
 49+ // single list item
 50+ // TODO: move this into its own file?
 51+ var ListItem = Backbone.View.extend( {
 52+ tagName: "div",
 53+ template: _.template( $( "#listItemTemplate" ).html() ),
5354
54 - // listen for changes to the model and re-render.
55 - initialize: function() {
56 - this.model.bind('change', this.render, this);
57 - this.model.bind('destroy', this.remove, this);
58 - },
 55+ // listen for changes to the model and re-render.
 56+ initialize: function() {
 57+ this.model.bind('change', this.render, this);
 58+ this.model.bind('destroy', this.remove, this);
 59+ },
5960
60 - render: function() {
61 - // insert the template into the document. fill with the current model.
62 - this.$el.html( this.template( this.model.toJSON() ) );
63 - return this;
64 - }
 61+ render: function() {
 62+ // insert the template into the document. fill with the current model.
 63+ this.$el.html( this.template( this.model.toJSON() ) );
 64+ return this;
 65+ }
6566
66 -} );
 67+ } );
6768
68 -// overall list view
69 -// currently, this is the main application view.
70 -ListView = Backbone.View.extend( {
 69+ // overall list view
 70+ // currently, this is the main application view.
 71+ var ListView = Backbone.View.extend( {
7172
72 - initialize: function() {
 73+ initialize: function() {
7374
74 - // these events are triggered when items are added to the articles collection
75 - articles.bind( 'add', this.addOne, this );
76 - articles.bind( 'reset', this.addAll, this );
 75+ // these events are triggered when items are added to the articles collection
 76+ articles.bind( 'add', this.addOne, this );
 77+ articles.bind( 'reset', this.addAll, this );
7778
78 - // this event is triggered when the collection finishes loading.
79 - articles.bind( 'all', this.render, this );
 79+ // this event is triggered when the collection finishes loading.
 80+ articles.bind( 'all', this.render, this );
8081
81 - // on init, make sure to load the contents of the collection.
82 - articles.fetch();
83 - },
 82+ // on init, make sure to load the contents of the collection.
 83+ articles.fetch();
 84+ },
8485
85 - render: function() {
86 - // TODO: refresh the view (show/hide the parts that aren't attached to the ListItem view)
87 - },
 86+ render: function() {
 87+ // TODO: refresh the view (show/hide the parts that aren't attached to the ListItem view)
 88+ },
8889
89 - // add a single article to the list
90 - addOne: function( article ) {
91 - // pass in the specific article instance
92 - var view = new ListItem( { model: article } );
93 - this.$( "#listView" ).append( view.render().el );
94 - },
 90+ // add a single article to the list
 91+ addOne: function( article ) {
 92+ // pass in the specific article instance
 93+ var view = new ListItem( { model: article } );
 94+ this.$( "#listView" ).append( view.render().el );
 95+ },
9596
96 - // add all the items in the articles collection
97 - addAll: function() {
98 - $("#listView").empty(); // remove the spinner before displaying.
99 - articles.each( this.addOne );
100 - }
 97+ // add all the items in the articles collection
 98+ addAll: function() {
 99+ $("#listView").empty(); // remove the spinner before displaying.
 100+ articles.each( this.addOne );
 101+ }
101102
 103+ } );
 104+
 105+ var list = new ListView();
102106 } );
103 -
104 -var list = new ListView();
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js
@@ -1,13 +1,18 @@
2 - var Article = Backbone.Model.extend( {
3 - defaults: {
4 - title: 'Empty Article',
5 - pageid: ''
6 - },
 2+$( function() {
 3+ mw.pageTriage = {
 4+ Article: Backbone.Model.extend( {
 5+ defaults: {
 6+ title: 'Empty Article',
 7+ pageid: ''
 8+ },
79
8 - } );
9 -
10 - var ArticleList = Backbone.Collection.extend( {
11 - model: Article,
 10+ } ),
 11+ };
 12+
 13+ // can't include this in the declaration above because it references the
 14+ // object created therein.
 15+ mw.pageTriage.ArticleList = Backbone.Collection.extend( {
 16+ model: mw.pageTriage.Article,
1217 url: '/w/api.php?action=pagetriagelist&format=json',
1318
1419 parse: function( response ) {
@@ -16,4 +21,4 @@
1722 }
1823
1924 } );
20 -
 25+} );
Index: trunk/extensions/PageTriage/PageTriage.php
@@ -133,13 +133,18 @@
134134 'ext.pageTriage.external'
135135 ),
136136 'scripts' => array(
137 - 'ext.pageTriage.models/ext.pageTriage.article.js'
 137+ 'ext.pageTriage.models/ext.pageTriage.article.js',
 138+ 'ext.pageTriage.views/ext.pageTriage.articleListItem.js'
 139+ ),
 140+ 'styles' => array(
 141+ 'ext.pageTriage.views/ext.pageTriage.articleListItem.css'
138142 )
139143 );
140144
 145+/*
141146 $wgResourceModules['ext.pageTriage.views'] = $ptResourceTemplate + array(
142147 'dependencies' => array(
143 - 'ext.pageTriage.models',
 148+ 'ext.pageTriage.models'
144149 ),
145150 'scripts' => array(
146151 'ext.pageTriage.views/ext.pageTriage.articleListItem.js'
@@ -148,6 +153,7 @@
149154 'ext.pageTriage.views/ext.pageTriage.articleListItem.css'
150155 )
151156 );
 157+*/
152158
153159 $wgResourceModules['ext.pageTriage.article'] = $ptResourceTemplate + array(
154160 'styles' => 'ext.pageTriage.article/ext.pageTriage.article.css',

Status & tagging log