r63300 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63299‎ | r63300 | r63301 >
Date:22:42, 5 March 2010
Author:vyznev
Status:ok (Comments)
Tags:
Comment:
(bug 10183) allow users to add custom css/js for all skins via /common.css & /common.js user subpages
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -2199,13 +2199,16 @@
22002200 $this->addInlineScript( $wgRequest->getText( 'wpTextbox1' ) );
22012201 } else {
22022202 $userpage = $wgUser->getUserPage();
2203 - $scriptpage = Title::makeTitleSafe(
2204 - NS_USER,
2205 - $userpage->getDBkey() . '/' . $sk->getSkinName() . '.js'
2206 - );
2207 - if ( $scriptpage && $scriptpage->exists() ) {
2208 - $userjs = Skin::makeUrl( $scriptpage->getPrefixedText(), 'action=raw&ctype=' . $wgJsMimeType );
2209 - $this->addScriptFile( $userjs );
 2203+ $names = array( 'common', $sk->getSkinName() );
 2204+ foreach( $names as $name ) {
 2205+ $scriptpage = Title::makeTitleSafe(
 2206+ NS_USER,
 2207+ $userpage->getDBkey() . '/' . $name . '.js'
 2208+ );
 2209+ if ( $scriptpage && $scriptpage->exists() ) {
 2210+ $userjs = $scriptpage->getLocalURL( 'action=raw&ctype=' . $wgJsMimeType );
 2211+ $this->addScriptFile( $userjs );
 2212+ }
22102213 }
22112214 }
22122215 }
Index: trunk/phase3/includes/Title.php
@@ -1709,8 +1709,10 @@
17101710 */
17111711 public function isValidCssJsSubpage() {
17121712 if ( $this->isCssJsSubpage() ) {
 1713+ $name = $this->getSkinFromCssJsSubpage();
 1714+ if ( $name == 'common' ) return true;
17131715 $skinNames = Skin::getSkinNames();
1714 - return array_key_exists( $this->getSkinFromCssJsSubpage(), $skinNames );
 1716+ return array_key_exists( $name, $skinNames );
17151717 } else {
17161718 return false;
17171719 }
Index: trunk/phase3/includes/Skin.php
@@ -650,10 +650,13 @@
651651 // @FIXME: properly escape the cdata!
652652 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
653653 } else {
654 - $out->addStyle( self::makeUrl(
655 - $this->userpage . '/' . $this->getSkinName() . '.css',
656 - 'action=raw&ctype=text/css' )
657 - );
 654+ $names = array( 'common', $this->getSkinName() );
 655+ foreach( $names as $name ) {
 656+ $out->addStyle( self::makeUrl(
 657+ $this->userpage . '/' . $name . '.css',
 658+ 'action=raw&ctype=text/css' )
 659+ );
 660+ }
658661 }
659662 }
660663
Index: trunk/phase3/RELEASE-NOTES
@@ -23,6 +23,8 @@
2424 has been removed.
2525
2626 === New features in 1.17 ===
 27+* (bug 10183) Users can now add personal styles and scripts to all skins via
 28+ User:<name>/common.css and /common.js (if user css/js is enabled)
2729
2830 === Bug fixes in 1.17 ===
2931 * (bug 17560) Half-broken deletion moved image files to deletion archive without

Follow-up revisions

RevisionCommit summaryAuthorDate
r63338followup to r63300: add links to /common.css & /common.js to preferencesvyznev20:42, 6 March 2010

Comments

#Comment by Raymond (talk | contribs)   16:48, 6 March 2010

Links to these new messages should be added to Special:Preferences, "Apperance/Skin" section

#Comment by Ilmari Karonen (talk | contribs)   20:45, 6 March 2010

Done in r63338. Both the code and the display could probably be made prettier, but this was about the best I could come up with right now. I'm not really used to working with HTMLForm, to be honest.

#Comment by Simetrical (talk | contribs)   19:34, 9 March 2010

Reviewed and tested, appears to be sane and work as advertised. Adds an extra stylesheet load, but that's a drop in the bucket at this point, and can only realistically be fixed by a stylesheet combiner of some kind.

Status & tagging log