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

Revision: 68854
Author:   tparscal
Date:     2010-07-01 21:08:41 +0000 (Thu, 01 Jul 2010)

Log Message:
-----------
Added debug mode and component, which right now is just a flag but it's assumed 
that it's existence means we're in debug mode, so we can make it an object that 
does cool stuff later if we want. Also made sure that dynamic loads keep the 
state of the debug argument.

Modified Paths:
--------------
    branches/resourceloader/phase3/includes/ResourceLoader.php
    branches/resourceloader/phase3/load.php
    branches/resourceloader/phase3/resources/core/mw/mw.loader.js
    branches/resourceloader/phase3/resources/test/index.html

Added Paths:
-----------
    branches/resourceloader/phase3/resources/core/mw/mw.debug.js
    branches/resourceloader/phase3/resources/core/mw/mw.log.js

Removed Paths:
-------------
    branches/resourceloader/phase3/resources/core/mw/mw.log.js

Modified: branches/resourceloader/phase3/includes/ResourceLoader.php
===================================================================
--- branches/resourceloader/phase3/includes/ResourceLoader.php  2010-07-01 
20:51:01 UTC (rev 68853)
+++ branches/resourceloader/phase3/includes/ResourceLoader.php  2010-07-01 
21:08:41 UTC (rev 68854)
@@ -31,10 +31,13 @@
                'mw' => 'resources/core/mw.js',
                'mw.config' => 'resources/core/mw/mw.config.js',
                'mw.loader' => 'resources/core/mw/mw.loader.js',
-               'mw.log' => 'resources/core/mw/mw.log.js',
                'mw.msg' => 'resources/core/mw/mw.msg.js',
                'mw.util' => 'resources/core/mw/mw.util.js',
        );
+       private static $debugScripts = array(
+               'mw.debug' => 'resources/core/mw/mw.debug.js',
+               'mw.log' => 'resources/core/mw/mw.log.js',
+       );
        /**
         * List of modules.
         * 
@@ -137,6 +140,16 @@
                        }
                        $retval .= $this->getLoaderJS();
                }
+               if ( $this->useDebugMode ) {
+                       // TODO: file_get_contents() errors?
+                       // TODO: CACHING!
+                       foreach ( self::$debugScripts as $script ) {
+                               if ( file_exists( $script ) ) {
+                                       $retval .= file_get_contents( $script );
+                               }
+                       }
+                       $retval .= $this->getLoaderJS();
+               }
                
                /*
                 * Skin::makeGlobalVariablesScript needs to be modified so that 
we still output the globals for now, but also

Modified: branches/resourceloader/phase3/load.php
===================================================================
--- branches/resourceloader/phase3/load.php     2010-07-01 20:51:01 UTC (rev 
68853)
+++ branches/resourceloader/phase3/load.php     2010-07-01 21:08:41 UTC (rev 
68854)
@@ -49,8 +49,8 @@
 $loader = new ResourceLoader( $wgRequest->getVal( 'lang', 'en' ) );
 $loader->setUseJSMin( $wgRequest->getBool( 'jsmin', true ) );
 $loader->setUseCSSMin( $wgRequest->getBool( 'cssmin', true ) );
+$loader->setUseCSSJanus( $wgRequest->getVal( 'dir', 'ltr' ) == 'rtl' );
 $loader->setUseDebugMode( $wgRequest->getBool( 'debug', false ) );
-$loader->setUseCSSJanus( $wgRequest->getVal( 'dir', 'ltr' ) == 'rtl' );
 $moduleParam = $wgRequest->getVal( 'modules' );
 $modules = $moduleParam ? explode( '|', $moduleParam ) : array();
 foreach ( $modules as $module ) {

Added: branches/resourceloader/phase3/resources/core/mw/mw.debug.js
===================================================================
--- branches/resourceloader/phase3/resources/core/mw/mw.debug.js                
                (rev 0)
+++ branches/resourceloader/phase3/resources/core/mw/mw.debug.js        
2010-07-01 21:08:41 UTC (rev 68854)
@@ -0,0 +1,5 @@
+/**
+ * Debug system
+ */
+
+window.mw.debug = true;
\ No newline at end of file


Property changes on: 
branches/resourceloader/phase3/resources/core/mw/mw.debug.js
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: branches/resourceloader/phase3/resources/core/mw/mw.loader.js
===================================================================
--- branches/resourceloader/phase3/resources/core/mw/mw.loader.js       
2010-07-01 20:51:01 UTC (rev 68853)
+++ branches/resourceloader/phase3/resources/core/mw/mw.loader.js       
2010-07-01 21:08:41 UTC (rev 68854)
@@ -135,7 +135,9 @@
                                                                        // 
Modules are in the format foo|bar|baz|buz
                                                                        { 
'modules': batch.join( '|' ) },
                                                                        // Pass 
configuration values through the URL
-                                                                       
mw.config.get( [ 'user', 'skin', 'space', 'view', 'language' ] )
+                                                                       
mw.config.get( [ 'user', 'skin', 'space', 'view', 'language' ] ),
+                                                                       // 
Ensure request comes back in the proper mode (debug or not)
+                                                                       { 
'debug': typeof mw.debug !== 'undefined' ? '1' : '0' }
                                                                )
                                                } ) )
                                                .load( function() {

Deleted: branches/resourceloader/phase3/resources/core/mw/mw.log.js
===================================================================
--- branches/resourceloader/phase3/resources/core/mw/mw.log.js  2010-07-01 
20:51:01 UTC (rev 68853)
+++ branches/resourceloader/phase3/resources/core/mw/mw.log.js  2010-07-01 
21:08:41 UTC (rev 68854)
@@ -1,55 +0,0 @@
-/**
- * Loader system
- */
-
-/**
-* Log a string msg to the console
-* 
-* All mw.log statements will be removed on minification so lots of mw.log 
calls will not impact performance in non-debug
-* mode. This is done using simple regular expressions, so the input of this 
function needs to not contain things like a
-* self-executing closure. In the case that the browser does not have a console 
available, one is created by appending a
-* <div> element to the bottom of the body and then appending a <div> element 
to that for each message. In the case that
-* the browser does have a console available 
-*
-* @author Michael Dale <md...@wikimedia.org>, Trevor Parscal 
<tpars...@wikimedia.org>
-* @param {String} string String to output to console
-*/
-window.mw.log = function( string ) {
-       // Allow log messages to use a configured prefix                
-       if ( mw.config.exists( 'mw.log.prefix' ) ) {
-               string = mw.config.get( 'mw.log.prefix' ) + string;             
-       }
-       // Try to use an existing console
-       if ( typeof window.console !== 'undefined' && typeof window.console.log 
== 'function' ) {
-               window.console.log( string );
-       } else {
-               // Show a log box for console-less browsers
-               var $log = $( '#mw_log_console' );
-               if ( !$log.length ) {
-                       $log = $( '<div id="mw_log_console"></div>' )
-                               .css( {
-                                       'position': 'absolute',
-                                       'overflow': 'auto',
-                                       'z-index': 500,
-                                       'bottom': '0px',
-                                       'left': '0px',
-                                       'right': '0px',
-                                       'height': '150px',
-                                       'background-color': 'white',
-                                       'border-top': 'solid 1px #DDDDDD'
-                               } )
-                               .appendTo( $( 'body' ) );
-               }
-               if ( $log.length ) {
-                       $log.append(
-                               $( '<div>' + string + '</div>' )
-                                       .css( {
-                                               'border-bottom': 'solid 1px 
#DDDDDD',
-                                               'font-size': 'small',
-                                               'font-family': 'monospace',
-                                               'padding': '0.125em 0.25em'
-                                       } )
-                       );
-               }
-       }
-};
\ No newline at end of file

Added: branches/resourceloader/phase3/resources/core/mw/mw.log.js
===================================================================
--- branches/resourceloader/phase3/resources/core/mw/mw.log.js                  
        (rev 0)
+++ branches/resourceloader/phase3/resources/core/mw/mw.log.js  2010-07-01 
21:08:41 UTC (rev 68854)
@@ -0,0 +1,55 @@
+/**
+ * Loader system
+ */
+
+/**
+* Log a string msg to the console
+* 
+* All mw.log statements will be removed on minification so lots of mw.log 
calls will not impact performance in non-debug
+* mode. This is done using simple regular expressions, so the input of this 
function needs to not contain things like a
+* self-executing closure. In the case that the browser does not have a console 
available, one is created by appending a
+* <div> element to the bottom of the body and then appending a <div> element 
to that for each message. In the case that
+* the browser does have a console available 
+*
+* @author Michael Dale <md...@wikimedia.org>, Trevor Parscal 
<tpars...@wikimedia.org>
+* @param {String} string String to output to console
+*/
+window.mw.log = function( string ) {
+       // Allow log messages to use a configured prefix                
+       if ( mw.config.exists( 'mw.log.prefix' ) ) {
+               string = mw.config.get( 'mw.log.prefix' ) + string;             
+       }
+       // Try to use an existing console
+       if ( typeof window.console !== 'undefined' && typeof window.console.log 
== 'function' ) {
+               window.console.log( string );
+       } else {
+               // Show a log box for console-less browsers
+               var $log = $( '#mw_log_console' );
+               if ( !$log.length ) {
+                       $log = $( '<div id="mw_log_console"></div>' )
+                               .css( {
+                                       'position': 'absolute',
+                                       'overflow': 'auto',
+                                       'z-index': 500,
+                                       'bottom': '0px',
+                                       'left': '0px',
+                                       'right': '0px',
+                                       'height': '150px',
+                                       'background-color': 'white',
+                                       'border-top': 'solid 1px #DDDDDD'
+                               } )
+                               .appendTo( $( 'body' ) );
+               }
+               if ( $log.length ) {
+                       $log.append(
+                               $( '<div>' + string + '</div>' )
+                                       .css( {
+                                               'border-bottom': 'solid 1px 
#DDDDDD',
+                                               'font-size': 'small',
+                                               'font-family': 'monospace',
+                                               'padding': '0.125em 0.25em'
+                                       } )
+                       );
+               }
+       }
+};
\ No newline at end of file

Modified: branches/resourceloader/phase3/resources/test/index.html
===================================================================
--- branches/resourceloader/phase3/resources/test/index.html    2010-07-01 
20:51:01 UTC (rev 68853)
+++ branches/resourceloader/phase3/resources/test/index.html    2010-07-01 
21:08:41 UTC (rev 68854)
@@ -5,7 +5,7 @@
                <title>Resource Loader Test</title>
                <script type="text/javascript" 
src="../../load.php?modules=core|test"></script>
                <script>
-                       mw.config.set( 'wgScriptPath', '../../' );
+                       mw.config.set( 'wgScriptPath', '../..' );
                </script>
        </head>
        <body>



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

Reply via email to