r72733 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72732‎ | r72733 | r72734 >
Date:18:52, 10 September 2010
Author:dale
Status:deferred
Tags:
Comment:
keep sequence page text ( categories / description )
Modified paths:
  • /branches/MwEmbedStandAlone/components/mw.Api.js (modified) (history)
  • /branches/MwEmbedStandAlone/components/mw.Language.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/components/mw.Language.js
@@ -434,7 +434,7 @@
435435 }
436436 }
437437 return ( typeInt )? parseInt( convertedNumber) : convertedNumber;
438 - }
 438+ };
439439
440440 /**
441441 * Checks if a language key is valid ( is part of languageCodeList )
@@ -443,7 +443,7 @@
444444 */
445445 mw.isValidLang = function( langKey ) {
446446 return ( mw.Language.names[ langKey ] )? true : false;
447 - }
 447+ };
448448
449449 /**
450450 * Get a language transform key
@@ -462,7 +462,7 @@
463463 }
464464 // By default return the base 'en' class
465465 return 'en';
466 - }
 466+ };
467467
468468 /**
469469 * getRemoteMsg loads remote msg strings
Index: branches/MwEmbedStandAlone/components/mw.Api.js
@@ -106,7 +106,7 @@
107107 *
108108 * @param {Mixed} url or data request
109109 * @param {Mixed} data or callback
110 - * @param {Function} callbcak function called on success
 110+ * @param {Function} callback function called on success
111111 * @param {Function} callbackTimeout - optional function called on timeout
112112 * Setting timeout callback also avoids default timed-out dialog for proxy requests
113113 */
Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -2595,7 +2595,7 @@
25962596
25972597 if( window.jQuery ){
25982598 if( ! mw.versionIsAtLeast( '1.4.0', jQuery.fn.jquery ) ){
2599 - if( console && console.log ) {
 2599+ if( window.console && window.console.log ) {
26002600 console.log( 'Error mwEmbed requires jQuery 1.4 or above' );
26012601 }
26022602 }
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js
@@ -6,6 +6,8 @@
77
88 //Wrap in mw closure
99 ( function( mw ) {
 10+
 11+ var SEQUENCER_PAYLOADKEY = '@gadgetSequencePayload@_$%^%';
1012
1113 mw.SequencerServer = function( sequencer ) {
1214 return this.init( sequencer );
@@ -100,20 +102,51 @@
101103 */
102104 getSmilXml: function( callback ){
103105 var _this = this;
104 - mw.getTitleText( this.getApiUrl(), this.getTitleKey(), function( smilXml ){
105 - // set smil to empty string if unset:
106 - if(!smilXml )
107 - smilXml = '';
 106+ mw.getTitleText( this.getApiUrl(), this.getTitleKey(), function( smilPage ){
 107+ // Check for remote payload wrapper
 108+ // XXX need to support multipe pages in single context
 109+ _this.currentSequencePage = _this.parseSequencerPage( smilPage );
 110+ // Cache the latest serverSmil ( for local change checks )
 111+ // ( save requests automatically respond with warnings on other user updates )
 112+ _this.serverSmilXml =_this.currentSequencePage.sequenceXML;
108113
109 - // Check for remote payload wrapper
110 - smilXml = mw.getRemoteSequencerPayLoad( smilXml );
 114+ // Cache the pre / post bits
111115
112 - // Cache the latest serverSmil ( for local change checks )
113 - // ( save requests automatically respond with warnings on other user updates )
114 - _this.serverSmilXml = smilXml;
115 - callback( smilXml );
 116+ callback( _this.serverSmilXml );
116117 })
117118 },
 119+ wrapSequencerWikiText : function( xmlString ){
 120+ var _this = this;
 121+ if( !_this.currentSequencePage.pageStart ){
 122+ _this.currentSequencePage.pageStart ="\nTo edit this sequence " +
 123+ '[{{fullurl:{{FULLPAGENAME}}|withJS=MediaWiki:MwEmbed.js}} enable the sequencer] for this page';
 124+ }
 125+ return _this.currentSequencePage.pageStart +
 126+ "\n\n<!-- " + SEQUENCER_PAYLOADKEY + "\n" +
 127+ xmlString +
 128+ "\n\n " + SEQUENCER_PAYLOADKEY + " -->\n" +
 129+ _this.currentSequencePage.pageEnd;
 130+ },
 131+
 132+ parseSequencerPage : function( pageText ){
 133+ var _this = this;
 134+ var startKey = '<!-- ' + SEQUENCER_PAYLOADKEY;
 135+ var endKey = SEQUENCER_PAYLOADKEY + ' -->';
 136+ // If the key is not found fail
 137+ if( !pageText || pageText.indexOf( startKey ) == -1 || pageText.indexOf(endKey) == -1 ){
 138+ mw.log("Error could not find sequence payload");
 139+ return '';
 140+ }
 141+ // trim the output:
 142+ return {
 143+ 'pageStart' : pageText.substring(0, pageText.indexOf( startKey ) ),
 144+ 'sequenceXML' : pageText.substring( pageText.indexOf( startKey ) + startKey.length,
 145+ pageText.indexOf(endKey ) ),
 146+ 'pageEnd' : pageText.substring( pageText.indexOf(endKey) )
 147+ }
 148+ },
 149+
 150+
118151 getTemplateText: function( templateTitle, callback ){
119152 var _this = this;
120153 if( this.templateTextCache[templateTitle] ){
@@ -159,7 +192,7 @@
160193 'action' : 'edit',
161194 'summary' : saveSummary,
162195 'title' : _this.titleKey,
163 - 'text' : mw.getRemoteSequencerPageHelper( sequenceXML ),
 196+ 'text' : _this.wrapSequencerWikiText( sequenceXML ),
164197 'token': token
165198 };
166199 mw.getJSON( _this.getApiUrl(), request, function( data ) {
@@ -175,7 +208,8 @@
176209 }
177210 })
178211 })
179 - },
 212+ },
 213+
180214 /**
181215 * Check if the published file is up-to-date with the saved sequence
182216 * ( higher page revision for file than sequence )
Index: branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js
@@ -49,31 +49,6 @@
5050 return url;
5151 };
5252
53 -var SEQUENCER_PAYLOADKEY = '@gadgetSequencePayload@_$%^%';
54 -
55 -
56 -mw.getRemoteSequencerPageHelper = function( xmlString ){
57 - return 'To edit this sequence ' +
58 - '[{{fullurl:{{FULLPAGENAME}}|withJS=MediaWiki:MwEmbed.js}} enable the sequencer] for this page' +
59 - "\n\n<!-- " + SEQUENCER_PAYLOADKEY + "\n" +
60 - xmlString +
61 - "\n\n " + SEQUENCER_PAYLOADKEY + " -->"
62 -};
63 -mw.getRemoteSequencerPayLoad = function( pageText ){
64 - var startKey = '<!-- ' + SEQUENCER_PAYLOADKEY;
65 - var endKey = SEQUENCER_PAYLOADKEY + ' -->';
66 - // if the key is not found fail
67 - if( pageText.indexOf( startKey ) == -1 || pageText.indexOf(endKey) == -1 ){
68 - mw.log("Error could not find sequence payload");
69 - return '';
70 - }
71 - var payload = pageText.substring( pageText.indexOf( startKey ) + startKey.length,
72 - pageText.indexOf(endKey )
73 - );
74 - // trim the output:
75 - return $j.trim( payload );
76 -};
77 -
7853 // Add player pause binding if config is set::
7954 $j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayerId ) {
8055 if( mw.getConfig( 'Sequencer.KalturaPlayerEditOverlay' )){

Status & tagging log