Remove obsolete class IwTitle

Bug: T77349
Change-Id: Idc81f0d97ebfef725bcdb93ca50deac197d67590
This commit is contained in:
Simon Legner 2024-06-13 21:11:58 +02:00
parent 33f327dc69
commit 048c359806
6 changed files with 1 additions and 122 deletions

View file

@ -2,7 +2,7 @@
"modules": [
{
"resourceModule": "mmv",
"maxSize": "26.8 kB"
"maxSize": "26.6 kB"
},
{
"resourceModule": "mmv.ui.restriction",

View file

@ -44,7 +44,6 @@
"packageFiles": [
"mmv/mmv.js",
"mmv/logging/mmv.logging.ViewLogger.js",
"mmv/model/mmv.model.IwTitle.js",
"mmv/model/mmv.model.License.js",
"mmv/model/mmv.model.Image.js",
"mmv/model/mmv.model.Thumbnail.js",
@ -346,7 +345,6 @@
"tests/qunit/mmv/mmv.HtmlUtils.test.js",
"tests/qunit/mmv/logging/mmv.logging.ViewLogger.test.js",
"tests/qunit/mmv/model/mmv.model.test.js",
"tests/qunit/mmv/model/mmv.model.IwTitle.test.js",
"tests/qunit/mmv/model/mmv.model.TaskQueue.test.js",
"tests/qunit/mmv/model/mmv.model.License.test.js",
"tests/qunit/mmv/model/mmv.model.Image.test.js",

View file

@ -23,7 +23,6 @@ const ImageProvider = require( './provider/mmv.provider.Image.js' );
const ImageInfo = require( './provider/mmv.provider.ImageInfo.js' );
const ThumbnailInfo = require( './provider/mmv.provider.ThumbnailInfo.js' );
const ImageModel = require( './model/mmv.model.Image.js' );
const IwTitle = require( './model/mmv.model.IwTitle.js' );
const License = require( './model/mmv.model.License.js' );
const TaskQueue = require( './model/mmv.model.TaskQueue.js' );
const Thumbnail = require( './model/mmv.model.Thumbnail.js' );
@ -913,7 +912,6 @@ module.exports = {
ImageInfo,
ImageModel,
ImageProvider,
IwTitle,
License,
LightboxInterface,
MetadataPanel,

View file

@ -1,71 +0,0 @@
/*
* This file is part of the MediaWiki extension MediaViewer.
*
* MediaViewer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* MediaViewer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MediaViewer. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* IwTitle represents a title in a foreign wiki. The long-term goal is to have an interface
* largely compatible with mw.Title, but for now we only implement what we actually need.
*/
class IwTitle {
/**
* @param {string} namespaceId namespace number
* @param {string} title full title, including namespace name; with underscores (as in mw.Title#getPrefixedDb())
* @param {string} domain domain name of the wiki
* @param {string} url full URL to the page
*/
constructor( namespaceId, title, domain, url ) {
/** @property {number} namespaceId - */
this.namespaceId = namespaceId;
/** @property {string} title - */
this.title = title;
/** @property {string} domain - */
this.domain = domain;
/** @property {string} url - */
this.url = url;
}
getUrl() {
return this.url;
}
getPrefixedDb() {
return this.title;
}
getPrefixedText() {
return text( this.getPrefixedDb() );
/**
* Turn underscores into spaces.
* Copy of the private function in mw.Title.
*
* @param {string} s
* @return {string}
*/
function text( s ) {
return s ? s.replace( /_/g, ' ' ) : '';
}
}
getDomain() {
return this.domain;
}
}
module.exports = IwTitle;

View file

@ -27,7 +27,6 @@ require( './mmv.Config.test.js' );
require( './mmv.HtmlUtils.test.js' );
require( './logging/mmv.logging.ViewLogger.test.js' );
require( './model/mmv.model.test.js' );
require( './model/mmv.model.IwTitle.test.js' );
require( './model/mmv.model.TaskQueue.test.js' );
require( './model/mmv.model.License.test.js' );
require( './model/mmv.model.Image.test.js' );

View file

@ -1,45 +0,0 @@
/*
* This file is part of the MediaWiki extension MediaViewer.
*
* MediaViewer is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* MediaViewer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MediaViewer. If not, see <http://www.gnu.org/licenses/>.
*/
const { IwTitle } = require( 'mmv' );
( function () {
QUnit.module( 'mmv.model.IwTitle', QUnit.newMwEnvironment() );
QUnit.test( 'constructor sense test', ( assert ) => {
const namespace = 4;
const fullPageName = 'User_talk:John_Doe';
const domain = 'en.wikipedia.org';
const url = 'https://en.wikipedia.org/wiki/User_talk:John_Doe';
const title = new IwTitle( namespace, fullPageName, domain, url );
assert.true( title instanceof IwTitle );
} );
QUnit.test( 'getters', ( assert ) => {
const namespace = 4;
const fullPageName = 'User_talk:John_Doe';
const domain = 'en.wikipedia.org';
const url = 'https://en.wikipedia.org/wiki/User_talk:John_Doe';
const title = new IwTitle( namespace, fullPageName, domain, url );
assert.strictEqual( title.getUrl(), url, 'getUrl()' );
assert.strictEqual( title.getDomain(), domain, 'getDomain()' );
assert.strictEqual( title.getPrefixedDb(), fullPageName, 'getPrefixedDb()' );
assert.strictEqual( title.getPrefixedText(), 'User talk:John Doe', 'getPrefixedText()' );
} );
}() );