Unicornisaurous has uploaded a new change for review.
https://gerrit.wikimedia.org/r/260955
Change subject: Shorten MediaViewer credit lines
......................................................................
Shorten MediaViewer credit lines
Drop the title and site name. Use a shortened URL
created using the pageID for the curid query parameter.
Add pageID property to mmv.model.Image, using value already
fetched from an existing API request.
Bug: T119686
Change-Id: I9189f00bfbf7639974d66cf1921773855a77a865
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M resources/mmv/mmv.EmbedFileFormatter.js
M resources/mmv/model/mmv.model.Image.js
M tests/qunit/mmv/mmv.EmbedFileFormatter.test.js
M tests/qunit/mmv/model/mmv.model.Image.test.js
7 files changed, 71 insertions(+), 116 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer
refs/changes/55/260955/1
diff --git a/extension.json b/extension.json
index c89d023..4b98c99 100644
--- a/extension.json
+++ b/extension.json
@@ -239,28 +239,12 @@
],
"messages": [
"multimediaviewer-credit",
- "multimediaviewer-text-embed-credit-text-tbls",
-
"multimediaviewer-text-embed-credit-text-tbls-nonfree",
- "multimediaviewer-text-embed-credit-text-tls",
-
"multimediaviewer-text-embed-credit-text-tls-nonfree",
- "multimediaviewer-text-embed-credit-text-tbs",
- "multimediaviewer-text-embed-credit-text-tbl",
-
"multimediaviewer-text-embed-credit-text-tbl-nonfree",
- "multimediaviewer-text-embed-credit-text-tb",
- "multimediaviewer-text-embed-credit-text-ts",
- "multimediaviewer-text-embed-credit-text-tl",
-
"multimediaviewer-text-embed-credit-text-tl-nonfree",
- "multimediaviewer-html-embed-credit-text-tbls",
-
"multimediaviewer-html-embed-credit-text-tbls-nonfree",
- "multimediaviewer-html-embed-credit-text-tls",
-
"multimediaviewer-html-embed-credit-text-tls-nonfree",
- "multimediaviewer-html-embed-credit-text-tbs",
- "multimediaviewer-html-embed-credit-text-tbl",
-
"multimediaviewer-html-embed-credit-text-tbl-nonfree",
- "multimediaviewer-html-embed-credit-text-tb",
- "multimediaviewer-html-embed-credit-text-ts",
- "multimediaviewer-html-embed-credit-text-tl",
-
"multimediaviewer-html-embed-credit-text-tl-nonfree"
+ "multimediaviewer-text-embed-credit-text-bl",
+ "multimediaviewer-text-embed-credit-text-b",
+ "multimediaviewer-text-embed-credit-text-l",
+ "multimediaviewer-html-embed-credit-text-bl",
+ "multimediaviewer-html-embed-credit-text-b",
+ "multimediaviewer-html-embed-credit-text-l"
]
},
"mmv.ui.download.pane": {
diff --git a/i18n/en.json b/i18n/en.json
index bed042c..61cd0b8 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -91,30 +91,12 @@
"multimediaviewer-embed-wt": "Wikitext",
"multimediaviewer-embed-html": "HTML",
"multimediaviewer-embed-explanation": "Use this code to embed the file",
- "multimediaviewer-text-embed-credit-text-tbls": "\"$1\" by $2. Licensed
under $3 via $4",
- "multimediaviewer-text-embed-credit-text-tbls-nonfree": "\"$1\" by $2.
$3 via $4",
- "multimediaviewer-text-embed-credit-text-tls": "\"$1\". Licensed under
$2 via $3",
- "multimediaviewer-text-embed-credit-text-tls-nonfree": "\"$1\". $2 via
$3",
- "multimediaviewer-text-embed-credit-text-tbs": "\"$1\" by $2. Via $3",
- "multimediaviewer-text-embed-credit-text-tbl": "\"$1\" by $2. Licensed
under $3",
- "multimediaviewer-text-embed-credit-text-tbl-nonfree": "\"$1\" by $2.
$3",
- "multimediaviewer-text-embed-credit-text-tb": "\"$1\" by $2",
- "multimediaviewer-text-embed-credit-text-ts": "\"$1\". Via $2",
- "multimediaviewer-text-embed-credit-text-tl": "\"$1\". Licensed under
$2",
- "multimediaviewer-text-embed-credit-text-tl-nonfree": "\"$1\". $2",
- "multimediaviewer-text-embed-credit-text-t": "\"$1\"",
- "multimediaviewer-html-embed-credit-text-tbls": "\"$1\" by $2. Licensed
under $3 via $4.",
- "multimediaviewer-html-embed-credit-text-tbls-nonfree": "\"$1\" by $2.
$3 via $4.",
- "multimediaviewer-html-embed-credit-text-tls": "\"$1\". Licensed under
$2 via $3.",
- "multimediaviewer-html-embed-credit-text-tls-nonfree": "\"$1\". $2 via
$3.",
- "multimediaviewer-html-embed-credit-text-tbs": "\"$1\" by $2. Via $3.",
- "multimediaviewer-html-embed-credit-text-tbl": "\"$1\" by $2. Licensed
under $3.",
- "multimediaviewer-html-embed-credit-text-tbl-nonfree": "\"$1\" by $2.
$3.",
- "multimediaviewer-html-embed-credit-text-tb": "\"$1\" by $2.",
- "multimediaviewer-html-embed-credit-text-ts": "\"$1\". Via $2.",
- "multimediaviewer-html-embed-credit-text-tl": "\"$1\". Licensed under
$2.",
- "multimediaviewer-html-embed-credit-text-tl-nonfree": "\"$1\". $2.",
- "multimediaviewer-html-embed-credit-text-t": "\"$1\".",
+ "multimediaviewer-text-embed-credit-text-bl": "By $1, $2, $3",
+ "multimediaviewer-text-embed-credit-text-b": "By $1, $2",
+ "multimediaviewer-text-embed-credit-text-l": "$1, $2",
+ "multimediaviewer-html-embed-credit-text-bl": "By $1, $2, $3",
+ "multimediaviewer-html-embed-credit-text-b": "By $1, $2",
+ "multimediaviewer-html-embed-credit-text-l": "$1, $2",
"multimediaviewer-embed-byline": "By $1",
"multimediaviewer-embed-license": "Licensed under $1.",
"multimediaviewer-embed-license-nonfree": "$1.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 7584099..4126101 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -100,30 +100,12 @@
"multimediaviewer-embed-wt": "Used to represent a choice for embedding
a file in a wiki page, as wikitext.\n{{Identical|Wikitext}}",
"multimediaviewer-embed-html": "Used to represent a choice for
embedding a file in an HTML document, as HTML.\n{{Identical|HTML}}",
"multimediaviewer-embed-explanation": "Used below the embed textarea to
explain what we expect the user to do.",
- "multimediaviewer-text-embed-credit-text-tbls": "Credit text, used when
generating plain text for attributing an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
author\n* $3 - name of the license\n* $4 - name of the website/institution
which was the direct source for this image. This parameter is usually an
URL.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-text-embed-credit-text-tbls-nonfree": "Like
{{msg-mw|multimediaviewer-text-embed-credit-text-tbls}}, but for non-free
images (where $3 is typically not a license name but something like \"Fair
use\").\n\nParameters:\n* $1 - name of the work (typically the filename without
an extension)\n* $2 - name of the author\n* $3 - name of the license\n* $4 -
name of the website/institution which was the direct source for this image.
This parameter is usually an URL.",
- "multimediaviewer-text-embed-credit-text-tls": "Credit text, used when
generating plain text to attribute an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
license\n* $3 - name of the website/institution which was the direct source for
this image. This parameter is usually an
URL.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-text-embed-credit-text-tls-nonfree": "Like
{{msg-mw|multimediaviewer-text-embed-credit-text-tls}}, but for non-free
images, so $2 is typically not a real license name but something like \"Fair
use\".\n{{Identical|Via}}\n\nParameters:\n* $1 - name of the work (typically
the filename without an extension)\n* $2 - name of the license, or something
like \"Fair use\"\n* $3 - name of the website/institution which was the direct
source for this image. This parameter is usually an URL.",
- "multimediaviewer-text-embed-credit-text-tbs": "Credit text, used when
generating plain text to attribute an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
author\n* $3 - name of the website/institution which was the direct source for
this image. This parameter is usually an
URL.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-text-embed-credit-text-tbl": "Credit text, used when
generating plain text to attribute an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
author\n* $3 - name of the
license\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-text-embed-credit-text-tbl-nonfree": "Like
{{msg-mw|multimediaviewer-text-embed-credit-text-tbl}}, but for non-free
images, so $3 is typically not a license name but something like \"Fair
use\".\n\nParameters:\n* $1 - name of the work (typically the filename without
an extension)\n* $2 - name of the author\n* $3 - name of the license or
something like \"Fair use\".",
- "multimediaviewer-text-embed-credit-text-tb": "Credit text, used when
generating plain text to attribute an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
author\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-text-embed-credit-text-ts": "Credit text, used when
generating plain text to attribute an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
website/institution which was the direct source for this image. This parameter
is usually an URL.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-text-embed-credit-text-tl": "Credit text, used when
generating plain text to attribute an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
license\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-text-embed-credit-text-tl-nonfree": "Like
{{msg-mw|multimediaviewer-text-embed-credit-text-tl}}, but for non-free images
(where $2 is typically not a license name but something like \"Fair use\").",
- "multimediaviewer-text-embed-credit-text-t": "Credit text, used when
generating plain text to attribute an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an
extension)\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-html-embed-credit-text-tbls": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
author\n* $3 - name of the license\n* $4 - name of the website/institution
which was the direct source for this image\nEach of the parameters could be
either plain text or a link.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-html-embed-credit-text-tbls-nonfree": "Like
{{msg-mw|multimediaviewer-html-embed-credit-text-tbls}}, but for non-free
images, so $3 is typically not a license name but something like \"Fair
use\".\n\nParameters:\n* $1 - name of the work (typically the filename without
an extension)\n* $2 - name of the author\n* $3 - name of the license or
something like \"Fair use\"\n* $4 - name of the website/institution which was
the direct source for this image\n\nEach of the parameters could be either
plain text or a link.",
- "multimediaviewer-html-embed-credit-text-tls": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
license\n* $3 - name of the website/institution which was the direct source for
this image\nEach of the parameters could be either plain text or a
link.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-html-embed-credit-text-tls-nonfree": "Like
{{msg-mw|multimediaviewer-html-embed-credit-text-tls}}, but for non-free
images, so $2 is typically not a license name but something like \"Fair
use\".\n\nParameters:\n* $1 - name of the work (typically the filename without
an extension)\n* $2 - name of the license or something like \"Fair use\"\n* $3
- name of the website/institution which was the direct source for this
image\nEach of the parameters could be either plain text or a
link.\n\n\n{{Identical|Via}}",
- "multimediaviewer-html-embed-credit-text-tbs": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
author\n* $3 - name of the website/institution which was the direct source for
this image\nEach of the parameters could be either plain text or a
link.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-html-embed-credit-text-tbl": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
author\n* $3 - name of the license\nEach of the parameters could be either
plain text or a link.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-html-embed-credit-text-tbl-nonfree": "Like
{{msg-mw|multimediaviewer-html-embed-credit-text-tbl}}, but for non-free
images, so $3 is typically not a license name but something like \"Fair
use\".\n\n\nParameters:\n* $1 - name of the work (typically the filename
without an extension)\n* $2 - name of the author\n* $3 - name of the license or
something like \"Fair use\"\nEach of the parameters could be either plain text
or a link.",
- "multimediaviewer-html-embed-credit-text-tb": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
author\nEach of the parameters could be either plain text or a
link.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-html-embed-credit-text-ts": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
website/institution which was the direct source for this image\nEach of the
parameters could be either plain text or a
link.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-html-embed-credit-text-tl": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\n* $2 - name of the
license\nEach of the parameters could be either plain text or a
link.\n{{Related|Multimediaviewer-embed-credit-text}}",
- "multimediaviewer-html-embed-credit-text-tl-nonfree": "Like
{{msg-mw|multimediaviewer-html-embed-credit-text-tl}}, but for non-free images
(where $2 is typically not a license name but something like \"Fair use\").",
- "multimediaviewer-html-embed-credit-text-t": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
work (typically the filename without an extension)\nEach of the parameters
could be either plain text or a
link.\n{{Related|Multimediaviewer-embed-credit-text}}",
+ "multimediaviewer-text-embed-credit-text-bl": "Credit text, used when
generating plain text for attributing an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
author\n* $2 - name of the license\n* $3 - URL to the image
source.\n{{Related|Multimediaviewer-embed-credit-text}}",
+ "multimediaviewer-text-embed-credit-text-b": "Credit text, used when
generating plain text for attributing an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
author\n* $2 - URL to the image
source.\n{{Related|Multimediaviewer-embed-credit-text}}",
+ "multimediaviewer-text-embed-credit-text-l": "Credit text, used when
generating plain text for attributing an image.\n\nWhich one of the
multimediaviewer-text-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
license\n* $2 - URL to the image
source.\n{{Related|Multimediaviewer-embed-credit-text}}",
+ "multimediaviewer-html-embed-credit-text-bl": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
author\n* $2 - name of the license\n* $3 - URL to the image source\nEach of the
parameters could be either plain text or a
link.\n{{Related|Multimediaviewer-embed-credit-text}}",
+ "multimediaviewer-html-embed-credit-text-b": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
author\n* $2 - URL to the image source\nEach of the parameters could be either
plain text or a link.\n{{Related|Multimediaviewer-embed-credit-text}}",
+ "multimediaviewer-html-embed-credit-text-l": "Credit text, used when
generating HTML to reuse an image.\n\nWhich one of the
multimediaviewer-html-embed-credit-text-* messages is used will depend on what
information about the image is available.\n\nParameters:\n* $1 - name of the
license\n* $2 - URL to the image source\nEach of the parameters could be either
plain text or a link.\n{{Related|Multimediaviewer-embed-credit-text}}",
"multimediaviewer-embed-byline": "Byline (author credit) text, used
when generating wikitext/HTML to reuse the image. $1 is author
name.\n{{Identical|By}}",
"multimediaviewer-embed-license": "License information, used when
generating wikitext/HTML to reuse the image. $1 is the license name.",
"multimediaviewer-embed-license-nonfree": "Like
{{msg-mw|multimediaviewer-embed-license}}, but for non-free images (where $1 is
typically not a license name but something like \"Fair use\").",
diff --git a/resources/mmv/mmv.EmbedFileFormatter.js
b/resources/mmv/mmv.EmbedFileFormatter.js
index 205b208..5dfed3b 100644
--- a/resources/mmv/mmv.EmbedFileFormatter.js
+++ b/resources/mmv/mmv.EmbedFileFormatter.js
@@ -118,33 +118,32 @@
EFFP.getCreditText = function ( info ) {
var creditText, creditParams,
formatter = this,
- titleText = info.imageInfo.title.getNameText(),
- titleUrl = this.getLinkUrl( info ),
+ shortURL = this.getShortUrl( info ),
+ license = info.imageInfo.license,
byline = this.getByline( info.imageInfo.author,
info.imageInfo.source, info.imageInfo.attribution, function ( txt ) {
return formatter.htmlUtils.htmlToText( txt );
} );
+ // If both the byline and licence are missing, the credit text
is simply the URL
+ if ( !byline && !license ) {
+ return shortURL;
+ }
+
creditParams = [
- 'multimediaviewer-text-embed-credit-text-t',
- titleText
+ 'multimediaviewer-text-embed-credit-text-'
];
if ( byline ) {
creditParams[0] += 'b';
creditParams.push( byline );
}
- if ( info.imageInfo.license ) {
+
+ if ( license ) {
creditParams[0] += 'l';
- creditParams.push( this.htmlUtils.htmlToText(
info.imageInfo.license.getShortName() ) );
+ creditParams.push( this.htmlUtils.htmlToText(
license.getShortName() ) );
}
- creditParams[0] += 's';
- creditParams.push( info.repoInfo.displayName + ' - ' + titleUrl
);
-
- if ( info.imageInfo.license && !info.imageInfo.license.isFree()
) {
- creditParams[0] += '-nonfree';
- }
-
+ creditParams.push( shortURL );
creditText = mw.message.apply( mw, creditParams ).plain();
return creditText;
@@ -158,31 +157,28 @@
EFFP.getCreditHtml = function ( info ) {
var creditText, creditParams,
titleText = info.imageInfo.title.getNameText(),
- titleUrl = this.getLinkUrl( info ),
- $title = $( '<a>' ).text( titleText ).prop( 'href',
titleUrl ),
+ shortURL = this.getShortUrl( info ),
+ license = info.imageInfo.license,
byline = this.getByline( info.imageInfo.author,
info.imageInfo.source, info.imageInfo.attribution );
+ if ( !byline && !license ) {
+ return shortURL;
+ }
+
creditParams = [
- 'multimediaviewer-html-embed-credit-text-t',
- this.htmlUtils.jqueryToHtml( $title )
+ 'multimediaviewer-html-embed-credit-text-'
];
if ( byline ) {
creditParams[0] += 'b';
creditParams.push( byline );
}
- if ( info.imageInfo.license ) {
+ if ( license ) {
creditParams[0] += 'l';
- creditParams.push(
info.imageInfo.license.getShortLink() );
+ creditParams.push( license.getShortLink() );
}
- creditParams[0] += 's';
- creditParams.push( this.getSiteLink( info ) );
-
- if ( info.imageInfo.license && !info.imageInfo.license.isFree()
) {
- creditParams[0] += '-nonfree';
- }
-
+ creditParams.push( shortURL );
creditText = mw.message.apply( mw, creditParams ).plain();
return creditText;
@@ -242,5 +238,9 @@
return this.router.createHashedUrl( route,
info.imageInfo.descriptionUrl );
};
+ EFFP.getShortUrl = function ( info ) {
+ return mw.config.get( 'wgServer' )+mw.config.get( 'wgScript'
)+'?curid='+info.imageInfo.pageID;
+ }
+
mw.mmv.EmbedFileFormatter = EmbedFileFormatter;
}( mediaWiki, jQuery ) );
diff --git a/resources/mmv/model/mmv.model.Image.js
b/resources/mmv/model/mmv.model.Image.js
index 293ac01..8316f01 100644
--- a/resources/mmv/model/mmv.model.Image.js
+++ b/resources/mmv/model/mmv.model.Image.js
@@ -55,6 +55,7 @@
mimeType,
url,
descriptionUrl,
+ pageID,
repo,
lastUploader,
uploadDateTime,
@@ -94,6 +95,9 @@
/** @property {string} descriptionUrl The URL to the
description page for the image */
this.descriptionUrl = descriptionUrl;
+
+ /** @property {number} pageId of the description page for the
image */
+ this.pageID = pageID
/** @property {string} repo The name of the repository where
this image is stored */
this.repo = repo;
@@ -207,6 +211,7 @@
innerInfo.mime,
innerInfo.url,
innerInfo.descriptionurl,
+ imageInfo.pageid,
imageInfo.imagerepository,
innerInfo.user,
uploadDateTime,
diff --git a/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js
b/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js
index 5e9eeb0..ee577cc 100644
--- a/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js
+++ b/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js
@@ -5,7 +5,7 @@
var license = options.licenseShortName ? new
mw.mmv.model.License( options.licenseShortName,
options.licenseInternalName,
options.licenseLongName, options.licenseUrl ) : undefined,
imageInfo = new mw.mmv.model.Image( options.title,
options.title.getNameText(), undefined,
- undefined, undefined, undefined,
options.imgUrl, options.filePageUrl, 'repo', undefined,
+ undefined, undefined, undefined,
options.imgUrl, options.filePageUrl, 42, 'repo', undefined,
undefined, undefined, undefined, undefined,
options.source, options.author, options.authorCount, license ),
repoInfo = { displayName: options.siteName, getSiteLink:
function () { return options.siteUrl; } };
@@ -84,17 +84,17 @@
siteName: siteName, siteUrl: siteUrl, licenseShortName:
licenseShortName,
licenseInternalName: licenseInternalName,
licenseLongName: licenseLongName,
licenseUrl: licenseUrl, author: author, source: source
} );
+
generatedHtml = formatter.getThumbnailHtml( info, thumbUrl,
width, height );
-
assert.ok( generatedHtml.match( titleText ), 'Title appears in
generated HTML.' );
assert.ok( generatedHtml.match( filePageUrl ), 'Page url
appears in generated HTML.' );
assert.ok( generatedHtml.match( thumbUrl ), 'Thumbnail url
appears in generated HTML' );
- assert.ok( generatedHtml.match( siteName ), 'Site name appears
in generated HTML' );
assert.ok( generatedHtml.match( 'Public License' ), 'License
appears in generated HTML' );
assert.ok( generatedHtml.match( 'Homer' ), 'Author appears in
generated HTML' );
assert.ok( generatedHtml.match( 'Iliad' ), 'Source appears in
generated HTML' );
assert.ok( generatedHtml.match( width ), 'Width appears in
generated HTML' );
assert.ok( generatedHtml.match( height ), 'Height appears in
generated HTML' );
+ assert.ok( generatedHtml.match( '\\?curid=42'), 'Short URL
query parameter appears in generated HTML');
// Bylines, no license and site
info = createEmbedFileInfo( { title: title, imgUrl: imgUrl,
filePageUrl: filePageUrl,
@@ -105,12 +105,12 @@
assert.ok( generatedHtml.match( titleText ), 'Title appears in
generated HTML.' );
assert.ok( generatedHtml.match( filePageUrl ), 'Page url
appears in generated HTML.' );
assert.ok( generatedHtml.match( thumbUrl ), 'Thumbnail url
appears in generated HTML' );
- assert.ok( generatedHtml.match( siteName ), 'Site name appears
in generated HTML' );
assert.ok( !generatedHtml.match( 'Public License' ), 'License
should not appear in generated HTML' );
assert.ok( generatedHtml.match( 'Homer' ), 'Author appears in
generated HTML' );
assert.ok( generatedHtml.match( 'Iliad' ), 'Source appears in
generated HTML' );
assert.ok( generatedHtml.match( width ), 'Width appears in
generated HTML' );
assert.ok( generatedHtml.match( height ), 'Height appears in
generated HTML' );
+ assert.ok( generatedHtml.match( '\\?curid=42'), 'Short URL
query parameter appears in generated HTML');
// No bylines, license and site
info = createEmbedFileInfo( { title: title, imgUrl: imgUrl,
filePageUrl: filePageUrl,
@@ -122,12 +122,12 @@
assert.ok( generatedHtml.match( titleText ), 'Title appears in
generated HTML.' );
assert.ok( generatedHtml.match( filePageUrl ), 'Page url
appears in generated HTML.' );
assert.ok( generatedHtml.match( thumbUrl ), 'Thumbnail url
appears in generated HTML' );
- assert.ok( generatedHtml.match( siteName ), 'Site name appears
in generated HTML' );
assert.ok( generatedHtml.match( 'Public License' ), 'License
appears in generated HTML' );
assert.ok( !generatedHtml.match( 'Homer' ), 'Author should not
appear in generated HTML' );
assert.ok( !generatedHtml.match( 'Iliad' ), 'Source should not
appear in generated HTML' );
assert.ok( generatedHtml.match( width ), 'Width appears in
generated HTML' );
assert.ok( generatedHtml.match( height ), 'Height appears in
generated HTML' );
+ assert.ok( generatedHtml.match( '\\?curid=42' ), 'Short URL
query parameter appears in generated HTML');
// No bylines, no license and site
info = createEmbedFileInfo( { title: title, imgUrl: imgUrl,
filePageUrl: filePageUrl,
@@ -137,12 +137,12 @@
assert.ok( generatedHtml.match( titleText ), 'Title appears in
generated HTML.' );
assert.ok( generatedHtml.match( filePageUrl ), 'Page url
appears in generated HTML.' );
assert.ok( generatedHtml.match( thumbUrl ), 'Thumbnail url
appears in generated HTML' );
- assert.ok( generatedHtml.match( siteName ), 'Site name should
appear in generated HTML' );
assert.ok( !generatedHtml.match( 'Public License' ), 'License
should not appear in generated HTML' );
assert.ok( !generatedHtml.match( 'Homer' ), 'Author should not
appear in generated HTML' );
assert.ok( !generatedHtml.match( 'Iliad' ), 'Source should not
appear in generated HTML' );
assert.ok( generatedHtml.match( width ), 'Width appears in
generated HTML' );
assert.ok( generatedHtml.match( height ), 'Height appears in
generated HTML' );
+ assert.ok( generatedHtml.match( '\\?curid=42'), 'Short URL
query parameter appears in generated HTML');
} );
@@ -188,7 +188,7 @@
QUnit.test( 'getCreditText():', 2, function ( assert ) {
var txt, formatter = new mw.mmv.EmbedFileFormatter();
- this.sandbox.stub( formatter, 'getLinkUrl' ).returns( 'quuuux'
);
+ this.sandbox.stub( formatter, 'getShortUrl' ).returns( 'link' );
txt = formatter.getCreditText( {
repoInfo: {
@@ -204,7 +204,7 @@
}
} );
- assert.strictEqual( txt, '"Image Title" by Author - Source. Via
Localcommons - quuuux', 'Sanity check' );
+ assert.strictEqual( txt, 'By Author - Source, link', 'Sanity
check' );
txt = formatter.getCreditText( {
repoInfo: {
@@ -218,20 +218,20 @@
getNameText: function () { return
'Image Title'; }
},
license: {
- getShortName: function () { return
'DWTFYWPL'; },
- longName: 'Do What the Fuck You Want
Public License',
+ getShortName: function () { return
'WTFPL v2'; },
+ longName: 'Do What the Fuck You Want
Public License Version 2',
isFree: this.sandbox.stub().returns(
true )
}
}
} );
- assert.strictEqual( txt, '"Image Title" by Author - Source.
Licensed under DWTFYWPL via Localcommons - quuuux', 'License message works' );
+ assert.strictEqual( txt, 'By Author - Source, WTFPL v2, link',
'License message works' );
} );
QUnit.test( 'getCreditHtml():', 2, function ( assert ) {
var html, formatter = new mw.mmv.EmbedFileFormatter();
- this.sandbox.stub( formatter, 'getLinkUrl' ).returns( 'quuuux'
);
+ this.sandbox.stub( formatter, 'getShortUrl' ).returns( 'link' );
html = formatter.getCreditHtml( {
repoInfo: {
@@ -248,7 +248,7 @@
}
} );
- assert.strictEqual( html, '"<a href="quuuux">Image Title</a>"
by Author - Source. Via <a href="quux">Localcommons</a>.', 'Sanity check' );
+ assert.strictEqual( html, 'By Author - Source, link', 'Sanity
check' );
html = formatter.getCreditHtml( {
repoInfo: {
@@ -263,13 +263,13 @@
getNameText: function () { return
'Image Title'; }
},
license: {
- getShortLink: function () { return '<a
href="http://dwtfywpl.net/">DWTFYWPL</a>'; },
- longName: 'Do What the Fuck You Want
Public License',
+ getShortLink: function () { return '<a
href="http://www.wtfpl.net/">WTFPL v2</a>'; },
+ longName: 'Do What the Fuck You Want
Public License Version 2',
isFree: this.sandbox.stub().returns(
true )
}
}
} );
- assert.strictEqual( html, '"<a href="quuuux">Image Title</a>"
by Author - Source. Licensed under <a href="http://dwtfywpl.net/">DWTFYWPL</a>
via <a href="quux">Localcommons</a>.', 'Sanity check' );
+ assert.strictEqual( html, 'By Author - Source, <a
href="http://www.wtfpl.net/">WTFPL v2</a>, link', 'Sanity check' );
} );
}( mediaWiki ) );
diff --git a/tests/qunit/mmv/model/mmv.model.Image.test.js
b/tests/qunit/mmv/model/mmv.model.Image.test.js
index 109b799..5622b89 100644
--- a/tests/qunit/mmv/model/mmv.model.Image.test.js
+++ b/tests/qunit/mmv/model/mmv.model.Image.test.js
@@ -18,7 +18,7 @@
( function ( mw ) {
QUnit.module( 'mmv.model.Image', QUnit.newMwEnvironment() );
- QUnit.test( 'Image model constructor sanity check', 24, function (
assert ) {
+ QUnit.test( 'Image model constructor sanity check', 25, function (
assert ) {
var
title = mw.Title.newFromText( 'File:Foobar.jpg' ),
name = 'Foo bar',
@@ -27,6 +27,7 @@
height = 15,
mime = 'image/jpeg',
url =
'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg',
+ pageID = 42,
descurl =
'https://commons.wikimedia.org/wiki/File:Foobar.jpg',
repo = 'wikimediacommons',
user = 'Kaldari',
@@ -45,7 +46,7 @@
restrictions = ['trademarked'],
imageData = new mw.mmv.model.Image(
title, name, size, width, height, mime, url,
- descurl, repo, user, datetime, anondatetime,
origdatetime,
+ descurl, pageID, repo, user, datetime,
anondatetime, origdatetime,
description, source, author, authorCount,
license, permission, attribution,
latitude, longitude, restrictions );
@@ -57,6 +58,7 @@
assert.strictEqual( imageData.mimeType, mime, 'MIME type is set
correctly' );
assert.strictEqual( imageData.url, url, 'URL for original image
is set correctly' );
assert.strictEqual( imageData.descriptionUrl, descurl, 'URL for
image description page is set correctly' );
+ assert.strictEqual( imageData.pageID, pageID, "Page ID of image
description is set correctly")
assert.strictEqual( imageData.repo, repo, 'Repository name is
set correctly' );
assert.strictEqual( imageData.lastUploader, user, 'Name of last
uploader is set correctly' );
assert.strictEqual( imageData.uploadDateTime, datetime, 'Date
and time of last upload is set correctly' );
@@ -79,13 +81,13 @@
var
firstImageData = new mw.mmv.model.Image(
mw.Title.newFromText( 'File:Foobar.pdf.jpg' ),
'Foo bar',
- 10, 10, 10, 'image/jpeg', 'http://example.org',
'http://example.com',
+ 10, 10, 10, 'image/jpeg', 'http://example.org',
'http://example.com', 42,
'example', 'tester', '2013-11-10', '20131110',
'2013-11-09', 'Blah blah blah',
'A person', 'Another person', 1,
'CC-BY-SA-3.0', 'Permitted', 'My cat'
),
secondImageData = new mw.mmv.model.Image(
mw.Title.newFromText( 'File:Foobar.pdf.jpg' ),
'Foo bar',
- 10, 10, 10, 'image/jpeg', 'http://example.org',
'http://example.com',
+ 10, 10, 10, 'image/jpeg', 'http://example.org',
'http://example.com', 42,
'example', 'tester', '2013-11-10', '20131110',
'2013-11-09', 'Blah blah blah',
'A person', 'Another person', 1,
'CC-BY-SA-3.0', 'Permitted', 'My cat',
'39.91820938', '78.09812938'
--
To view, visit https://gerrit.wikimedia.org/r/260955
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9189f00bfbf7639974d66cf1921773855a77a865
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Unicornisaurous <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits