r106782 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106781‎ | r106782 | r106783 >
Date:12:01, 20 December 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Resourceloader-ify CSS/JS from CentralAuth

Kill $wgCentralAuthStyleVersion as now un-needed
Modified paths:
  • /trunk/extensions/CentralAuth/CentralAuth.php (modified) (history)
  • /trunk/extensions/CentralAuth/centralauth.css (deleted) (history)
  • /trunk/extensions/CentralAuth/centralauth.js (deleted) (history)
  • /trunk/extensions/CentralAuth/modules (added) (history)
  • /trunk/extensions/CentralAuth/modules/ext.centralauth.css (added) (history)
  • /trunk/extensions/CentralAuth/modules/ext.centralauth.js (added) (history)
  • /trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralAuth/centralauth.js
@@ -1,34 +0,0 @@
2 -wgCursorPosition = { x : 0, y : 0 };
3 -function updateCursorPosition( e ) {
4 - e = e || window.event;
5 - wgCursorPosition.x = e.clientX + ( document.documentElement.scrollLeft || document.body.scrollLeft )
6 - - document.documentElement.clientLeft;
7 - wgCursorPosition.y = e.clientY + ( document.documentElement.scrollTop || document.body.scrollTop )
8 - - document.documentElement.clientTop;
9 -}
10 -document.onmousemove = updateCursorPosition;
11 -
12 -methodHint = null;
13 -function showMethodHint( methodName ) {
14 - hideMethodHint();
15 -
16 - method = wgMergeMethodDescriptions[methodName];
17 - helpHtml = "<p class='merge-method-help-name'>" + method.short + "</p>" + method.desc;
18 -
19 - methodHint = document.createElement( 'div' );
20 - methodHint.innerHTML = helpHtml;
21 - methodHint.setAttribute( 'class', 'merge-method-help-div' );
22 - methodHint.style.left = wgCursorPosition.x + 'px';
23 - methodHint.style.top = wgCursorPosition.y + 'px';
24 - methodHint.setAttribute( 'onclick', 'hideMethodHint()' );
25 -
26 - var content = document.getElementById('content') || document.getElementById('mw_content') || document.body;
27 - content.appendChild( methodHint );
28 -}
29 -
30 -function hideMethodHint() {
31 - if( methodHint ) {
32 - methodHint.parentNode.removeChild( methodHint );
33 - methodHint = null;
34 - }
35 -}
Index: trunk/extensions/CentralAuth/centralauth.css
@@ -1,21 +0,0 @@
2 -.merge-method-help {
3 - color: #aaa;
4 - cursor: pointer;
5 - font-size: 7pt;
6 - padding: 3px;
7 -}
8 -
9 -.merge-method-help-div {
10 - position: absolute;
11 - z-index: 3;
12 - cursor: pointer;
13 -
14 - width: 15em;
15 - border: 1px solid black;
16 - background-color: #ff9;
17 - padding: 0.5em;
18 -}
19 -
20 -.merge-method-help-name {
21 - font-weight: bold;
22 -}
Index: trunk/extensions/CentralAuth/CentralAuth.php
@@ -126,11 +126,6 @@
127127 $wgCentralAuthNew2UDPPrefix = '';
128128
129129 /**
130 - * A CSS file version. Change each time centralauth.css is changed.
131 - */
132 -$wgCentralAuthStyleVersion = 2;
133 -
134 -/**
135130 * List of local pages global users may edit while being globally locked.
136131 */
137132 $wgCentralAuthLockedCanEdit = array();
@@ -250,6 +245,17 @@
251246 $wgLogActionsHandlers["gblrights/{$type}"] = 'efHandleWikiSetLogEntry';
252247 }
253248
 249+$commonModuleInfo = array(
 250+ 'localBasePath' => dirname( __FILE__ ) . '/modules',
 251+ 'remoteExtPath' => 'CentralAuth/modules',
 252+);
 253+
 254+// Styles and any code common to all Special:Code subviews:
 255+$wgResourceModules['ext.centralauth'] = array(
 256+ 'scripts' => 'ext.centralauth.js',
 257+ 'styles' => 'ext.centralauth.css',
 258+) + $commonModuleInfo;
 259+
254260 /**
255261 * @param $type
256262 * @param $action
@@ -260,7 +266,7 @@
261267 * @return String
262268 */
263269 function efHandleWikiSetLogEntry( $type, $action, $title, $skin, $params, $filterWikilinks = false ) {
264 - $link = $skin ? $skin->makeLinkObj( $title, htmlspecialchars( $params[0] ) ) : $params[0];
 270+ $link = Linker::makeLinkObj( $title, htmlspecialchars( $params[0] ) );
265271
266272 switch( $action ) {
267273 case 'newset':
Index: trunk/extensions/CentralAuth/specials/SpecialCentralAuth.php
@@ -17,7 +17,6 @@
1818
1919 function execute( $subpage ) {
2020 global $wgOut;
21 - global $wgExtensionAssetsPath, $wgCentralAuthStyleVersion;
2221 global $wgUser, $wgRequest, $wgContLang;
2322 $this->setHeaders();
2423
@@ -26,10 +25,7 @@
2726 $this->mCanOversight = $wgUser->isAllowed( 'centralauth-oversight' );
2827 $this->mCanEdit = $this->mCanUnmerge || $this->mCanLock || $this->mCanOversight;
2928
30 - $wgOut->addExtensionStyle( "{$wgExtensionAssetsPath}/CentralAuth/centralauth.css?" .
31 - $wgCentralAuthStyleVersion );
32 - $wgOut->addScriptFile( "{$wgExtensionAssetsPath}/CentralAuth/centralauth.js?" .
33 - $wgCentralAuthStyleVersion );
 29+ $wgOut->addModules( 'ext.centralauth' );
3430 $this->addMergeMethodDescriptions();
3531
3632 $this->mUserName =
Index: trunk/extensions/CentralAuth/modules/ext.centralauth.css
@@ -0,0 +1,21 @@
 2+.merge-method-help {
 3+ color: #aaa;
 4+ cursor: pointer;
 5+ font-size: 7pt;
 6+ padding: 3px;
 7+}
 8+
 9+.merge-method-help-div {
 10+ position: absolute;
 11+ z-index: 3;
 12+ cursor: pointer;
 13+
 14+ width: 15em;
 15+ border: 1px solid black;
 16+ background-color: #ff9;
 17+ padding: 0.5em;
 18+}
 19+
 20+.merge-method-help-name {
 21+ font-weight: bold;
 22+}
Property changes on: trunk/extensions/CentralAuth/modules/ext.centralauth.css
___________________________________________________________________
Added: svn:eol-style
123 + native
Index: trunk/extensions/CentralAuth/modules/ext.centralauth.js
@@ -0,0 +1,34 @@
 2+wgCursorPosition = { x : 0, y : 0 };
 3+function updateCursorPosition( e ) {
 4+ e = e || window.event;
 5+ wgCursorPosition.x = e.clientX + ( document.documentElement.scrollLeft || document.body.scrollLeft )
 6+ - document.documentElement.clientLeft;
 7+ wgCursorPosition.y = e.clientY + ( document.documentElement.scrollTop || document.body.scrollTop )
 8+ - document.documentElement.clientTop;
 9+}
 10+document.onmousemove = updateCursorPosition;
 11+
 12+methodHint = null;
 13+function showMethodHint( methodName ) {
 14+ hideMethodHint();
 15+
 16+ method = wgMergeMethodDescriptions[methodName];
 17+ helpHtml = "<p class='merge-method-help-name'>" + method.short + "</p>" + method.desc;
 18+
 19+ methodHint = document.createElement( 'div' );
 20+ methodHint.innerHTML = helpHtml;
 21+ methodHint.setAttribute( 'class', 'merge-method-help-div' );
 22+ methodHint.style.left = wgCursorPosition.x + 'px';
 23+ methodHint.style.top = wgCursorPosition.y + 'px';
 24+ methodHint.setAttribute( 'onclick', 'hideMethodHint()' );
 25+
 26+ var content = document.getElementById('content') || document.getElementById('mw_content') || document.body;
 27+ content.appendChild( methodHint );
 28+}
 29+
 30+function hideMethodHint() {
 31+ if( methodHint ) {
 32+ methodHint.parentNode.removeChild( methodHint );
 33+ methodHint = null;
 34+ }
 35+}
Property changes on: trunk/extensions/CentralAuth/modules/ext.centralauth.js
___________________________________________________________________
Added: svn:eol-style
136 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r107123Fixup CA js/css per Roan on r106782...reedy23:24, 22 December 2011
r114151* (bug 34980) [Regression] IRC action text should never contain HTML for title...ialex16:40, 19 March 2012

Comments

#Comment by Catrope (talk | contribs)   18:45, 21 December 2011
-		$wgOut->addExtensionStyle( "{$wgExtensionAssetsPath}/CentralAuth/centralauth.css?" .
-			$wgCentralAuthStyleVersion );
-		$wgOut->addScriptFile( "{$wgExtensionAssetsPath}/CentralAuth/centralauth.js?" .
-			$wgCentralAuthStyleVersion );
+		$wgOut->addModules( 'ext.centralauth' );

This will cause a flash of unstyled content for the +.merge-method-help rule.

#Comment by Reedy (talk | contribs)   01:03, 22 December 2011

If can someone can either advise how to best fix this, else, fix it for me, it'd be appreciated

#Comment by Catrope (talk | contribs)   20:45, 22 December 2011

Sorry :)

You need to put the CSS file in a separate module and load that module with addModuleStyles().

#Comment by Reedy (talk | contribs)   22:03, 22 December 2011

Cheers!

Roan, do you realise you're using HTTP? ;)

#Comment by Catrope (talk | contribs)   22:04, 22 December 2011

Huh? What do you mean? Posting over HTTP? That sounds unlikely, I have HTTPSEverywhere enabled.

#Comment by Reedy (talk | contribs)   22:06, 22 December 2011
"Catrope" posted a comment on MediaWiki.[[Special:Code/MediaWiki/106782|r106782]].
URL: [http://www.mediawiki.org/wiki/Special:Code/MediaWiki/106782#c28363 http://www.mediawiki.org/wiki/Special:Code/MediaWiki/106782#c28363]

Commit summary for MediaWiki.[[Special:Code/MediaWiki/106782|r106782]]:

Resourceloader-ify CSS/JS from CentralAuth

Kill $wgCentralAuthStyleVersion as now un-needed

Catrope's comment:

Huh? What do you mean? Posting over HTTP? That sounds unlikely, I have HTTPSEverywhere enabled.

Ok, so CR is giving non https links again? :/

#Comment by Catrope (talk | contribs)   22:07, 22 December 2011

Yeah, I guess CR is probably just using getCanonicalUrl() now? I don't know.

Status & tagging log