r114623 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114622‎ | r114623 | r114624 >
Date:01:26, 30 March 2012
Author:raindrift
Status:deferred (Comments)
Tags:
Comment:
added stuff to the article collection to allow specifying api parameters
fetch a list of namespaces from config for making a select list
Modified paths:
  • /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.listControlNav.js (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/SpecialPageTriage.php
@@ -176,7 +176,14 @@
177177 <span class="mwe-pt-control-label"><b><%= gM( 'pagetriage-filter-namespace-heading' ) %></b></span>
178178 <div class="mwe-pt-control-options">
179179 <select id="mwe-pt-filter-namespace">
180 - <option>(namespaces)</option>
 180+ <%
 181+ var wgFormattedNamespaces = mw.config.get( 'wgFormattedNamespaces' );
 182+ var nsOptions = '';
 183+ for ( var key in wgFormattedNamespaces ) {
 184+ nsOptions += String('<option value=' + String(key) + '>' + wgFormattedNamespaces[key] + '</option>');
 185+ }
 186+ print(nsOptions);
 187+ %>
181188 </select>
182189 </div>
183190 <span class="mwe-pt-control-label"><b><%= gM( 'pagetriage-filter-user-heading' ) %></b></span>
@@ -202,7 +209,7 @@
203210 </script>
204211
205212 <script type="text/template" id="listStatsNavTemplate">
206 - <% if ( ptrAverage ) { %> <%= gM( 'pagetriage-stats-untriaged-age', ptrAverage, ptrOldest ) %> <% } %>
 213+ stats navbar
207214 </script>
208215
209216 HTML;
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js
@@ -40,15 +40,13 @@
4141 // render and return the template. fill with the current model.
4242 $( "#mwe-pt-list-control-nav").html( this.template( this.model.toJSON() ) );
4343
 44+ // now that the template's been inserted, set up some events for controlling it
 45+
4446 // make a button
4547 $( ".mwe-pt-filter-set-button" ).button( {
4648 label: mw.msg( 'pagetriage-filter-set-button' ) + ' &#x25b8;'
4749 });
4850
49 -
50 -
51 - // now that the template's been inserted, set up some events for controlling it
52 -
5351 // the filter dropdown menu control
5452 $( '#mwe-pt-filter-dropdown-control' ).click( function( e ) {
5553 // close the meny when the user clicks away
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.models/ext.pageTriage.article.js
@@ -24,7 +24,7 @@
2525 } else {
2626 article.set( 'user_creation_date_pretty', '');
2727 }
28 -
 28+
2929 var userName = article.get( 'user_name' );
3030 if( userName ) {
3131 article.set( 'user_title', new mw.Title( userName, mw.config.get('wgNamespaceIds')['user'] ) );
@@ -41,7 +41,30 @@
4242 // object created therein.
4343 mw.pageTriage.ArticleList = Backbone.Collection.extend( {
4444 model: mw.pageTriage.Article,
45 - url: mw.util.wikiScript( 'api' ) + '?action=pagetriagelist&format=json',
 45+
 46+ apiParams: {
 47+ namespace: 0,
 48+ /*
 49+ showbots: null,
 50+ showredirs: null,
 51+ showtriaged: null,
 52+ limit: 10,
 53+ namespace: 0,
 54+ no_category: 1,
 55+ no_inbound_links: 1,
 56+ non_autoconfirmed_users: 1,
 57+ blocked_users: 1,
 58+ */
 59+ },
 60+
 61+ url: function() {
 62+ var paramString = '';
 63+ for ( var key in this.apiParams ) {
 64+ paramString += '&' + key + '=' + this.apiParams[key];
 65+ }
 66+ var url = mw.util.wikiScript( 'api' ) + '?action=pagetriagelist&format=json' + paramString;
 67+ return url;
 68+ },
4669
4770 parse: function( response ) {
4871 // extract the useful bits of json.

Follow-up revisions

RevisionCommit summaryAuthorDate
r114720use $.param(), per kaldari's comment....raindrift22:31, 4 April 2012

Comments

#Comment by Kaldari (talk | contribs)   00:56, 4 April 2012
 for ( var key in this.apiParams ) {
     paramString += '&' + key + '=' + this.apiParams[key];
 }

You can have jQuery do this for you:

paramString = $.param( this.apiParams );
#Comment by Raindrift (talk | contribs)   22:31, 4 April 2012

Thanks!

Status & tagging log