From 0c3b0a5056e6d750733e4dad1fa1bb2efe78ab0b Mon Sep 17 00:00:00 2001 From: Andrew H Date: Sun, 4 Sep 2016 04:49:58 +0000 Subject: [PATCH] Shorten clickable link text in HTML credit lines Previously, the clickable text in the generated HTML credit lines was the entire link to the article. This is shortened to a localized version of "Link". Bug: T119686 Change-Id: I708f65a85bfa26c264cdd06a265096027266240c --- extension.json | 3 ++- i18n/en.json | 1 + i18n/qqq.json | 1 + resources/mmv/mmv.EmbedFileFormatter.js | 2 +- tests/qunit/mmv/mmv.EmbedFileFormatter.test.js | 8 ++++---- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/extension.json b/extension.json index f4b1b2089..0beefd249 100644 --- a/extension.json +++ b/extension.json @@ -232,7 +232,8 @@ "multimediaviewer-text-embed-credit-text-l", "multimediaviewer-html-embed-credit-text-bl", "multimediaviewer-html-embed-credit-text-b", - "multimediaviewer-html-embed-credit-text-l" + "multimediaviewer-html-embed-credit-text-l", + "multimediaviewer-html-embed-credit-link-text" ] }, "mmv.ui.download.pane": { diff --git a/i18n/en.json b/i18n/en.json index 17fc6f281..e7d7ac5b4 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -96,6 +96,7 @@ "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-html-embed-credit-link-text": "Link", "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 dda5c8ebb..bc0d0d309 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -105,6 +105,7 @@ "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": "{{optional}}\nCredit 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-html-embed-credit-link-text": "The clickable text of a link in a credit line, used when generating HTML to reuse an image.\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 07562389b..e0cdc063e 100644 --- a/resources/mmv/mmv.EmbedFileFormatter.js +++ b/resources/mmv/mmv.EmbedFileFormatter.js @@ -163,7 +163,7 @@ EFFP.getCreditHtml = function ( info ) { var creditText, creditParams, shortURL = info.imageInfo.descriptionShortUrl, - shortLink = this.htmlUtils.makeLinkText( shortURL, { href: shortURL } ), + shortLink = this.htmlUtils.makeLinkText( mw.message( 'multimediaviewer-html-embed-credit-link-text' ), { href: shortURL } ), license = info.imageInfo.license, byline = this.getByline( info.imageInfo.author, info.imageInfo.source, info.imageInfo.attribution ); diff --git a/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js b/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js index 6773312b5..0d78502b6 100644 --- a/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js +++ b/tests/qunit/mmv/mmv.EmbedFileFormatter.test.js @@ -258,14 +258,14 @@ imageInfo: { author: 'Author', source: 'Source', - descriptionShortUrl: 'link', + descriptionShortUrl: 'some link', title: { getNameText: function () { return 'Image Title'; } } } } ); - assert.strictEqual( html, 'By Author - Source, link', 'Sanity check' ); + assert.strictEqual( html, 'By Author - Source, Link', 'Sanity check' ); html = formatter.getCreditHtml( { repoInfo: { @@ -276,7 +276,7 @@ imageInfo: { author: 'Author', source: 'Source', - descriptionShortUrl: 'link', + descriptionShortUrl: 'some link', title: { getNameText: function () { return 'Image Title'; } }, @@ -288,6 +288,6 @@ } } ); - assert.strictEqual( html, 'By Author - Source, WTFPL v2, link', 'Sanity check' ); + assert.strictEqual( html, 'By Author - Source, WTFPL v2, Link', 'Sanity check' ); } ); }( mediaWiki ) );