Remove dual-type support for Languages and Categories

The new form was implemented in Parsoid and deployed in October, so enough time
has passed that there is no longer any need for VisualEditor to support the old
type.

Bug: 56009
Change-Id: Ief2e584345ccdb0e7eb44ab16c4bc14f7c14f5ec
This commit is contained in:
James D. Forrester 2013-12-04 18:37:29 -08:00
parent d2c74b18a7
commit 114a24f1d3
3 changed files with 20 additions and 34 deletions

View file

@ -30,14 +30,10 @@ ve.dm.MWCategoryMetaItem.static.group = 'mwCategory';
ve.dm.MWCategoryMetaItem.static.matchTagNames = [ 'link' ];
ve.dm.MWCategoryMetaItem.static.matchRdfaTypes = [
'mw:WikiLink/Category', // old type, pre-bug 53432
'mw:PageProp/Category' // new type
];
ve.dm.MWCategoryMetaItem.static.matchRdfaTypes = [ 'mw:PageProp/Category' ];
ve.dm.MWCategoryMetaItem.static.toDataElement = function ( domElements ) {
var firstDomElement = domElements[0],
href = firstDomElement.getAttribute( 'href' ),
var href = domElements[0].getAttribute( 'href' ),
/*jshint regexp:false */
matches = href.match( /^((?:\.\.?\/)*)(.*?)(?:#(.*))?$/ ),
rawSortkey = matches[3] || '';
@ -48,8 +44,7 @@ ve.dm.MWCategoryMetaItem.static.toDataElement = function ( domElements ) {
'category': decodeURIComponent( matches[2] ).replace( /_/g, ' ' ),
'origCategory': matches[2],
'sortkey': decodeURIComponent( rawSortkey ).replace( /_/g, ' ' ),
'origSortkey': rawSortkey,
'origRel': firstDomElement.getAttribute( 'rel' )
'origSortkey': rawSortkey
}
};
};
@ -74,7 +69,7 @@ ve.dm.MWCategoryMetaItem.static.toDomElements = function ( dataElement, doc ) {
} else {
category = encodeURIComponent( category );
}
domElement.setAttribute( 'rel', dataElement.attributes.origRel || 'mw:WikiLink/Category' );
domElement.setAttribute( 'rel', 'mw:PageProp/Category' );
href = hrefPrefix + category;
if ( sortkey !== '' ) {
href += '#' + sortkey;

View file

@ -28,26 +28,21 @@ ve.dm.MWLanguageMetaItem.static.name = 'mwLanguage';
ve.dm.MWLanguageMetaItem.static.matchTagNames = [ 'link' ];
ve.dm.MWLanguageMetaItem.static.matchRdfaTypes = [
'mw:WikiLink/Language', // old type, pre-bug 53432
'mw:PageProp/Language' // new type
];
ve.dm.MWLanguageMetaItem.static.matchRdfaTypes = [ 'mw:PageProp/Language' ];
ve.dm.MWLanguageMetaItem.static.toDataElement = function ( domElements ) {
var firstDomElement = domElements[0],
href = firstDomElement.getAttribute( 'href' );
var href = domElements[0].getAttribute( 'href' );
return {
'type': 'mwLanguage',
'attributes': {
'href': href,
'origRel': firstDomElement.getAttribute( 'rel' )
'href': href
}
};
};
ve.dm.MWLanguageMetaItem.static.toDomElements = function ( dataElement, doc ) {
var domElement = doc.createElement( 'link' );
domElement.setAttribute( 'rel', dataElement.attributes.origRel || 'mw:WikiLink/Language' );
domElement.setAttribute( 'rel', 'mw:PageProp/Language' );
domElement.setAttribute( 'href', dataElement.attributes.href );
return [ domElement ];
};

View file

@ -24,14 +24,14 @@ ve.dm.mwExample.MWTransclusion = {
'inlineOpenModified': '<span about="#mwt1" typeof="mw:Transclusion" data-mw="{&quot;id&quot;:&quot;mwt1&quot;,&quot;target&quot;:{&quot;wt&quot;:&quot;Inline&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;5,678&quot;}}}" data-parsoid="{&quot;tsr&quot;:[18,34],&quot;src&quot;:&quot;{{Inline|1,234}}&quot;,&quot;dsr&quot;:[18,34,null,null]}">',
'inlineContent': '$1,234.00',
'inlineClose': '</span>',
'mixed': '<link about="#mwt1" rel="mw:WikiLink/Category" typeof="mw:Transclusion" data-mw="{&quot;id&quot;:&quot;mwt1&quot;,&quot;target&quot;:{&quot;wt&quot;:&quot;Inline&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;5,678&quot;}}}"><span about="#mwt1">Foo</span>',
'mixed': '<link about="#mwt1" rel="mw:PageProp/Category" typeof="mw:Transclusion" data-mw="{&quot;id&quot;:&quot;mwt1&quot;,&quot;target&quot;:{&quot;wt&quot;:&quot;Inline&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;5,678&quot;}}}"><span about="#mwt1">Foo</span>',
'pairOne': '<p about="#mwt1" typeof="mw:Transclusion" data-mw="{&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo&quot;}}}" data-parsoid="1">foo</p>',
'pairTwo': '<p about="#mwt2" typeof="mw:Transclusion" data-mw="{&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo&quot;}}}" data-parsoid="2">foo</p>',
'meta':
'<link rel="mw:WikiLink/Category" href="./Category:Page" about="#mwt1" typeof="mw:Transclusion" ' +
'<link rel="mw:PageProp/Category" href="./Category:Page" about="#mwt1" typeof="mw:Transclusion" ' +
'data-mw="{&quot;target&quot;:{&quot;wt&quot;:&quot;Template:Echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;[[Category:Page]]\\n[[Category:Book]]&quot;}},&quot;i&quot;:0}">' +
'<span about="#mwt1" data-parsoid="{}">\n</span>' +
'<link rel="mw:WikiLink/Category" href="./Category:Book" about="#mwt1">'
'<link rel="mw:PageProp/Category" href="./Category:Book" about="#mwt1">'
};
ve.dm.mwExample.MWTransclusion.blockData = {
'type': 'mwTransclusionBlock',
@ -98,7 +98,7 @@ ve.dm.mwExample.MWTransclusion.mixedDataOpen = {
'htmlAttributes': [
{ 'values': {
'about': '#mwt1',
'rel': 'mw:WikiLink/Category',
'rel': 'mw:PageProp/Category',
'typeof': 'mw:Transclusion',
'data-mw': '{\"id\":\"mwt1\",\"target\":{\"wt\":\"Inline\"},\"params\":{\"1\":{\"wt\":\"5,678\"}}}'
} },
@ -255,8 +255,7 @@ ve.dm.mwExample.withMeta = [
'category': 'Category:Bar',
'origCategory': 'Category:Bar',
'sortkey': '',
'origSortkey': '',
'origRel': 'mw:PageProp/Category'
'origSortkey': ''
},
'htmlAttributes': [
{
@ -313,8 +312,7 @@ ve.dm.mwExample.withMeta = [
'category': 'Category:Foo foo',
'origCategory': 'Category:Foo_foo',
'sortkey': 'Bar baz#quux',
'origSortkey': 'Bar baz%23quux',
'origRel': 'mw:PageProp/Category'
'origSortkey': 'Bar baz%23quux'
},
'htmlAttributes': [
@ -388,7 +386,7 @@ ve.dm.mwExample.withMetaMetaData = [
'htmlAttributes': [
{
'values': {
'rel': 'mw:WikiLink/Category',
'rel': 'mw:PageProp/Category',
'href': './Category:Bar'
},
'computed': {
@ -441,7 +439,7 @@ ve.dm.mwExample.withMetaMetaData = [
'origSortkey': 'Bar baz%23quux'
},
'htmlAttributes': [ { 'values': {
'rel': 'mw:WikiLink/Category',
'rel': 'mw:PageProp/Category',
'href': './Category:Foo_foo#Bar baz%23quux'
} } ]
},
@ -1553,7 +1551,7 @@ ve.dm.mwExample.domToDataCases = {
},
'whitespace preservation with wrapped comments and language links': {
'body': 'Foo\n' +
'<link rel="mw:WikiLink/Language" href="http://de.wikipedia.org/wiki/Foo">\n' +
'<link rel="mw:PageProp/Language" href="http://de.wikipedia.org/wiki/Foo">\n' +
'<link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Foo">',
'data': [
{
@ -1570,14 +1568,13 @@ ve.dm.mwExample.domToDataCases = {
{
'type': 'mwLanguage',
'attributes': {
'href': 'http://de.wikipedia.org/wiki/Foo',
'origRel': 'mw:WikiLink/Language'
'href': 'http://de.wikipedia.org/wiki/Foo'
},
'htmlAttributes': [
{
'values': {
'href': 'http://de.wikipedia.org/wiki/Foo',
'rel': 'mw:WikiLink/Language'
'rel': 'mw:PageProp/Language'
},
'computed': {
'href': 'http://de.wikipedia.org/wiki/Foo'
@ -1590,8 +1587,7 @@ ve.dm.mwExample.domToDataCases = {
{
'type': 'mwLanguage',
'attributes': {
'href': 'http://fr.wikipedia.org/wiki/Foo',
'origRel': 'mw:PageProp/Language'
'href': 'http://fr.wikipedia.org/wiki/Foo'
},
'htmlAttributes': [
{