Index: branches/resourceloader/phase3/includes/ResourceLoader.php |
— | — | @@ -36,6 +36,10 @@ |
37 | 37 | * 'script' and 'loader' are mandatory. |
38 | 38 | */ |
39 | 39 | public static $modules = array( |
| 40 | + 'wikibits' => array( |
| 41 | + 'script' => 'skins/common/wikibits.js', |
| 42 | + 'loader' => 'skins/common/loader.js', |
| 43 | + ), |
40 | 44 | ); |
41 | 45 | |
42 | 46 | private $scripts = array(); |
— | — | @@ -76,6 +80,7 @@ |
77 | 81 | $retval = ''; |
78 | 82 | foreach ( $styles as $style ) { |
79 | 83 | // TODO: file_get_contents() errors? |
| 84 | + // TODO: CACHING! |
80 | 85 | $css = file_get_contents( $style ); |
81 | 86 | if ( $this->useCSSJanus ) { |
82 | 87 | $css = $this->cssJanus( $css ); |
— | — | @@ -103,6 +108,7 @@ |
104 | 109 | |
105 | 110 | foreach ( $this->scripts as $script ) { |
106 | 111 | // TODO: file_get_contents() errors? |
| 112 | + // TODO: CACHING! |
107 | 113 | $retval .= file_get_contents( $script ); |
108 | 114 | } |
109 | 115 | $retval .= $this->getStyleJS( $this->styles ); |
— | — | @@ -118,6 +124,7 @@ |
119 | 125 | $retval = ''; |
120 | 126 | foreach ( self::$modules as $name => $module ) { |
121 | 127 | // TODO: file_get_contents() errors? |
| 128 | + // TODO: CACHING! |
122 | 129 | $retval .= file_get_contents( $module['loader'] ); |
123 | 130 | } |
124 | 131 | // FIXME: Duplicated; centralize in doJSTransforms() or something? |
Index: branches/resourceloader/phase3/includes/AutoLoader.php |
— | — | @@ -186,6 +186,7 @@ |
187 | 187 | 'RegexlikeReplacer' => 'includes/StringUtils.php', |
188 | 188 | 'ReplacementArray' => 'includes/StringUtils.php', |
189 | 189 | 'Replacer' => 'includes/StringUtils.php', |
| 190 | + 'ResourceLoader' => 'includes/ResourceLoader.php', |
190 | 191 | 'ReverseChronologicalPager' => 'includes/Pager.php', |
191 | 192 | 'Revision' => 'includes/Revision.php', |
192 | 193 | 'RevisionDelete' => 'includes/RevisionDelete.php', |
Index: branches/resourceloader/phase3/load.php |
— | — | @@ -0,0 +1,64 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation; either version 2 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License along |
| 15 | + * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | + * http://www.gnu.org/copyleft/gpl.html |
| 18 | + * |
| 19 | + * @author Roan Kattouw |
| 20 | + * |
| 21 | + */ |
| 22 | + |
| 23 | +/** |
| 24 | + * This file is the entry point for the resource loader. |
| 25 | + */ |
| 26 | + |
| 27 | +// TODO: Caching + easy 304s before WebStart |
| 28 | + |
| 29 | +require ( dirname( __FILE__ ) . '/includes/WebStart.php' ); |
| 30 | +wfProfileIn( 'loader.php' ); |
| 31 | + |
| 32 | +// URL safety checks |
| 33 | +// |
| 34 | +// See RawPage.php for details; summary is that MSIE can override the |
| 35 | +// Content-Type if it sees a recognized extension on the URL, such as |
| 36 | +// might be appended via PATH_INFO after 'api.php'. |
| 37 | +// |
| 38 | +// Some data formats can end up containing unfiltered user-provided data |
| 39 | +// which will end up triggering HTML detection and execution, hence |
| 40 | +// XSS injection and all that entails. |
| 41 | +// |
| 42 | +if ( $wgRequest->isPathInfoBad() ) { |
| 43 | + wfHttpError( 403, 'Forbidden', |
| 44 | + 'Invalid file extension found in PATH_INFO. ' . |
| 45 | + 'The resource loader must be accessed through the primary script entry point.' ); |
| 46 | + return; |
| 47 | + // FIXME: Doesn't this execute the rest of the request anyway? |
| 48 | + // Was taken from api.php so I guess it's maybe OK but it doesn't look good. |
| 49 | +} |
| 50 | + |
| 51 | +$loader = new ResourceLoader(); |
| 52 | +$moduleParam = $wgRequest->getVal( 'modules' ); |
| 53 | +$modules = $moduleParam ? explode( '|', $moduleParam ) : array(); |
| 54 | +foreach ( $modules as $module ) { |
| 55 | + $loader->addModule( $module ); |
| 56 | +} |
| 57 | + |
| 58 | +// TODO: Cache-Control header |
| 59 | +echo $loader->getOutput(); |
| 60 | + |
| 61 | +wfProfileOut( 'loader.php' ); |
| 62 | +wfLogProfilingData(); |
| 63 | + |
| 64 | +// Shut down the database |
| 65 | +wfGetLBFactory()->shutdown(); |
\ No newline at end of file |