Jdlrobson has submitted this change and it was merged.
Change subject: Don't use ":" in file names
......................................................................
Don't use ":" in file names
Broken in 2a49b5e. ":" can't be used in MediaWiki file names.
Change-Id: I9e74430bd75e983e77a73b91f032e20098c54b91
---
M javascripts/modules/mf-photo.js
M javascripts/specials/uploads.js
M tests/javascripts/modules/test_mf-photo.js
M tests/javascripts/specials/test_uploads.js
4 files changed, 10 insertions(+), 10 deletions(-)
Approvals:
Jdlrobson: Verified; Looks good to me, approved
diff --git a/javascripts/modules/mf-photo.js b/javascripts/modules/mf-photo.js
index d19d066..6d57127 100644
--- a/javascripts/modules/mf-photo.js
+++ b/javascripts/modules/mf-photo.js
@@ -127,7 +127,7 @@
suffix = ' ' + date.getFullYear() + '-' +
pad( date.getMonth() + 1 ) + '-' + pad( date.getDate()
) + ' ' +
- pad( date.getHours() ) + ':' + pad( date.getMinutes() )
+ fileSuffix;
+ pad( date.getHours() ) + '-' + pad( date.getMinutes() )
+ fileSuffix;
allowedLength -= suffix.length;
return trimUtf8String( name, allowedLength ) + suffix;
diff --git a/javascripts/specials/uploads.js b/javascripts/specials/uploads.js
index 5857ffd..7eda933 100644
--- a/javascripts/specials/uploads.js
+++ b/javascripts/specials/uploads.js
@@ -52,7 +52,7 @@
function getDescription( title ) {
title = title.replace( /\.[^\. ]+$/, '' ); // replace filename
suffix
// strip namespace: prefix and date suffix from remainder
- return title.replace( /^[^:]*:/, '').replace( /
\d{4}-\d{1,2}-\d{1,2} \d{1,2}[:-]\d{1,2}$/, '' );
+ return title.replace( /^[^:]*:/, '').replace( /
\d{4}-\d{1,2}-\d{1,2} \d{1,2}-\d{1,2}$/, '' );
}
function getImageDataFromPage( page ) {
diff --git a/tests/javascripts/modules/test_mf-photo.js
b/tests/javascripts/modules/test_mf-photo.js
index 9011e56..afbc220 100644
--- a/tests/javascripts/modules/test_mf-photo.js
+++ b/tests/javascripts/modules/test_mf-photo.js
@@ -64,14 +64,14 @@
QUnit.test( 'generateFileName', 1, function() {
var date = new Date( 2010, 9, 15, 12, 9 ),
name = photo.generateFileName( 'Jon eating bacon next to an
armadillo', '.jpg', date );
- strictEqual( name, 'Jon eating bacon next to an armadillo 2010-10-15
12:09.jpg',
+ strictEqual( name, 'Jon eating bacon next to an armadillo 2010-10-15
12-09.jpg',
'Check file name is description with appended date' );
} );
QUnit.test( 'generateFileName test padding', 1, function() {
var date = new Date( 2013, 2, 1, 12, 51 ), // note 0 = january
name = photo.generateFileName( 'Tomasz eating bacon next to a
dinosaur', '.jpg', date );
- strictEqual( name, 'Tomasz eating bacon next to a dinosaur 2013-03-01
12:51.jpg',
+ strictEqual( name, 'Tomasz eating bacon next to a dinosaur 2013-03-01
12-51.jpg',
'Check file name is description with appended date and numbers
were padded' );
} );
@@ -85,7 +85,7 @@
}
name = photo.generateFileName( longDescription, '.jpg', date );
strictEqual( name.length, 240, 'Check file name was shortened to the
minimum length' );
- strictEqual( name.substr( 233, 7 ), ':51.jpg', 'ends with date' );
+ strictEqual( name.substr( 233, 7 ), '-51.jpg', 'ends with date' );
} );
QUnit.test( 'generateFileName with new lines', 1, function() {
@@ -94,7 +94,7 @@
date = new Date( 2013, 2, 1, 12, 51 ), name;
name = photo.generateFileName( description, '.jpg', date );
- strictEqual( name, 'One-Two-Three 2013-03-01 12:51.jpg', 'New lines
converted' );
+ strictEqual( name, 'One-Two-Three 2013-03-01 12-51.jpg', 'New lines
converted' );
} );
QUnit.test( 'trimUtf8String', 4, function() {
diff --git a/tests/javascripts/specials/test_uploads.js
b/tests/javascripts/specials/test_uploads.js
index a884068..401d804 100644
--- a/tests/javascripts/specials/test_uploads.js
+++ b/tests/javascripts/specials/test_uploads.js
@@ -5,12 +5,12 @@
QUnit.test( 'getDescription', function() {
var tests = [
- [ 'File:Pirates in SF 2013-04-03 15:44.png', 'Pirates
in SF' ],
- [ 'File:Legacy pirates in SF 2013-04-03 15-9.png',
'Legacy pirates in SF' ],
- [ 'File:Jon lies next to volcano 2013-03-18
13:37.jpeg', 'Jon lies next to volcano' ],
+ [ 'File:Pirates in SF 2013-04-03 15-44.png', 'Pirates
in SF' ],
+ [ 'File:Unpadded 9 pirates in SF 2013-04-03 15-9.png',
'Unpadded 9 pirates in SF' ],
+ [ 'File:Jon lies next to volcano 2013-03-18
13-37.jpeg', 'Jon lies next to volcano' ],
[ 'hello world 37.jpg', 'hello world 37' ],
[ 'hello world again.jpeg', 'hello world again' ],
- [ 'Fichier:French Photo Timestamp 2013-04-03
15:44.jpg', 'French Photo Timestamp' ],
+ [ 'Fichier:French Photo Timestamp 2013-04-03
15-44.jpg', 'French Photo Timestamp' ],
[ 'Fichier:Full stop. Photo.unknownfileextension',
'Full stop. Photo' ],
[ 'File:No file extension but has a . in the title',
'No file extension but has a . in the title' ],
[ 'Fichier:French Photo.jpg', 'French Photo' ]
--
To view, visit https://gerrit.wikimedia.org/r/62726
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9e74430bd75e983e77a73b91f032e20098c54b91
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits