r83292 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83291‎ | r83292 | r83293 >
Date:16:01, 5 March 2011
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
Include MediaWiki:Noscript.css in <noscript></noscript> tags in the header, to allow wikis to load styles for users with JS disabled.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/OutputPage.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderNoscriptModule.php (added) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/OutputPage.php
@@ -2524,18 +2524,24 @@
25252525 if ( $useESI && $wgResourceLoaderUseESI ) {
25262526 $esi = Xml::element( 'esi:include', array( 'src' => $url ) );
25272527 if ( $only == ResourceLoaderModule::TYPE_STYLES ) {
2528 - $links .= Html::inlineStyle( $esi );
 2528+ $link = Html::inlineStyle( $esi );
25292529 } else {
2530 - $links .= Html::inlineScript( $esi );
 2530+ $link = Html::inlineScript( $esi );
25312531 }
25322532 } else {
25332533 // Automatically select style/script elements
25342534 if ( $only === ResourceLoaderModule::TYPE_STYLES ) {
2535 - $links .= Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
 2535+ $link = Html::linkedStyle( wfAppendQuery( $wgLoadScript, $query ) );
25362536 } else {
2537 - $links .= Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) ) . "\n";
 2537+ $link = Html::linkedScript( wfAppendQuery( $wgLoadScript, $query ) );
25382538 }
25392539 }
 2540+
 2541+ if( $group == 'noscript' ){
 2542+ $links .= Html::rawElement( 'noscript', array(), $link ) . "\n";
 2543+ } else {
 2544+ $links .= $link . "\n";
 2545+ }
25402546 }
25412547 return $links;
25422548 }
@@ -2829,7 +2835,7 @@
28302836 $ret = '';
28312837 // Add ResourceLoader styles
28322838 // Split the styles into four groups
2833 - $styles = array( 'other' => array(), 'user' => array(), 'site' => array(), 'private' => array() );
 2839+ $styles = array( 'other' => array(), 'user' => array(), 'site' => array(), 'private' => array(), 'noscript' => array() );
28342840 $resourceLoader = $this->getResourceLoader();
28352841 foreach ( $this->getModuleStyles() as $name ) {
28362842 $group = $resourceLoader->getModule( $name )->getGroup();
@@ -2847,12 +2853,12 @@
28482854 $ret .= implode( "\n", $this->buildCssLinksArray() ) . $this->mInlineStyles;
28492855 // Add marker tag to mark the place where the client-side loader should inject dynamic styles
28502856 // We use a <meta> tag with a made-up name for this because that's valid HTML
2851 - $ret .= Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) );
 2857+ $ret .= Html::element( 'meta', array( 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ) ) . "\n";
28522858
28532859 // Add site, private and user styles
28542860 // 'private' at present only contains user.options, so put that before 'user'
28552861 // Any future private modules will likely have a similar user-specific character
2856 - foreach ( array( 'site', 'private', 'user' ) as $group ) {
 2862+ foreach ( array( 'site', 'noscript', 'private', 'user' ) as $group ) {
28572863 $ret .= $this->makeResourceLoaderLink( $sk, $styles[$group],
28582864 ResourceLoaderModule::TYPE_STYLES
28592865 );
Index: trunk/phase3/includes/resourceloader/ResourceLoaderNoscriptModule.php
@@ -0,0 +1,50 @@
 2+<?php
 3+/**
 4+ * This program is free software; you can redistribute it and/or modify
 5+ * it under the terms of the GNU General Public License as published by
 6+ * the Free Software Foundation; either version 2 of the License, or
 7+ * (at your option) any later version.
 8+ *
 9+ * This program is distributed in the hope that it will be useful,
 10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 12+ * GNU General Public License for more details.
 13+ *
 14+ * You should have received a copy of the GNU General Public License along
 15+ * with this program; if not, write to the Free Software Foundation, Inc.,
 16+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 17+ * http://www.gnu.org/copyleft/gpl.html
 18+ *
 19+ * @file
 20+ * @author Trevor Parscal
 21+ * @author Roan Kattouw
 22+ */
 23+
 24+/**
 25+ * Module for site customizations
 26+ */
 27+class ResourceLoaderNoscriptModule extends ResourceLoaderWikiModule {
 28+
 29+ /* Protected Methods */
 30+
 31+ /**
 32+ * Gets list of pages used by this module. Obviously, it makes absolutely no
 33+ * sense to include JavaScript files here... :D
 34+ *
 35+ * @return Array: List of pages
 36+ */
 37+ protected function getPages( ResourceLoaderContext $context ) {
 38+ return array( 'MediaWiki:Noscript.css' => array( 'type' => 'style' ) );
 39+ }
 40+
 41+ /* Methods */
 42+
 43+ /**
 44+ * Gets group name
 45+ *
 46+ * @return String: Name of group
 47+ */
 48+ public function getGroup() {
 49+ return 'noscript';
 50+ }
 51+}
Property changes on: trunk/phase3/includes/resourceloader/ResourceLoaderNoscriptModule.php
___________________________________________________________________
Added: svn:eol-style
152 + native
Index: trunk/phase3/includes/AutoLoader.php
@@ -201,6 +201,7 @@
202202 'ResourceLoaderWikiModule' => 'includes/resourceloader/ResourceLoaderWikiModule.php',
203203 'ResourceLoaderFileModule' => 'includes/resourceloader/ResourceLoaderFileModule.php',
204204 'ResourceLoaderSiteModule' => 'includes/resourceloader/ResourceLoaderSiteModule.php',
 205+ 'ResourceLoaderNoscriptModule' => 'includes/resourceloader/ResourceLoaderNoscriptModule.php',
205206 'ResourceLoaderUserModule' => 'includes/resourceloader/ResourceLoaderUserModule.php',
206207 'ResourceLoaderUserGroupsModule' => 'includes/resourceloader/ResourceLoaderUserGroupsModule.php',
207208 'ResourceLoaderUserOptionsModule' => 'includes/resourceloader/ResourceLoaderUserOptionsModule.php',
Index: trunk/phase3/includes/Skin.php
@@ -565,7 +565,7 @@
566566
567567 // Per-site custom styles
568568 if ( $wgUseSiteCss ) {
569 - $out->addModuleStyles( 'site' );
 569+ $out->addModuleStyles( array( 'site', 'noscript' ) );
570570 if( $wgUser->isLoggedIn() ){
571571 $out->addModuleStyles( 'user.groups' );
572572 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3508,6 +3508,7 @@
35093509 'vector.css' => '/* CSS placed here will affect users of the Vector skin */', # only translate this message to other languages if you have to change it
35103510 'print.css' => '/* CSS placed here will affect the print output */', # only translate this message to other languages if you have to change it
35113511 'handheld.css' => '/* CSS placed here will affect handheld devices based on the skin configured in $wgHandheldStyle */', # only translate this message to other languages if you have to change it
 3512+'noscript.css' => '/* CSS placed here will affect users with JavaScript disabled */', # only translate this message to other languages if you have to change it
35123513 'autoconfirmed.css' => '/* CSS placed here will affect autoconfirmed users only */', # only translate this message to other languages if you have to change it
35133514 'bot.css' => '/* CSS placed here will affect bots only */', # only translate this message to other languages if you have to change it
35143515 'sysop.css' => '/* CSS placed here will affect sysops only */', # only translate this message to other languages if you have to change it
Index: trunk/phase3/RELEASE-NOTES
@@ -87,6 +87,8 @@
8888 specifically, rather than all ZIP files being blocked.
8989 * (bug 2429) Allow selection of associated namespace in recent changes
9090 * (bug 26995) File size is now checked before uploading in HTML5 browsers
 91+* CSS stylesheet MediaWiki:Noscript.css is now loaded for users with JavaScript
 92+ disabled (enclosed in the head in a <noscript> tag)
9193
9294 === Bug fixes in 1.18 ===
9395 * (bug 23119) WikiError class and subclasses are now marked as deprecated
Index: trunk/phase3/resources/Resources.php
@@ -5,6 +5,7 @@
66 /* Special resources who have their own classes */
77
88 'site' => array( 'class' => 'ResourceLoaderSiteModule' ),
 9+ 'noscript' => array( 'class' => 'ResourceLoaderNoscriptModule' ),
910 'startup' => array( 'class' => 'ResourceLoaderStartUpModule' ),
1011 'user' => array( 'class' => 'ResourceLoaderUserModule' ),
1112 'user.options' => array( 'class' => 'ResourceLoaderUserOptionsModule' ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r83310Follow-up r83292: Messages of the type foo.css are optional to translate.raymond19:12, 5 March 2011
r83481Follow-up r83292/r83310: Add new message to the maintenance file tooraymond20:03, 7 March 2011

Comments

#Comment by Catrope (talk | contribs)   18:27, 7 March 2011
+ * @author Trevor Parscal
+ * @author Roan Kattouw
+ */
+
+/**
+ * Module for site customizations

These should be updated.

Status & tagging log