r85680 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85679‎ | r85680 | r85681 >
Date:18:22, 8 April 2011
Author:dale
Status:deferred
Tags:
Comment:
removed LocalSettings.php
updated mwEmbed specific global function mwGetFilePathFromKey
removed mediawiki.language.parser from core resources ( right now its supported via the mediaWiki support module )
Modified paths:
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/LocalSettings.php (deleted) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/cache (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/DefaultSettings.php (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/MwEmbedMediaWikiGlobalFunctions.php (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/MwEmbedPoorManSquidProxy.php (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/MwEmbedWebStartSetup.php (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/mwEmbedLoader.php (added) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/remotes/AddMediaWizardEditPage.js (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/remotes/mediaWiki.js (modified) (history)
  • /branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/resources/MwEmbedSharedResources.php (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/LocalSettings.php
@@ -1,14 +0,0 @@
2 -<?php
3 -/**
4 - * This file store all of mwEmbed local configuration ( in a default svn check out this file is empty )
5 - *
6 - * For core configuration see: includes/DefaultSettings.php
7 - *
8 - * Set $wgMwEmbedEnabledModules to the set of "mwEmbed modules" you want enabled.
9 - *
10 - * For per module configuration see modules/{moduleName}/{moduleName}.config.php
11 - * Module configuration options can be set via:
12 - * $wgMwEmbedModuleConfig[ {configuration name} ] = value;
13 - */
14 -
15 -$wgResourceLoaderDebug = false;
\ No newline at end of file
Property changes on: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/cache
___________________________________________________________________
Modified: svn:ignore
161 - a
9
4
2
5
f
d
172 + a
9
4
2
5
f
d
c
e
3
6
0
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/MwEmbedWebStartSetup.php
@@ -77,13 +77,11 @@
7878 # LocalSettings.php is the per site customization file. If it does not exist
7979 # error out
8080 if( !file_exists( MW_CONFIG_FILE ) ) {
81 - print "alert('your mwEmbed install is missing a localSettings.php');";
82 - die();
 81+ print "if( console && typeof console.log == 'function' ){ console.log('MwEmbed could not find LocalSettings.php ( using default configuration )');";
 82+} else {
 83+ # Load local settings
 84+ require_once( "$IP/LocalSettings.php" );
8385 }
84 -
85 -# Load local settings
86 -require_once( "$IP/LocalSettings.php" );
87 -
8886 # Include utility files:
8987 require_once( "$IP/includes/Hooks.php");
9088
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/MwEmbedMediaWikiGlobalFunctions.php
@@ -263,7 +263,7 @@
264264 */
265265 function mweGetFromFileCache( $key ){
266266 global $IP;
267 - $filePath = mwGetFilePathFromKey( $key );
 267+ $filePath = mweGetFilePathFromKey( $key );
268268 $rawResult = @file_get_contents( $filePath );
269269 if( $rawResult === false ){
270270 return null;
@@ -277,7 +277,7 @@
278278 */
279279 function mweSaveFileToCache ( $key, $data){
280280 global $IP;
281 - $filePath = mwGetFilePathFromKey( $key );
 281+ $filePath = mweGetFilePathFromKey( $key );
282282 $path = dirname( $filePath );
283283 if( !is_dir($path ) ){
284284 $ok = mkdir( $path, 0777, true ); // PHP5 <3
@@ -287,11 +287,34 @@
288288 }
289289 return @file_put_contents( $filePath, serialize( $data ) );
290290 }
291 -function mwGetFilePathFromKey( $key ){
 291+function mweGetFilePathFromKey( $key ){
292292 global $IP;
293293 $hash = md5( $key );
294294 // Pretty darn unlikely cache missmatch:
295295 return "$IP/cache/". substr( $hash, 0, 1) . '/' . substr( $hash, 1, 1) .
296296 '/' . substr( $key, 0, 48 );
297297 }
 298+
 299+
 300+/**
 301+ * Expand a potentially local URL to a fully-qualified URL. Assumes $wgServer
 302+ * and $wgProto are correct.
 303+ *
 304+ * @todo this won't work with current-path-relative URLs
 305+ * like "subdir/foo.html", etc.
 306+ *
 307+ * @param $url String: either fully-qualified or a local path + query
 308+ * @return string Fully-qualified URL
 309+ */
 310+function wfExpandUrl( $url ) {
 311+ if( substr( $url, 0, 2 ) == '//' ) {
 312+ global $wgProto;
 313+ return $wgProto . ':' . $url;
 314+ } elseif( substr( $url, 0, 1 ) == '/' ) {
 315+ global $wgServer;
 316+ return $wgServer . $url;
 317+ } else {
 318+ return $url;
 319+ }
 320+}
298321 ?>
\ No newline at end of file
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/MwEmbedPoorManSquidProxy.php
@@ -1,5 +1,9 @@
22 <?php
3 -// quick MwEmbedPoorManSquidProxy implementation
 3+// Quick MwEmbedPoorManSquidProxy implementation
 4+
 5+// This does basic file based cache and response reverse proxy for resource loader.
 6+// This is needed in cases where you don't have the resource loader behind a reverse proxy.
 7+
48 class MwEmbedPoorManSquidProxy {
59 public static $hash = null;
610 public static $debug = null;
@@ -39,12 +43,12 @@
4044 */
4145
4246 // Check if we have a cached file:
43 - if( !is_file( mwGetFilePathFromKey( self::$hash ) ) ){
 47+ if( ! is_file( mweGetFilePathFromKey( self::$hash ) ) ){
4448 return ;
4549 }
4650
4751 // Check file modified time:
48 - $fileTime = wfTimestamp( TS_UNIX, filemtime( mwGetFilePathFromKey( self::$hash ) ) );
 52+ $fileTime = wfTimestamp( TS_UNIX, filemtime( mweGetFilePathFromKey( self::$hash ) ) );
4953 if( wfTimestamp( TS_UNIX, time() ) - $fileTime > $smaxage){
5054 // Run the normal resource loader
5155 return ;
@@ -70,17 +74,18 @@
7175 header( 'Content-Type: text/javascript' );
7276 }
7377 header( 'Last-Modified: ' . wfTimestamp( TS_RFC2822, $fileTime ) );
 78+
7479 // no private cache in mwEmbed resource loader land ( both smaxage )
7580 header( "Cache-Control: public, max-age=$smaxage, s-maxage=$smaxage" );
7681 header( 'Expires: ' . wfTimestamp( TS_RFC2822, $smaxage + time() ) );
7782
7883 // Gzip if possible:
79 - ob_start("ob_gzhandler");
 84+ //ob_start("ob_gzhandler");
8085
8186 echo mweGetFromFileCache( self::$hash );
8287
8388 // Clear and send the buffer:
84 - ob_end_flush();
 89+ //ob_end_flush();
8590 // exit ( don't continue resource loader handling )
8691 exit(1);
8792 }
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/includes/DefaultSettings.php
@@ -9,12 +9,11 @@
1010 // The default cache directory
1111 $wgScriptCacheDirectory = realpath( dirname( __FILE__ ) ) . '/cache';
1212
13 -
1413 /**
1514 * Guess at URL to resource loader load.php
1615 */
17 -$protocol = ( isset( $_SERVER['HTTPS'] ) )? 'https' : 'http';
18 -$wgServer = $protocol . '://' . $_SERVER['SERVER_NAME'] . dirname( $_SERVER['SCRIPT_NAME'] ) . '/';
 16+$wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
 17+$wgServer = $wgProto . '://' . $_SERVER['SERVER_NAME'] . dirname( $_SERVER['SCRIPT_NAME'] ) . '/';
1918
2019 // By default set $wgScriptPath to empty
2120 $wgScriptPath = '';
@@ -103,5 +102,3 @@
104103 require_once( $wgLocalSettingsFile );
105104 }
106105
107 -
108 -?>
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/resources/MwEmbedSharedResources.php
@@ -386,13 +386,13 @@
387387 ),
388388 ),
389389
390 - 'mediawiki.language.parser' => new MwEmbedResourceLoaderFileModule( array(
 390+ /*'mediawiki.language.parser' => new MwEmbedResourceLoaderFileModule( array(
391391 'scripts' => 'resources/mediawiki.language/mediawiki.language.parser.js',
392392 'dependencies' => array( 'mediawiki.language', 'mediawiki.util' ),
393393 'debugScripts' => 'resources/mediawiki.language/mediawiki.language.parserTest.js',
394394 // @@FIXME note the messages are only needed for debugScirpts
395395 // It appears that debugScripts can only be direct resource paths not 'modules'
396396 'messages' => array( 'undelete_short', 'category-subcat-count' )
397 - ) ),
 397+ )),*/
398398
399399 );
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/mwEmbedLoader.php
@@ -0,0 +1,8 @@
 2+<?php
 3+/**
 4+ * Legacy entry point to resource loader
 5+ */
 6+// Set the request variables:
 7+$_REQUEST['modules'] = 'startup';
 8+$_REQUEST['only'] = 'scripts';
 9+include_once( 'load.php' );
\ No newline at end of file
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/remotes/AddMediaWizardEditPage.js
@@ -21,7 +21,7 @@
2222 'uploadEngine' : 'uploadWizard',
2323
2424 // Here we can setup the content provider overrides
25 - 'enabled_providers': ['wiki_commons'],
 25+ 'enabled_providers': ['commons'],
2626 // The local wiki API URL:
2727 'local_wiki_apiUrl': wgServer + wgScriptPath + '/api.php'
2828 };
Index: branches/MwEmbedStandAloneRL1_17/MwEmbedStandAlone/remotes/mediaWiki.js
@@ -95,7 +95,7 @@
9696 if( typeof mwAddMediaConfig == 'undefined'){
9797 mwAddMediaConfig = {};
9898 }
99 -mwAddMediaConfig['enabled_providers'] = [ 'wiki_commons', 'upload' ];
 99+mwAddMediaConfig['enabled_providers'] = [ 'commons', 'upload' ];
100100
101101
102102 // Special embedplayer handler ( iframe )

Status & tagging log