Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/70224


Change subject: Prevent uploading of anything other than images
......................................................................

Prevent uploading of anything other than images

Wait for the preview image to load. If it fails to do so
assume a bad filetype has been given.

Change-Id: I4a3404380524ae6b16d431024d706e0089ae0258
---
M MobileFrontend.i18n.php
M includes/Resources.php
M javascripts/common/uploads/PhotoUploaderPreview.js
3 files changed, 14 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/24/70224/1

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index 3c031e4..72dae0b 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -225,6 +225,7 @@
        'mobile-frontend-image-uploading-long' => 'Image still uploading! 
Thanks for your patience.',
        'mobile-frontend-image-uploading-cancel' => '<a href="#">Cancel</a> if 
this is taking too long.',
        'mobile-frontend-photo-upload-error' => 'Error, try again.',
+       'mobile-frontend-photo-upload-error-file-type' => 'Please only upload 
images.',
        'mobile-frontend-photo-upload-error-filename' => 'Error, please provide 
a more descriptive summary.',
        'mobile-frontend-photo-upload-success-article' => 'Success! Your image 
is now live on this page.',
        'mobile-frontend-photo-license' => 'By clicking "Submit", you agree to 
our [//wikimediafoundation.org/wiki/Terms_of_use Terms of Use] and agree to 
release your image under the [//creativecommons.org/licenses/by-sa/3.0/ 
Creative Commons Attribution-ShareAlike 3.0 License].',
@@ -621,6 +622,7 @@
        'mobile-frontend-image-uploading-long' => 'Text that displays whilst an 
image is taking long to upload',
        'mobile-frontend-image-uploading-cancel' => 'Text saying that user can 
cancel the image upload. Word "cancel" should be a link.',
        'mobile-frontend-photo-upload-error' => 'Text that displays when an 
image fails to upload',
+       'mobile-frontend-photo-upload-error-file-type' => 'Text that displays 
when user tries to preview something that cannot be rendered in an img tag 
(e.g. mp3 or video)',
        'mobile-frontend-photo-upload-error-filename' => 'Text that displays 
when an image fails to upload due to filename',
        'mobile-frontend-photo-upload-success-article' => 'Text that displays 
when an image has been successfully added to a page.',
        'mobile-frontend-photo-license' => 'Text notifying user of license that 
image will be published under. You can change the URL to a "local" Wikipedia 
URL, but you cannot make it point to the country specific CC BY-SA 3.0 
license.',
@@ -13849,7 +13851,7 @@
        'mobile-frontend-nearby-error' => '{{SITENAME}}附近功能有一些問題。',
        'mobile-frontend-nearby-error-guidance' => '嘗試更新你的位置。',
        'mobile-frontend-nearby-link' => '以全顯幕閱讀此頁',
-       'mobile-frontend-nearby-directions' => '瀏覽這𥚃',
+       'mobile-frontend-nearby-directions' => '瀏覽這嚃',
        'mobile-frontend-donate-image-login' => '您必須登入以查看您的上傳。',
        'mobile-frontend-photo-upload-generic' => '貢獻圖片',
        'mobile-frontend-donate-image-title' => '上載',
diff --git a/includes/Resources.php b/includes/Resources.php
index 31d3ab4..998d2c2 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -448,6 +448,7 @@
                        'mobile-frontend-photo-ownership-bullet-one',
                        'mobile-frontend-photo-ownership-bullet-two',
                        'mobile-frontend-photo-ownership-bullet-three',
+                       'mobile-frontend-photo-upload-error-file-type',
 
                        // PhotoUploadProgress.js
                        'mobile-frontend-image-uploading-wait',
diff --git a/javascripts/common/uploads/PhotoUploaderPreview.js 
b/javascripts/common/uploads/PhotoUploaderPreview.js
index 23e5914..d06feab 100644
--- a/javascripts/common/uploads/PhotoUploaderPreview.js
+++ b/javascripts/common/uploads/PhotoUploaderPreview.js
@@ -1,5 +1,6 @@
 ( function( M, $ ) {
        var View = M.require( 'view' ),
+               popup = M.require( 'notifications' ),
                Overlay = M.require( 'Overlay' ),
                LearnMoreOverlay = M.require( 'uploads/LearnMoreOverlay' ),
                ownershipMessage = mw.msg( 'mobile-frontend-photo-ownership', 
mw.config.get( 'wgUserName' ), mw.user ),
@@ -60,7 +61,8 @@
                },
 
                setImageUrl: function( url ) {
-                       var self = this;
+                       var self = this, $img;
+
                        this.imageUrl = url;
                        this.overlay.$( '.loading' ).remove();
                        this.overlay.$( 'a.help' ).on( 'click', function( ev ) {
@@ -77,7 +79,13 @@
                                overlay.show();
                                self.log( { action: 'whatDoesThisMean' } );
                        } );
-                       $( '<img>' ).attr( 'src', url ).prependTo( 
this.overlay.$( '.photoPreview' ) );
+                       $img = $( '<img>' ).attr( 'src', url ).prependTo( 
this.overlay.$( '.photoPreview' ) );
+
+                       // When adding a bad filename close the overlay
+                       $img.on( 'error', function() {
+                               popup.show( mw.msg( 
'mobile-frontend-photo-upload-error-file-type' ), 'toast error' );
+                               self.overlay.hide();
+                       } );
                }
        } );
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a3404380524ae6b16d431024d706e0089ae0258
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to