r111088 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111087‎ | r111088 | r111089 >
Date:20:52, 9 February 2012
Author:johnduhart
Status:deferred
Tags:
Comment:
Implemented mobile main page
Modified paths:
  • /trunk/extensions/MobileFrontend2/MobileFrontend2.i18n.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/MobileFrontend2.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php (modified) (history)
  • /trunk/extensions/MobileFrontend2/modules/ext.mobileFrontend2/ext.mobileFrontend2.css (modified) (history)
  • /trunk/extensions/MobileFrontend2/modules/ext.mobileFrontend2/ext.mobileFrontend2.js (modified) (history)
  • /trunk/extensions/MobileFrontend2/skins/Mobile.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend2/MobileFrontend2.php
@@ -39,6 +39,7 @@
4040 $wgHooks['ArticleViewHeader'][] = 'MobileFrontend2_Hooks::articleView';
4141 $wgHooks['ResourceLoaderGetStartupModules'][] = 'MobileFrontend2_Hooks::startupModule';
4242 $wgHooks['ResourceLoaderRegisterModules'][] = 'MobileFrontend2_Hooks::registerModules';
 43+$wgHooks['BeforeInitialize'][] = 'MobileFrontend2_Hooks::beforeInitialize';
4344 $wgExtensionFunctions[] = 'MobileFrontend2_Hooks::setup';
4445
4546 // Modules
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php
@@ -27,6 +27,8 @@
2828 /**
2929 * Adds jump back a section links to content blocks
3030 *
 31+ * @todo broken, see mobile main page
 32+ *
3133 * @param $parser MobileFrontend2_Parser
3234 * @param $i int
3335 * @param $section string
@@ -118,6 +120,27 @@
119121 }
120122
121123 /**
 124+ * Overrides the main page with the mobile version of the main page
 125+ *
 126+ * @param Title $title
 127+ * @param $unused
 128+ * @param $output
 129+ * @param $user
 130+ * @param $request
 131+ * @param $wiki
 132+ * @return bool
 133+ */
 134+ public static function beforeInitialize( Title &$title, &$unused, &$output, &$user, $request, $wiki ) {
 135+ if ( MobileFrontend2_Detection::isEnabled() && $title->isMainPage() ) {
 136+ $title = Title::newFromText( wfMsgForContent( 'mainpage-mobile' ) );
 137+ RequestContext::getMain()->setTitle( $title );
 138+ MobileFrontend2_Options::setMainPage( true );
 139+ }
 140+
 141+ return true;
 142+ }
 143+
 144+ /**
122145 * Checks if the skin parameter is for a mobile skin
123146 *
124147 * This only works for load.php
Index: trunk/extensions/MobileFrontend2/skins/Mobile.php
@@ -27,6 +27,18 @@
2828
2929 // TODO: Hook for adding modules
3030
 31+ $bodyClass = 'mobile';
 32+
 33+ if ( MobileFrontend2_Options::getMainPage() ) {
 34+ // fixup the HTML title
 35+ $msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
 36+ if ( !$msg->isDisabled() ) {
 37+ $out->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
 38+ }
 39+
 40+ $bodyClass .= ' mainPage';
 41+ }
 42+
3143 Profiler::instance()->setTemplated( true );
3244
3345 $this->initPage( $out );
@@ -67,6 +79,9 @@
6880
6981 $tpl->setRef( 'bodycontent', MobileFrontend2_PostParse::mangle( $out->mBodytext ) );
7082
 83+ // Pass the bodyClass for CSS magic
 84+ $tpl->set( 'bodyclass', $bodyClass );
 85+
7186 // CSS & JS
7287 // Make these last
7388 $tpl->set( 'headscripts', $this->getHeadScripts( $out ) );
@@ -103,7 +118,7 @@
104119 * @return string
105120 */
106121 public function doEditSectionLink( Title $nt, $section, $tooltip = null, $lang = false ) {
107 - return '<button>' . wfMessage( 'mobile-frontend2-show-button' )->escaped() . '</button>';
 122+ return '<button class="mf2-section-toggle">' . wfMessage( 'mobile-frontend2-show-button' )->escaped() . '</button>';
108123 }
109124
110125 /**
@@ -146,7 +161,7 @@
147162 <?php $this->html( 'csslinks' ) ?>
148163 <?php $this->html( 'headscripts' ) ?>
149164 </head>
150 - <body>
 165+ <body class="<?php $this->text( 'bodyclass' ) ?>">
151166
152167 <?php if ( !MobileFrontend2_Options::getHideSearch() ): ?>
153168 <!-- search/header -->
@@ -171,11 +186,13 @@
172187
173188 <!-- content -->
174189 <div class="show" id="content_wrapper">
 190+ <?php if ( !MobileFrontend2_Options::getMainPage() ): ?>
175191 <!-- firstHeading -->
176192 <h1 id="firstHeading" class="firstHeading">
177193 <span dir="auto"><?php $this->html( 'title' ) ?></span>
178194 </h1>
179195 <!-- /firstHeading -->
 196+ <?php endif ?>
180197 <!-- bodyContent -->
181198 <div id="bodyContent">
182199 <?php $this->html( 'bodycontent' ) ?>
Index: trunk/extensions/MobileFrontend2/modules/ext.mobileFrontend2/ext.mobileFrontend2.css
@@ -483,10 +483,6 @@
484484 float: right;
485485 }
486486
487 -#content_wrapper.home h1#firstHeading {
488 - display: none;
489 -}
490 -
491487 body {
492488 margin: 0;
493489 }
@@ -610,3 +606,12 @@
611607 outline: none;
612608 }
613609
 610+/* Disable content folding on the main page */
 611+body.mainPage .section_anchors,
 612+body.mainPage button.mf2-section-toggle {
 613+ display: none;
 614+}
 615+
 616+body.mainPage .content_block {
 617+ display: block;
 618+}
\ No newline at end of file
Index: trunk/extensions/MobileFrontend2/modules/ext.mobileFrontend2/ext.mobileFrontend2.js
@@ -152,4 +152,4 @@
153153
154154 $( mf2.init );
155155
156 -})( Zepto, MediaWiki );
\ No newline at end of file
 156+})( Zepto, mediaWiki );
\ No newline at end of file
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_Options.php
@@ -24,6 +24,14 @@
2525 protected static $hideFooter = false;
2626
2727 /**
 28+ * Not a user-option, used to do thing such as hide the title for the main
 29+ * page
 30+ *
 31+ * @var bool
 32+ */
 33+ protected static $mainPage = false;
 34+
 35+ /**
2836 * Detects options based on user preferences
2937 */
3038 public static function detect() {
@@ -57,4 +65,18 @@
5866 public static function getHideFooter() {
5967 return self::$hideFooter;
6068 }
 69+
 70+ /**
 71+ * @param boolean $mainPage
 72+ */
 73+ public static function setMainPage( $mainPage ) {
 74+ self::$mainPage = $mainPage;
 75+ }
 76+
 77+ /**
 78+ * @return boolean
 79+ */
 80+ public static function getMainPage() {
 81+ return self::$mainPage;
 82+ }
6183 }
Index: trunk/extensions/MobileFrontend2/MobileFrontend2.i18n.php
@@ -10,4 +10,12 @@
1111
1212 $messages['en'] = array(
1313 'mobile-frontend2-desc' => 'Mobile Frontend',
 14+
 15+ 'mainpage-mobile' => '{{int:mainpage}}',
 16+);
 17+
 18+$messages['qqq'] = array(
 19+ 'mobile-frontend2-desc' => '{{desc}}',
 20+
 21+ 'mainpage-mobile' => 'Page name for the Main Page used in the mobile view. Defaults to {{mw-msg|mainpage}}',
1422 );
\ No newline at end of file

Status & tagging log