http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72797
Revision: 72797
Author: tparscal
Date: 2010-09-11 10:20:26 +0000 (Sat, 11 Sep 2010)
Log Message:
-----------
Made CSSMin::remap take both local and remote directory parameters, allowing
more felxible configuration. Also made ResourceLoaderFileModule use
$wgScriptPath as the base of the remote directory parameter.
Modified Paths:
--------------
trunk/phase3/includes/ResourceLoaderModule.php
trunk/phase3/includes/libs/CSSMin.php
Modified: trunk/phase3/includes/ResourceLoaderModule.php
===================================================================
--- trunk/phase3/includes/ResourceLoaderModule.php 2010-09-11 10:10:34 UTC
(rev 72796)
+++ trunk/phase3/includes/ResourceLoaderModule.php 2010-09-11 10:20:26 UTC
(rev 72797)
@@ -684,8 +684,13 @@
* @return string Remapped CSS
*/
protected static function remapStyle( $file ) {
- global $wgUseDataURLs;
- return CSSMin::remap( file_get_contents( self::remapFilename(
$file ) ), dirname( $file ), $wgUseDataURLs );
+ global $wgUseDataURLs, $wgScriptPath;
+ return CSSMin::remap(
+ file_get_contents( self::remapFilename( $file ) ),
+ dirname( $file ),
+ $wgScriptPath . '/' . dirname( $file ),
+ $wgUseDataURLs
+ );
}
}
Modified: trunk/phase3/includes/libs/CSSMin.php
===================================================================
--- trunk/phase3/includes/libs/CSSMin.php 2010-09-11 10:10:34 UTC (rev
72796)
+++ trunk/phase3/includes/libs/CSSMin.php 2010-09-11 10:20:26 UTC (rev
72797)
@@ -18,7 +18,7 @@
* This class provides minification, URL remapping, URL extracting, and
data-URL embedding.
*
* @file
- * @version 0.1.0 -- 2010-09-09
+ * @version 0.1.1 -- 2010-09-11
* @author Trevor Parscal <[email protected]>
* @copyright Copyright 2010 Wikimedia Foundation
* @license http://www.apache.org/licenses/LICENSE-2.0
@@ -81,7 +81,7 @@
* @param $path string File path where the source was read from
* @return string Remapped CSS data
*/
- public static function remap( $source, $path, $embed = true ) {
+ public static function remap( $source, $local, $remote, $embed = true )
{
$pattern =
'/((?<embed>\s*\/\*\...@embed\s*\*\/)(?<pre>[^\;\}]*))?' . self::URL_REGEX .
'(?<post>[^;]*)[\;]?/';
$offset = 0;
while ( preg_match( $pattern, $source, $match,
PREG_OFFSET_CAPTURE, $offset ) ) {
@@ -89,11 +89,12 @@
$embed = $match['embed'][0];
$pre = $match['pre'][0];
$post = $match['post'][0];
- $file = "{$path}/{$match['file'][0]}";
- // Only proceed if we can access the file
+ $file = "{$local}/{$match['file'][0]}";
+ $url = "{$remote}/{$match['file'][0]}";
+ // Only proceed if we can access the fill
if ( file_exists( $file ) ) {
// Add version parameter as a time-stamp in ISO
8601 format, using Z for the timezone, meaning GMT
- $url = "{$file}?" . gmdate( 'Y-m-d\TH:i:s\Z',
round( filemtime( $file ), -2 ) );
+ $url .= '?' . gmdate( 'Y-m-d\TH:i:s\Z', round(
filemtime( $file ), -2 ) );
// If we the mime-type can't be determined, no
embedding will take place
$type = false;
// Try a couple of different ways to get the
mime-type of a file, in order of preference
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs