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

Change subject: Add image's license to the lightbox header
......................................................................


Add image's license to the lightbox header

Depends on…

* core
:* I77303d8e535fc1c42e14cfb853814e5c434a81ec
* CommonsMetadata
:* I5e6bc45f9751641e16426231dabcc8277b86fee0 (merged)
:* If3cf6a0ee444d1613d0caf14045b92fad6afa2ab (merged)

Change-Id: I60180f7ca3a16a04a0adee8af8482fa0940ac555
---
M MultimediaViewer.i18n.php
M MultimediaViewer.php
M css/ext.multimediaViewer.css
A img/cc.svg
M js/ext.multimediaViewer.js
5 files changed, 142 insertions(+), 3 deletions(-)

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



diff --git a/MultimediaViewer.i18n.php b/MultimediaViewer.i18n.php
index bfbad9e..f2614e9 100644
--- a/MultimediaViewer.i18n.php
+++ b/MultimediaViewer.i18n.php
@@ -35,6 +35,22 @@
        'multimediaviewer-datetime-uploaded' => 'Uploaded on $1',
        'multimediaviewer-userpage-link' => '{{GENDER:$2|Uploaded}} by $1',
        'multimediaviewer-credit' => '$1 - $2',
+
+       // Licenses
+       'multimediaviewer-license-cc-by-1.0' => 'CC BY 1.0',
+       'multimediaviewer-license-cc-sa-1.0' => 'CC SA 1.0',
+       'multimediaviewer-license-cc-by-sa-1.0' => 'CC BY-SA 1.0',
+       'multimediaviewer-license-cc-by-2.0' => 'CC BY 2.0',
+       'multimediaviewer-license-cc-by-sa-2.0' => 'CC BY-SA 2.0',
+       'multimediaviewer-license-cc-by-2.1' => 'CC BY 2.1',
+       'multimediaviewer-license-cc-by-sa-2.1' => 'CC BY-SA 2.1',
+       'multimediaviewer-license-cc-by-2.5' => 'CC BY 2.5',
+       'multimediaviewer-license-cc-by-sa-2.5' => 'CC BY-SA 2.5',
+       'multimediaviewer-license-cc-by-3.0' => 'CC BY 3.0',
+       'multimediaviewer-license-cc-by-sa-3.0' => 'CC BY-SA 3.0',
+       'multimediaviewer-license-cc-pd' => 'Public Domain',
+       'multimediaviewer-license-cc-zero' => 'CC 0',
+       'multimediaviewer-license-default' => 'Licensing information',
 );
 
 /** Message documentation (Message documentation)
@@ -70,6 +86,23 @@
 Neither parameters are usernames, so GENDER is useless. Both come directly 
from the API, the extended metadata imageinfo prop in particular.
 
 They will usually be derived from the HTML output from wikitext on a file 
description page - however, no complicated HTML, only links, will be allowed.',
+       'multimediaviewer-userpage-link' => 'Link to the user page for the 
uploader of the image. $1 is the username of the uploader, $2 is their gender.',
+       'multimediaviewer-credit' => 'Credit line for images - $1 is HTML 
describing the authour, $2 is HTML describing the source. Neither are 
usernames, so GENDER is useless. Both come directly from the API, the extended 
metadata imageinfo prop in particular. They will usually be derived from the 
HTML output from wikitext on a file description page - however, no complicated 
HTML, only links, will be allowed.',
+
+       'multimediaviewer-license-cc-sa-1.0' => 'Very short label for the 
Creative Commons ShareAlike license, version 1.0, used in a link to the file 
information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-1.0' => 'Very short label for the 
Creative Commons Attribution license, version 1.0, used in a link to the file 
information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-sa-1.0' => 'Very short label for the 
Creative Commons Attribution ShareAlike license, version 1.0, used in a link to 
the file information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-2.0' => 'Very short label for the 
Creative Commons Attribution license, version 2.0, used in a link to the file 
information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-sa-2.0' => 'Very short label for the 
Creative Commons Attribution ShareAlike license, version 2.0, used in a link to 
the file information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-2.1' => 'Very short label for the 
Creative Commons Attribution license, version 2.1, used in a link to the file 
information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-sa-2.1' => 'Very short label for the 
Creative Commons Attribution ShareAlike license, version 2.1, used in a link to 
the file information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-2.5' => 'Very short label for the 
Creative Commons Attribution license, version 2.5, used in a link to the file 
information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-sa-2.5' => 'Very short label for the 
Creative Commons Attribution ShareAlike license, version 2.5, used in a link to 
the file information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-3.0' => 'Very short label for the 
Creative Commons Attribution license, version 3.0, used in a link to the file 
information page that has more licensing information.',
+       'multimediaviewer-license-cc-by-sa-3.0' => 'Very short label for the 
Creative Commons Attribution ShareAlike license, version 3.0, used in a link to 
the file information page that has more licensing information.',
+       'multimediaviewer-license-cc-pd' => 'Very short label for the Creative 
Commons Public Domain license, used in a link to the file information page that 
has more licensing information.',
+       'multimediaviewer-license-cc-zero' => 'Very short label for the 
Creative Commons Zero license, used in a link to the file information page that 
has more licensing information.',
+       'multimediaviewer-license-default' => 'Short label for a link to 
generic license information.',
 );
 
 /** Arabic (العربية)
diff --git a/MultimediaViewer.php b/MultimediaViewer.php
index eb5d849..f797a9b 100644
--- a/MultimediaViewer.php
+++ b/MultimediaViewer.php
@@ -94,6 +94,27 @@
        }
 };
 
+$licenses = array(
+       'cc-by-1.0',
+       'cc-sa-1.0',
+       'cc-by-sa-1.0',
+       'cc-by-2.0',
+       'cc-by-sa-2.0',
+       'cc-by-2.1',
+       'cc-by-sa-2.1',
+       'cc-by-2.5',
+       'cc-by-sa-2.5',
+       'cc-by-3.0',
+       'cc-by-sa-3.0',
+       'cc-by-sa-3.0-migrated',
+       'cc-pd',
+       'cc-zero',
+       'default',
+);
+
+foreach ( $licenses as $license ) {
+       $wgResourceModules['ext.multimediaViewer']['messages'][] = 
'multimediaviewer-license-' . $license;
+}
 
 $wgAutoloadClasses['MultimediaViewerHooks'] = __DIR__ . 
'/MultimediaViewerHooks.php';
 $wgHooks['GetBetaFeaturePreferences'][] = 
'MultimediaViewerHooks::getBetaPreferences';
diff --git a/css/ext.multimediaViewer.css b/css/ext.multimediaViewer.css
index 77e8bb2..da89c1a 100644
--- a/css/ext.multimediaViewer.css
+++ b/css/ext.multimediaViewer.css
@@ -78,9 +78,9 @@
        background-image: url( '../img/mw-fullscreen.svg' );
 }
 
+.mw-mlb-license,
 .mw-mlb-title-contain {
        vertical-align: middle;
-       margin-left: 10px;
 }
 
 .mw-mlb-title {
@@ -156,3 +156,44 @@
 .mw-mlb-credit.empty {
        display: none;
 }
+
+.mw-mlb-license-contain,
+.mw-mlb-title-credit {
+       display: inline-block;
+}
+
+.mw-mlb-license-contain {
+       width: 30%;
+}
+
+.mw-mlb-title-credit {
+       width: 70%;
+}
+
+.mw-mlb-title-contain {
+       padding-left: 10px;
+}
+
+.mw-mlb-license {
+       padding-right: 10px;
+}
+
+.mw-mlb-license.empty {
+       display: none;
+}
+
+.mw-mlb-license.cc-license:before {
+       background-size: contain;
+       background-image: url( '../img/cc.svg' );
+       display: inline-block;
+       vertical-align: middle;
+       height: 20px;
+       width: 20px;
+       content: ' ';
+       margin-right: 5px;
+}
+
+.mw-mlb-license-contain,
+.mw-mlb-license {
+       text-align: right;
+}
diff --git a/img/cc.svg b/img/cc.svg
new file mode 100644
index 0000000..80c0747
--- /dev/null
+++ b/img/cc.svg
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" 
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd";>
+<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; width="64px" height="64px" 
viewBox="5.5 -3.5 64 64"><circle fill="#FFFFFF" stroke="#939598" cx="37.785" 
cy="28.501" r="28.836"/><path 
d="M37.441-3.5c8.951,0,16.572,3.125,22.857,9.372c3.008,3.009,5.295,6.448,6.857,10.314c1.561,3.867,2.344,7.971,2.344,12.314c0,4.381-0.773,8.486-2.314,12.313c-1.543,3.828-3.82,7.21-6.828,10.143c-3.123,3.085-6.666,5.448-10.629,7.086c-3.961,1.638-8.057,2.457-12.285,2.457s-8.276-0.808-12.143-2.429c-3.866-1.618-7.333-3.961-10.4-7.027c-3.067-3.066-5.4-6.524-7-10.372S5.5,32.767,5.5,28.5c0-4.229,0.809-8.295,2.428-12.2c1.619-3.905,3.972-7.4,7.057-10.486C21.08-0.394,28.565-3.5,37.441-3.5z
 
M37.557,2.272c-7.314,0-13.467,2.553-18.458,7.657c-2.515,2.553-4.448,5.419-5.8,8.6c-1.354,3.181-2.029,6.505-2.029,9.972c0,3.429,0.675,6.734,2.029,9.913c1.353,3.183,3.285,6.021,5.8,8.516c2.514,2.496,5.351,4.399,8.515,5.715c3.161,1.314,6.476,1.971,9.943,1.971c3.428,0,6.75-0.665,9.973-1.999c3.219-1.335,6.121-3.257,8.713-5.771c4.99-4.876,7.484-10.99,7.484-18.344c0-3.543-0.648-6.895-1.943-10.057c-1.293-3.162-3.18-5.98-5.654-8.458C50.984,4.844,44.795,2.272,37.557,2.272z
 
M37.156,23.187l-4.287,2.229c-0.458-0.951-1.019-1.619-1.685-2c-0.667-0.38-1.286-0.571-1.858-0.571c-2.856,0-4.286,1.885-4.286,5.657c0,1.714,0.362,3.084,1.085,4.113c0.724,1.029,1.791,1.544,3.201,1.544c1.867,0,3.181-0.915,3.944-2.743l3.942,2c-0.838,1.563-2,2.791-3.486,3.686c-1.484,0.896-3.123,1.343-4.914,1.343c-2.857,0-5.163-0.875-6.915-2.629c-1.752-1.752-2.628-4.19-2.628-7.313c0-3.048,0.886-5.466,2.657-7.257c1.771-1.79,4.009-2.686,6.715-2.686C32.604,18.558,35.441,20.101,37.156,23.187z
 
M55.613,23.187l-4.229,2.229c-0.457-0.951-1.02-1.619-1.686-2c-0.668-0.38-1.307-0.571-1.914-0.571c-2.857,0-4.287,1.885-4.287,5.657c0,1.714,0.363,3.084,1.086,4.113c0.723,1.029,1.789,1.544,3.201,1.544c1.865,0,3.18-0.915,3.941-2.743l4,2c-0.875,1.563-2.057,2.791-3.541,3.686c-1.486,0.896-3.105,1.343-4.857,1.343c-2.896,0-5.209-0.875-6.941-2.629c-1.736-1.752-2.602-4.19-2.602-7.313c0-3.048,0.885-5.466,2.658-7.257c1.77-1.79,4.008-2.686,6.713-2.686C51.117,18.558,53.938,20.101,55.613,23.187z"
 fill="#939598"/></svg>
diff --git a/js/ext.multimediaViewer.js b/js/ext.multimediaViewer.js
index d797b64..02c9801 100755
--- a/js/ext.multimediaViewer.js
+++ b/js/ext.multimediaViewer.js
@@ -213,6 +213,15 @@
 
                        this.$imageLinks.append( this.$usernameLi );
 
+                       this.$license = $( '<a>' )
+                               .addClass( 'mw-mlb-license' )
+                               .addClass( 'empty' )
+                               .prop( 'href', '#' );
+
+                       this.$licensePara = $( '<p>' )
+                               .addClass( 'mw-mlb-license-contain' )
+                               .html( this.$license );
+
                        this.$title = $( '<p>' )
                                .addClass( 'mw-mlb-title' );
 
@@ -233,11 +242,18 @@
                                        ).plain()
                                );
 
-                       this.$titleDiv = $( '<div>' )
-                               .addClass( 'mw-mlb-title-contain' )
+                       this.$titleAndCredit = $( '<div>' )
+                               .addClass( 'mw-mlb-title-credit' )
                                .append(
                                        this.$title,
                                        this.$credit
+                               );
+
+                       this.$titleDiv = $( '<div>' )
+                               .addClass( 'mw-mlb-title-contain' )
+                               .append(
+                                       this.$titleAndCredit,
+                                       this.$licensePara
                                );
 
                        this.$controlBar.append( this.$titleDiv );
@@ -363,6 +379,7 @@
                        repoInfo, articlePath,
                        desc,
                        datetime, dtmsg,
+                       license, msgname,
                        username,
                        source, author,
                        ui = this.lightbox.iface,
@@ -482,7 +499,31 @@
                        }
 
                        ui.$credit.toggleClass( 'empty', !Boolean( source ) && 
!Boolean( author ) );
+
+                       license = extmeta.License;
                }
+
+               if ( license ) {
+                       license = license.value;
+               }
+
+               msgname = 'multimediaviewer-license-' + ( license || '' );
+
+               if ( !license || !mw.messages.exists( msgname ) ) {
+                       // Cannot display, fallback or fail
+                       license = 'default';
+                       msgname = 'multimediaviewer-license-default';
+               }
+
+               if ( license ) {
+                       articlePath = articlePath || mw.config.get( 
'wgArticlePath', '' );
+                       ui.$license
+                               .text( mw.message( msgname ).text() )
+                               .prop( 'href', articlePath.replace( '$1', 
fileTitle.getPrefixedText() ) )
+                               .toggleClass( 'cc-license', license.substr( 0, 
2 ) === 'cc' );
+               }
+
+               ui.$license.toggleClass( 'empty', !license );
        };
 
        MultimediaViewer.prototype.fetchImageInfo = function ( fileTitle, cb ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/90267
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I60180f7ca3a16a04a0adee8af8482fa0940ac555
Gerrit-PatchSet: 14
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: MarkTraceur <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to