r45848 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45847‎ | r45848 | r45849 >
Date:19:42, 17 January 2009
Author:raymond
Status:ok
Tags:
Comment:
* Add $wgDraftsStyleVersion to enforce always the latest .css/.js versions clientside
* Add var wgDraftsStyleVersion in HTML code
* Change addScriptFile to addScript to use $wgDraftsStyleVersion
Modified paths:
  • /trunk/extensions/Drafts/Drafts.hooks.php (modified) (history)
  • /trunk/extensions/Drafts/Drafts.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Drafts/Drafts.php
@@ -38,6 +38,9 @@
3939 // Shortcut to this extension directory
4040 $dir = dirname( __FILE__ ) . '/';
4141
 42+# Bump the version number every time you change any of the .css/.js files
 43+$wgDraftsStyleVersion = 1;
 44+
4245 // Seconds of inactivity after change before autosaving
4346 // Use the value 0 to disable autosave
4447 $egDraftsAutoSaveWait = 120;
Index: trunk/extensions/Drafts/Drafts.hooks.php
@@ -230,12 +230,13 @@
231231 * Add ajax support script
232232 */
233233 public static function addJS( $out ) {
234 - global $wgScriptPath;
235 -
 234+ global $wgScriptPath, $wgJsMimeType, $wgDraftsStyleVersion;
 235+
236236 // FIXME: assumes standard dir structure
237237 // Add javascript to support ajax draft saving
238 - $out->addScriptFile( $wgScriptPath . '/extensions/Drafts/Drafts.js' );
239 -
 238+ $out->addInlineScript( "var wgDraftsStyleVersion = \"$wgDraftsStyleVersion\";\n" );
 239+ $out->addScript( "<script type=\"$wgJsMimeType\" src=\"$wgScriptPath/extensions/Drafts/Drafts.js?$wgDraftsStyleVersion\"></script>\n" );
 240+
240241 // Continue
241242 return true;
242243 }
@@ -245,18 +246,18 @@
246247 * Add ajax support script
247248 */
248249 public static function addCSS( $out ) {
249 - global $wgScriptPath;
250 -
 250+ global $wgScriptPath, $wgDraftsStyleVersion;
 251+
251252 // FIXME: assumes standard dir structure
252253 // Add css for various styles
253254 $out->addLink(
254255 array(
255256 'rel' => 'stylesheet',
256257 'type' => 'text/css',
257 - 'href' => $wgScriptPath . '/extensions/Drafts/Drafts.css',
 258+ 'href' => "$wgScriptPath/extensions/Drafts/Drafts.css?$wgDraftsStyleVersion",
258259 )
259260 );
260 -
 261+
261262 // Continue
262263 return true;
263264 }

Status & tagging log