Remove MinervaTemplate::getContentHtml

* Move method to SkinMinerva
* Turn preparePageContent into a getter that returns the subject
page
* Use getSubjectPage in template

For mobile special pages this now means the page has two .content elements
On those pages I've disabled the initial content element. It also means
various .content <heading> and .content ul  rules now apply that need to be
disabled.

While testing several other issues were taken care of - for example
the h2 in errors

Depends-On: I7761396d6a33830f279742be01240796573556a7
Bug: T291871
Change-Id: I13bc4b5dae7aed86eca31ef306212365e1759481
This commit is contained in:
jdlrobson 2021-10-04 15:03:29 -07:00 committed by Jdlrobson
parent 99008f90db
commit a7b66f6f63
9 changed files with 81 additions and 37 deletions

View file

@ -149,27 +149,6 @@ class MinervaTemplate extends BaseTemplate {
return $html;
}
/**
* Get the HTML for the content of a page
* @param array $data Data used to build the page
* @return string representing HTML of content
*/
protected function getContentHtml( $data ) {
if ( !$data[ 'unstyledContent' ] ) {
$content = Html::openElement( 'div', [
'id' => 'bodyContent',
'class' => 'content',
] );
$content .= $data[ 'bodytext' ];
if ( isset( $data['subject-page'] ) ) {
$content .= $data['subject-page'];
}
return $content . Html::closeElement( 'div' );
}
return $data[ 'bodytext' ];
}
/**
* Gets the main menu HTML.
* @param array $data Data used to build the page
@ -203,7 +182,6 @@ class MinervaTemplate extends BaseTemplate {
'postheadinghtml' => $data['postheadinghtml'] ?? '',
'pageactionshtml' => $hasPageActions ? $this->getPageActionsHtml() : '',
'userMenuHTML' => $data['userMenuHTML'],
'contenthtml' => $this->getContentHtml( $data ),
'secondaryactionshtml' => $this->getSecondaryActionsHtml(),
'html-minerva-lastmodified' => $this->getHistoryLinkHtml( $data ),

View file

@ -72,7 +72,9 @@ class SkinMinerva extends SkinMustache {
$tpl = $this->prepareQuickTemplate();
$tplData = $tpl->execute();
return $data + $tplData;
return $data + $tplData + [
'html-minerva-subject-link' => $this->getSubjectPage(),
];
}
/**
@ -119,16 +121,11 @@ class SkinMinerva extends SkinMustache {
// Generate skin template
$tpl = parent::prepareQuickTemplate();
// Set whether or not the page content should be wrapped in div.content (for
// example, on a special page)
$tpl->set( 'unstyledContent', $out->getProperty( 'unstyledContent' ) );
// Set the links for page secondary actions
$tpl->set( 'secondary_actions', $this->getSecondaryActions( $tpl ) );
// Construct various Minerva-specific interface elements
$this->prepareMenus( $tpl );
$this->preparePageContent( $tpl );
$this->prepareHeaderAndFooter( $tpl );
$this->prepareBanners( $tpl );
$this->prepareUserNotificationsButton( $tpl, $tpl->get( 'newtalk' ) );
@ -161,11 +158,9 @@ class SkinMinerva extends SkinMustache {
}
/**
* Prepares the header and the content of a page
* Stores in QuickTemplate prebodytext, postbodytext keys
* @param QuickTemplate $tpl
* @return string
*/
protected function preparePageContent( QuickTemplate $tpl ) {
protected function getSubjectPage() {
$services = MediaWikiServices::getInstance();
$title = $this->getTitle();
$skinOptions = $this->getSkinOptions();
@ -190,11 +185,13 @@ class SkinMinerva extends SkinMustache {
}
$subjectPage = $services->getNamespaceInfo()->getSubjectPage( $title );
$tpl->set( 'subject-page', MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
return MediaWikiServices::getInstance()->getLinkRenderer()->makeLink(
$subjectPage,
$this->msg( $msg, $title->getText() )->text(),
[ 'class' => 'return-link' ]
) );
);
} else {
return '';
}
}

View file

@ -66,7 +66,12 @@
<div class="minerva__subtitle">{{{html-subtitle}}}</div>
</div>
{{/hasheadingholder}}
{{{contenthtml}}}
<div id="bodyContent" class="content">
{{{html-body-content}}}
{{! This shows "Return to page" on talk page when talk tab not shown at top.
To see set wgMinervaTalkAtTop to false and visit a talk page}}
{{{html-minerva-subject-link}}}
</div>
<div class="post-content" id="page-secondary-actions">
{{{secondaryactionshtml}}}
</div>

View file

@ -34,6 +34,7 @@ A file for css that optimises the Minerva skin on larger devices.
/* Form only pages e.g. Special:MobileOptions */
#mw-content-text > form,
.content,
.content-unstyled,
.post-content {
max-width: @contentMaxWidthTablet;
margin: 0 @contentPaddingTablet;

View file

@ -194,6 +194,9 @@
"mobile.init.styles": [
"skinStyles/mobile.init.styles/mobile.less"
],
"mobile.special.nearby.styles": [
"skinStyles/mobile.special.nearby.styles.less"
],
"mediawiki.diff.styles": [
"skinStyles/mediawiki.diff.styles.less"
],

View file

@ -1,5 +1,5 @@
// stylelint-disable selector-max-id
@import 'mediawiki.ui/variables';
@import '../minerva.less/minerva.variables.less';
// Override MobileFrontend styles (can be weakened/removed when MobileDiff no longer exists)
#mw-mf-diffview .mw-diff-empty-line {
@ -19,6 +19,21 @@
}
}
.mw-special-MobileDiff {
#mw-mf-diffarea {
padding-left: 0;
padding-right: 0;
}
}
@media all and ( max-width: @width-breakpoint-tablet ) {
.mw-special-MobileDiff {
.content-unstyled {
margin: 0 @contentMargin;
}
}
}
@media all and ( max-width: @width-breakpoint-tablet ) {
// T233151: Remove post-content margin on mobile diff page drawer
// .post-content margin

View file

@ -0,0 +1,6 @@
// stylelint-disable selector-max-id
#bodyContent.content {
max-width: none;
margin: 0;
width: auto;
}

View file

@ -1,6 +1,13 @@
@import 'mediawiki.ui/variables';
@import '../minerva.less/minerva.variables.less';
// Reset .content ul styles from core.
.content {
.page-summary h3 {
padding: 0;
}
}
@media screen and ( min-width: @width-breakpoint-tablet ) {
.empty-page {
max-width: @contentMaxWidthTablet + 2 * @iconGutterWidth;

View file

@ -1,6 +1,32 @@
// stylelint-disable selector-max-id
@import '../../minerva.less/minerva.variables.less';
@import '../../minerva.less/minerva.mixins.less';
.mw-mf-special-page {
#bodyContent.content {
max-width: none;
margin: 0;
width: auto;
ul {
list-style: none;
padding: 0;
}
// override core .content li rule
.page-header-bar li {
margin-bottom: 0;
}
.mw-mf-history-wrap-link {
@media all and ( min-width: @width-breakpoint-desktop ) {
margin: 0;
max-width: none;
}
}
}
}
// FIXME [mediawiki ui] These rules should not be needed in the mobile context
.mw-ui-button-group {
text-align: center;
@ -16,7 +42,7 @@
}
.ns-special {
.mw-body #section_0 { // stylelint-disable-line selector-max-id
.mw-body #section_0 {
font-size: 1.5em;
font-weight: bold;
}
@ -34,6 +60,12 @@
font-family: @font-family-base !important;
}
.errorbox {
h2 {
display: block;
}
}
.content-header {
h1,
h2 {