r103768 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103767‎ | r103768 | r103769 >
Date:18:07, 20 November 2011
Author:catrope
Status:resolved
Tags:
Comment:
(bug 27714) Load MediaWiki:Geshi.css using ResourceLoader. Modified patch by Lewis Cawte
Modified paths:
  • /trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php (modified) (history)
  • /trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php
@@ -54,14 +54,10 @@
5555 $wgAutoloadClasses['SyntaxHighlight_GeSHi'] = $dir . 'SyntaxHighlight_GeSHi.class.php';
5656 $wgHooks['ShowRawCssJs'][] = 'SyntaxHighlight_GeSHi::viewHook';
5757 $wgHooks['ParserFirstCallInit'][] = 'efSyntaxHighlight_GeSHiSetup';
 58+$wgHooks['ExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hSpecialVersion_GeSHi';
5859
59 -if ( version_compare( $wgVersion, '1.17alpha', '>=' ) ) {
60 - // For MediaWiki 1.17 alpha and later.
61 - $wgHooks['ExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hSpecialVersion_GeSHi';
62 -} else {
63 - // For pre-MediaWiki 1.17 alpha.
64 - $wgHooks['SpecialVersionExtensionTypes'][] = 'SyntaxHighlight_GeSHi::hOldSpecialVersion_GeSHi';
65 -}
 60+$wgAutoloadClasses['HighlightGeSHilocal'] = $dir . 'SyntaxHighlight_GeSHi.local.php';
 61+$wgResourceModules['ext.geshi.local'] = array( 'class' => 'HighlightGeSHilocal' );
6662
6763 /**
6864 * Register parser hook
Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.class.php
@@ -21,7 +21,7 @@
2222 * @return string
2323 */
2424 public static function parserHook( $text, $args = array(), $parser ) {
25 - global $wgSyntaxHighlightDefaultLang, $wgUseTidy;
 25+ global $wgSyntaxHighlightDefaultLang, $wgUseSiteCss, $wgUseTidy;
2626 wfProfileIn( __METHOD__ );
2727 self::initialise();
2828 $text = rtrim( $text );
@@ -103,6 +103,10 @@
104104 // Register CSS
105105 $parser->mOutput->addHeadItem( self::buildHeadItem( $geshi ), "source-{$lang}" );
106106
 107+ if( $wgUseSiteCss ) {
 108+ $parser->mOutput->addModuleStyles( 'ext.geshi.local' );
 109+ }
 110+
107111 $encloseTag = $enclose === GESHI_HEADER_NONE ? 'span' : 'div';
108112 $attribs = Sanitizer::validateTagAttributes( $args, $encloseTag );
109113
@@ -220,6 +224,7 @@
221225 * @return bool
222226 */
223227 public static function viewHook( $text, $title, $output ) {
 228+ global $wgUseSiteCss;
224229 // Determine the language
225230 $matches = array();
226231 preg_match( '!\.(css|js)$!u', $title->getText(), $matches );
@@ -232,6 +237,9 @@
233238 // Done
234239 $output->addHeadItem( "source-$lang", self::buildHeadItem( $geshi ) );
235240 $output->addHTML( "<div dir=\"ltr\">{$out}</div>" );
 241+ if( $wgUseSiteCss ) {
 242+ $output->addModuleStyles( 'ext.geshi.local' );
 243+ }
236244 return false;
237245 }
238246 }
@@ -279,14 +287,6 @@
280288 $css[] = $geshi->get_stylesheet( false );
281289 $css[] = '/*]]>*/';
282290 $css[] = '</style>';
283 - if( $wgUseSiteCss ) {
284 - $title = Title::makeTitle( NS_MEDIAWIKI, 'Geshi.css' );
285 - $q = "usemsgcache=yes&action=raw&ctype=text/css&smaxage={$wgSquidMaxage}";
286 - $css[] = '<style type="text/css">/*<![CDATA[*/';
287 - $css[] = '@import "' . $title->getLocalUrl( $q ) . '";';
288 - $css[] = '/*]]>*/';
289 - $css[] = '</style>';
290 - }
291291 return implode( "\n", $css );
292292 }
293293

Sign-offs

UserFlagDate
Lcawtetested18:31, 20 November 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r103769Followup r103768: svn addcatrope18:08, 20 November 2011

Status & tagging log