http://www.mediawiki.org/wiki/Special:Code/MediaWiki/60543

Revision: 60543
Author:   catrope
Date:     2010-01-01 17:33:22 +0000 (Fri, 01 Jan 2010)

Log Message:
-----------
UsabilityInitiative: Run wikitext through PST before diffing. This fixes 
handling of signatures as well as the added line at the end

Modified Paths:
--------------
    trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
    trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.preview.js
    trunk/extensions/UsabilityInitiative/js/plugins.combined.js
    trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js

Modified: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
===================================================================
--- trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php  
2010-01-01 16:24:06 UTC (rev 60542)
+++ trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php  
2010-01-01 17:33:22 UTC (rev 60543)
@@ -77,15 +77,15 @@
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 40 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 10 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.toc.js', 'version' => 55 ),
-                               array( 'src' => 
'js/plugins/jquery.wikiEditor.preview.js', 'version' => 8 ),
+                               array( 'src' => 
'js/plugins/jquery.wikiEditor.preview.js', 'version' => 9 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.templateEditor.js', 'version' => 12 ),
                                array( 'src' => 
'js/plugins/jquery.wikiEditor.publish.js', 'version' => 1 ),
                        ),
                        'combined' => array(
-                               array( 'src' => 'js/plugins.combined.js', 
'version' => 127 ),
+                               array( 'src' => 'js/plugins.combined.js', 
'version' => 128 ),
                        ),
                        'minified' => array(
-                               array( 'src' => 'js/plugins.combined.min.js', 
'version' => 127 ),
+                               array( 'src' => 'js/plugins.combined.min.js', 
'version' => 128 ),
                        ),
                ),
        );

Modified: 
trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.preview.js
===================================================================
--- 
trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.preview.js    
    2010-01-01 16:24:06 UTC (rev 60542)
+++ 
trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.preview.js    
    2010-01-01 17:33:22 UTC (rev 60543)
@@ -73,39 +73,51 @@
                                context.$changesTab.find( 'table.diff tbody' 
).empty();
                                context.$changesTab.find( 
'.wikiEditor-preview-loading' ).show();
                                
+                               // Call the API. First PST the input, then diff 
it
                                var postdata = {
-                                       'action': 'query',
-                                       'indexpageids': '',
-                                       'prop': 'revisions',
-                                       'titles': wgPageName,
-                                       'rvdifftotext': wikitext,
-                                       'rvprop': '',
+                                       'action': 'parse',
+                                       'onlypst': '',
+                                       'text': wikitext,
                                        'format': 'json'
                                };
-                               var section = $( '[name=wpSection]' ).val();
-                               if ( section != '' )
-                                       postdata['rvsection'] = section;
                                
                                $.post( wgScriptPath + '/api.php', postdata, 
function( data ) {
-                                               // Add diff CSS
-                                               if ( $( 'link[href=' + 
stylepath + '/common/diff.css]' ).size() == 0 ) {
-                                                       $( 'head' ).append( $( 
'<link />' ).attr( {
-                                                               'rel': 
'stylesheet',
-                                                               'type': 
'text/css',
-                                                               'href': 
stylepath + '/common/diff.css'
-                                                       } ) );
-                                               }
-                                               try {
-                                                       var diff = 
data.query.pages[data.query.pageids[0]]
-                                                               
.revisions[0].diff['*'];
-                                                       
context.$changesTab.find( 'table.diff tbody' )
-                                                               .html( diff );
-                                                       context.$changesTab
-                                                               .find( 
'.wikiEditor-preview-loading' ).hide();
-                                                       
context.modules.preview.changesText = wikitext;
-                                               } catch (e) { } // "blah is 
undefined" error, ignore
-                                       }, 'json'
-                               );
+                                       try {
+                                               var postdata2 = {
+                                                       'action': 'query',
+                                                       'indexpageids': '',
+                                                       'prop': 'revisions',
+                                                       'titles': wgPageName,
+                                                       'rvdifftotext': 
data.parse.text['*'],
+                                                       'rvprop': '',
+                                                       'format': 'json'
+                                               };
+                                               var section = $( 
'[name=wpSection]' ).val();
+                                               if ( section != '' )
+                                                       postdata['rvsection'] = 
section;
+                                               
+                                               $.post( wgScriptPath + 
'/api.php', postdata2, function( data ) {
+                                                               // Add diff CSS
+                                                               if ( $( 
'link[href=' + stylepath + '/common/diff.css]' ).size() == 0 ) {
+                                                                       $( 
'head' ).append( $( '<link />' ).attr( {
+                                                                               
'rel': 'stylesheet',
+                                                                               
'type': 'text/css',
+                                                                               
'href': stylepath + '/common/diff.css'
+                                                                       } ) );
+                                                               }
+                                                               try {
+                                                                       var 
diff = data.query.pages[data.query.pageids[0]]
+                                                                               
.revisions[0].diff['*'];
+                                                                       
context.$changesTab.find( 'table.diff tbody' )
+                                                                               
.html( diff );
+                                                                       
context.$changesTab
+                                                                               
.find( '.wikiEditor-preview-loading' ).hide();
+                                                                       
context.modules.preview.changesText = wikitext;
+                                                               } catch ( e ) { 
} // "blah is undefined" error, ignore
+                                                       }, 'json'
+                                               );
+                                       } catch( e ) { } // "blah is undefined" 
error, ignore
+                               }, 'json' );
                        }
                } );
                

Modified: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
===================================================================
--- trunk/extensions/UsabilityInitiative/js/plugins.combined.js 2010-01-01 
16:24:06 UTC (rev 60542)
+++ trunk/extensions/UsabilityInitiative/js/plugins.combined.js 2010-01-01 
17:33:22 UTC (rev 60543)
@@ -2411,14 +2411,14 @@
                                }
                                else if ( startDepth < depth ) {
                                        for ( var j = 0; j < depth - startDepth 
&& ca2; j++ ) {
-                                               ca2 = ca2.parentNode.firstChild 
== ca2 ? ca2.parentNode : null;
+                                               ca2 = ca2.parentNode.lastChild 
== ca2 ? ca2.parentNode : null;
                                        }
                                }
                                // Now that ca1 and ca2 have the same depth, 
have them walk up the tree simultaneously
                                // to find the common ancestor
                                while ( ca1 && ca2 && ca1.parentNode != 
ca2.parentNode ) {
                                        ca1 = ca1.parentNode.firstChild == ca1 
? ca1.parentNode : null;
-                                       ca2 = ca2.parentNode.firstChild == ca2 
? ca2.parentNode : null;
+                                       ca2 = ca2.parentNode.lastChild == ca2 ? 
ca2.parentNode : null;
                                }
                                if ( ca1 && ca2 ) {
                                        var wrapper = markers[i].getWrapper( 
ca1, ca2 );
@@ -2555,39 +2555,51 @@
                                context.$changesTab.find( 'table.diff tbody' 
).empty();
                                context.$changesTab.find( 
'.wikiEditor-preview-loading' ).show();
                                
+                               // Call the API. First PST the input, then diff 
it
                                var postdata = {
-                                       'action': 'query',
-                                       'indexpageids': '',
-                                       'prop': 'revisions',
-                                       'titles': wgPageName,
-                                       'rvdifftotext': wikitext,
-                                       'rvprop': '',
+                                       'action': 'parse',
+                                       'onlypst': '',
+                                       'text': wikitext,
                                        'format': 'json'
                                };
-                               var section = $( '[name=wpSection]' ).val();
-                               if ( section != '' )
-                                       postdata['rvsection'] = section;
                                
                                $.post( wgScriptPath + '/api.php', postdata, 
function( data ) {
-                                               // Add diff CSS
-                                               if ( $( 'link[href=' + 
stylepath + '/common/diff.css]' ).size() == 0 ) {
-                                                       $( 'head' ).append( $( 
'<link />' ).attr( {
-                                                               'rel': 
'stylesheet',
-                                                               'type': 
'text/css',
-                                                               'href': 
stylepath + '/common/diff.css'
-                                                       } ) );
-                                               }
-                                               try {
-                                                       var diff = 
data.query.pages[data.query.pageids[0]]
-                                                               
.revisions[0].diff['*'];
-                                                       
context.$changesTab.find( 'table.diff tbody' )
-                                                               .html( diff );
-                                                       context.$changesTab
-                                                               .find( 
'.wikiEditor-preview-loading' ).hide();
-                                                       
context.modules.preview.changesText = wikitext;
-                                               } catch (e) { } // "blah is 
undefined" error, ignore
-                                       }, 'json'
-                               );
+                                       try {
+                                               var postdata2 = {
+                                                       'action': 'query',
+                                                       'indexpageids': '',
+                                                       'prop': 'revisions',
+                                                       'titles': wgPageName,
+                                                       'rvdifftotext': 
data.parse.text['*'],
+                                                       'rvprop': '',
+                                                       'format': 'json'
+                                               };
+                                               var section = $( 
'[name=wpSection]' ).val();
+                                               if ( section != '' )
+                                                       postdata['rvsection'] = 
section;
+                                               
+                                               $.post( wgScriptPath + 
'/api.php', postdata2, function( data ) {
+                                                               // Add diff CSS
+                                                               if ( $( 
'link[href=' + stylepath + '/common/diff.css]' ).size() == 0 ) {
+                                                                       $( 
'head' ).append( $( '<link />' ).attr( {
+                                                                               
'rel': 'stylesheet',
+                                                                               
'type': 'text/css',
+                                                                               
'href': stylepath + '/common/diff.css'
+                                                                       } ) );
+                                                               }
+                                                               try {
+                                                                       var 
diff = data.query.pages[data.query.pageids[0]]
+                                                                               
.revisions[0].diff['*'];
+                                                                       
context.$changesTab.find( 'table.diff tbody' )
+                                                                               
.html( diff );
+                                                                       
context.$changesTab
+                                                                               
.find( '.wikiEditor-preview-loading' ).hide();
+                                                                       
context.modules.preview.changesText = wikitext;
+                                                               } catch ( e ) { 
} // "blah is undefined" error, ignore
+                                                       }, 'json'
+                                               );
+                                       } catch( e ) { } // "blah is undefined" 
error, ignore
+                               }, 'json' );
                        }
                } );
                

Modified: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
===================================================================
--- trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js     
2010-01-01 16:24:06 UTC (rev 60542)
+++ trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js     
2010-01-01 17:33:22 UTC (rev 60543)
@@ -141,8 +141,8 @@
 var endNode=node;while(startNode.nodeName=='BR'&&startNode!=endNode)
 
startNode=startNode.nextSibling;while(endNode.nodeName=='BR'&&endNode!=startNode)
 endNode=endNode.previousSibling;var 
ca1=startNode,ca2=endNode;if(startDepth>depth){for(var 
j=0;j<startDepth-depth&&ca1;j++){ca1=ca1.parentNode.firstChild==ca1?ca1.parentNode:null;}}
-else if(startDepth<depth){for(var 
j=0;j<depth-startDepth&&ca2;j++){ca2=ca2.parentNode.firstChild==ca2?ca2.parentNode:null;}}
-while(ca1&&ca2&&ca1.parentNode!=ca2.parentNode){ca1=ca1.parentNode.firstChild==ca1?ca1.parentNode:null;ca2=ca2.parentNode.firstChild==ca2?ca2.parentNode:null;}
+else if(startDepth<depth){for(var 
j=0;j<depth-startDepth&&ca2;j++){ca2=ca2.parentNode.lastChild==ca2?ca2.parentNode:null;}}
+while(ca1&&ca2&&ca1.parentNode!=ca2.parentNode){ca1=ca1.parentNode.firstChild==ca1?ca1.parentNode:null;ca2=ca2.parentNode.lastChild==ca2?ca2.parentNode:null;}
 if(ca1&&ca2){var wrapper=markers[i].getWrapper(ca1,ca2);if(!wrapper){var 
newNode=ca1.ownerDocument.createElement('div');var 
commonAncestor=ca1.parentNode;var nextNode=ca2.nextSibling;var 
n=ca1;while(n!=nextNode){var ns=n.nextSibling;newNode.appendChild(n);n=ns;}
 
if(nextNode){commonAncestor.insertBefore(newNode,nextNode);}else{commonAncestor.appendChild(newNode);}
 $(newNode).data('marker',markers[i]).addClass('wikiEditor-highlight 
wikiEditor-highlight-tmp');markers[i].afterWrap(newNode,markers[i]);}else{$(wrapper).addClass('wikiEditor-highlight-tmp');}}
@@ -153,9 +153,9 @@
 
context.modules.preview={'initialized':true,'previewText':null,'changesText':null};context.modules.preview.$preview=context.fn.addView({'name':'preview','titleMsg':'wikieditor-preview-tab','init':function(context){var
 
wikitext=context.fn.getContents();if(context.modules.preview.previewText==wikitext){return;}
 
context.modules.preview.$preview.find('.wikiEditor-preview-contents').empty();context.modules.preview.$preview.find('.wikiEditor-preview-loading').show();$.post(wgScriptPath+'/api.php',{'action':'parse','title':wgPageName,'text':wikitext,'prop':'text','pst':'','format':'json'},function(data){if(typeof
 data.parse=='undefined'||typeof data.parse.text=='undefined'||typeof 
data.parse.text['*']=='undefined'){return;}
 
context.modules.preview.previewText=wikitext;context.modules.preview.$preview.find('.wikiEditor-preview-loading').hide();context.modules.preview.$preview.find('.wikiEditor-preview-contents').html(data.parse.text['*']).find('a:not([href^=#])').click(function(){return
 
false;});},'json');}});context.$changesTab=context.fn.addView({'name':'changes','titleMsg':'wikieditor-preview-changes-tab','init':function(context){var
 
wikitext=context.fn.getContents();if(context.modules.preview.changesText==wikitext){return;}
-context.$changesTab.find('table.diff 
tbody').empty();context.$changesTab.find('.wikiEditor-preview-loading').show();var
 
postdata={'action':'query','indexpageids':'','prop':'revisions','titles':wgPageName,'rvdifftotext':wikitext,'rvprop':'','format':'json'};var
 section=$('[name=wpSection]').val();if(section!='')
-postdata['rvsection']=section;$.post(wgScriptPath+'/api.php',postdata,function(data){if($('link[href='+stylepath+'/common/diff.css]').size()==0){$('head').append($('<link
 
/>').attr({'rel':'stylesheet','type':'text/css','href':stylepath+'/common/diff.css'}));}
-try{var 
diff=data.query.pages[data.query.pageids[0]].revisions[0].diff['*'];context.$changesTab.find('table.diff
 
tbody').html(diff);context.$changesTab.find('.wikiEditor-preview-loading').hide();context.modules.preview.changesText=wikitext;}catch(e){}},'json');}});var
 
loadingMsg=gM('wikieditor-preview-loading');context.modules.preview.$preview.add(context.$changesTab).append($('<div
 />').addClass('wikiEditor-preview-loading').append($('<img 
/>').addClass('wikiEditor-preview-spinner').attr({'src':$.wikiEditor.imgPath+'dialogs/loading.gif','valign':'absmiddle','alt':loadingMsg,'title':loadingMsg})).append($('<span></span>').text(loadingMsg))).append($('<div
 
/>').addClass('wikiEditor-preview-contents'));context.$changesTab.find('.wikiEditor-preview-contents').html('<table
 class="diff"><col class="diff-marker" /><col class="diff-content" />'+'<col 
class="diff-marker" /><col class="diff-content" /><tbody 
/></table>');}}};})(jQuery);(function($){$.wikiEditor.modules.publish={fn:{create:function(context,config){var
 
dialogID='wikiEditor-'+context.instance+'-dialog';$.wikiEditor.modules.dialogs.fn.create(context,{previewsave:{id:dialogID,titleMsg:'wikieditor-publish-dialog-title',html:'\
+context.$changesTab.find('table.diff 
tbody').empty();context.$changesTab.find('.wikiEditor-preview-loading').show();var
 
postdata={'action':'parse','onlypst':'','text':wikitext,'format':'json'};$.post(wgScriptPath+'/api.php',postdata,function(data){try{var
 
postdata2={'action':'query','indexpageids':'','prop':'revisions','titles':wgPageName,'rvdifftotext':data.parse.text['*'],'rvprop':'','format':'json'};var
 section=$('[name=wpSection]').val();if(section!='')
+postdata['rvsection']=section;$.post(wgScriptPath+'/api.php',postdata2,function(data){if($('link[href='+stylepath+'/common/diff.css]').size()==0){$('head').append($('<link
 
/>').attr({'rel':'stylesheet','type':'text/css','href':stylepath+'/common/diff.css'}));}
+try{var 
diff=data.query.pages[data.query.pageids[0]].revisions[0].diff['*'];context.$changesTab.find('table.diff
 
tbody').html(diff);context.$changesTab.find('.wikiEditor-preview-loading').hide();context.modules.preview.changesText=wikitext;}catch(e){}},'json');}catch(e){}},'json');}});var
 
loadingMsg=gM('wikieditor-preview-loading');context.modules.preview.$preview.add(context.$changesTab).append($('<div
 />').addClass('wikiEditor-preview-loading').append($('<img 
/>').addClass('wikiEditor-preview-spinner').attr({'src':$.wikiEditor.imgPath+'dialogs/loading.gif','valign':'absmiddle','alt':loadingMsg,'title':loadingMsg})).append($('<span></span>').text(loadingMsg))).append($('<div
 
/>').addClass('wikiEditor-preview-contents'));context.$changesTab.find('.wikiEditor-preview-contents').html('<table
 class="diff"><col class="diff-marker" /><col class="diff-content" />'+'<col 
class="diff-marker" /><col class="diff-content" /><tbody 
/></table>');}}};})(jQuery);(function($){$.wikiEditor.modules.publish={fn:{create:function(context,config){var
 
dialogID='wikiEditor-'+context.instance+'-dialog';$.wikiEditor.modules.dialogs.fn.create(context,{previewsave:{id:dialogID,titleMsg:'wikieditor-publish-dialog-title',html:'\
       <div class="wikiEditor-dialog-copywarn"></div>\
       <div class="wikiEditor-dialog-editoptions">\
        <form>\



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

Reply via email to