r64201 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64200‎ | r64201 | r64202 >
Date:00:30, 26 March 2010
Author:neilk
Status:deferred
Tags:
Comment:
Fixed issue with not getting new URL post rename
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/UploadWizard/mw.UploadWizard.js
@@ -47,7 +47,7 @@
4848 "mwe-upwiz-other-prefill": "Free wikitext field",
4949 "mwe-upwiz-showall": "show all",
5050 "mwe-upwiz-source": "Source",
51 - "mwe-upwiz-macro-edit-intro": "Please add some descriptions and other information to your uploads, and then press 'Update descriptions'",
 51+ "mwe-upwiz-macro-edit-intro": "Please add some descriptions and other information to your uploads, and then press 'Update descriptions'.",
5252 "mwe-upwiz-macro-edit": "Update descriptions",
5353 "mwe-upwiz-thanks-intro": "Thanks for uploading your works! You can now use your files on a Wikipedia article or link to them from elsewhere on the web.",
5454 "mwe-upwiz-thanks-link": "This file is now available at <b><tt>$1</tt></b>.",
@@ -1365,7 +1365,7 @@
13661366 // check descriptions
13671367 // the filename is in a sane state
13681368 var desiredFilename = "File:" + $j( _this.filenameInput ).val();
1369 - shouldRename = (desiredFilename != _this.upload.title);
 1369+ shouldRename = ( desiredFilename != _this.upload.title );
13701370
13711371 // if ok to go
13721372 // XXX lock down the interface, spinnerify
@@ -1379,30 +1379,33 @@
13801380
13811381 var params = {
13821382 action: 'edit',
1383 - token: mw.getConfig('token'),
 1383+ token: mw.getConfig( 'token' ),
13841384 title: _this.upload.title,
13851385 // section: 0, ?? causing issues?
13861386 text: wikiText,
13871387 summary: "User edited page with " + mw.UploadWizard.userAgent,
13881388 // notminor: 1,
1389 - // basetimestamp: _this.upload.imageinfo.timestamp, (conflicts?)
 1389+ // basetimestamp: _this.upload.imageinfo.timestamp, ( conflicts? )
13901390 nocreate: 1
13911391 };
1392 - mw.log("editing!");
1393 - mw.log(params);
1394 - var callback = function(result) {
1395 - mw.log(result);
1396 - mw.log("successful edit");
 1392+
 1393+ var endCallback = function() { _this.completeDetailsSubmission(); }
 1394+
 1395+ mw.log( "editing!" );
 1396+ mw.log( params );
 1397+ var callback = function( result ) {
 1398+ mw.log( result );
 1399+ mw.log( "successful edit" );
13971400 if ( shouldRename ) {
1398 - _this.rename( desiredFilename );
 1401+ _this.rename( desiredFilename, endCallback );
13991402 } else {
1400 - _this.completeDetailsSubmission();
 1403+ endCallback();
14011404 }
14021405 }
14031406
14041407 _this.upload.state = 'submitting-details';
14051408 _this.showProgress();
1406 - mw.getJSON(params, callback);
 1409+ mw.getJSON( params, callback );
14071410 },
14081411
14091412 /**
@@ -1417,7 +1420,7 @@
14181421 *
14191422 * @param filename to rename this file to
14201423 */
1421 - rename: function( title ) {
 1424+ rename: function( title, endCallback ) {
14221425 var _this = this;
14231426 mw.log("renaming!");
14241427 params = {
@@ -1435,30 +1438,65 @@
14361439 // handle errors later
14371440 // possible error data: { code = 'missingtitle' } -- orig filename not there
14381441 // and many more
1439 -
 1442+
 1443+ // which should match our request.
 1444+ // we should update the current upload filename
 1445+ // then call the uploadwizard with our progress
 1446+
14401447 // success is
14411448 // { move = { from : ..., reason : ..., redirectcreated : ..., to : .... }
14421449 if (data !== undefined && data.move !== undefined && data.move.to !== undefined) {
14431450 _this.upload.title = data.move.to;
 1451+ _this.refreshImageInfo( _this.upload, _this.upload.title, endCallback );
14441452 }
 1453+ } );
 1454+ },
14451455
1446 - // which should match our request.
1447 - // we should update the current upload filename
1448 - // then call the uploadwizard with our progress
1449 - _this.completeDetailsSubmission();
 1456+ /**
 1457+ * Get new image info, for instance, after we renamed an image
 1458+ * XXX this is very similar to getThumbnail
 1459+ * XXX ought to be a method on upload instead
 1460+ *
 1461+ * @param upload an UploadWizardUpload object
 1462+ * @param title title to look up remotely
 1463+ * @param endCallback execute upon completion
 1464+ */
 1465+ refreshImageInfo: function( upload, title, endCallback ) {
 1466+ var params = {
 1467+ 'titles': title,
 1468+ 'prop': 'imageinfo',
 1469+ 'iiprop': 'timestamp|url|user|size|sha1|mime|metadata'
 1470+ };
 1471+ // XXX timeout callback?
 1472+ mw.getJSON( params, function( data ) {
 1473+ if ( data && data.query && data.query.pages ) {
 1474+ if ( ! data.query.pages[-1] ) {
 1475+ for ( var page_id in data.query.pages ) {
 1476+ var page = data.query.pages[ page_id ];
 1477+ if ( ! page.imageinfo ) {
 1478+ // not found? error
 1479+ } else {
 1480+ upload.imageinfo = page.imageinfo[0];
 1481+ }
 1482+ }
 1483+ }
 1484+ }
 1485+ endCallback();
14501486 } );
14511487 },
14521488
14531489 showProgress: function() {
14541490 var _this = this;
1455 - _this.div.css( { background: 'grey' } );
 1491+ _this.div.disableInputsFade();
 1492+ // XXX spinnerize
14561493 _this.upload.detailsProgress = 1.0;
14571494 },
14581495
14591496 completeDetailsSubmission: function() {
14601497 var _this = this;
14611498 _this.upload.state = 'complete';
1462 - _this.div.css( { background: 'white' } );
 1499+ // XXX de-spinnerize
 1500+ _this.div.enableInputsFade();
14631501 },
14641502
14651503 /**
@@ -1561,8 +1599,8 @@
15621600
15631601
15641602 + '<div id="mwe-upwiz-content">'
1565 - + '<div id="mwe-upwiz-tabdiv-file">'
1566 - + '<div id="mwe-upwiz-intro">' + gM('mwe-upwiz-intro') + '</div>'
 1603+ + '<div id="mwe-upwiz-tabdiv-file">'
 1604+ + '<div id="mwe-upwiz-intro">' + gM('mwe-upwiz-intro') + '</div>'
15671605 + '<div id="mwe-upwiz-select-files">' + gM('mwe-upwiz-select-files') + '</div>'
15681606 + '<div id="mwe-upwiz-files"></div>'
15691607 + '<div><a id="mwe-upwiz-add-file">' + gM("mwe-upwiz-add-file-0") + '</a></div>'
@@ -1570,48 +1608,47 @@
15711609 + '<div id="mwe-upwiz-progress"></div>'
15721610 + '<div style="clear: left;"></div>'
15731611 + '</div>'
1574 - + '</div>'
1575 - + '<div id="mwe-upwiz-tabdiv-details">'
1576 - + '<div id="mwe-upwiz-macro">'
1577 - + '<div id="mwe-upwiz-macro-choice">'
1578 - + '<div>' + gM( 'mwe-upwiz-intro-details' ) + '</div>'
1579 - + '<div id="mwe-upwiz-macro-deeds">'
1580 - + '<div id="mwe-upwiz-macro-deed-ownwork" class="deed">'
1581 - + '<div class="mwe-deed-option-title">'
1582 - + '<span class="deed-header closed"><a id="mwe-upwiz-source-ownwork">' + gM( 'mwe-upwiz-source-ownwork' ) + '</a></span>'
1583 - + '<span class="deed-header open" style="display: none;">'
1584 - + gM( 'mwe-upwiz-source-ownwork' )
1585 - + ' <a id="mwe-upwiz-source-ownwork-close">' + gM( 'mwe-upwiz-change' ) + '</a>'
1586 - + '</span>'
1587 - + '</div>' // more deed stuff set up below
1588 - + '<div id="mwe-upwiz-macro-deed-ownwork-form" class="deed-form" style="display: none"></div>'
1589 - + '</div>'
1590 - + '<div id="mwe-upwiz-macro-deed-thirdparty" class="deed">'
1591 - + '<div class="mwe-deed-option-title">'
1592 - + '<span class="deed-header closed"><a id="mwe-upwiz-source-thirdparty">' + gM( 'mwe-upwiz-source-thirdparty' ) + '</a></span>'
1593 - + '<span class="deed-header open" style="display: none;">'
1594 - + gM( 'mwe-upwiz-source-thirdparty' )
1595 - + ' <a id="mwe-upwiz-source-thirdparty-close">' + gM( 'mwe-upwiz-change' ) + '</a>'
1596 - + '</span>'
1597 - + '</div>' // more deed stuff set up below
1598 - + '<div id="mwe-upwiz-macro-deed-thirdparty-form" class="deed-form" style="display: none"></div>'
1599 - + '</div>'
1600 - + '</div>'
 1612+ + '<div id="mwe-upwiz-tabdiv-details">'
 1613+ + '<div id="mwe-upwiz-macro">'
 1614+ + '<div id="mwe-upwiz-macro-choice">'
 1615+ + '<div>' + gM( 'mwe-upwiz-intro-details' ) + '</div>'
 1616+ + '<div id="mwe-upwiz-macro-deeds">'
 1617+ + '<div id="mwe-upwiz-macro-deed-ownwork" class="deed">'
 1618+ + '<div class="mwe-deed-option-title">'
 1619+ + '<span class="deed-header closed"><a id="mwe-upwiz-source-ownwork">' + gM( 'mwe-upwiz-source-ownwork' ) + '</a></span>'
 1620+ + '<span class="deed-header open" style="display: none;">'
 1621+ + gM( 'mwe-upwiz-source-ownwork' )
 1622+ + ' <a id="mwe-upwiz-source-ownwork-close">' + gM( 'mwe-upwiz-change' ) + '</a>'
 1623+ + '</span>'
 1624+ + '</div>' // more deed stuff set up below
 1625+ + '<div id="mwe-upwiz-macro-deed-ownwork-form" class="deed-form" style="display: none"></div>'
 1626+ + '</div>'
 1627+ + '<div id="mwe-upwiz-macro-deed-thirdparty" class="deed">'
 1628+ + '<div class="mwe-deed-option-title">'
 1629+ + '<span class="deed-header closed"><a id="mwe-upwiz-source-thirdparty">' + gM( 'mwe-upwiz-source-thirdparty' ) + '</a></span>'
 1630+ + '<span class="deed-header open" style="display: none;">'
 1631+ + gM( 'mwe-upwiz-source-thirdparty' )
 1632+ + ' <a id="mwe-upwiz-source-thirdparty-close">' + gM( 'mwe-upwiz-change' ) + '</a>'
 1633+ + '</span>'
 1634+ + '</div>' // more deed stuff set up below
 1635+ + '<div id="mwe-upwiz-macro-deed-thirdparty-form" class="deed-form" style="display: none"></div>'
 1636+ + '</div>'
 1637+ + '</div>'
 1638+ + '</div>'
 1639+ + '<div id="mwe-upwiz-macro-edit" style="display: none">'
 1640+ + '<div class="mwe-upwiz-macro-edit-submit">'
 1641+ + '<p>' + gM( 'mwe-upwiz-macro-edit-intro' ) + '</p>'
 1642+ + '</div>' // button added below
 1643+ + '<div id="mwe-upwiz-macro-progress"></div>'
 1644+ + '<div id="mwe-upwiz-macro-files"></div>'
 1645+ + '<div class="mwe-upwiz-macro-edit-submit"></div>' // button added below
 1646+ + '</div>'
16011647 + '</div>'
1602 - + '<div id="mwe-upwiz-macro-edit" style="display: none">'
1603 - + '<div class="mwe-upwiz-macro-edit-submit">'
1604 - + '<p>' + gM( 'mwe-upwiz-macro-edit-intro' ) + '</p>'
1605 - + '</div>' // button added below
1606 - + '<div id="mwe-upwiz-macro-progress"></div>'
1607 - + '<div id="mwe-upwiz-macro-files"></div>'
1608 - + '<div class="mwe-upwiz-macro-edit-submit"></div>' // button added below
1609 - + '</div>'
16101648 + '</div>'
 1649+ + '<div id="mwe-upwiz-tabdiv-thanks">'
 1650+ + '<div id="mwe-upwiz-thanks"></div>'
 1651+ + '</div>'
16111652 + '</div>'
1612 - + '<div id="mwe-upwiz-tabdiv-thanks">'
1613 - + '<div id="mwe-upwiz-thanks"></div>'
1614 - + '</div>'
1615 - +'</div>'
16161653
16171654 + '<div id="mwe-upwiz-clearing"></div>';
16181655
@@ -1917,27 +1954,7 @@
19181955
19191956 },
19201957
1921 - /**
1922 - * in details mode, reconfigure all the uploads, for various copyright modes
1923 - */
1924 - configureCopyrightDetails: function( mode ) {
1925 - $j.each( _this._uploadsEditingDetails, function (i, upload) {
1926 - if (mode == 'ownwork') {
1927 - // disable inputs
1928 - // link source to macro input
1929 - } else if (mode == 'permission') {
1930 - alert( 'unimplemented' );
19311958
1932 - } else if (mode == 'found') {
1933 - // disable inputs
1934 - // link source to macro input
1935 -
1936 - } else {
1937 - alert( 'unknown mode = ' + mode);
1938 - }
1939 - } );
1940 - },
1941 -
19421959 // might as well hardcode more of this?
19431960 prefillThanksPage: function() {
19441961 var _this = this;
@@ -1973,6 +1990,7 @@
19741991 var thumbTitle = upload.title.replace(/^File/, 'Image');
19751992 var thumbWikiText = "[[" + thumbTitle + "|thumb|right]]";
19761993
 1994+ // XXX this doesn't have the correct URL -- old "unique" descriptionurl
19771995 thanksDiv.append(
19781996 $j( '<div></div>' )
19791997 .addClass( 'mwe-upwiz-thanks-links' )

Status & tagging log