Split legacy and modern experience on template level

The new template 'index.mustache' drops the Navigation
template partial (component) - instead embedding it in
the master template given its lack of usability.

Note to reviewer: Please ensure index.mustache and
legacy.mustache are identical.

Change-Id: I580fe55ca6aeb35dae8afee41e87172a5a729c7b
This commit is contained in:
jdlrobson 2020-03-31 10:51:48 -07:00
parent 13c6a959a9
commit c8001f91b1
3 changed files with 110 additions and 3 deletions

View File

@ -43,6 +43,8 @@ class VectorTemplate extends BaseTemplate {
/** @var TemplateParser */
private $templateParser;
/** @var string */
private $templateRoot = 'index';
/** @var bool */
private $isLegacy;
@ -61,6 +63,9 @@ class VectorTemplate extends BaseTemplate {
$this->templateParser = $templateParser;
$this->isLegacy = $isLegacy;
if ( $isLegacy ) {
$this->templateRoot = 'legacy';
}
}
/**
@ -215,7 +220,7 @@ class VectorTemplate extends BaseTemplate {
*/
public function execute() {
$tp = $this->getTemplateParser();
echo $tp->processTemplate( 'index', $this->getSkinData() );
echo $tp->processTemplate( $this->templateRoot, $this->getSkinData() );
}
/**

View File

@ -0,0 +1,101 @@
{{!
string html-headelement a string of attribute HTML that begins with `<html> and ends with '</head>'
and contains `meta` tags and ResourceLoader internals.
string|null html-sitenotice the contents of a banner defined in MediaWiki:Sitenotice.
Also used by CentralNotice to inject banners into Vector.
string html-indicators raw HTML containing wiki-defined badges such as "good article", "featured article".
An empty string if none are defined.
string page-langcode the content language of the article. Assumed to be escaped HTML./
string html-title
string html-prebodyhtml
bool page-isarticle
string msg-tagline
string html-subtitle
string html-undelete
string html-newtalk
string msg-jumptonavigation
string msg-jumptosearch
string html-bodycontent
string html-printfooter
string html-catlinks
string html-debuglog
string html-dataAfterContent
string html-navigation-heading heading for entire navigation that is
usually hidden to screen readers
object data-personal-menu See PersonalMenu.mustache for documentation.
object data-namespace-tabs. See VectorTabs.mustache for documentation.
object data-variants. See VectorMenu.mustache for documentation.
object data-page-actions. See VectorTabs.mustache for documentation.
object data-page-actions-more. See VectorMenu.mustache for documentation.
object data-search-box. See SearchBox.mustache for documentation.
object data-sidebar. See Sidebar.mustache for documentation.
object data-footer for footer template partial. see Footer.mustache for documentation.
string html-printtail HTML to render at the end of the page contained necessary script tags for ResourceLoader
terminated with `</body></html>`.
}}
{{{html-headelement}}}
<div id="mw-page-base" class="noprint"></div>
<div id="mw-head-base" class="noprint"></div>
<div id="content" class="mw-body" role="main">
<a id="top"></a>
{{#html-sitenotice}}<div id="siteNotice" class="mw-body-content">{{{html-sitenotice}}}</div>{{/html-sitenotice}}
{{{html-indicators}}}
<h1 id="firstHeading" class="firstHeading" lang="{{page-langcode}}">{{{html-title}}}</h1>
{{{html-prebodyhtml}}}
<div id="bodyContent" class="mw-body-content">
{{#page-isarticle}}<div id="siteSub" class="noprint">{{msg-tagline}}</div>{{/page-isarticle}}
<div id="contentSub"{{{html-userlangattributes}}}>{{{html-subtitle}}}</div>
{{#html-undelete}}<div id="contentSub2">{{{html-undelete}}}</div>{{/html-undelete}}
{{#html-newtalk}}<div class="usermessage">{{{html-newtalk}}}</div>{{/html-newtalk}}
{{!
Keep this empty `div` for compatibility with gadgets and user scripts
using this place to insert extra elements before.
}}
<div id="jump-to-nav"></div>
<a class="mw-jump-link" href="#mw-head">{{msg-jumptonavigation}}</a>
<a class="mw-jump-link" href="#p-search">{{msg-jumptosearch}}</a>
{{{html-bodycontent}}}
{{#html-printfooter}}
<div class="printfooter">{{{html-printfooter}}}</div>
{{/html-printfooter}}
{{{html-catlinks}}}
<div class="visualClear"></div>
{{{html-debuglog}}}
</div>
</div>
{{{html-dataAfterContent}}}
<div id="mw-navigation">
<h2>{{{html-navigation-heading}}}</h2>
<div id="mw-head">
{{#data-personal-menu}}
{{>PersonalMenu}}
{{/data-personal-menu}}
<div id="left-navigation">
{{#data-namespace-tabs}}
{{>VectorTabs}}
{{/data-namespace-tabs}}
{{#data-variants}}
{{>VectorMenu}}
{{/data-variants}}
</div>
<div id="right-navigation">
{{#data-page-actions}}
{{>VectorTabs}}
{{/data-page-actions}}
{{#data-page-actions-more}}
{{>VectorMenu}}
{{/data-page-actions-more}}
{{#data-search-box}}
{{>SearchBox}}
{{/data-search-box}}
</div>
</div>
{{#data-sidebar}}
{{>Sidebar}}
{{/data-sidebar}}
</div>
{{#data-footer}}
{{>Footer}}
{{/data-footer}}
{{{html-printtail}}}

View File

@ -1,6 +1,7 @@
import mustache from 'mustache';
import { htmluserlangattributes } from './utils';
import skinTemplate from '!!raw-loader!../includes/templates/index.mustache';
import legacySkinTemplate from '!!raw-loader!../includes/templates/legacy.mustache';
import { placeholder } from './utils';
import '../resources/skins.vector.styles/index.less';
@ -76,7 +77,7 @@ const HTML_INDICATORS = `<div class="mw-indicators mw-body-content">
</div>
`;
export const vectorLegacyLoggedOut = () => mustache.render( skinTemplate, Object.assign( {
export const vectorLegacyLoggedOut = () => mustache.render( legacySkinTemplate, Object.assign( {
'html-title': 'Vector 2019',
'page-isarticle': true,
'msg-tagline': 'From Wikipedia, the free encyclopedia',
@ -100,7 +101,7 @@ export const vectorLegacyLoggedOut = () => mustache.render( skinTemplate, Object
'html-subtitle': placeholder( 'Extensions can configure subtitle', 20 )
}, NAVIGATION_TEMPLATE_DATA.loggedOutWithVariants ), TEMPLATE_PARTIALS );
export const vectorLegacyLoggedIn = () => mustache.render( skinTemplate, Object.assign( {
export const vectorLegacyLoggedIn = () => mustache.render( legacySkinTemplate, Object.assign( {
'html-title': 'Vector 2019',
'page-isarticle': true,
'msg-tagline': 'From Wikipedia, the free encyclopedia',