jenkins-bot has submitted this change and it was merged.
Change subject: Breaking change: Move logic for section wrapping out of skin
into hook
......................................................................
Breaking change: Move logic for section wrapping out of skin into hook
This allows other skins to benefit from having lead sections marked up.
This is backwards compatible with old HTML for sections (checked vigorously)
Changes:
* Update toggling code to only take into account children so that table of
contents is not included if it has rendered already
* #content now has .mw-body class so that notification area is not added inside
the content element (see mw.util)
Breaking change:
* Now entire content is wrapped in element with id mw-content-text - this
is consistent with desktop but now means the lead section is one more deep
then before. For clients using Page.getLeadSection this will not be a problem
but things like QuickSurveys will need to be updated. Given the deployment
freeze this is a good time to do this! Please can merger open a bug to fix
QuickSurveys in mobile?
Bug: T115147
Change-Id: I11fd44f183a95c7564961c6273235c126eaa3b8b
---
M includes/MobileFrontend.body.php
M includes/MobileFrontend.hooks.php
M includes/skins/MinervaTemplate.php
M includes/skins/SkinMinerva.php
M resources/mobile.startup/Page.js
M resources/mobile.startup/Section.hogan
M resources/mobile.toggle/toggle.js
M resources/skins.minerva.toggling/init.js
8 files changed, 28 insertions(+), 32 deletions(-)
Approvals:
Florianschmidtwelzow: Looks good to me, approved
Jdlrobson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/MobileFrontend.body.php b/includes/MobileFrontend.body.php
index bb54f0c..f078beb 100644
--- a/includes/MobileFrontend.body.php
+++ b/includes/MobileFrontend.body.php
@@ -31,8 +31,8 @@
*
* @return string
*/
- public static function DOMParse( OutputPage $out, $mode ) {
- $html = $out->getHTML();
+ public static function DOMParse( OutputPage $out, $text = null, $isBeta
= false ) {
+ $html = $text ? $text : $out->getHTML();
$context = MobileContext::singleton();
@@ -64,7 +64,7 @@
// If the page is a user page which has not been created, then
let the
// user know about it with pretty graphics and different texts
depending
// on whether the user is the owner of the page or not.
- if ( $mode === 'beta' && $title->inNamespace( NS_USER ) &&
!$title->isSubpage() ) {
+ if ( $isBeta && $title->inNamespace( NS_USER ) &&
!$title->isSubpage() ) {
$pageUserId = User::idFromName( $title->getText() );
if ( $pageUserId && !$title->exists() ) {
$pageUser = User::newFromId( $pageUserId );
diff --git a/includes/MobileFrontend.hooks.php
b/includes/MobileFrontend.hooks.php
index e409282..1abb999 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -1089,13 +1089,14 @@
global $wgMFWikibaseImageCategory;
$context = MobileContext::singleton();
+ $isBeta = $context->isBetaGroupMember();
$mfUseWikibaseDescription = $context->getMFConfig()->get(
'MFUseWikibaseDescription' );
if ( $context->shouldDisplayMobileView() ) {
$outputPage->enableTOC( false );
$outputPage->setProperty( 'MinervaTOC',
$po->getTOCHTML() !== '' );
- if ( $mfUseWikibaseDescription &&
$context->isBetaGroupMember() ) {
+ if ( $mfUseWikibaseDescription && $isBeta ) {
$item = $po->getProperty( 'wikibase_item' );
if ( $item ) {
$desc =
ExtMobileFrontend::getWikibaseDescription( $item );
@@ -1108,6 +1109,8 @@
}
}
}
+ // Enable wrapped sections
+ $po->setText( ExtMobileFrontend::DOMParse( $outputPage,
$po->getText(), $isBeta ) );
}
return true;
}
diff --git a/includes/skins/MinervaTemplate.php
b/includes/skins/MinervaTemplate.php
index 878ffef..59ffd95 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -217,13 +217,9 @@
*/
protected function renderContent( $data ) {
if ( !$data[ 'unstyledContent' ] ) {
- // Add a mw-content-ltr/rtl class to be able to style
based on text direction
- $langClass = 'mw-content-' . $data['pageDir'];
echo Html::openElement( 'div', array(
'id' => 'bodyContent',
- 'class' => 'content ' . $langClass,
- 'lang' => $data['pageLang'],
- 'dir' => $data['pageDir'],
+ 'class' => 'content',
) );
echo $data[ 'bodytext' ];
if ( isset( $data['subject-page'] ) ) {
@@ -347,7 +343,7 @@
echo $this->getHeaderHtml(
$data );
?>
</div>
- <div id="content">
+ <div id="content" class="mw-body">
<?php
$this->renderContentWrapper( $data );
?>
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 8fa33b9..7ae0a09 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -48,18 +48,6 @@
'maximum-scale=5.0, width=device-width'
);
- if ( $this->isMobileMode ) {
- // Customize page content for mobile view, e.g. add
togglable sections, filter
- // out various elements.
- // We do this before executing
parent::prepareQuickTemplate() since the parent
- // overwrites $out->mBodytext, adding an
mw-content-text div which is
- // redundant to our own content div. By defining the
bodytext HTML before
- // $out->mBodytext is overwritten, we avoid including
the mw-content-text div.
- // FIXME: Git rid of our content div and consolidate
this line with the other
- // isMobileMode lines below. This will bring us more in
line with core DOM.
- $html = ExtMobileFrontend::DOMParse( $out, $this->mode
);
- }
-
// Generate skin template
$tpl = parent::prepareQuickTemplate();
@@ -82,12 +70,6 @@
$this->preparePageActions( $tpl );
$this->prepareUserButton( $tpl );
$this->prepareLanguages( $tpl );
-
- // Perform a few extra changes if we are in mobile mode
- if ( $this->isMobileMode ) {
- // Set our own bodytext that has been filtered by
MobileFormatter
- $tpl->set( 'bodytext', $html );
- }
return $tpl;
}
diff --git a/resources/mobile.startup/Page.js b/resources/mobile.startup/Page.js
index 58e566f..1fc513b 100644
--- a/resources/mobile.startup/Page.js
+++ b/resources/mobile.startup/Page.js
@@ -108,7 +108,18 @@
* @return {jQuery.Object}
*/
getLeadSectionElement: function () {
- return this.$( '> div' ).eq( 0 );
+ /*
+ * The page is formatted as follows:
+ * <div id="bodyContent">
+ * <!-- content of the page.. -->
+ * <div id="mw-content-text">
+ * <div>lead section</div>
+ * <h2></h2>
+ * <div>second section</div>
+ * </div>
+ * </div>
+ */
+ return this.$( '> div > div' ).eq( 0 );
},
/**
diff --git a/resources/mobile.startup/Section.hogan
b/resources/mobile.startup/Section.hogan
index 0ad5fdb..9f05598 100644
--- a/resources/mobile.startup/Section.hogan
+++ b/resources/mobile.startup/Section.hogan
@@ -1,2 +1,2 @@
-{{#line}}<h{{level}} id="{{anchor}}">{{{line}}}</h{{level}}>{{/line}}
+<h{{level}} id="{{anchor}}">{{{line}}}</h{{level}}>
{{{text}}}
diff --git a/resources/mobile.toggle/toggle.js
b/resources/mobile.toggle/toggle.js
index 9b600ed..bbdeb55 100644
--- a/resources/mobile.toggle/toggle.js
+++ b/resources/mobile.toggle/toggle.js
@@ -262,7 +262,7 @@
}
}
- $container.find( tagName ).each( function ( i ) {
+ $container.children( tagName ).each( function ( i ) {
var $heading = $( this ),
id = prefix + 'collapsible-block-' + i;
// Be sure there is a div wrapping the section content.
diff --git a/resources/skins.minerva.toggling/init.js
b/resources/skins.minerva.toggling/init.js
index ec24db4..dfdad32 100644
--- a/resources/skins.minerva.toggling/init.js
+++ b/resources/skins.minerva.toggling/init.js
@@ -2,7 +2,7 @@
var schema,
page = M.getCurrentPage(),
SchemaMobileWebSectionUsage = M.require(
'mobile.loggingSchemas/SchemaMobileWebSectionUsage' ),
- $contentContainer = $( '#content #bodyContent' ),
+ $contentContainer = $( '#mw-content-text' ),
Toggler = M.require( 'mobile.toggle/Toggler' );
/**
@@ -25,6 +25,10 @@
new Toggler( $container, prefix, page, schema );
}
+ // FIXME: remove when cache clears
+ if ( !$contentContainer.length ) {
+ $contentContainer = $( '#content #bodyContent' );
+ }
// avoid this running on Watchlist
if (
!page.inNamespace( 'special' ) &&
--
To view, visit https://gerrit.wikimedia.org/r/243227
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I11fd44f183a95c7564961c6273235c126eaa3b8b
Gerrit-PatchSet: 14
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhobs <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits