jenkins-bot has submitted this change and it was merged.

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
Depends-On: I0f00b986e6095bdb9b8d6af6fbc5b01995227e02
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, 84 insertions(+), 124 deletions(-)

Approvals:
  Gergő Tisza: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 946dbbb..b78340c 100644
--- a/extension.json
+++ b/extension.json
@@ -234,28 +234,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 516a0a5..067ffa1 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -90,30 +90,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 441fdd1..4e4b90f 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -99,30 +99,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 - used as a caption, not in the 
middle of a sentence.\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 - copyright tag (usually a 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 - used as a caption, not in the 
middle of a sentence.\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 - used as a caption, not in the 
middle of a sentence.\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 - copyright tag 
(usually a 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 - used as a caption, not in the middle of a 
sentence.\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 - copyright tag 
(usually a 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 - used as a caption, not in the middle of a 
sentence.\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 - used as a caption, not in the middle of a 
sentence.\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 - copyright tag (usually a 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..dd2f0ce 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 = info.imageInfo.descriptionShortUrl,
+                       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;
@@ -157,32 +156,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 = info.imageInfo.descriptionShortUrl,
+                       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;
diff --git a/resources/mmv/model/mmv.model.Image.js 
b/resources/mmv/model/mmv.model.Image.js
index c4214ba..5f519d4 100644
--- a/resources/mmv/model/mmv.model.Image.js
+++ b/resources/mmv/model/mmv.model.Image.js
@@ -54,6 +54,8 @@
                        mimeType,
                        url,
                        descriptionUrl,
+                       descriptionShortUrl,
+                       pageID,
                        repo,
                        uploadDateTime,
                        anonymizedUploadDateTime,
@@ -92,6 +94,12 @@
 
                /** @property {string} descriptionUrl The URL to the 
description page for the image */
                this.descriptionUrl = descriptionUrl;
+
+               /** @property {string} descriptionShortUrl A short URL to the 
description page for the image, using curid=... */
+               this.descriptionShortUrl = descriptionShortUrl;
+
+               /** @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;
@@ -202,6 +210,8 @@
                        innerInfo.mime,
                        innerInfo.url,
                        innerInfo.descriptionurl,
+                       innerInfo.descriptionshorturl,
+                       imageInfo.pageid,
                        imageInfo.imagerepository,
                        uploadDateTime,
                        anonymizedUploadDateTime,
diff --git a/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js 
b/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js
index 58dc00c..8e15dae 100644
--- a/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js
+++ b/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js
@@ -14,6 +14,8 @@
                                undefined,
                                options.imgUrl,
                                options.filePageUrl,
+                               options.shortFilePageUrl,
+                               42,
                                'repo',
                                undefined,
                                undefined,
@@ -81,6 +83,7 @@
                        title = mw.Title.newFromText( titleText ),
                        imgUrl = 
'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg',
                        filePageUrl = 
'https://commons.wikimedia.org/wiki/File:Foobar.jpg',
+                       filePageShortUrl = 
'https://commons.wikimedia.org/wiki/index.php?curid=42',
                        siteName = 'Site Name',
                        siteUrl = '//site.url/',
                        licenseShortName = 'Public License',
@@ -97,68 +100,69 @@
 
                // Bylines, license and site
                info = createEmbedFileInfo( { title: title, imgUrl: imgUrl, 
filePageUrl: filePageUrl,
-                       siteName: siteName, siteUrl: siteUrl, licenseShortName: 
licenseShortName,
-                       licenseInternalName: licenseInternalName, 
licenseLongName: licenseLongName,
-                       licenseUrl: licenseUrl, author: author, source: source 
} );
-               generatedHtml = formatter.getThumbnailHtml( info, thumbUrl, 
width, height );
+                       shortFilePageUrl: filePageShortUrl, 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' );
+               // .includes() for checking the short url since it contains a ? 
(bad for regex). Could escape instead.
+               assert.ok( generatedHtml.includes( filePageShortUrl ), 'Short 
URL appears in generated HTML');
 
                // Bylines, no license and site
                info = createEmbedFileInfo( { title: title, imgUrl: imgUrl, 
filePageUrl: filePageUrl,
-                       siteName: siteName, siteUrl: siteUrl,
+                       shortFilePageUrl: filePageShortUrl, siteName: siteName, 
siteUrl: siteUrl,
                        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 
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.includes( filePageShortUrl ), 'Short 
URL appears in generated HTML');
 
                // No bylines, license and site
                info = createEmbedFileInfo( { title: title, imgUrl: imgUrl, 
filePageUrl: filePageUrl,
                        siteName: siteName, siteUrl: siteUrl, licenseShortName: 
licenseShortName,
                        licenseInternalName: licenseInternalName, 
licenseLongName: licenseLongName,
-                       licenseUrl: licenseUrl } );
+                       licenseUrl: licenseUrl, shortFilePageUrl: 
filePageShortUrl } );
                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 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.includes( filePageShortUrl ), 'Short 
URL appears in generated HTML');
 
                // No bylines, no license and site
                info = createEmbedFileInfo( { title: title, imgUrl: imgUrl, 
filePageUrl: filePageUrl,
-                       siteName: siteName, siteUrl: siteUrl } );
+                       siteName: siteName, siteUrl: siteUrl, shortFilePageUrl: 
filePageShortUrl } );
                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 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.includes( filePageShortUrl ), 'Short 
URL appears in generated HTML');
 
        } );
 
@@ -204,8 +208,6 @@
        QUnit.test( 'getCreditText():', 2, function ( assert ) {
                var txt, formatter = new mw.mmv.EmbedFileFormatter();
 
-               this.sandbox.stub( formatter, 'getLinkUrl' ).returns( 'quuuux' 
);
-
                txt = formatter.getCreditText( {
                        repoInfo: {
                                displayName: 'Localcommons'
@@ -214,13 +216,14 @@
                        imageInfo: {
                                author: 'Author',
                                source: 'Source',
+                               descriptionShortUrl: 'link',
                                title: {
                                        getNameText: function () { return 
'Image Title'; }
                                }
                        }
                } );
 
-               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: {
@@ -230,25 +233,24 @@
                        imageInfo: {
                                author: 'Author',
                                source: 'Source',
+                               descriptionShortUrl: 'link',
                                title: {
                                        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' 
);
-
                html = formatter.getCreditHtml( {
                        repoInfo: {
                                displayName: 'Localcommons',
@@ -258,13 +260,14 @@
                        imageInfo: {
                                author: 'Author',
                                source: 'Source',
+                               descriptionShortUrl: 'link',
                                title: {
                                        getNameText: function () { return 
'Image Title'; }
                                }
                        }
                } );
 
-               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: {
@@ -275,17 +278,18 @@
                        imageInfo: {
                                author: 'Author',
                                source: 'Source',
+                               descriptionShortUrl: 'link',
                                title: {
                                        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 d482e57..c7c06d7 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', 23, function ( 
assert ) {
+       QUnit.test( 'Image model constructor sanity check', 24, function ( 
assert ) {
                var
                        title = mw.Title.newFromText( 'File:Foobar.jpg' ),
                        name = 'Foo bar',
@@ -27,7 +27,9 @@
                        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',
+                       descShortUrl = '',
                        repo = 'wikimediacommons',
                        datetime = '2011-07-04T23:31:14Z',
                        anondatetime = '20110704000000',
@@ -44,7 +46,7 @@
                        restrictions = ['trademarked'],
                        imageData = new mw.mmv.model.Image(
                                title, name, size, width, height, mime, url,
-                               descurl, repo, datetime, anondatetime, 
origdatetime,
+                               descurl, descShortUrl, pageID, repo, datetime, 
anondatetime, origdatetime,
                                description, source, author, authorCount, 
license, permission, attribution,
                                latitude, longitude, restrictions );
 
@@ -56,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.uploadDateTime, datetime, 'Date 
and time of last upload is set correctly' );
                assert.strictEqual( imageData.anonymizedUploadDateTime, 
anondatetime, 'Anonymized date and time of last upload is set correctly' );
@@ -77,13 +80,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: merged
Gerrit-Change-Id: I9189f00bfbf7639974d66cf1921773855a77a865
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Unicornisaurous <crazy...@gmail.com>
Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Nemo bis <federicol...@tiscali.it>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: Unicornisaurous <crazy...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to