Merge "Minerva uses core page title handling"

This commit is contained in:
jenkins-bot 2021-12-22 18:06:54 +00:00 committed by Gerrit Code Review
commit 3bb487b733
11 changed files with 41 additions and 43 deletions

View file

@ -15,7 +15,6 @@
"mobile-frontend-home-button": "Home",
"mobile-frontend-language-article-heading": "Language",
"mobile-frontend-languages-not-available": "This page is not available in other languages.",
"mobile-frontend-logged-in-homepage-notification": "{{GENDER:$1|Welcome}}, $1!",
"mobile-frontend-main-menu-button-tooltip": "Open main menu",
"mobile-frontend-main-menu-contributions": "Contributions",
"mobile-frontend-main-menu-login": "Log in",

View file

@ -29,7 +29,6 @@
"mobile-frontend-home-button": "This appears in the mobile web menu, which appears when tapping the three stripes at the top corner.\n\nThis button takes the user to the home page of the wiki site.\n{{Identical|Home}}",
"mobile-frontend-language-article-heading": "In the secondary page menu, a short label that describes the button that displays a list of available languages\n{{Identical|Language}}",
"mobile-frontend-languages-not-available": "A toast message that is shown when the user taps on the language button on an article which is not available in other languages.",
"mobile-frontend-logged-in-homepage-notification": "Heading at top of a wiki's main page telling user they are logged in. Parameters:\n* $1 - username\n{{Identical|Welcome}}",
"mobile-frontend-main-menu-button-tooltip": "Tooltip for menu button",
"mobile-frontend-main-menu-contributions": "Contributions link in main menu\n{{Identical|Contribution}}",
"mobile-frontend-main-menu-login": "Text for log in link in main menu.\n{{Identical|Log in}}",

View file

@ -115,12 +115,19 @@ class SkinMinerva extends SkinMustache {
unset( $data['html-categories'] );
}
// Special handling for certain pages.
// This is technical debt that should be upstreamed to core.
$isUserPage = $this->getUserPageHelper()->isUserPage();
$isUserPageAccessible = $this->getUserPageHelper()->isUserPageAccessibleToCurrentUser();
if ( $isUserPage && $isUserPageAccessible ) {
$data['html-title-heading'] = $this->getUserPageHeadingHtml( $data['html-title-heading' ] );
}
return $data + [
'array-minerva-banners' => $this->prepareBanners( $data['html-site-notice'] ),
'html-minerva-user-notifications' => $this->prepareUserNotificationsButton( $this->getNewtalks() ),
'data-minerva-main-menu' => $this->getMainMenu()->getMenuData()['items'],
'html-minerva-tagline' => $this->getTaglineHtml(),
'html-minerva-heading' => $this->prepareHeader(),
'html-minerva-post-heading' => $this->isTalkPageWithViewAction()
? $this->getTalkPagePostHeadingHtml()
: '',
@ -537,18 +544,23 @@ class SkinMinerva extends SkinMustache {
/**
* Returns the HTML representing the heading.
*
* @param string $heading The heading suggested by core.
* @return string HTML for header
*/
protected function getHeadingHtml() {
$isUserPage = $this->getUserPageHelper()->isUserPage();
$isUserPageAccessible = $this->getUserPageHelper()->isUserPageAccessibleToCurrentUser();
if ( $isUserPage && $isUserPageAccessible ) {
// The heading is just the username without namespace
$heading = $this->getUserPageHelper()->getPageUser()->getName();
} else {
$heading = $this->getOutput()->getPageTitle();
}
return Html::rawElement( 'h1', [ 'id' => 'section_0' ], $heading );
private function getUserPageHeadingHtml( $heading ) {
// The heading is just the username without namespace
// This is escaped as a precaution (user name should be safe).
return Html::rawElement( 'h1',
// These IDs and classes should match Skin::getTemplateData
[
'id' => 'firstHeading',
'class' => 'firstHeading mw-first-heading mw-minerva-user-heading',
],
htmlspecialchars(
$this->getUserPageHelper()->getPageUser()->getName()
)
);
}
/**
@ -625,29 +637,6 @@ class SkinMinerva extends SkinMustache {
return $html;
}
/**
* Create and prepare header content
* @return string
*/
protected function prepareHeader() {
$title = $this->getTitle();
if ( $title->isMainPage() ) {
$user = $this->getUser();
$msg = $this->msg( 'mobile-frontend-logged-in-homepage-notification', $user->getName() );
if ( $user->isRegistered() && !$msg->isDisabled() ) {
$out = $this->getOutput();
$out->setPageTitle( $msg->text() );
} else {
// Dont add any <h1> to main pages
// for logged-out users
return '';
}
}
return $this->getHeadingHtml();
}
/**
* Load internal banner content to show in pre content in template
* Beware of HTML caching when using this function.

View file

@ -56,9 +56,10 @@
{{{html-user-message}}}
</div>
{{/html-user-message}}
{{^is-title-blank}}
<div class="pre-content heading-holder">
<div class="page-heading">
{{{html-minerva-heading}}}
{{{html-title-heading}}}
{{{html-minerva-tagline}}}
</div>
{{#data-minerva-tabs}}
@ -74,6 +75,7 @@
{{{html-minerva-post-heading}}}
<div class="minerva__subtitle">{{{html-subtitle}}}</div>
</div>
{{/is-title-blank}}
<div id="bodyContent" class="content">
{{{html-body-content}}}
{{! This shows "Return to page" on talk page when talk tab not shown at top.

View file

@ -86,6 +86,9 @@
display: none;
}
// FIXME: #section_0 rule can be removed > 1 week after
// I2ffdedd64414ffb3c6e441391a75fd6e744847a4 is in production.
.mw-first-heading,
#section_0 { // stylelint-disable-line selector-max-id
border: 0;
}

View file

@ -3,6 +3,9 @@
// stylelint-disable selector-max-id
.page-Main_Page {
// FIXME: #section_0 rule can be removed > 1 week after
// I2ffdedd64414ffb3c6e441391a75fd6e744847a4 is in production.
.mw-first-heading,
#section_0 {
border: 0;
}

View file

@ -42,8 +42,10 @@
function insertPageIssueNotice( labelText, section ) {
var $link = newPageIssueLink( labelText );
$link.attr( 'href', '#/issues/' + section );
// FIXME: #section_0 rule can be removed > 1 week after
// I2ffdedd64414ffb3c6e441391a75fd6e744847a4 is in production.
// eslint-disable-next-line no-jquery/no-global-selector
$link.insertAfter( $( 'h1#section_0' ) );
$link.insertAfter( $( 'h1#section_0, h1.mw-first-heading' ) );
}
module.exports = {

View file

@ -40,13 +40,14 @@
// Parsing information doesn't need to be so big
// neither to headers for diffs (.diff-otitle),
// the page title (#section_0) or all the warnings (#editpage-copywarn, #mw-anon-edit-warning)
// the page title (.mw-first-heading)
// or all the warnings (#editpage-copywarn, #mw-anon-edit-warning)
.mw-editnotice,
.mw-editTools,
.preview-limit-report-wrapper,
.diff-otitle,
.diff-ntitle,
#section_0,
.mw-first-heading,
#editpage-copywarn,
#mw-anon-edit-warning {
.secondary-text();

View file

@ -42,7 +42,7 @@
}
.ns-special {
.mw-body #section_0 {
.mw-body .mw-first-heading {
font-size: 1.5em;
font-weight: bold;
}

View file

@ -33,7 +33,7 @@ class ArticlePage extends MinervaPage {
get notifications_button_element() { return $( '#pt-notifications-alert' ); }
get drawer_element() { return $( '.drawer' ); }
get edit_link_element() { return $( '#ca-edit' ); }
get first_heading_element() { return $( '#section_0' ); }
get first_heading_element() { return $( 'h1.mw-first-heading' ); }
get notification_element() { return $( '.mw-notification-area .mw-notification' ); }
get overlay_heading_element() { return $( '.overlay-title h2' ); }
get overlay_category_topic_item_element() { return $( '.topic-title-list li' ); }

View file

@ -5,7 +5,7 @@ const Page = require( 'wdio-mediawiki/Page' );
class EditPage extends Page {
get content() { return $( '#wikitext-editor' ); }
get displayedContent() { return $( '#mw-content-text .mw-parser-output' ); }
get heading() { return $( '#section_0' ); }
get heading() { return $( 'h1.mw-first-heading' ); }
get next() { return $( '.mw-ui-icon-mf-next-invert' ); }
get save() { return $( 'button.mw-ui-button' ); }