mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/MultimediaViewer
synced 2024-09-24 10:49:40 +00:00
Display warning for licence/attribution problems
Bug: T76030 Bug: T71389 Bug: T71557 Change-Id: I38c1548a0de6cfd3a48db7efd7502a99f168d4a5
This commit is contained in:
parent
eca337e62f
commit
bbe174bca8
|
@ -170,6 +170,10 @@
|
|||
"multimediaviewer-restriction-trademarked",
|
||||
"multimediaviewer-restriction-default",
|
||||
"multimediaviewer-restriction-default-and-others",
|
||||
"multimediaviewer-reuse-warning-deletion",
|
||||
"multimediaviewer-reuse-warning-nonfree",
|
||||
"multimediaviewer-reuse-warning-noattribution",
|
||||
"multimediaviewer-reuse-warning-generic",
|
||||
"multimediaviewer-geoloc-north",
|
||||
"multimediaviewer-geoloc-east",
|
||||
"multimediaviewer-geoloc-south",
|
||||
|
|
|
@ -129,6 +129,10 @@
|
|||
"multimediaviewer-download-optional-attribution-cta-header": "You can attribute the author",
|
||||
"multimediaviewer-download-attribution-cta": "Show me how",
|
||||
"multimediaviewer-download-attribution-copy": "Select and copy (if supported) the attribution text for this file",
|
||||
"multimediaviewer-reuse-warning-deletion": "This file is considered for deletion.",
|
||||
"multimediaviewer-reuse-warning-nonfree": "This file does not have a free license.",
|
||||
"multimediaviewer-reuse-warning-noattribution": "This file has no attribution information.",
|
||||
"multimediaviewer-reuse-warning-generic": "Check [$1 its details] before using it.",
|
||||
"multimediaviewer-attr-plain": "Plain",
|
||||
"multimediaviewer-attr-html": "HTML",
|
||||
"multimediaviewer-options-tooltip": "Enable or disable Media Viewer",
|
||||
|
|
|
@ -138,6 +138,10 @@
|
|||
"multimediaviewer-download-optional-attribution-cta-header": "Header for inviting the user to attribute author of the image during a download action. This is used for images where attribution is not a legal requirement. See also {{msg-mw|multimediaviewer-download-attribution-cta-header}}.",
|
||||
"multimediaviewer-download-attribution-cta": "Call to action for a user to find out how to attribute the author of an image.",
|
||||
"multimediaviewer-download-attribution-copy": "Text of the tooltip for the button to select and copy the attribution of a file (if supported by the browser) in the download panel, that is displayed when hovered over.",
|
||||
"multimediaviewer-reuse-warning-deletion": "Warning message shown in the share/embed/download panels for files tagged with a deletion template. Followed by {{msg-mw|multimediaviewer-reuse-warning-generic}}.",
|
||||
"multimediaviewer-reuse-warning-nonfree": "Warning message shown in the share/embed/download panels for files under a nonfree license / copyright tag. Followed by {{msg-mw|multimediaviewer-reuse-warning-generic}}.",
|
||||
"multimediaviewer-reuse-warning-noattribution": "Warning message shown in the share/embed/download panels for files which have no machine-readable author or source. Followed by {{msg-mw|multimediaviewer-reuse-warning-generic}}.",
|
||||
"multimediaviewer-reuse-warning-generic": "Generic message at the end of every warning. $1 is the link to the file page.",
|
||||
"multimediaviewer-attr-plain": "Label for a button that lets the user pick plain text as an output format.",
|
||||
"multimediaviewer-attr-html": "{{optional}}\nLabel for a button that lets the user pick HTML as an output format.\n{{Identical|HTML}}",
|
||||
"multimediaviewer-options-tooltip": "Tooltip for a button that opens a panel for enabling or disabling the media viewer.",
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
* @param {mw.mmv.model.License} license
|
||||
* @param {string} permission
|
||||
* @param {string} attribution Custom attribution string that replaces credit line when set
|
||||
* @param {string} deletionReason
|
||||
* @param {number} latitude
|
||||
* @param {number} longitude
|
||||
* @param {string[]} restrictions
|
||||
|
@ -70,6 +71,7 @@
|
|||
license,
|
||||
permission,
|
||||
attribution,
|
||||
deletionReason,
|
||||
latitude,
|
||||
longitude,
|
||||
restrictions
|
||||
|
@ -138,6 +140,9 @@
|
|||
/** @property {string} attribution custom attribution string set by uploader that replaces credit line */
|
||||
this.attribution = attribution;
|
||||
|
||||
/** @property {string|null} reason for pending deletion, null if image is not about to be deleted */
|
||||
this.deletionReason = deletionReason;
|
||||
|
||||
/** @property {number} latitude The latitude of the place where the image was created */
|
||||
this.latitude = latitude;
|
||||
|
||||
|
@ -169,7 +174,7 @@
|
|||
Image.newFromImageInfo = function ( title, imageInfo ) {
|
||||
var name, uploadDateTime, anonymizedUploadDateTime, creationDateTime, imageData,
|
||||
description, source, author, authorCount, license, permission, attribution,
|
||||
latitude, longitude, restrictions,
|
||||
deletionReason, latitude, longitude, restrictions,
|
||||
innerInfo = imageInfo.imageinfo[ 0 ],
|
||||
extmeta = innerInfo.extmetadata;
|
||||
|
||||
|
@ -194,6 +199,7 @@
|
|||
license = this.newLicenseFromImageInfo( extmeta );
|
||||
permission = this.parseExtmeta( extmeta.Permission, 'string' );
|
||||
attribution = this.parseExtmeta( extmeta.Attribution, 'string' );
|
||||
deletionReason = this.parseExtmeta( extmeta.DeletionReason, 'string' );
|
||||
restrictions = this.parseExtmeta( extmeta.Restrictions, 'list' );
|
||||
|
||||
latitude = this.parseExtmeta( extmeta.GPSLatitude, 'float' );
|
||||
|
@ -226,6 +232,7 @@
|
|||
license,
|
||||
permission,
|
||||
attribution,
|
||||
deletionReason,
|
||||
latitude,
|
||||
longitude,
|
||||
restrictions
|
||||
|
|
|
@ -77,7 +77,8 @@
|
|||
'Attribution',
|
||||
'AttributionRequired',
|
||||
'NonFree',
|
||||
'Restrictions'
|
||||
'Restrictions',
|
||||
'DeletionReason'
|
||||
].join( '|' );
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,6 +77,10 @@
|
|||
this.$warning = $( '<div>' )
|
||||
.addClass( 'mw-mmv-dialog-warning' )
|
||||
.hide()
|
||||
.click( function ( e ) {
|
||||
// prevent other click handlers such as the download CTA from intercepting clicks at the warning
|
||||
e.stopPropagation();
|
||||
} )
|
||||
.appendTo( this.$dialog );
|
||||
};
|
||||
|
||||
|
@ -212,5 +216,43 @@
|
|||
this.$dialog.removeClass( 'mw-mmv-warning-visible' );
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {mw.mmv.model.Image} image
|
||||
* @return {string[]}
|
||||
*/
|
||||
DP.getImageWarnings = function ( image ) {
|
||||
var warnings = [];
|
||||
|
||||
if ( image.deletionReason ) {
|
||||
warnings.push( mw.message( 'multimediaviewer-reuse-warning-deletion' ).plain() );
|
||||
// Don't inform about other warnings (they may be the cause of the deletion)
|
||||
return warnings;
|
||||
}
|
||||
|
||||
if ( !image.license || image.license.needsAttribution() && !image.author && !image.attribution ) {
|
||||
warnings.push( mw.message( 'multimediaviewer-reuse-warning-noattribution' ).plain() );
|
||||
}
|
||||
|
||||
if ( image.license && !image.license.isFree() ) {
|
||||
warnings.push( mw.message( 'multimediaviewer-reuse-warning-nonfree' ).plain() );
|
||||
}
|
||||
|
||||
return warnings;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {mw.mmv.model.Image} image
|
||||
*/
|
||||
DP.showImageWarnings = function ( image ) {
|
||||
var warnings = this.getImageWarnings( image );
|
||||
|
||||
if ( warnings.length > 0 ) {
|
||||
warnings.push( mw.message( 'multimediaviewer-reuse-warning-generic', image.descriptionUrl ).parse() );
|
||||
this.setWarning( warnings.join( '<br />' ) );
|
||||
} else {
|
||||
this.clearWarning();
|
||||
}
|
||||
};
|
||||
|
||||
mw.mmv.ui.Dialog = Dialog;
|
||||
}( mediaWiki, jQuery, OO ) );
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
DP.set = function ( image, repo ) {
|
||||
if ( this.download ) {
|
||||
this.download.set( image, repo );
|
||||
this.clearWarning();
|
||||
this.showImageWarnings( image );
|
||||
} else {
|
||||
this.setValues = {
|
||||
image: image,
|
||||
|
@ -102,7 +102,7 @@
|
|||
|
||||
if ( this.setValues ) {
|
||||
this.download.set( this.setValues.image, this.setValues.repo );
|
||||
this.clearWarning();
|
||||
this.showImageWarnings( this.setValues.image );
|
||||
this.setValues = undefined;
|
||||
}
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@
|
|||
// This is a delayed set() for the elements we've just created on demand
|
||||
this.tabs.share.set.apply( this.tabs.share, this.tabsSetValues.share );
|
||||
this.tabs.embed.set.apply( this.tabs.embed, this.tabsSetValues.embed );
|
||||
this.showImageWarnings( this.tabsSetValues.share[ 0 ] );
|
||||
this.tabsSetValues = undefined;
|
||||
this.clearWarning();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -207,7 +207,7 @@
|
|||
this.tabs.share.set( image );
|
||||
this.tabs.embed.set( image, repo, caption, alt );
|
||||
this.tabs.embed.set( image, repo, caption );
|
||||
this.clearWarning();
|
||||
this.showImageWarnings( image );
|
||||
} else {
|
||||
this.tabsSetValues = {
|
||||
share: [ image ],
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
author = 'Ryan Kaldari',
|
||||
authorCount = 1,
|
||||
permission = 'only use for good, not evil',
|
||||
deletionReason = 'poor quality',
|
||||
license = new mw.mmv.model.License( 'cc0' ),
|
||||
attribution = 'Created by my cats on a winter morning',
|
||||
latitude = 39.12381283,
|
||||
|
@ -48,7 +49,7 @@
|
|||
title, name, size, width, height, mime, url,
|
||||
descurl, descShortUrl, pageID, repo, datetime, anondatetime, origdatetime,
|
||||
description, source, author, authorCount, license, permission, attribution,
|
||||
latitude, longitude, restrictions );
|
||||
deletionReason, latitude, longitude, restrictions );
|
||||
|
||||
assert.strictEqual( imageData.title, title, 'Title is set correctly' );
|
||||
assert.strictEqual( imageData.name, name, 'Name is set correctly' );
|
||||
|
@ -70,6 +71,7 @@
|
|||
assert.strictEqual( imageData.license, license, 'License is set correctly' );
|
||||
assert.strictEqual( imageData.permission, permission, 'Permission is set correctly' );
|
||||
assert.strictEqual( imageData.attribution, attribution, 'Attribution is set correctly' );
|
||||
assert.strictEqual( imageData.deletionReason, deletionReason, 'Deletion reason is set correctly' );
|
||||
assert.strictEqual( imageData.latitude, latitude, 'Latitude is set correctly' );
|
||||
assert.strictEqual( imageData.longitude, longitude, 'Longitude is set correctly' );
|
||||
assert.deepEqual( imageData.restrictions, restrictions, 'Restrictions is set correctly' );
|
||||
|
@ -89,7 +91,7 @@
|
|||
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'
|
||||
undefined, '39.91820938', '78.09812938'
|
||||
);
|
||||
|
||||
assert.strictEqual( firstImageData.hasCoords(), false, 'No coordinates present means hasCoords returns false.' );
|
||||
|
|
|
@ -97,13 +97,17 @@
|
|||
hidden: ''
|
||||
},
|
||||
Artist: {
|
||||
value: 'Wikimeda',
|
||||
value: 'John Smith',
|
||||
source: 'commons-desc-page'
|
||||
},
|
||||
AuthorCount: {
|
||||
value: '2',
|
||||
source: 'commons-desc-page'
|
||||
},
|
||||
Attribution: {
|
||||
value: 'By John Smith',
|
||||
source: 'commons-desc-page'
|
||||
},
|
||||
Permission: {
|
||||
value: 'Do not use. Ever.',
|
||||
source: 'commons-desc-page'
|
||||
|
@ -119,6 +123,10 @@
|
|||
Restrictions: {
|
||||
value: 'trademarked|insignia',
|
||||
source: 'commons-desc-page'
|
||||
},
|
||||
DeletionReason: {
|
||||
value: 'copyvio',
|
||||
source: 'commons-desc-page'
|
||||
}
|
||||
},
|
||||
mime: 'image/jpeg',
|
||||
|
@ -148,8 +156,9 @@
|
|||
assert.strictEqual( image.creationDateTime, '18 February 2009\u00a0(according to EXIF data)', 'creationDateTime is set correctly' );
|
||||
assert.strictEqual( image.description, 'Wikis stuff', 'description is set correctly' );
|
||||
assert.strictEqual( image.source, 'Wikipedia', 'source is set correctly' );
|
||||
assert.strictEqual( image.author, 'Wikimeda', 'author is set correctly' );
|
||||
assert.strictEqual( image.author, 'John Smith', 'author is set correctly' );
|
||||
assert.strictEqual( image.authorCount, 2, 'author count is set correctly' );
|
||||
assert.strictEqual( image.attribution, 'By John Smith', 'attribution is set correctly' );
|
||||
assert.strictEqual( image.license.shortName, 'CC0', 'license short name is set correctly' );
|
||||
assert.strictEqual( image.license.internalName, 'cc0', 'license internal name is set correctly' );
|
||||
assert.strictEqual( image.license.longName, 'Creative Commons Public Domain Dedication', 'license long name is set correctly' );
|
||||
|
@ -157,6 +166,7 @@
|
|||
assert.strictEqual( image.license.attributionRequired, false, 'Attribution required flag is honored' );
|
||||
assert.strictEqual( image.license.nonFree, true, 'Non-free flag is honored' );
|
||||
assert.strictEqual( image.permission, 'Do not use. Ever.', 'permission is set correctly' );
|
||||
assert.strictEqual( image.deletionReason, 'copyvio', 'permission is set correctly' );
|
||||
assert.strictEqual( image.latitude, 90, 'latitude is set correctly' );
|
||||
assert.strictEqual( image.longitude, 180, 'longitude is set correctly' );
|
||||
assert.deepEqual( image.restrictions, [ 'trademarked', 'insignia' ], 'restrictions is set correctly' );
|
||||
|
|
|
@ -226,4 +226,25 @@
|
|||
assert.ok( !reuseDialog.isOpen, 'Dialog closed now.' );
|
||||
} );
|
||||
|
||||
QUnit.test( 'getImageWarnings():', function ( assert ) {
|
||||
var reuseDialog = makeReuseDialog( this.sandbox ),
|
||||
title = mw.Title.newFromText( 'File:Foobar.jpg' ),
|
||||
src = 'https://upload.wikimedia.org/wikipedia/commons/3/3a/Foobar.jpg',
|
||||
url = 'https://commons.wikimedia.org/wiki/File:Foobar.jpg',
|
||||
image = { // fake mw.mmv.model.Image
|
||||
title: title,
|
||||
url: src,
|
||||
descriptionUrl: url,
|
||||
width: 100,
|
||||
height: 80
|
||||
},
|
||||
imageDeleted = $.extend( { deletionReason: 'deleted file test' }, image );
|
||||
|
||||
// Test that the lack of license is picked up
|
||||
assert.equal( 1, reuseDialog.getImageWarnings( image ).length, 'Lack of license detected' );
|
||||
|
||||
// Test that deletion supersedes other warnings and only that one is reported
|
||||
assert.equal( 1, reuseDialog.getImageWarnings( imageDeleted ).length, 'Deletion detected' );
|
||||
} );
|
||||
|
||||
}( mediaWiki, jQuery ) );
|
||||
|
|
Loading…
Reference in a new issue