Anomie has uploaded a new change for review.

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

Change subject: Update for core API changes
......................................................................

Update for core API changes

Core change Ib14c00df alters the output of action=paraminfo in ways that
need corresponding changes here for documentation to be properly fetched
and output.

This does the minimum necessary to keep ApiSandbox functioning; there
are further core changes both merged and upcoming that would allow more
enhancements to ApiSandbox (e.g. actually working for action=flow,
automatic token fetching, and so on), but actually doing so would take a
more comprehensive rewrite than I want to take on at this time.

Change-Id: I1028f56d7a92e0adcd4544f9624c270fa0e5e8af
---
M resources/main.js
1 file changed, 6 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ApiSandbox 
refs/changes/00/160800/1

diff --git a/resources/main.js b/resources/main.js
index 458b0a3..45da2d0 100644
--- a/resources/main.js
+++ b/resources/main.js
@@ -112,6 +112,7 @@
                        loadCallback();
                        needed.format = 'json';
                        needed.action = 'paraminfo';
+                       needed.helpformat = 'wikitext';
                        $.getJSON(
                                mw.util.wikiScript( 'api' ),
                                needed,
@@ -144,14 +145,10 @@
                                                        // We request more 
values than we can, but we have some of them cached now.
                                                        // Call getParamInfo() 
again, which will fire the same request with them skipped.
                                                        getParamInfo( what, 
loadCallback, completeCallback, errorCallback );
-                                               } else {
-                                                       // Some other warning, 
let's bail.
-                                                       errorCallback();
                                                        return;
                                                }
-                                       } else {
-                                               completeCallback();
                                        }
+                                       completeCallback();
                                }
                        ).error( errorCallback );
                }
@@ -315,39 +312,16 @@
                var i, $list, urlRegex, count, href, text, match, prefix, 
$prefix, linkText;
 
                $.each( info, function ( action, actionInfo ) {
-                       if ( actionInfo.allexamples === undefined ) {
+                       if ( actionInfo.examples === undefined ) {
                                return;
                        }
                        var $actionExamplesContent = $( 
'#api-sandbox-examples-' + action );
-                       // on 1.18, convert everything into 1.19 format
-                       if ( actionInfo.allexamples.length > 0 && typeof 
actionInfo.allexamples[0] === 'string' ) {
-                               for ( i = 0; i < actionInfo.allexamples.length; 
i++ ) {
-                                       actionInfo.allexamples[i] = { '*': 
actionInfo.allexamples[i] };
-                               }
-                       }
                        $actionExamplesContent.hide().html( '' );
                        $list = $( '<ul>' );
-                       urlRegex = /api.php\?\S+/m;
                        count = 0;
-                       for ( i = 0; i < actionInfo.allexamples.length; i++ ) {
-                               href = '';
-                               text = '';
-                               while ( i < actionInfo.allexamples.length && 
actionInfo.allexamples[i].description === undefined ) {
-                                       match = urlRegex.exec( 
actionInfo.allexamples[i]['*'] );
-                                       if ( match ) {
-                                               href = match[0];
-                                               break;
-                                       } else {
-                                               text += '\n' + 
actionInfo.allexamples[i]['*'];
-                                       }
-                                       i++;
-                               }
-                               if ( !href ) {
-                                       href = actionInfo.allexamples[i]['*'];
-                               }
-                               if ( !text ) {
-                                       text = 
actionInfo.allexamples[i].description !== undefined ? 
actionInfo.allexamples[i].description : href;
-                               }
+                       for ( i = 0; i < actionInfo.examples.length; i++ ) {
+                               href = actionInfo.examples[i].query;
+                               text = actionInfo.examples[i].description !== 
'' ? actionInfo.examples[i].description : href;
                                prefix = text.replace( /[^\n]*$/, '' );
                                $prefix = prefix.length ? $( '<b>' ).text( 
prefix ) : [];
                                linkText = text.replace( /^.*\n/, '' );

-- 
To view, visit https://gerrit.wikimedia.org/r/160800
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1028f56d7a92e0adcd4544f9624c270fa0e5e8af
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ApiSandbox
Gerrit-Branch: master
Gerrit-Owner: Anomie <bjor...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to