Index: branches/resourceloader/phase3/includes/ResourceLoader.php |
— | — | @@ -84,10 +84,6 @@ |
85 | 85 | case 'flip-css': |
86 | 86 | $result = CSSJanus::transform( $data, true, false ); |
87 | 87 | break; |
88 | | - case 'strip-debug': |
89 | | - // FIXME: Fragile |
90 | | - $result = preg_replace( '/\n\s*mw\.log\(([^\)]*\))*\s*[\;\n]/U', "\n", $data ); |
91 | | - break; |
92 | 88 | default: |
93 | 89 | // Don't cache anything, just pass right through |
94 | 90 | return $data; |
— | — | @@ -147,7 +143,7 @@ |
148 | 144 | 'loader' => null, |
149 | 145 | 'needs' => array(), |
150 | 146 | 'raw' => false, |
151 | | - 'debug' => false, |
| 147 | + 'debug' => null, |
152 | 148 | ), $options ); |
153 | 149 | // Validate script option |
154 | 150 | if ( !is_string( $options['script'] ) ) { |
— | — | @@ -209,9 +205,7 @@ |
210 | 206 | $modules = array(); |
211 | 207 | foreach ( explode( '|', $request->getVal( 'modules' ) ) as $module ) { |
212 | 208 | if ( isset( self::$modules[$module] ) ) { |
213 | | - if ( !self::$modules[$module]['debug'] || $parameters['debug'] ) { |
214 | | - $modules[] = $module; |
215 | | - } |
| 209 | + $modules[] = $module; |
216 | 210 | } |
217 | 211 | } |
218 | 212 | // Use output buffering |
— | — | @@ -221,8 +215,12 @@ |
222 | 216 | foreach ( $modules as $module ) { |
223 | 217 | if ( self::$modules[$module]['raw'] ) { |
224 | 218 | readfile( self::$modules[$module]['script'] ); |
225 | | - $ready[] = $module; |
226 | 219 | echo "\n"; |
| 220 | + if ( $parameters['debug'] && self::$modules[$module]['debug'] ) { |
| 221 | + readfile( self::$modules[$module]['debug'] ); |
| 222 | + echo "\n"; |
| 223 | + } |
| 224 | + $ready[] = $module; |
227 | 225 | } |
228 | 226 | } |
229 | 227 | // Special meta-information for the 'mediawiki' module |
— | — | @@ -268,14 +266,14 @@ |
269 | 267 | if ( !self::$modules[$module]['raw'] ) { |
270 | 268 | // Script |
271 | 269 | $script = file_get_contents( self::$modules[$module]['script'] ); |
| 270 | + // Debug |
| 271 | + if ( $parameters['debug'] && self::$modules[$module]['debug'] ) { |
| 272 | + $script .= file_get_contents( self::$modules[$module]['debug'] ); |
| 273 | + } |
272 | 274 | // Locale |
273 | 275 | if ( isset( self::$modules[$module]['locales'][$parameters['lang']] ) ) { |
274 | 276 | $script .= file_get_contents( self::$modules[$module]['locales'][$parameters['lang']] ); |
275 | 277 | } |
276 | | - // Debug stripping - scary and probably a bad idea |
277 | | - if ( !$parameters['debug'] ) { |
278 | | - $script = self::filter( 'strip-debug', $script ); |
279 | | - } |
280 | 278 | // Style |
281 | 279 | $style = self::$modules[$module]['style'] ? file_get_contents( self::$modules[$module]['style'] ) : ''; |
282 | 280 | // Theme |
Index: branches/resourceloader/phase3/resources/Resources.php |
— | — | @@ -414,7 +414,10 @@ |
415 | 415 | /* MediaWiki */ |
416 | 416 | |
417 | 417 | 'mediawiki' => array( |
418 | | - 'script' => 'resources/mediawiki/mediawiki.js', 'raw' => true ), |
| 418 | + 'script' => 'resources/mediawiki/mediawiki.js', |
| 419 | + 'debug' => 'resources/mediawiki/mediawiki.log.js', |
| 420 | + 'raw' => true, |
| 421 | + ), |
419 | 422 | |
420 | 423 | /* MediaWiki Legacy */ |
421 | 424 | |
Index: branches/resourceloader/phase3/resources/mediawiki/mediawiki.js |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | /* |
38 | 38 | * Core MediaWiki JavaScript Library |
39 | 39 | */ |
40 | | -( function() { |
| 40 | +( function( $ ) { |
41 | 41 | |
42 | 42 | /* Constants */ |
43 | 43 | |
— | — | @@ -49,57 +49,10 @@ |
50 | 50 | |
51 | 51 | /* Methods */ |
52 | 52 | |
53 | | - /** |
54 | | - * Log a string msg to the console |
55 | | - * |
56 | | - * All mw.log statements will be removed on minification so lots of mw.log calls will not impact performance in non-debug |
57 | | - * mode. This is done using simple regular expressions, so the input of this function needs to not contain things like a |
58 | | - * self-executing closure. In the case that the browser does not have a console available, one is created by appending a |
59 | | - * <div> element to the bottom of the body and then appending a <div> element to that for each message. In the case that |
60 | | - * the browser does have a console available |
61 | | - * |
62 | | - * @author Michael Dale <mdale@wikimedia.org>, Trevor Parscal <tparscal@wikimedia.org> |
63 | | - * @param string string message to output to console |
| 53 | + /* |
| 54 | + * Dummy function which in debug mode can be replaced with a function that does something clever |
64 | 55 | */ |
65 | | - this.log = function( string ) { |
66 | | - // Allow log messages to use a configured prefix |
67 | | - if ( mw.config.exists( 'mw.log.prefix' ) ) { |
68 | | - string = mw.config.get( 'mw.log.prefix' ) + string; |
69 | | - } |
70 | | - // Try to use an existing console |
71 | | - if ( typeof window.console !== 'undefined' && typeof window.console.log == 'function' ) { |
72 | | - window.console.log( string ); |
73 | | - } else { |
74 | | - // Show a log box for console-less browsers |
75 | | - var $log = $( '#mw_log_console' ); |
76 | | - if ( !$log.length ) { |
77 | | - $log = $( '<div id="mw_log_console"></div>' ) |
78 | | - .css( { |
79 | | - 'position': 'absolute', |
80 | | - 'overflow': 'auto', |
81 | | - 'z-index': 500, |
82 | | - 'bottom': '0px', |
83 | | - 'left': '0px', |
84 | | - 'right': '0px', |
85 | | - 'height': '150px', |
86 | | - 'background-color': 'white', |
87 | | - 'border-top': 'solid 1px #DDDDDD' |
88 | | - } ) |
89 | | - .appendTo( $( 'body' ) ); |
90 | | - } |
91 | | - if ( $log.length ) { |
92 | | - $log.append( |
93 | | - $( '<div>' + string + '</div>' ) |
94 | | - .css( { |
95 | | - 'border-bottom': 'solid 1px #DDDDDD', |
96 | | - 'font-size': 'small', |
97 | | - 'font-family': 'monospace', |
98 | | - 'padding': '0.125em 0.25em' |
99 | | - } ) |
100 | | - ); |
101 | | - } |
102 | | - } |
103 | | - }; |
| 56 | + this.log = function() { }; |
104 | 57 | /* |
105 | 58 | * An object which allows single and multiple existence, setting and getting on a list of key / value pairs |
106 | 59 | */ |
— | — | @@ -616,4 +569,4 @@ |
617 | 570 | |
618 | 571 | // Attach to window |
619 | 572 | window.MediaWiki = window.mw = this; |
620 | | -} )(); |
\ No newline at end of file |
| 573 | +} )( jQuery ); |
\ No newline at end of file |
Index: branches/resourceloader/phase3/resources/mediawiki/mediawiki.log.js |
— | — | @@ -0,0 +1,63 @@ |
| 2 | +/* |
| 3 | + * User-agent detection |
| 4 | + */ |
| 5 | + |
| 6 | +( function( $, mw ) { |
| 7 | + |
| 8 | +/* Extension */ |
| 9 | + |
| 10 | +$.extend( mw, { |
| 11 | + |
| 12 | + /* Functions */ |
| 13 | + |
| 14 | + /** |
| 15 | + * Log output to the console |
| 16 | + * |
| 17 | + * In the case that the browser does not have a console available, one is created by appending a <div> element to |
| 18 | + * the bottom of the body and then appending a <div> element to that for each message. |
| 19 | + * |
| 20 | + * @author Michael Dale <mdale@wikimedia.org>, Trevor Parscal <tparscal@wikimedia.org> |
| 21 | + * @param {string} string message to output to console |
| 22 | + */ |
| 23 | + 'log': function( string ) { |
| 24 | + // Allow log messages to use a configured prefix |
| 25 | + if ( mw.config.exists( 'mw.log.prefix' ) ) { |
| 26 | + string = mw.config.get( 'mw.log.prefix' ) + string; |
| 27 | + } |
| 28 | + // Try to use an existing console |
| 29 | + if ( typeof window.console !== 'undefined' && typeof window.console.log == 'function' ) { |
| 30 | + window.console.log( string ); |
| 31 | + } else { |
| 32 | + // Show a log box for console-less browsers |
| 33 | + var $log = $( '#mw_log_console' ); |
| 34 | + if ( !$log.length ) { |
| 35 | + $log = $( '<div id="mw_log_console"></div>' ) |
| 36 | + .css( { |
| 37 | + 'position': 'absolute', |
| 38 | + 'overflow': 'auto', |
| 39 | + 'z-index': 500, |
| 40 | + 'bottom': '0px', |
| 41 | + 'left': '0px', |
| 42 | + 'right': '0px', |
| 43 | + 'height': '150px', |
| 44 | + 'background-color': 'white', |
| 45 | + 'border-top': 'solid 1px #DDDDDD' |
| 46 | + } ) |
| 47 | + .appendTo( $( 'body' ) ); |
| 48 | + } |
| 49 | + if ( $log.length ) { |
| 50 | + $log.append( |
| 51 | + $( '<div>' + string + '</div>' ) |
| 52 | + .css( { |
| 53 | + 'border-bottom': 'solid 1px #DDDDDD', |
| 54 | + 'font-size': 'small', |
| 55 | + 'font-family': 'monospace', |
| 56 | + 'padding': '0.125em 0.25em' |
| 57 | + } ) |
| 58 | + ); |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | +} ); |
| 63 | + |
| 64 | +} )( jQuery, MediaWiki ); |
\ No newline at end of file |
Property changes on: branches/resourceloader/phase3/resources/mediawiki/mediawiki.log.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 65 | + native |