Gergő Tisza has uploaded a new change for review. https://gerrit.wikimedia.org/r/119554
Change subject: Improve embed credit line ...................................................................... Improve embed credit line Gets the text closer to the spec: * links have #mediaviewer (lots of code duplication, see #373) * image has alt text (was title in the spec but that made less sense) * less convoluted logic in getCreditHtml() Change-Id: I43db84adb7fe29850706f92ee978016939b59aaa Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/369 --- M MultimediaViewer.i18n.php M resources/mmv/mmv.EmbedFileFormatter.js 2 files changed, 23 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer refs/changes/54/119554/1 diff --git a/MultimediaViewer.i18n.php b/MultimediaViewer.i18n.php index 4a08f29..56c23f5 100644 --- a/MultimediaViewer.i18n.php +++ b/MultimediaViewer.i18n.php @@ -98,6 +98,7 @@ '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-t' => '"$1".', 'multimediaviewer-embed-byline' => 'By $1', 'multimediaviewer-embed-license' => 'Licensed under $1.', 'multimediaviewer-embed-via' => 'Via $1.', @@ -294,6 +295,10 @@ * $1 - name of the work (typically the filename without an extension) * $2 - name of the license Each of the parameters could be either plain text or a link.', + 'multimediaviewer-html-embed-credit-text-t' => 'Credit text, used when generating HTML to reuse an image. +Which one of the multimediaviewer-html-embed-credit-text-* messages is used will depend on what information about the image is available. +* $1 - name of the work (typically the filename without an extension) +Each of the parameters could be either plain text or a link.', 'multimediaviewer-embed-byline' => 'Byline (author credit) text, used when generating wikitext/HTML to reuse the image. $1 is author name.', 'multimediaviewer-embed-license' => 'License information, used when generating wikitext/HTML to reuse the image. $1 is the license name.', diff --git a/resources/mmv/mmv.EmbedFileFormatter.js b/resources/mmv/mmv.EmbedFileFormatter.js index 8065593..fe4a17d 100644 --- a/resources/mmv/mmv.EmbedFileFormatter.js +++ b/resources/mmv/mmv.EmbedFileFormatter.js @@ -95,11 +95,13 @@ */ AFP.getCreditHtml = function ( info ) { var creditText, creditFormat, creditParams, - title = info.title.getNameText(), + titleText = info.title.getNameText(), + titleUrl = this.getLinkUrl( info ), + titleHtml = $( '<a>' ).text( titleText ).prop( 'href', titleUrl ).get( 0 ).outerHTML, bylines = this.getBylines( info.author, info.source ); creditFormat = 't'; - creditParams = [ title ]; + creditParams = [ titleHtml ]; if ( bylines.html ) { creditFormat += 'b'; creditParams.push( bylines.html ); @@ -112,13 +114,8 @@ creditFormat += 's'; creditParams.push( info.siteName ); } - - if ( creditFormat === 't' || creditFormat === 'ts' ) { - creditText = '"' + title + '"'; - } else { - creditParams.unshift( 'multimediaviewer-html-embed-credit-text-' + creditFormat ); - creditText = mw.message.apply( mw, creditParams ).plain(); - } + creditParams.unshift( 'multimediaviewer-html-embed-credit-text-' + creditFormat ); + creditText = mw.message.apply( mw, creditParams ).plain(); return creditText; }; @@ -136,10 +133,11 @@ return $( '<div>' ).append( $( '<p>' ).append( $( '<a>' ) - .attr( 'href', info.url ) + .attr( 'href', this.getLinkUrl( info ) ) .append( $( '<img>' ) .attr( 'src', imgUrl ) + .attr( 'alt', info.title.getMainText() ) .attr( 'height', height ) .attr( 'width', width ) ), @@ -149,5 +147,15 @@ ).html(); }; + /** + * Generare a link which we will be using for sharing stuff. + * FIXME this should be handled by mmv.js to be DRY + * + * @param {mw.mmv.model.EmbedFileInfo} info + */ + AFP.getLinkUrl = function ( info ) { + return info.url + '#mediaviewer/' + info.title.getMainText(); + }; + mw.mmv.EmbedFileFormatter = EmbedFileFormatter; }( mediaWiki, jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/119554 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I43db84adb7fe29850706f92ee978016939b59aaa Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MultimediaViewer Gerrit-Branch: master Gerrit-Owner: Gergő Tisza <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
