From ec1ccf4367515dfeba5d5f8edb2dfca00b7505ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 11 Jun 2014 12:41:40 +0200 Subject: [PATCH] Separate MonoBook skin from core This makes it behave exactly like a custom skin. * Renamed directory to reflect skin name. * Split skin classes to separate PHP files. * Removed core autoloader entries for skin classes. * Changed the hack in Setup.php to require_once the skin PHP file, as the skin is now registered there. * Extracted skin-specific localisation messages. * Extracted skin-specific resources. Change-Id: Ife9926d12b6baaa84cd2aa9a415f1183415863c8 --- includes/AutoLoader.php | 4 -- includes/Setup.php | 2 +- includes/Skin.php | 1 - languages/i18n/en.json | 3 -- languages/i18n/qqq.json | 3 -- resources/Resources.php | 18 ------- skins/{monobook => MonoBook}/IE60Fixes.css | 0 skins/{monobook => MonoBook}/IE70Fixes.css | 0 skins/MonoBook/MonoBook.php | 48 +++++++++++++++++ .../MonoBookTemplate.php} | 30 ----------- skins/MonoBook/SkinMonoBook.php | 49 ++++++++++++++++++ skins/{monobook => MonoBook}/audio.png | Bin skins/{monobook => MonoBook}/bullet.gif | Bin .../discussionitem_icon.gif | Bin skins/{monobook => MonoBook}/document.png | Bin skins/{monobook => MonoBook}/external-ltr.png | Bin skins/{monobook => MonoBook}/external-rtl.png | Bin skins/{monobook => MonoBook}/file_icon.gif | Bin skins/{monobook => MonoBook}/headbg.jpg | Bin skins/MonoBook/i18n/en.json | 8 +++ skins/MonoBook/i18n/qqq.json | 8 +++ skins/{monobook => MonoBook}/link_icon.gif | Bin skins/{monobook => MonoBook}/lock_icon.gif | Bin skins/{monobook => MonoBook}/magnify-clip.png | Bin skins/{monobook => MonoBook}/mail_icon.gif | Bin skins/{monobook => MonoBook}/main.css | 0 skins/{monobook => MonoBook}/news_icon.png | Bin skins/{monobook => MonoBook}/required.gif | Bin skins/{monobook => MonoBook}/user.gif | Bin skins/{monobook => MonoBook}/video.png | Bin skins/{monobook => MonoBook}/wiki-indexed.png | Bin skins/{monobook => MonoBook}/wiki.png | Bin 32 files changed, 114 insertions(+), 60 deletions(-) rename skins/{monobook => MonoBook}/IE60Fixes.css (100%) rename skins/{monobook => MonoBook}/IE70Fixes.css (100%) create mode 100644 skins/MonoBook/MonoBook.php rename skins/{monobook/MonoBook.php => MonoBook/MonoBookTemplate.php} (93%) create mode 100644 skins/MonoBook/SkinMonoBook.php rename skins/{monobook => MonoBook}/audio.png (100%) rename skins/{monobook => MonoBook}/bullet.gif (100%) rename skins/{monobook => MonoBook}/discussionitem_icon.gif (100%) rename skins/{monobook => MonoBook}/document.png (100%) rename skins/{monobook => MonoBook}/external-ltr.png (100%) rename skins/{monobook => MonoBook}/external-rtl.png (100%) rename skins/{monobook => MonoBook}/file_icon.gif (100%) rename skins/{monobook => MonoBook}/headbg.jpg (100%) create mode 100644 skins/MonoBook/i18n/en.json create mode 100644 skins/MonoBook/i18n/qqq.json rename skins/{monobook => MonoBook}/link_icon.gif (100%) rename skins/{monobook => MonoBook}/lock_icon.gif (100%) rename skins/{monobook => MonoBook}/magnify-clip.png (100%) rename skins/{monobook => MonoBook}/mail_icon.gif (100%) rename skins/{monobook => MonoBook}/main.css (100%) rename skins/{monobook => MonoBook}/news_icon.png (100%) rename skins/{monobook => MonoBook}/required.gif (100%) rename skins/{monobook => MonoBook}/user.gif (100%) rename skins/{monobook => MonoBook}/video.png (100%) rename skins/{monobook => MonoBook}/wiki-indexed.png (100%) rename skins/{monobook => MonoBook}/wiki.png (100%) diff --git a/includes/AutoLoader.php b/includes/AutoLoader.php index f969f799cb..54425076e2 100644 --- a/includes/AutoLoader.php +++ b/includes/AutoLoader.php @@ -1177,10 +1177,6 @@ $wgAutoloadLocalClasses = array( # mw-config 'InstallerOverrides' => 'mw-config/overrides.php', 'MyLocalSettingsGenerator' => 'mw-config/overrides.php', - - # skins - 'MonoBookTemplate' => 'skins/monobook/MonoBook.php', - 'SkinMonoBook' => 'skins/monobook/MonoBook.php', ); class AutoLoader { diff --git a/includes/Setup.php b/includes/Setup.php index 91baefba7d..ccb3a154b5 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -605,7 +605,7 @@ $wgDeferredUpdateList = array(); // This is hacky and bad, but it will go away before 1.24 release (or so I hope). // These lines should eventually be placed in skins' meta definition files, and loaded by a // require_once for each skin file generated by the installer and placed in LocalSettings.php. -$wgValidSkinNames['monobook'] = 'MonoBook'; +require_once "$wgStyleDirectory/MonoBook/MonoBook.php"; require_once "$wgStyleDirectory/Vector/Vector.php"; wfProfileOut( $fname . '-globals' ); diff --git a/includes/Skin.php b/includes/Skin.php index 25c0b04f90..177e2b1df6 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -110,7 +110,6 @@ abstract class Skin extends ContextSource { static function getSkinNameMessages() { $messages = array(); foreach ( self::getSkinNames() as $skinKey => $skinName ) { - // Messages: skinname-vector, skinname-monobook $messages[] = "skinname-$skinKey"; } return $messages; diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 1ad6a38f22..76c9b8e96b 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2462,7 +2462,6 @@ "interlanguage-link-title-nonlang": "$1 – $2", "interlanguage-link-title-nonlangonly": "$1", "common.css": "/* CSS placed here will be applied to all skins */", - "monobook.css": "/* CSS placed here will affect users of the MonoBook skin */", "print.css": "/* CSS placed here will affect the print output */", "noscript.css": "/* CSS placed here will affect users with JavaScript disabled */", "group-autoconfirmed.css": "/* CSS placed here will affect autoconfirmed users only */", @@ -2471,7 +2470,6 @@ "group-sysop.css": "/* CSS placed here will affect sysops only */", "group-bureaucrat.css": "/* CSS placed here will affect bureaucrats only */", "common.js": "/* Any JavaScript here will be loaded for all users on every page load. */", - "monobook.js": "/* Any JavaScript here will be loaded for users using the MonoBook skin */", "group-autoconfirmed.js": "/* Any JavaScript here will be loaded for autoconfirmed users only */", "group-user.js": "/* Any JavaScript here will be loaded for registered users only */", "group-bot.js": "/* Any JavaScript here will be loaded for bots only */", @@ -2543,7 +2541,6 @@ "pageinfo-category-pages": "Number of pages", "pageinfo-category-subcats": "Number of subcategories", "pageinfo-category-files": "Number of files", - "skinname-monobook": "MonoBook", "markaspatrolleddiff": "Mark as patrolled", "markaspatrolledlink": "[$1]", "markaspatrolledtext": "Mark this page as patrolled", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 4d5d6e17bc..a2ddc7abce 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2624,7 +2624,6 @@ "interlanguage-link-title-nonlang": "{{Optional}}\nFormat of a tooltip for a sidebar interwiki link that points to a specific project. Parameters:\n* $1 - page name in the target wiki\n* $2 - name of the target wiki (probably not a language name)", "interlanguage-link-title-nonlangonly": "{{ignored}}Interlanguage link title. Parameters: $1 replaced with name of the target wiki (probably not a language name).", "common.css": "{{optional}}\nCSS applied to all users.", - "monobook.css": "{{optional}}\nCSS applied to users using Monobook skin.", "print.css": "{{optional}}", "noscript.css": "{{optional}}", "group-autoconfirmed.css": "{{doc-group|autoconfirmed|css}}", @@ -2633,7 +2632,6 @@ "group-sysop.css": "{{doc-group|sysop|css}}", "group-bureaucrat.css": "{{doc-group|bureaucrat|css}}", "common.js": "{{optional}}\nJS for all users.", - "monobook.js": "{{optional}}\nJS for users using Monobook skin.", "group-autoconfirmed.js": "{{doc-group|autoconfirmed|js}}", "group-user.js": "{{doc-group|user|js}}", "group-bot.js": "{{doc-group|bot|js}}", @@ -2705,7 +2703,6 @@ "pageinfo-category-pages": "See also:\n* {{msg-mw|Pageinfo-category-subcats}}\n* {{msg-mw|Pageinfo-category-files}}", "pageinfo-category-subcats": "See also:\n* {{msg-mw|Pageinfo-category-pages}}\n* {{msg-mw|Pageinfo-category-files}}", "pageinfo-category-files": "See also:\n* {{msg-mw|Pageinfo-category-pages}}\n* {{msg-mw|Pageinfo-category-subcats}}", - "skinname-monobook": "{{optional}}", "markaspatrolleddiff": "{{doc-actionlink}}\nSee also:\n* {{msg-mw|Markaspatrolledtext}}\n{{Identical|Mark as patrolled}}", "markaspatrolledlink": "{{notranslate}}\nParameters:\n* $1 - link which has text {{msg-mw|Markaspatrolledtext}}", "markaspatrolledtext": "{{doc-actionlink}}\nSee also:\n* {{msg-mw|Markaspatrolleddiff}}", diff --git a/resources/Resources.php b/resources/Resources.php index ec02e5b36f..fd62910b06 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -118,24 +118,6 @@ return array( 'targets' => array( 'desktop', 'mobile' ), ), - /** - * Skins - * Be careful not to add 'scripts' to these modules, - * since they are loaded with OutputPage::addModuleStyles so that the skin styles - * apply without javascript. - * If a skin needs custom js in the interface, register a separate module - * and add it to the load queue with OutputPage::addModules. - * - * See Vector for an example. - */ - 'skins.monobook.styles' => array( - 'styles' => array( - 'main.css' => array( 'media' => 'screen' ), - ), - 'remoteSkinPath' => 'monobook', - 'localBasePath' => $GLOBALS['wgStyleDirectory'] . '/monobook', - ), - /* jQuery */ 'jquery' => array( diff --git a/skins/monobook/IE60Fixes.css b/skins/MonoBook/IE60Fixes.css similarity index 100% rename from skins/monobook/IE60Fixes.css rename to skins/MonoBook/IE60Fixes.css diff --git a/skins/monobook/IE70Fixes.css b/skins/MonoBook/IE70Fixes.css similarity index 100% rename from skins/monobook/IE70Fixes.css rename to skins/MonoBook/IE70Fixes.css diff --git a/skins/MonoBook/MonoBook.php b/skins/MonoBook/MonoBook.php new file mode 100644 index 0000000000..c363eb12a3 --- /dev/null +++ b/skins/MonoBook/MonoBook.php @@ -0,0 +1,48 @@ + __FILE__, + 'name' => 'MonoBook', + 'url' => 'https://www.mediawiki.org/wiki/Skin:MonoBook', +); + +// Register files +$wgAutoloadClasses['SkinMonoBook'] = __DIR__ . '/SkinMonoBook.php'; +$wgAutoloadClasses['MonoBookTemplate'] = __DIR__ . '/MonoBookTemplate.php'; +$wgMessagesDirs['MonoBook'] = __DIR__ . '/i18n'; + +// Register skin +$wgValidSkinNames['monobook'] = 'MonoBook'; + +// Register modules +$wgResourceModules['skins.monobook.styles'] = array( + 'styles' => array( + 'main.css' => array( 'media' => 'screen' ), + ), + 'remoteSkinPath' => 'MonoBook', + 'localBasePath' => __DIR__, +); diff --git a/skins/monobook/MonoBook.php b/skins/MonoBook/MonoBookTemplate.php similarity index 93% rename from skins/monobook/MonoBook.php rename to skins/MonoBook/MonoBookTemplate.php index aeef8a9905..373c0041d1 100644 --- a/skins/monobook/MonoBook.php +++ b/skins/MonoBook/MonoBookTemplate.php @@ -20,41 +20,11 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html * - * @todo document * @file * @ingroup Skins */ -if ( !defined( 'MEDIAWIKI' ) ) { - die( -1 ); -} - -/** - * Inherit main code from SkinTemplate, set the CSS and template filter. - * @todo document - * @ingroup Skins - */ -class SkinMonoBook extends SkinTemplate { - /** Using monobook. */ - public $skinname = 'monobook'; - public $template = 'MonoBookTemplate'; - - /** - * @param OutputPage $out - */ - function setupSkinUserCss( OutputPage $out ) { - parent::setupSkinUserCss( $out ); - - $out->addModuleStyles( array( 'mediawiki.skinning.interface', 'skins.monobook.styles' ) ); - - // TODO: Migrate all of these - $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' ); - $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' ); - } -} - /** - * @todo document * @ingroup Skins */ class MonoBookTemplate extends BaseTemplate { diff --git a/skins/MonoBook/SkinMonoBook.php b/skins/MonoBook/SkinMonoBook.php new file mode 100644 index 0000000000..16fbd00847 --- /dev/null +++ b/skins/MonoBook/SkinMonoBook.php @@ -0,0 +1,49 @@ +addModuleStyles( array( 'mediawiki.skinning.interface', 'skins.monobook.styles' ) ); + + // TODO: Migrate all of these + $out->addStyle( $this->stylename . '/IE60Fixes.css', 'screen', 'IE 6' ); + $out->addStyle( $this->stylename . '/IE70Fixes.css', 'screen', 'IE 7' ); + } +} diff --git a/skins/monobook/audio.png b/skins/MonoBook/audio.png similarity index 100% rename from skins/monobook/audio.png rename to skins/MonoBook/audio.png diff --git a/skins/monobook/bullet.gif b/skins/MonoBook/bullet.gif similarity index 100% rename from skins/monobook/bullet.gif rename to skins/MonoBook/bullet.gif diff --git a/skins/monobook/discussionitem_icon.gif b/skins/MonoBook/discussionitem_icon.gif similarity index 100% rename from skins/monobook/discussionitem_icon.gif rename to skins/MonoBook/discussionitem_icon.gif diff --git a/skins/monobook/document.png b/skins/MonoBook/document.png similarity index 100% rename from skins/monobook/document.png rename to skins/MonoBook/document.png diff --git a/skins/monobook/external-ltr.png b/skins/MonoBook/external-ltr.png similarity index 100% rename from skins/monobook/external-ltr.png rename to skins/MonoBook/external-ltr.png diff --git a/skins/monobook/external-rtl.png b/skins/MonoBook/external-rtl.png similarity index 100% rename from skins/monobook/external-rtl.png rename to skins/MonoBook/external-rtl.png diff --git a/skins/monobook/file_icon.gif b/skins/MonoBook/file_icon.gif similarity index 100% rename from skins/monobook/file_icon.gif rename to skins/MonoBook/file_icon.gif diff --git a/skins/monobook/headbg.jpg b/skins/MonoBook/headbg.jpg similarity index 100% rename from skins/monobook/headbg.jpg rename to skins/MonoBook/headbg.jpg diff --git a/skins/MonoBook/i18n/en.json b/skins/MonoBook/i18n/en.json new file mode 100644 index 0000000000..0b96428590 --- /dev/null +++ b/skins/MonoBook/i18n/en.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [] + }, + "skinname-monobook": "MonoBook", + "monobook.css": "/* CSS placed here will affect users of the MonoBook skin */", + "monobook.js": "/* Any JavaScript here will be loaded for users using the MonoBook skin */" +} diff --git a/skins/MonoBook/i18n/qqq.json b/skins/MonoBook/i18n/qqq.json new file mode 100644 index 0000000000..7f3a38d7e0 --- /dev/null +++ b/skins/MonoBook/i18n/qqq.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [] + }, + "skinname-monobook": "{{optional}}", + "monobook.css": "{{optional}}\nCSS applied to users using Monobook skin.", + "monobook.js": "{{optional}}\nJS for users using Monobook skin." +} diff --git a/skins/monobook/link_icon.gif b/skins/MonoBook/link_icon.gif similarity index 100% rename from skins/monobook/link_icon.gif rename to skins/MonoBook/link_icon.gif diff --git a/skins/monobook/lock_icon.gif b/skins/MonoBook/lock_icon.gif similarity index 100% rename from skins/monobook/lock_icon.gif rename to skins/MonoBook/lock_icon.gif diff --git a/skins/monobook/magnify-clip.png b/skins/MonoBook/magnify-clip.png similarity index 100% rename from skins/monobook/magnify-clip.png rename to skins/MonoBook/magnify-clip.png diff --git a/skins/monobook/mail_icon.gif b/skins/MonoBook/mail_icon.gif similarity index 100% rename from skins/monobook/mail_icon.gif rename to skins/MonoBook/mail_icon.gif diff --git a/skins/monobook/main.css b/skins/MonoBook/main.css similarity index 100% rename from skins/monobook/main.css rename to skins/MonoBook/main.css diff --git a/skins/monobook/news_icon.png b/skins/MonoBook/news_icon.png similarity index 100% rename from skins/monobook/news_icon.png rename to skins/MonoBook/news_icon.png diff --git a/skins/monobook/required.gif b/skins/MonoBook/required.gif similarity index 100% rename from skins/monobook/required.gif rename to skins/MonoBook/required.gif diff --git a/skins/monobook/user.gif b/skins/MonoBook/user.gif similarity index 100% rename from skins/monobook/user.gif rename to skins/MonoBook/user.gif diff --git a/skins/monobook/video.png b/skins/MonoBook/video.png similarity index 100% rename from skins/monobook/video.png rename to skins/MonoBook/video.png diff --git a/skins/monobook/wiki-indexed.png b/skins/MonoBook/wiki-indexed.png similarity index 100% rename from skins/monobook/wiki-indexed.png rename to skins/MonoBook/wiki-indexed.png diff --git a/skins/monobook/wiki.png b/skins/MonoBook/wiki.png similarity index 100% rename from skins/monobook/wiki.png rename to skins/MonoBook/wiki.png -- 2.20.1