Index: trunk/extensions/MobileFrontend2/MobileFrontend2.php |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | $wgHooks['ArticleViewHeader'][] = 'MobileFrontend2_Hooks::articleView'; |
41 | 41 | $wgHooks['ResourceLoaderGetStartupModules'][] = 'MobileFrontend2_Hooks::startupModule'; |
42 | 42 | $wgHooks['ResourceLoaderRegisterModules'][] = 'MobileFrontend2_Hooks::registerModules'; |
| 43 | +$wgHooks['BeforeInitialize'][] = 'MobileFrontend2_Hooks::beforeInitialize'; |
43 | 44 | $wgExtensionFunctions[] = 'MobileFrontend2_Hooks::setup'; |
44 | 45 | |
45 | 46 | // Modules |
Index: trunk/extensions/MobileFrontend2/MobileFrontend2_Hooks.php |
— | — | @@ -27,6 +27,8 @@ |
28 | 28 | /** |
29 | 29 | * Adds jump back a section links to content blocks |
30 | 30 | * |
| 31 | + * @todo broken, see mobile main page |
| 32 | + * |
31 | 33 | * @param $parser MobileFrontend2_Parser |
32 | 34 | * @param $i int |
33 | 35 | * @param $section string |
— | — | @@ -118,6 +120,27 @@ |
119 | 121 | } |
120 | 122 | |
121 | 123 | /** |
| 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 | + /** |
122 | 145 | * Checks if the skin parameter is for a mobile skin |
123 | 146 | * |
124 | 147 | * This only works for load.php |
Index: trunk/extensions/MobileFrontend2/skins/Mobile.php |
— | — | @@ -27,6 +27,18 @@ |
28 | 28 | |
29 | 29 | // TODO: Hook for adding modules |
30 | 30 | |
| 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 | + |
31 | 43 | Profiler::instance()->setTemplated( true ); |
32 | 44 | |
33 | 45 | $this->initPage( $out ); |
— | — | @@ -67,6 +79,9 @@ |
68 | 80 | |
69 | 81 | $tpl->setRef( 'bodycontent', MobileFrontend2_PostParse::mangle( $out->mBodytext ) ); |
70 | 82 | |
| 83 | + // Pass the bodyClass for CSS magic |
| 84 | + $tpl->set( 'bodyclass', $bodyClass ); |
| 85 | + |
71 | 86 | // CSS & JS |
72 | 87 | // Make these last |
73 | 88 | $tpl->set( 'headscripts', $this->getHeadScripts( $out ) ); |
— | — | @@ -103,7 +118,7 @@ |
104 | 119 | * @return string |
105 | 120 | */ |
106 | 121 | 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>'; |
108 | 123 | } |
109 | 124 | |
110 | 125 | /** |
— | — | @@ -146,7 +161,7 @@ |
147 | 162 | <?php $this->html( 'csslinks' ) ?> |
148 | 163 | <?php $this->html( 'headscripts' ) ?> |
149 | 164 | </head> |
150 | | - <body> |
| 165 | + <body class="<?php $this->text( 'bodyclass' ) ?>"> |
151 | 166 | |
152 | 167 | <?php if ( !MobileFrontend2_Options::getHideSearch() ): ?> |
153 | 168 | <!-- search/header --> |
— | — | @@ -171,11 +186,13 @@ |
172 | 187 | |
173 | 188 | <!-- content --> |
174 | 189 | <div class="show" id="content_wrapper"> |
| 190 | + <?php if ( !MobileFrontend2_Options::getMainPage() ): ?> |
175 | 191 | <!-- firstHeading --> |
176 | 192 | <h1 id="firstHeading" class="firstHeading"> |
177 | 193 | <span dir="auto"><?php $this->html( 'title' ) ?></span> |
178 | 194 | </h1> |
179 | 195 | <!-- /firstHeading --> |
| 196 | + <?php endif ?> |
180 | 197 | <!-- bodyContent --> |
181 | 198 | <div id="bodyContent"> |
182 | 199 | <?php $this->html( 'bodycontent' ) ?> |
Index: trunk/extensions/MobileFrontend2/modules/ext.mobileFrontend2/ext.mobileFrontend2.css |
— | — | @@ -483,10 +483,6 @@ |
484 | 484 | float: right; |
485 | 485 | } |
486 | 486 | |
487 | | -#content_wrapper.home h1#firstHeading { |
488 | | - display: none; |
489 | | -} |
490 | | - |
491 | 487 | body { |
492 | 488 | margin: 0; |
493 | 489 | } |
— | — | @@ -610,3 +606,12 @@ |
611 | 607 | outline: none; |
612 | 608 | } |
613 | 609 | |
| 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 @@ |
153 | 153 | |
154 | 154 | $( mf2.init ); |
155 | 155 | |
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 @@ |
25 | 25 | protected static $hideFooter = false; |
26 | 26 | |
27 | 27 | /** |
| 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 | + /** |
28 | 36 | * Detects options based on user preferences |
29 | 37 | */ |
30 | 38 | public static function detect() { |
— | — | @@ -57,4 +65,18 @@ |
58 | 66 | public static function getHideFooter() { |
59 | 67 | return self::$hideFooter; |
60 | 68 | } |
| 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 | + } |
61 | 83 | } |
Index: trunk/extensions/MobileFrontend2/MobileFrontend2.i18n.php |
— | — | @@ -10,4 +10,12 @@ |
11 | 11 | |
12 | 12 | $messages['en'] = array( |
13 | 13 | '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}}', |
14 | 22 | ); |
\ No newline at end of file |