Theopolisme has uploaded a new change for review.
https://gerrit.wikimedia.org/r/108539
Change subject: Use DISPLAYTITLE when rendering pages
......................................................................
Use DISPLAYTITLE when rendering pages
Bug: 60251
Change-Id: I21d7a66fa8b632555fa745ddb1c1ab975cfeb8ed
---
M includes/api/ApiMobileView.php
M javascripts/common/Page.js
M javascripts/common/PageApi.js
M javascripts/common/application.js
M templates/page.html
5 files changed, 25 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/39/108539/1
diff --git a/includes/api/ApiMobileView.php b/includes/api/ApiMobileView.php
index caaff54..ec44f10 100644
--- a/includes/api/ApiMobileView.php
+++ b/includes/api/ApiMobileView.php
@@ -86,6 +86,11 @@
array( 'hasvariants' => $data['hasvariants'] )
);
}
+ if ( isset( $prop['displaytitle'] ) ) {
+ $this->getResult()->addValue( null,
$this->getModuleName(),
+ array( 'displaytitle' => $data['displaytitle'] )
+ );
+ }
if ( $this->usePageImages ) {
$this->addPageImage( $data, $prop, $params['thumbsize']
);
}
@@ -420,6 +425,12 @@
$data['hasvariants'] = true;
}
+ if ( $parserOutput ) {
+ $data['displaytitle'] =
$parserOutput->getDisplayTitle();
+ } else {
+ $data['displaytitle'] = $title->getPrefixedText();
+ }
+
// Don't store small pages to decrease cache size requirements
if ( strlen( $html ) >= $wgMFMinCachedPageSize ) {
// store for the same time as original parser output
@@ -529,6 +540,7 @@
'protection',
'languagecount',
'hasvariants',
+ 'displaytitle',
)
),
'sectionprop' => array(
@@ -594,6 +606,7 @@
' protection - information about
protection level',
' languagecount - number of languages that
the page is available in',
' hasvariants - whether or not the page is
available in other language variants',
+ ' displaytitle - the rendered title of the
page, with {{DISPLAYTITLE}} and such applied'
),
'sectionprop' => 'What information about sections to
get',
'variant' => "Convert content into this language
variant",
diff --git a/javascripts/common/Page.js b/javascripts/common/Page.js
index 3e6c594..5e941e5 100644
--- a/javascripts/common/Page.js
+++ b/javascripts/common/Page.js
@@ -41,6 +41,7 @@
defaults: {
// For titles from other namespaces use a prefix e.g.
Talk:Foo
title: '',
+ displayTitle: '',
lead: '',
inBetaOrAlpha: M.isBetaGroupMember(),
isMainPage: false,
@@ -148,6 +149,11 @@
} );
},
+ postRender: function( options ) {
+ // Set the display title
+ this.displayTitle = options.displayTitle;
+ },
+
/**
* @name Page.prototype.getReferenceSection
* @function
diff --git a/javascripts/common/PageApi.js b/javascripts/common/PageApi.js
index b8f5547..24902e1 100644
--- a/javascripts/common/PageApi.js
+++ b/javascripts/common/PageApi.js
@@ -77,7 +77,7 @@
page: title,
variant: mw.config.get(
'wgPreferredVariant' ),
redirect: 'yes',
- prop:
'id|sections|text|lastmodified|lastmodifiedby|languagecount|hasvariants',
+ prop:
'id|sections|text|lastmodified|lastmodifiedby|languagecount|hasvariants|displaytitle',
noheadings: 'yes',
noimages: mw.config.get(
'wgImagesDisabled', false ) ? 1 : undefined,
sectionprop: 'level|line|anchor',
@@ -105,7 +105,8 @@
historyUrl:
mw.util.getUrl( title, { action: 'history' } ),
lastModifiedTimestamp:
timestamp,
languageCount:
resp.mobileview.languagecount,
- hasVariants:
resp.mobileview.hasOwnProperty( 'hasvariants' )
+ hasVariants:
resp.mobileview.hasOwnProperty( 'hasvariants' ),
+ displayTitle:
resp.mobileview.displaytitle
};
// Add non-anonymous user
information
if ( lastModified ) {
diff --git a/javascripts/common/application.js
b/javascripts/common/application.js
index 9360e1e..e20491f 100644
--- a/javascripts/common/application.js
+++ b/javascripts/common/application.js
@@ -362,8 +362,8 @@
mw.config.set( 'wgRelevantPageName', page.title );
mw.config.set( 'wgArticleId', page.getId() );
M.emit( 'page-loaded', page );
- // Update page title
- document.title = page.title;
+ // Update page title with the displayTitle
+ document.title = page.displayTitle;
}
/**
diff --git a/templates/page.html b/templates/page.html
index 4b0ab18..0381347 100644
--- a/templates/page.html
+++ b/templates/page.html
@@ -4,7 +4,7 @@
></a>
{{/inBetaOrAlpha}}
<div class="pre-content">
- <h1 id="section_0">{{title}}</h1>
+ <h1 id="section_0">{{displayTitle}}</h1>
<ul id="page-actions" class="hlist">
<li id="ca-edit"></li><li id="ca-upload">
</li><li id="ca-talk"
class="{{#isTalkPage}}selected{{/isTalkPage}}"><a href="{{talkLink}}"
id="talk">{{talkLabel}}</a>
--
To view, visit https://gerrit.wikimedia.org/r/108539
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I21d7a66fa8b632555fa745ddb1c1ab975cfeb8ed
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Theopolisme <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits