r104604 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104603‎ | r104604 | r104605 >
Date:22:32, 29 November 2011
Author:tstarling
Status:ok
Tags:
Comment:
Merged all VipsScaler revisions from trunk up to r104587
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/VipsScaler (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/VipsScaler/SpecialVipsTest.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/VipsScaler/VipsScaler.i18n.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/VipsScaler/VipsScaler_body.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/VipsScaler/modules/ext.vipsScaler/ext.vipsScaler.css (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/VipsScaler/modules/ext.vipsScaler/ext.vipsScaler.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/VipsScaler/VipsScaler.i18n.php
@@ -24,7 +24,10 @@
2525 'vipsscaler-form-sharpen-radius' => 'Amount of sharpening:',
2626 'vipsscaler-form-bilinear' => 'Bilinear scaling',
2727 'vipsscaler-form-submit' => 'Generate thumbnails',
28 -
 28+
 29+ 'vipsscaler-thumbs-legend' => 'Generated thumbnails',
 30+ 'vipsscaler-thumbs-help' => 'The thumbnail shown below was generated with the default scaler. Move your mouse over the thumbnail to compare it with the one generated by VIPS. Alternatively, you can click / unclick the checkbox below to switch between thumbnails.',
 31+ 'vipsscaler-thumbs-switch-label' => 'Click to switch between default and VIPS scaling output.',
2932 'vipsscaler-default-thumb' => 'Thumbnail generated with default scaler',
3033 'vipsscaler-vips-thumb' => 'Thumbnail generated with VIPS',
3134
@@ -117,7 +120,7 @@
118121 */
119122 $messages['de'] = array(
120123 'vipstest' => 'Testseite zur VIPS-Skalierung',
121 - 'vipsscaler-desc' => 'Ermöglicht das Erstellen von Miniaturbildern mit VIPS',
 124+ 'vipsscaler-desc' => 'Ermöglicht das Generieren von Miniaturbildern mit VIPS',
122125 'vipsscaler-invalid-file' => 'Die angeforderte Datei konnte nicht verarbeitet werden. Bitte überprüfen, ob Sie auf diesem Wiki vorhanden ist.',
123126 'vipsscaler-invalid-width' => 'Die Breite des Miniaturbildes sollte größer als Null und nicht größer als die Breite des Bildes sein.',
124127 'vipsscaler-invalid-sharpen' => 'Der Wert der Bildschärfe sollte größer als Null und kleiner als Fünf sein.',
@@ -128,12 +131,15 @@
129132 'vipsscaler-form-sharpen-radius' => 'Wert der Bildschärfe:',
130133 'vipsscaler-form-bilinear' => 'Bilineare Skalierung',
131134 'vipsscaler-form-submit' => 'Miniaturbild generieren',
132 - 'vipsscaler-default-thumb' => 'Das Miniaturbild wurde mit dem Standardsaklierungsprogramm generiert.',
 135+ 'vipsscaler-thumbs-legend' => 'Generierte Miniaturbilder',
 136+ 'vipsscaler-thumbs-help' => 'Das unten angezeigte Miniaturbild wurde mit dem Standardskalierungsprogramm generiert. Bitte die Maus über das Miniaturbild bewegen, um es mit einer von VIPS generierten Version zu vergleichen. Alternativ kann man auch das Kästchen unten selektieren/deselektieren, um zwischen den Miniaturbildern zu wechseln.',
 137+ 'vipsscaler-thumbs-switch-label' => 'Anklicken, um zwischen der Standardskalierung und der VIPS-Skalierung zu wechseln.',
 138+ 'vipsscaler-default-thumb' => 'Das Miniaturbild wurde mit dem Standardskalierungsprogramm generiert.',
133139 'vipsscaler-vips-thumb' => 'Das Miniaturbild wurde mit VIPS generiert.',
134140 'vipsscaler-show-both' => 'Beide Miniaturbilder anzeigen',
135141 'vipsscaler-show-default' => 'Nur das Standardminiaturbild anzeigen',
136142 'vipsscaler-show-vips' => 'Nur das VIPS-Miniaturbild anzeigen',
137 - 'right-vipsscaler-test' => 'Nutze das Testinterface zur VIPS-Skalierung [[Special:VipsTest]]',
 143+ 'right-vipsscaler-test' => 'Das [[Special:VipsTest|Testinterface zur VIPS-Skalierung]] nutzen',
138144 );
139145
140146 /** German (formal address) (‪Deutsch (Sie-Form)‬)
@@ -191,6 +197,9 @@
192198 'vipsscaler-form-sharpen-radius' => 'Cantidade de agudización:',
193199 'vipsscaler-form-bilinear' => 'Escala bilinear',
194200 'vipsscaler-form-submit' => 'Xerar a miniatura',
 201+ 'vipsscaler-thumbs-legend' => 'Miniaturas xeradas',
 202+ 'vipsscaler-thumbs-help' => 'A miniatura mostrada a continuación foi xerada coa escala por defecto. Desprace o rato por riba da miniatura para comparala con aquela xerada por VIPS. Como alternativa, pode marcar ou desmarcar a caixa de verificación inferior para alternar entre as miniaturas.',
 203+ 'vipsscaler-thumbs-switch-label' => 'Preme para alternar entre a saída coa escala predeterminada e a de VIPS.',
195204 'vipsscaler-default-thumb' => 'Miniatura xerada coa escala por defecto',
196205 'vipsscaler-vips-thumb' => 'Miniatura xerada con VIPS',
197206 'vipsscaler-show-both' => 'Mostrar ambas as miniaturas',
@@ -270,7 +279,10 @@
271280 */
272281 $messages['lb'] = array(
273282 'vipsscaler-desc' => 'Miniaturbiller mat VIPS maachen',
 283+ 'vipsscaler-form-width' => 'Breet vum Miniatur-Bild:',
274284 'vipsscaler-form-file' => 'Fichier an dëser Wiki:',
 285+ 'vipsscaler-form-submit' => 'Miniaturbiller generéieren',
 286+ 'vipsscaler-show-both' => 'Déi zwee Miniatur-Biller wesien',
275287 );
276288
277289 /** Macedonian (Македонски)
@@ -289,6 +301,9 @@
290302 'vipsscaler-form-sharpen-radius' => 'Изострување:',
291303 'vipsscaler-form-bilinear' => 'Билинеарно размерување',
292304 'vipsscaler-form-submit' => 'Создај минијатура',
 305+ 'vipsscaler-thumbs-legend' => 'Создадени минијатури',
 306+ 'vipsscaler-thumbs-help' => 'Долуприкажаната минијатура е создадена со стандардниот зададен резмерител. Ставете глушецот врз минијатурата за да ја споредите со онаа создадена од VIPS. Друг начин: можете да го штиклирате / отштиклирате кутивчето подолу за да се префрлите од една на друга минијатура.',
 307+ 'vipsscaler-thumbs-switch-label' => 'Стиснете за да се префрлите од стандарден на VIPS размерен извод и обратно',
293308 'vipsscaler-default-thumb' => 'Минијатура создадена со основно-зададениот размерител',
294309 'vipsscaler-vips-thumb' => 'Минијатура создадена со VIPS',
295310 'vipsscaler-show-both' => 'Прикажи ги двете минијатури',
@@ -320,7 +335,10 @@
321336 'vipsscaler-form-file' => 'Bestand op deze wiki:',
322337 'vipsscaler-form-sharpen-radius' => 'Hoeveelheid verscherping:',
323338 'vipsscaler-form-bilinear' => 'Bilineair schalen',
324 - 'vipsscaler-form-submit' => 'Miniatuur genereren',
 339+ 'vipsscaler-form-submit' => 'Miniatuur aanmaken',
 340+ 'vipsscaler-thumbs-legend' => 'Aangemaakte miniaturen',
 341+ 'vipsscaler-thumbs-help' => 'De hieronder weergegeven miniatuurafbeelding is gegenereerd met de standaard schaler. Beweeg uw muis over de afbeelding om deze te vergelijken met degene die is gegenereerd met VIPS. U kunt ook klikken op het aanvinkvakje hieronder om te wisselen tussen de miniatuurafbeeldingen.',
 342+ 'vipsscaler-thumbs-switch-label' => 'Klik hierop om te wisselen tussen standaard- en VIPS-schalingsuitvoer.',
325343 'vipsscaler-default-thumb' => 'Er is een miniatuurafbeelding aangemaakt met de standaard opschaler',
326344 'vipsscaler-vips-thumb' => 'Er is een miniatuurafbeelding aangemaakt met VIPS',
327345 'vipsscaler-show-both' => 'Beide miniatuurafbeeldingen weergeven',
Index: branches/wmf/1.18wmf1/extensions/VipsScaler/SpecialVipsTest.php
@@ -98,8 +98,8 @@
9999 # Make url to the vips thumbnail
100100 $vipsThumbUrl = $this->getTitle()->getLocalUrl( $vipsUrlOptions );
101101
102 - # Add to output
103 - $html = Html::rawElement( 'div', array( 'id' => 'mw-vipstest-thumbnails' ),
 102+ # HTML for the thumbnails
 103+ $thumbs = Html::rawElement( 'div', array( 'id' => 'mw-vipstest-thumbnails' ),
104104 Html::element( 'img', array(
105105 'src' => $normalThumbUrl,
106106 'alt' => wfMessage( 'vipsscaler-default-thumb' ),
@@ -109,6 +109,24 @@
110110 'alt' => wfMessage( 'vipsscaler-vips-thumb' ),
111111 ) )
112112 );
 113+
 114+ # Helper messages shown above the thumbnails rendering
 115+ $help = wfMessage( 'vipsscaler-thumbs-help' )->parseAsBlock();
 116+
 117+ # A checkbox to easily alternate between both views:
 118+ $checkbox = Xml::checkLabel(
 119+ wfMessage( 'vipsscaler-thumbs-switch-label' ),
 120+ 'mw-vipstest-thumbs-switch',
 121+ 'mw-vipstest-thumbs-switch'
 122+ );
 123+
 124+ # Wrap the three HTML snippets above in a fieldset:
 125+ $html = Xml::fieldset(
 126+ wfMessage( 'vipsscaler-thumbs-legend' ),
 127+ $help . $checkbox . $thumbs
 128+ );
 129+
 130+ # Finally output all of the above
113131 $this->getOutput()->addHTML( $html );
114132 $this->getOutput()->addModules( array(
115133 'ext.vipsscaler',
@@ -242,23 +260,23 @@
243261 # Validate title and file existance
244262 $title = Title::makeTitleSafe( NS_FILE, $request->getText( 'thumb' ) );
245263 if ( is_null( $title ) ) {
246 - return $this->streamError( 404 );
 264+ return $this->streamError( 404, "VipsScaler: invalid title\n" );
247265 }
248266 $file = wfFindFile( $title );
249267 if ( !$file || !$file->exists() ) {
250 - return $this->streamError( 404 );
 268+ return $this->streamError( 404, "VipsScaler: file not found\n" );
251269 }
252270
253271 # Check if vips can handle this file
254272 if ( VipsScaler::getVipsHandler( $file ) === false ) {
255 - return $this->streamError( 500 );
 273+ return $this->streamError( 500, "VipsScaler: VIPS cannot handle this file type\n" );
256274 }
257275
258276 # Validate param string
259277 $handler = $file->getHandler();
260278 $params = array( 'width' => $request->getInt( 'width' ) );
261279 if ( !$handler->normaliseParams( $file, $params ) ) {
262 - return $this->streamError( 500 );
 280+ return $this->streamError( 500, "VipsScaler: invalid parameters\n" );
263281 }
264282
265283
Index: branches/wmf/1.18wmf1/extensions/VipsScaler/modules/ext.vipsScaler/ext.vipsScaler.css
@@ -3,6 +3,9 @@
44 margin-top: 1em;
55 margin-right: 1em;
66 }
 7+#mw-vipstest-thumbs-switch{
 8+ margin-bottom: 2em;
 9+}
710 .uc-caption {
811 /** Overrides ucompare caption position from bottom (bottom:10px) to top */
912 top:10px;
Index: branches/wmf/1.18wmf1/extensions/VipsScaler/modules/ext.vipsScaler/ext.vipsScaler.js
@@ -1,40 +1,27 @@
22 jQuery( function( $ ) {
 3+ $.vipsScaler = {
 4+ /** function to alternate between both thumbnails */
 5+ switchThumbs: function() {
 6+ var e = $('#mw-vipstest-thumbnails');
 7+ var mask = e.children(".uc-mask");
 8+ var caption = e.children(".uc-caption");
 9+
 10+ width = e.width();
 11+ maskWidth = mask.width();
 12+
 13+ if( maskWidth < width / 2 ) {
 14+ /** Bar is 3 pixels width. We want to show it on the right */
 15+ mask.width( width - 3);
 16+ caption.html( e.children("img:eq(0)").attr("alt") );
 17+ } else {
 18+ mask.width( 0 );
 19+ caption.html( e.children("img:eq(1)").attr("alt") );
 20+ }
 21+ }
 22+ };
 23+
324 var container = document.getElementById( 'mw-vipstest-thumbnails' );
425 if ( container ) {
5 -/*
6 - $( '<p id="mw-vipstest-buttons">\n' +
7 - '<button id="mw-vipstest-show-both">' +
8 - mediaWiki.message( 'vipsscaler-show-both' ).escaped() +
9 - '</button> ' +
10 - '<button id="mw-vipstest-show-default">' +
11 - mediaWiki.message( 'vipsscaler-show-default' ).escaped() +
12 - '</button> ' +
13 - '<button id="mw-vipstest-show-vips">' +
14 - mediaWiki.message( 'vipsscaler-show-vips' ).escaped() +
15 - '</button> ' +
16 - '</p>'
17 - ).prependTo( container );
18 -*/
19 -/**
20 - $( '#mw-vipstest-show-both' ).click( function() {
21 - document.getElementById( 'mw-vipstest-show-default' ).style.display = 'inline';
22 - document.getElementById( 'mw-vipstest-show-vips' ).style.display = 'inline';
23 - document.getElementById( 'mw-vipstest-default-thumb' ).style.display = 'block';
24 - document.getElementById( 'mw-vipstest-vips-thumb' ).style.display = 'block';
25 - } );
26 - $( '#mw-vipstest-show-default' ).click( function() {
27 - document.getElementById( 'mw-vipstest-show-default' ).style.display = 'none';
28 - document.getElementById( 'mw-vipstest-show-vips' ).style.display = 'inline';
29 - document.getElementById( 'mw-vipstest-default-thumb' ).style.display = 'block';
30 - document.getElementById( 'mw-vipstest-vips-thumb' ).style.display = 'none';
31 - } );
32 - $( '#mw-vipstest-show-vips' ).click( function() {
33 - document.getElementById( 'mw-vipstest-show-default' ).style.display = 'inline';
34 - document.getElementById( 'mw-vipstest-show-vips' ).style.display = 'none';
35 - document.getElementById( 'mw-vipstest-default-thumb' ).style.display = 'none';
36 - document.getElementById( 'mw-vipstest-vips-thumb' ).style.display = 'block';
37 - } );
38 -**/
3926 /**
4027 * options are detailed in upstream documentation available at
4128 * http://www.userdot.net/files/jquery/jquery.ucompare/demo/
@@ -49,27 +36,20 @@
5037 defaultgap: 50,
5138 leftgap: 0,
5239 rightgap: 0,
53 - caption: true,
 40+ caption: false,
5441 reveal: 0.5
5542 });
5643
57 - /** Also add a click handler to instantly switch beetween pics */
58 - $('#mw-vipstest-thumbnails').click( function() {
59 - var e = $(this)
60 - var mask = e.children(".uc-mask")
61 - var caption = e.children(".uc-caption")
62 -
63 - width = e.width();
64 - maskWidth = mask.width();
65 -
66 - if( maskWidth < width / 2 ) {
67 - mask.width( width );
68 - caption.html( e.children("img:eq(0)").attr("alt") );
69 - } else {
70 - mask.width( 0 );
71 - caption.html( e.children("img:eq(1)").attr("alt") );
72 - }
73 - });
 44+ /**
 45+ * Also add a click handler to instantly switch beetween pics
 46+ * This can be done by clicking the thumbnail or using a checkbox
 47+ */
 48+ $('#mw-vipstest-thumbs-switch').click(
 49+ function() { $.vipsScaler.switchThumbs(); }
 50+ );
 51+ $('#mw-vipstest-thumbnails').click(
 52+ function() { $.vipsScaler.switchThumbs(); }
 53+ );
7454 }
75 -}
 55+}
7656 );
Index: branches/wmf/1.18wmf1/extensions/VipsScaler/VipsScaler_body.php
@@ -133,11 +133,16 @@
134134
135135 wfDebug( __METHOD__ . " rotating '{$file->getName()}' by {$rotation}°\n" );
136136 if ( empty( $options['bilinear'] ) ) {
137 - # Calculate shrink factors. Offsetting by 0.5 pixels is required
 137+ # Calculate shrink factors. Offsetting by a small amount is required
138138 # because of rounding down of the target size by VIPS. See 25990#c7
139 - # No need to invert source and physical dimensions. They already got switched if needed.
140 - $rx = $params['srcWidth'] / ($params['physicalWidth'] + 0.5);
141 - $ry = $params['srcHeight'] / ($params['physicalHeight'] + 0.5);
 139+ #
 140+ # No need to invert source and physical dimensions. They already got
 141+ # switched if needed.
 142+ #
 143+ # Use sprintf() instead of plain string conversion so that we can
 144+ # control the precision
 145+ $rx = sprintf( "%.18e", $params['srcWidth'] / ($params['physicalWidth'] + 0.125) );
 146+ $ry = sprintf( "%.18e", $params['srcHeight'] / ($params['physicalHeight'] + 0.125) );
142147
143148 wfDebug( sprintf(
144149 "%s to shrink '%s'. Source: %sx%s, Physical: %sx%s. Shrink factors (rx,ry) = %sx%s.\n",
Property changes on: branches/wmf/1.18wmf1/extensions/VipsScaler
___________________________________________________________________
Added: svn:mergeinfo
145150 Merged /branches/sqlite/extensions/VipsScaler:r58211-58321
146151 Merged /trunk/phase3/extensions/VipsScaler:r92580,92634,92713,92762,92765,92791,92854,92884,92886-92887,92894,92898,92907,92932,92958,93141,93149,93151,93233-93234,93258,93266,93303,93516-93518,93520,93818-93822,93847,93858,93891,93935-93936,94058,94062,94068,94107,94155,94235,94277,94346,94372,94422,94425,94444,94448,94456,94498,94517,94601,94630,94728,94738,94825,94862,94995-94997,95023,95042,95072-95073,95155,95327,95332,95410,95422,95426,95442,95468,95601,95812,98578,98598,98656
147152 Merged /branches/new-installer/phase3/extensions/VipsScaler:r43664-66004
148153 Merged /branches/REL1_15/phase3/extensions/VipsScaler:r51646
149154 Merged /branches/REL1_18/extensions/VipsScaler:r101758,103190
150155 Merged /branches/REL1_17/phase3/extensions/VipsScaler:r81445,81448
151156 Merged /trunk/extensions/VipsScaler:r99592,99653,100092,100419,100686,100692,100699,103669,104390-104603

Follow-up revisions

RevisionCommit summaryAuthorDate
r104663vipsScaler: enable ucompare caption...hashar10:01, 30 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r104587Localisation updates for core and extension messages from translatewiki.netraymond20:32, 29 November 2011

Status & tagging log