Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/210084
Change subject: Remove uploads
......................................................................
Remove uploads
They are not getting the support they deserve. Given UploadWizard
is being rewritten by the new editing team it makes sense to support
efforts there instead.
Change-Id: I29ae18e2b8cd8e9b91d20c4f85d42c79dc70d6fd
---
M includes/Resources.php
D javascripts/modules/uploads/LeadPhoto.js
D javascripts/modules/uploads/LeadPhotoUploaderButton.js
D javascripts/modules/uploads/PhotoApi.js
D javascripts/modules/uploads/PhotoUploadOverlay.js
D javascripts/modules/uploads/PhotoUploadProgress.js
D javascripts/modules/uploads/PhotoUploaderButton.js
D javascripts/modules/uploads/ProgressBar.js
D javascripts/modules/uploads/UploadTutorial.js
D javascripts/modules/uploads/init.js
D javascripts/modules/uploads/routes.js
D javascripts/specials/userlogin.js
12 files changed, 0 insertions(+), 1,265 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/84/210084/1
diff --git a/includes/Resources.php b/includes/Resources.php
index d0802c2..3e5bd1e 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -448,19 +448,6 @@
),
),
- 'mobile.leadPhotoUploader' => $wgMFResourceFileModuleBoilerplate +
array(
- 'dependencies' => array(
- 'mobile.startup',
- 'mobile.user',
- 'mobile.upload.ui',
- ),
- 'scripts' => array(
- 'javascripts/modules/uploads/init.js',
- ),
- // This is a logged in user feature only.
- 'group' => 'user',
- ),
-
'mobile.editor' => $wgMFResourceParsedMessageModuleBoilerplate + array(
'dependencies' => array(
'mobile.startup',
@@ -600,71 +587,6 @@
),
'messages' => array(
'mobile-frontend-editor-viewing-source-page',
- ),
- ),
-
- 'mobile.uploads' => $wgMFResourceParsedMessageModuleBoilerplate + array(
- 'dependencies' => array(
- 'mobile.startup',
- 'mobile.editor.api',
- 'mobile.contentOverlays',
- 'mobile.foreignApi',
- 'mobile.microAutoSize',
- 'mobile.loggingSchemas',
- ),
- 'scripts' => array(
- 'javascripts/modules/uploads/PhotoApi.js',
- 'javascripts/modules/uploads/LeadPhoto.js',
- 'javascripts/modules/uploads/UploadTutorial.js',
- 'javascripts/modules/uploads/PhotoUploadProgress.js',
- 'javascripts/modules/uploads/PhotoUploadOverlay.js',
- 'javascripts/externals/exif-js/binaryajax.js',
- 'javascripts/externals/exif-js/exif.js',
- ),
- 'styles' => array(
- 'less/modules/uploads/UploadTutorial.less',
- 'less/modules/uploads/PhotoUploadOverlay.less',
- 'less/modules/uploads/PhotoUploadProgress.less',
- ),
- 'templates' => array(
- 'LeadPhoto.hogan' =>
'templates/modules/uploads/LeadPhoto.hogan',
- 'UploadTutorial.hogan' =>
'templates/modules/uploads/UploadTutorial.hogan',
- 'PhotoUploadOverlay.hogan' =>
'templates/modules/uploads/PhotoUploadOverlay.hogan',
- 'PhotoUploadProgress.hogan' =>
'templates/modules/uploads/PhotoUploadProgress.hogan',
- ),
- 'messages' => array(
- 'mobile-frontend-photo-upload-success-article',
- 'mobile-frontend-photo-upload-error',
-
- // PhotoApi.js
- 'mobile-frontend-photo-article-edit-comment',
- 'mobile-frontend-photo-article-donate-comment',
- 'mobile-frontend-photo-upload-error-filename',
- 'mobile-frontend-photo-upload-comment',
-
- // UploadTutorial.js
- 'mobile-frontend-first-upload-wizard-new-page-1-header',
- 'mobile-frontend-first-upload-wizard-new-page-1',
- 'mobile-frontend-first-upload-wizard-new-page-2-header',
- 'mobile-frontend-first-upload-wizard-new-page-2',
- 'mobile-frontend-first-upload-wizard-new-page-3-header',
- 'mobile-frontend-first-upload-wizard-new-page-3',
- 'mobile-frontend-first-upload-wizard-new-page-3-ok',
-
- // PhotoUploadOverlay.js
- 'mobile-frontend-image-heading-describe' => array(
'parse' ),
- 'mobile-frontend-photo-ownership',
- 'mobile-frontend-photo-ownership-help',
- 'mobile-frontend-photo-caption-placeholder',
- 'mobile-frontend-photo-submit',
- 'mobile-frontend-photo-upload-error-file-type',
- 'mobile-frontend-photo-licensing',
- 'mobile-frontend-photo-licensing-with-terms',
- 'mobile-frontend-photo-upload-copyvio',
-
- // PhotoUploadProgress.js
- 'mobile-frontend-image-uploading' => array( 'parse' ),
- 'mobile-frontend-image-cancel-confirm' => array(
'parse' ),
),
),
@@ -916,33 +838,6 @@
),
'styles' => array(
'resources/mobile.toast/toast.less',
- ),
- ),
-
- 'mobile.upload.ui' => $wgMFResourceFileModuleBoilerplate + array(
- 'dependencies' => array(
- 'mobile.startup',
- 'mobile.ajax',
- 'mobile.overlays',
- ),
- 'templates' => array(
- // FIXME: This should not be a hogan template. Use a
txt template.
- 'template.hogan' =>
'templates/modules/uploads/commons-upload.hogan',
- // PhotoUploaderButton.js
- 'LeadButton.hogan' =>
'templates/modules/uploads/LeadPhotoUploaderButton.hogan',
- // @todo FIXME: this should be in special.uploads (need
to split
- // code in PhotoUploaderButton.js into separate files
too)
- 'Button.hogan' =>
'templates/modules/uploads/PhotoUploaderButton.hogan',
- ),
- 'scripts' => array(
- 'javascripts/modules/uploads/ProgressBar.js',
- 'javascripts/modules/uploads/PhotoUploaderButton.js',
-
'javascripts/modules/uploads/LeadPhotoUploaderButton.js',
- 'javascripts/modules/uploads/routes.js',
- ),
- 'messages' => array(
- // LeadPhotoUploaderButton.js
- 'mobile-frontend-photo-upload',
),
),
diff --git a/javascripts/modules/uploads/LeadPhoto.js
b/javascripts/modules/uploads/LeadPhoto.js
deleted file mode 100644
index 1877aef..0000000
--- a/javascripts/modules/uploads/LeadPhoto.js
+++ /dev/null
@@ -1,17 +0,0 @@
-( function ( M ) {
-
- var LeadPhoto,
- View = M.require( 'View' );
-
- /**
- * Class for showing lead photo
- * @class LeadPhoto
- * @extends View
- */
- LeadPhoto = View.extend( {
- template: mw.template.get( 'mobile.uploads', 'LeadPhoto.hogan' )
- } );
-
- M.define( 'modules/uploads/LeadPhoto', LeadPhoto );
-
-}( mw.mobileFrontend ) );
diff --git a/javascripts/modules/uploads/LeadPhotoUploaderButton.js
b/javascripts/modules/uploads/LeadPhotoUploaderButton.js
deleted file mode 100644
index aa42c9c..0000000
--- a/javascripts/modules/uploads/LeadPhotoUploaderButton.js
+++ /dev/null
@@ -1,46 +0,0 @@
-( function ( M ) {
- var
- PhotoUploaderButton = M.require(
'modules/uploads/PhotoUploaderButton' ),
- Icon = M.require( 'Icon' ),
- uploadIcon = new Icon( {
- name: 'addimage-enabled',
- additionalClassNames: 'enabled'
- } ),
- LeadPhotoUploaderButton;
-
- /**
- * Component for uploading lead photo
- * @class LeadPhotoUploaderButton
- * @extends PhotoUploaderButton
- */
- LeadPhotoUploaderButton = PhotoUploaderButton.extend( {
- template: mw.template.get( 'mobile.upload.ui',
'LeadButton.hogan' ),
- className: uploadIcon.getClassName(),
-
- /**
- * @cfg {Object} defaults Default options hash.
- * @cfg {String} defaults.buttonCaption Caption that is a call
to action to add the
- * first image.
- * @cfg {Boolean} defaults.insertInPage If the image should be
prepended to the wikitext
- * of a page specified by options.pageTitle.
- * @cfg {String} defaults.el CSS selector of the element in
which the
- * LeadPhotoUploaderButton is rendered.
- */
- defaults: {
- buttonCaption: mw.msg( 'mobile-frontend-photo-upload' ),
- insertInPage: true,
- el: '#ca-upload'
- },
-
- /** @inheritdoc */
- initialize: function ( options ) {
- options.pageTitle = mw.config.get( 'wgPageName' );
- PhotoUploaderButton.prototype.initialize.apply( this,
arguments );
- }
- } );
-
- LeadPhotoUploaderButton.isSupported = PhotoUploaderButton.isSupported;
-
- M.define( 'modules/uploads/LeadPhotoUploaderButton',
LeadPhotoUploaderButton );
-
-}( mw.mobileFrontend ) );
diff --git a/javascripts/modules/uploads/PhotoApi.js
b/javascripts/modules/uploads/PhotoApi.js
deleted file mode 100644
index 475a1c8..0000000
--- a/javascripts/modules/uploads/PhotoApi.js
+++ /dev/null
@@ -1,305 +0,0 @@
-( function ( M, $ ) {
- var Api, PhotoApi,
- user = M.require( 'user' ),
- endpoint = mw.config.get( 'wgMFPhotoUploadEndpoint' );
-
- if ( endpoint ) {
- Api = M.require( 'modules/ForeignApi' );
- } else {
- Api = M.require( 'api' ).Api;
- }
-
- /**
- * Originally written by Brion for WikiLovesMonuments app, trims a
string
- * to a certain number of bytes
- *
- * @param {String} str
- * @param {Number} allowedLength in bytes
- * @ignore
- */
- function trimUtf8String( str, allowedLength ) {
- // Count UTF-8 bytes to see where we need to crop long names.
- var codeUnit, len, i,
- bytes = 0,
- chars = 0;
-
- for ( i = 0; i < str.length; i++ ) {
- // JavaScript strings are UTF-16.
- codeUnit = str.charCodeAt( i );
-
- // https://en.wikipedia.org/wiki/UTF-8#Description
- if ( codeUnit < 0x80 ) {
- len = 1;
- } else if ( codeUnit < 0x800 ) {
- len = 2;
- } else if ( codeUnit >= 0xd800 && codeUnit < 0xe000 ) {
- //
https://en.wikipedia.org/wiki/UTF-16#Description
- // Code point is one half of a surrogate pair.
- // This and its partner combine to form a
single 4 byte character in UTF-8.
- len = 4;
- } else {
- len = 3;
- }
-
- if ( bytes + len <= allowedLength ) {
- bytes += len;
- chars++;
- if ( len === 4 ) {
- // Skip over second half of surrogate
pair as a unit.
- chars++;
- i++;
- }
- } else {
- // Ran out of bytes.
- return str.substr( 0, chars );
- }
- }
-
- // We fit!
- return str;
- }
-
- /**
- * Generates a file name from a description and a date
- * Removes illegal characters
- * Respects maximum file name length (240 bytes)
- *
- * @param {String} description Data to be preprocessed and added to
options
- * @param {String} fileSuffix An optional file extension e.g. '.jpg' or
'.gif'
- * @param {Date} date An optional date (defaults to current date)
- * @return {String} a legal filename
- * @ignore
- */
- function generateFileName( description, fileSuffix, date ) {
- // 240 bytes maximum enforced by MediaWiki - allow 10bytes
margin of error
- var allowedLength = 230,
- name, suffix;
-
- fileSuffix = fileSuffix || '.jpg';
- date = date || new Date();
- name = description.replace(
/[\x1B\n\x7f\.\[#<>\[\]\|\{\}\/:]/g, '-' );
- // remove double spaces (bug 62241)
- // also trim it in case it ends with a double space
- name = $.trim( name ).replace( / /g, ' ' );
- //
https://commons.wikimedia.org/wiki/MediaWiki:Titleblacklist-custom-double-apostrophe
- name = name.replace( /''/g, '\'_' );
-
- /**
- * Pad single digit numbers with leading 0.
- * @param {Number} number
- * @ignore
- * @returns {Number|String} representing number with at least 2
digits
- */
- function pad( number ) {
- return number < 10 ? '0' + number : number;
- }
-
- suffix = ' ' + date.getUTCFullYear() + '-' +
- pad( date.getUTCMonth() + 1 ) + '-' + pad(
date.getUTCDate() ) + ' ' +
- pad( date.getUTCHours() ) + '-' + pad(
date.getUTCMinutes() ) + fileSuffix;
-
- allowedLength -= suffix.length;
- return trimUtf8String( name, allowedLength ) + suffix;
- }
-
- /**
- * API to handle photo uploads
- *
- * @class PhotoApi
- * @extends Api
- */
- PhotoApi = Api.extend( {
- /** @inheritdoc */
- apiUrl: endpoint || Api.prototype.apiUrl,
-
- /**
- * @inheritdoc
- * @param {Object} options
- * [options.editorApi] EditorApi An API instance that will
be used
- * [options.page] Page to upload to
- * for inserting images in a page.
- */
- initialize: function ( options ) {
- Api.prototype.initialize.apply( this, arguments );
- options = options || {};
- this.page = options.page;
- this.editorApi = options.editorApi;
- },
-
- /**
- * Applies special handling for uploads which fail due to a
lack of filename.
- * Scans the warnings and tries to construct a suitable error
message.
- * FIXME: See UploadBase::checkWarnings - why these are not
errors only the MediaWiki Gods know See Bug 48261
- * @private
- * @param {jQuery.Deferred} result from an upload api request.
- * @param {Object} warnings as found in the
data.upload.warnings.
- * FIXME: This is part of the result and thus is an
unnecessary parameter.
- */
- _handleWarnings: function ( result, warnings ) {
- var humanErrorMsg,
- err = {
- stage: 'upload',
- type: 'warning'
- };
-
- warnings = $.map( warnings, function ( value, code ) {
- return code + '/' + value;
- } );
- err.details = warnings[0] || 'unknown';
-
- if ( warnings.exists ) {
- humanErrorMsg = mw.msg(
'mobile-frontend-photo-upload-error-filename' );
- }
-
- return result.reject( err, humanErrorMsg );
- },
-
- /**
- * Upload an image and, optionally, add it to current page (if
PhotoApi
- * was initialized with `editorApi`).
- *
- * @param {Object} options
- * options.file File A file object obtained from a file
input.
- * options.description String Image description.
- * @return {jQuery.Deferred} On failure callback is passed an
object with
- * `stage`, `type` and `details` properties. `stage` is either
"upload"
- * or "edit" (inserting image in a page). `type` is a string
describing
- * the type of error, `details` can be any object (usually a
string
- * containing error message).
- */
- save: function ( options ) {
- var page = this.page,
- // FIXME: Use page.getId()
- isNewPage = mw.config.get( 'wgArticleId' ) ===
0,
- isNewFile = page.inNamespace( 'file' ) &&
isNewPage,
- self = this,
- result = $.Deferred();
-
- options.editSummaryMessage = options.insertInPage ?
- 'mobile-frontend-photo-article-edit-comment' :
- 'mobile-frontend-photo-article-donate-comment';
-
- /**
- * Performs upload
- *
- * @ignore
- */
- function doUpload() {
- var
- ext = options.file.name.slice(
options.file.name.lastIndexOf( '.' ) + 1 ),
- request, data;
-
- if ( !isNewFile ) {
- options.fileName = generateFileName(
options.description, '.' + ext );
- } else {
- options.fileName = mw.config.get(
'wgTitle' );
- }
-
- data = {
- action: 'upload',
- filename: options.fileName,
- comment: mw.msg(
options.editSummaryMessage ),
- file: options.file,
- text: mw.template.get(
'mobile.upload.ui', 'template.hogan' )
- .render( {
- suffix: mw.config.get(
'wgMFPhotoUploadAppendToDesc' ),
- text:
options.description,
- username: user.getName()
- } )
- };
-
- request = self.postWithToken( 'edit', data, {
- contentType: 'multipart/form-data',
- cache: false
- } ).done( function ( data ) {
- var descriptionUrl = '',
- warnings = data.upload ?
data.upload.warnings : false,
- err = {
- stage: 'upload',
- type: 'error'
- };
-
- if ( !data || !data.upload ) {
- // error uploading image
- if ( data.error ) {
- if ( data.error.code ) {
- err.details =
data.error.code;
- if (
data.error.details && data.error.details[0] ) {
-
err.details += '/' + data.error.details[0];
- }
- }
- }
- result.reject( err );
- return;
- }
-
- options.fileName = data.upload.filename;
-
- if ( !options.fileName ) {
- // FIXME: Handle this case as
an error in handleWarnings
- if ( warnings &&
warnings.duplicate ) {
- options.fileName =
warnings.duplicate[ '0' ];
- } else if ( warnings ) {
- return
self._handleWarnings( result, warnings );
- } else {
- return result.reject( {
- stage: 'upload',
- type: 'unknown',
- details:
'missing-filename'
- } );
- }
- }
-
- // FIXME: API doesn't return this
information on duplicate images...
- if ( data.upload.imageinfo ) {
- descriptionUrl =
data.upload.imageinfo.descriptionurl;
- }
-
- if ( self.editorApi && !isNewFile ) {
- self.editorApi.setPrependText(
'[[File:' + options.fileName + '|thumbnail|' + options.description + ']]\n\n' );
- self.editorApi.save( {
- summary: mw.msg(
'mobile-frontend-photo-upload-comment' )
- } )
- .done( function () {
- result.resolve(
options.fileName, descriptionUrl );
- } )
- .fail( function ( err )
{
- err.stage =
'edit';
- result.reject(
err );
- } );
- } else if ( isNewFile ) {
- window.location.reload();
- } else {
- result.resolve(
options.fileName, descriptionUrl );
- }
-
- } ).fail( function () {
- // error on the server side (abort
happens when user cancels the upload)
- if ( status !== 'abort' ) {
- result.reject( {
- stage: 'upload',
- type: 'error',
- details: 'http'
- } );
- }
- } );
-
- self.on( 'progress', function ( req, progress )
{
- if ( req === request ) {
- self.emit( 'uploadProgress',
progress );
- }
- } );
- }
- doUpload();
-
- return result;
- }
- } );
-
- M.define( 'modules/uploads/PhotoApi', PhotoApi );
- M.define( 'modules/uploads/_photo', {
- generateFileName: generateFileName,
- trimUtf8String: trimUtf8String
- } );
-
-}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploads/PhotoUploadOverlay.js
b/javascripts/modules/uploads/PhotoUploadOverlay.js
deleted file mode 100644
index 9551501..0000000
--- a/javascripts/modules/uploads/PhotoUploadOverlay.js
+++ /dev/null
@@ -1,337 +0,0 @@
-/* global EXIF */
-( function ( M, $ ) {
- var popup = M.require( 'toast' ),
- user = M.require( 'user' ),
- router = M.require( 'router' ),
- Overlay = M.require( 'Overlay' ),
- EditorApi = M.require( 'modules/editor/EditorApi' ),
- PhotoApi = M.require( 'modules/uploads/PhotoApi' ),
- PhotoUploadProgress = M.require(
'modules/uploads/PhotoUploadProgress' ),
- SchemaMobileWebUploads = M.require(
'loggingSchemas/SchemaMobileWebUploads' ),
- ownershipMessage = mw.msg( 'mobile-frontend-photo-ownership',
user.getName(), user ),
- PhotoUploadOverlay;
-
- /**
- * Overlay for photo upload
- * @class PhotoUploadOverlay
- * @uses PhotoApi
- * @extends Overlay
- */
- PhotoUploadOverlay = Overlay.extend( {
- /**
- * @inheritdoc
- * @cfg {Object} defaults Default options hash.
- * @cfg {Page} defaults.page the page being uploaded to
- * @cfg {String} defaults.descriptionPlaceholder Placeholder
text prompting user to add
- * a mandatory caption to an image.
- * @cfg {String} defaults.help A link that allows the user to
open more information
- * about photo ownership.
- * @cfg {String} defaults.ownerStatement A statement saying the
user created the image.
- * @cfg {String} defaults.heading A heading instructing the
user to describe uploaded image.
- * @cfg {String} defaults.headerButtonsListClassName Class name
of the wrapper of the
- * header buttons.
- * @cfg {Array} defaults.headerButtons Objects that will be
used as defaults to create
- * header buttons. Defaults to the 'submit' button.
- */
- defaults: {
- page: undefined,
- descriptionPlaceholder: mw.msg(
'mobile-frontend-photo-caption-placeholder' ),
- help: mw.msg( 'mobile-frontend-photo-ownership-help' ),
- ownerStatement: ownershipMessage,
- heading: mw.msg(
'mobile-frontend-image-heading-describe' ),
- headerButtonsListClassName: 'overlay-action',
- headerButtons: [ {
- className: 'submit',
- msg: mw.msg( 'mobile-frontend-photo-submit' )
- } ]
- },
- /** @inheritdoc */
- events: $.extend( {}, Overlay.prototype.events, {
- 'click .submit': 'onSubmit',
- 'keyup textarea': 'onDescriptionChange',
- // use input event too, Firefox doesn't fire keyup on
many devices:
- // https://bugzilla.mozilla.org/show_bug.cgi?id=737658
- 'input textarea': 'onDescriptionChange'
- } ),
-
- className: 'overlay photo-overlay',
-
- templatePartials: {
- content: mw.template.get( 'mobile.uploads',
'PhotoUploadOverlay.hogan' )
- },
-
- /** @inheritdoc */
- initialize: function ( options ) {
- var fileReader = new FileReader(),
- self = this;
-
- this.schema = new SchemaMobileWebUploads( {
- funnel: options.funnel
- } );
- this.file = options.file;
-
- if ( this.file ) {
- fileReader.readAsDataURL( options.file );
- /**
- * onload event for FileReader
- * @ignore
- */
- fileReader.onload = function () {
- var dataUri = fileReader.result;
- // add mimetype if not present (some
browsers need it, e.g. Android browser)
- dataUri = dataUri.replace(
/^data:base64/, 'data:image/jpeg;base64' );
- self.schema.log( {
- action: 'preview'
- } );
- self.setImageUrl( dataUri );
- };
- }
-
- if ( options.insertInPage ) {
- this.api = new PhotoApi( {
- page: options.page,
- editorApi: new EditorApi( {
- // FIXME: Use options.page
instead
- title: options.pageTitle
- } )
- } );
- } else {
- this.api = new PhotoApi( {
- page: options.page
- } );
- }
- this.api.on( 'uploadProgress', function ( value ) {
- self.progressPopup.setValue( value );
- } );
-
- this.progressPopup = new PhotoUploadProgress().on(
'cancel', function () {
- self.api.abort();
- self.schema.log( {
- action: 'cancel'
- } );
- } ).on( 'submit', function () {
- // handle resubmitting after abusefilter message
- self._save();
- } );
-
- // If terms of use is enabled, include it in the
licensing message
- if ( $( '#footer-places-terms-use' ).length > 0 ) {
- options.license = mw.msg(
-
'mobile-frontend-photo-licensing-with-terms',
- $( '#footer-places-terms-use' ).html(),
- mw.config.get( 'wgMFUploadLicenseLink' )
- );
- } else {
- options.license = mw.msg(
- 'mobile-frontend-photo-licensing',
- mw.config.get( 'wgMFUploadLicenseLink' )
- );
- }
-
- Overlay.prototype.initialize.apply( this, arguments );
- },
-
- /**
- * Performs a file upload based on current state of
PhotoUploadOverlay
- * When succeeds either reloads page or emits a global event
_file-upload
- * If error occurs shows a toast
- * @uses PhotoApi
- * @private
- */
- _save: function () {
- var
- self = this,
- description = this.getDescription(),
- saveOptions = {
- file: this.file,
- description: description
- };
-
- this.api.save( saveOptions ).done( function ( fileName,
descriptionUrl ) {
- self.progressPopup.hide( true );
-
- self.schema.log( {
- action: 'success'
- } );
- if ( self.options.insertInPage ) {
- popup.show( mw.msg(
'mobile-frontend-photo-upload-success-article' ), 'toast' );
-
- // reload the page
- window.location.reload();
- } else {
- /**
- * @event _file-upload
- * Emits global event _file-upload.
- * FIXME: handle Special:Uploads case -
find more generic way of doing this
- */
- M.emit( '_file-upload', {
- fileName: fileName,
- description: description,
- descriptionUrl: descriptionUrl,
- url: self.imageUrl
- } );
- }
- } ).fail( function ( err, statusMessage,
httpErrorThrown ) {
- var errMsg;
-
- if ( err.type === 'abusefilter' ) {
- self.progressPopup.showAbuseFilter(
err.details.type, err.details.message );
- } else {
- self.progressPopup.hide( true );
- popup.show( statusMessage || mw.msg(
'mobile-frontend-photo-upload-error' ), 'toast error' );
- // If there is error information in API
response, report that in the log
- if ( err.stage !== undefined ||
err.type !== undefined ) {
- errMsg = err.stage + '/' +
err.type;
- if ( typeof err.details ===
'string' ) {
- errMsg += '/' +
err.details;
- }
- // Otherwise, record the stage
as 'unknown' and record the type as the
- // status message ("timeout",
"error", "abort", etc. ) and include any
- // HTTP error that was thrown.
- } else {
- errMsg = 'unknown';
- if ( statusMessage ) {
- errMsg += '/' +
statusMessage;
- if ( httpErrorThrown ) {
- errMsg += '/' +
httpErrorThrown;
- }
- }
- }
- self.schema.log( {
- action: 'error',
- errorText: errMsg
- } );
- }
- } );
- },
-
- /**
- * Submits a photo for upload, reveals a progress bar and hides
the overlay.
- * Invokes _save method.
- * @private
- */
- _submit: function () {
- this.hide( true );
-
- this.progressPopup.show();
-
- this._save();
- },
-
- /** @inheritdoc */
- postRender: function () {
- var $submitButton,
- self = this;
-
- Overlay.prototype.postRender.apply( this );
-
- $submitButton = this.$( '.submit' )
- .prop( 'disabled', true );
- this.$description = this.$( 'textarea' )
- .microAutosize();
-
- // make license links open in separate tabs
- this.$( '.license a' ).attr( 'target', '_blank' );
-
- // Deal with case where user refreshes the page
- if ( !self.file ) {
- router.navigate( '#' );
- }
- },
-
- /** @inheritdoc */
- show: function () {
- var self = this;
-
- Overlay.prototype.show.apply( this, arguments );
-
- if ( this.file ) {
- EXIF.getData( this.file, function () {
- if ( $.isEmptyObject( this.exifdata ) )
{
- if ( window.confirm( mw.msg(
'mobile-frontend-photo-upload-copyvio' ) ) ) {
- self.schema.log( {
- action:
'copyvioOk'
- } );
- } else {
- self.schema.log( {
- action:
'copyvioCancel'
- } );
- self.hide( true );
- }
- }
- } );
- }
- },
-
- /** @inheritdoc */
- hide: function ( force ) {
- var _super = Overlay.prototype.hide;
- // In the case of a missing file force close
- if ( force || !this.file ) {
- return _super.apply( this, arguments );
- } else if ( window.confirm( mw.msg(
'mobile-frontend-image-cancel-confirm' ) ) ) {
- this.emit( 'cancel' );
- this.schema.log( {
- action: 'previewCancel'
- } );
- return _super.apply( this, arguments );
- } else {
- return false;
- }
- },
-
- /**
- * Gets the user inputted description
- * @returns {String} of current value of description according
to view
- */
- getDescription: function () {
- return this.$description.val();
- },
-
- /**
- * Set the url of the image in the preview.
- * Throws toast if for some reason image cannot render e.g. bad
file type.
- * @param {String} url usually a data uri
- */
- setImageUrl: function ( url ) {
- var self = this,
- $preview = this.$( '.preview' );
-
- this.imageUrl = url;
- this.$( '.spinner' ).hide();
- this.$( '.help' ).on( 'click', function () {
- self.schema.log( {
- action: 'whatDoesThisMean'
- } );
- } );
- $( '<img>' )
- .attr( 'src', url )
- .appendTo( $preview )
- .on( 'error', function () {
- // When using a bad filetype close the
overlay
- popup.show( mw.msg(
'mobile-frontend-photo-upload-error-file-type' ), 'toast error' );
- self.hide( true );
- } );
- },
-
- /**
- * event handler to submit
- */
- onSubmit: function () {
- this.schema.log( {
- action: 'previewSubmit'
- } );
- this._submit();
- },
-
- /**
- * event handler for changing description of property
- */
- onDescriptionChange: function () {
- this.$( '.submit' ).prop( 'disabled', this.$(
'textarea' ).val() === '' );
- }
- } );
-
- M.define( 'modules/uploads/PhotoUploadOverlay', PhotoUploadOverlay );
-
-}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploads/PhotoUploadProgress.js
b/javascripts/modules/uploads/PhotoUploadProgress.js
deleted file mode 100644
index 360d64e..0000000
--- a/javascripts/modules/uploads/PhotoUploadProgress.js
+++ /dev/null
@@ -1,94 +0,0 @@
-( function ( M, $ ) {
- var Overlay = M.require( 'Overlay' ),
- ProgressBar = M.require( 'modules/uploads/ProgressBar' ),
- AbuseFilterPanel = M.require( 'modules/editor/AbuseFilterPanel'
),
- PhotoUploadProgress;
-
- /**
- * Overlay displaying photo upload progress bar.
- ** Appears at top of the page does not cover display.
- * @class PhotoUploadProgress
- * @extends Overlay
- * @uses ProgressBar
- * @uses AbuseFilterPanel
- */
- PhotoUploadProgress = Overlay.extend( {
- /**
- * @inheritdoc
- * @cfg {Object} defaults Default options hash. Extends
{Overlay} defaults.
- * @cfg {String} defaults.uploadingMsg A message telling the
user that an image is being
- * uploaded.
- */
- defaults: $.extend( {}, Overlay.prototype.defaults, {
- uploadingMsg: mw.msg( 'mobile-frontend-image-uploading'
)
- } ),
- /** @inheritdoc */
- events: $.extend( {}, Overlay.prototype.events, {
- 'click .submit': 'onSubmit'
- } ),
- template: mw.template.get( 'mobile.uploads',
'PhotoUploadProgress.hogan' ),
- fullScreen: false,
-
- /** @inheritdoc */
- initialize: function () {
- Overlay.prototype.initialize.apply( this, arguments );
- this.progressBar = new ProgressBar();
- },
-
- /** @inheritdoc */
- postRender: function () {
- Overlay.prototype.postRender.apply( this );
- },
-
- /**
- * Show abuse filter
- * @method
- * @param {String} type The type of alert, e.g. 'warning' or
'disallow'
- * @param {String} message Message to show in the AbuseFilter
overlay
- */
- showAbuseFilter: function ( type, message ) {
- new AbuseFilterPanel().appendTo( this.$(
'.overlay-header-container' ) )
- .show( type, message );
- this.showHidden( '.save-header' );
- },
-
- /** @inheritdoc */
- hide: function ( force ) {
- var _super = Overlay.prototype.hide;
- if ( force ) {
- return _super.apply( this, arguments );
- } else if ( window.confirm( mw.msg(
'mobile-frontend-image-cancel-confirm' ) ) ) {
- this.emit( 'cancel' );
- return _super.apply( this, arguments );
- } else {
- return false;
- }
- },
-
- /**
- * Set the value of the progress bar in percentages
- * @method
- * @param {Number} value of the progress bar
- */
- setValue: function ( value ) {
- var $uploading = this.$( '.uploading' );
- // only add progress bar if we're getting progress
events
- if ( $uploading.length && $uploading.text() !== '' ) {
- $uploading.text( '' );
- this.progressBar.appendTo( $uploading );
- this.$( '.right' ).remove();
- }
- this.progressBar.setValue( value );
- },
-
- /**
- * event handler to submit
- */
- onSubmit: function () {
- this.emit( 'submit' );
- }
- } );
-
- M.define( 'modules/uploads/PhotoUploadProgress', PhotoUploadProgress );
-
-}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploads/PhotoUploaderButton.js
b/javascripts/modules/uploads/PhotoUploaderButton.js
deleted file mode 100644
index fb08955..0000000
--- a/javascripts/modules/uploads/PhotoUploaderButton.js
+++ /dev/null
@@ -1,79 +0,0 @@
-( function ( M, $ ) {
- var browser = M.require( 'browser' ),
- View = M.require( 'View' ),
- Icon = M.require( 'Icon' ),
- photoIcon = new Icon( {
- name: 'photo',
- hasText: true,
- additionalClassNames: 'mw-ui-progressive mw-ui-button
button'
- } ),
- router = M.require( 'router' ),
- PhotoUploaderButton;
-
- /**
- * @class PhotoUploaderButton
- * @extends View
- * @uses Icon
- * PhotoUploaderButton is a component for uploading images to the wiki.
- *
- * @example
- * <code>
- * var photoUploaderButton = new PhotoUploaderButton( {
- * buttonCaption: 'Add a photo',
- * } );
- * photoUploaderButton.
- * insertAfter( 'h1' ).
- * on( 'upload', function ( fileName, url ) {
- * $( '.someImage' ).attr( 'src', url );
- * } );
- * </code>
- *
- * @param {Object} options Uploader options.
- * @param {String} options.buttonCaption Caption for the upload button.
- * @param {Boolean} options.insertInPage If the image should be
prepended
- * to the wikitext of a page specified by options.pageTitle.
- * @param {String} options.pageTitle Title of the page to which the
image
- * belongs (image name will be based on this) and to which it should be
- * prepended (if options.insertInPage is true).
- * @param {String} options.funnel Funnel for EventLogging.
- */
- PhotoUploaderButton = View.extend( {
- template: mw.template.get( 'mobile.upload.ui', 'Button.hogan' ),
- className: photoIcon.getClassName(),
- events: {
- 'change input': 'onFileSelected'
- },
-
- /**
- * Event handler, called when a file is selected in the input
- * @param {jQuery.Event} ev
- */
- onFileSelected: function ( ev ) {
- var $input = $( ev.target );
- this.handleFile( $input[0].files[0] );
- // clear so that change event is fired again when user
selects the same file
- $input.val( '' );
- },
-
- /**
- * Handle a selected file for upload, emit event and route to
the
- * appropiate url
- * @param {File} file associated with file upload input
- */
- handleFile: function ( file ) {
- // FIXME: this is hacky but it would be hard to pass a
file in a route
- M.emit( '_upload-preview', file );
- router.navigate( '#/upload-preview/' +
this.options.funnel );
- },
-
- /** @inheritdoc */
- postRender: function () {
- this.$el.removeClass( 'hidden' );
- }
- } );
-
- PhotoUploaderButton.isSupported = browser.supportsFileUploads();
-
- M.define( 'modules/uploads/PhotoUploaderButton', PhotoUploaderButton );
-
-}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploads/ProgressBar.js
b/javascripts/modules/uploads/ProgressBar.js
deleted file mode 100644
index 6915ab0..0000000
--- a/javascripts/modules/uploads/ProgressBar.js
+++ /dev/null
@@ -1,28 +0,0 @@
-( function ( M ) {
-
- var ProgressBar,
- View = M.require( 'View' );
-
- /**
- * Progress bar
- * @class ProgressBar
- * @extends View
- */
- ProgressBar = View.extend( {
- className: 'progress-bar',
-
- template: mw.template.compile( '<div class="value"></div>',
'hogan' ),
-
- /**
- * Set the value of the progress bar in percentages
- * @method
- * @param {Number} value of the progress bar
- */
- setValue: function ( value ) {
- this.$( '.value' ).css( 'width', value * 100 + '%' );
- }
- } );
-
- M.define( 'modules/uploads/ProgressBar', ProgressBar );
-
-}( mw.mobileFrontend ) );
diff --git a/javascripts/modules/uploads/UploadTutorial.js
b/javascripts/modules/uploads/UploadTutorial.js
deleted file mode 100644
index 3591093..0000000
--- a/javascripts/modules/uploads/UploadTutorial.js
+++ /dev/null
@@ -1,126 +0,0 @@
-( function ( M, $ ) {
-
- var context = M.require( 'context' ),
- Overlay = M.require( 'Overlay' ),
- Icon = M.require( 'Icon' ),
- LeadPhotoUploaderButton = M.require(
'modules/uploads/PhotoUploaderButton' ),
- buttonMsg = mw.msg(
'mobile-frontend-first-upload-wizard-new-page-3-ok' ),
- UploadTutorial;
-
- /**
- * Overlay for displaying upload tutorial
- * @class UploadTutorial
- * @extends Overlay
- * @uses Icon
- * @uses LeadPhotoUploaderButton
- */
- UploadTutorial = Overlay.extend( {
- template: mw.template.get( 'mobile.uploads',
'UploadTutorial.hogan' ),
- className: 'overlay carousel tutorial content-overlay
tutorial-overlay',
-
- /** @inheritdoc */
- events: $.extend( {}, Overlay.prototype.events, {
- 'click .prev': 'onPreviousClick',
- 'click .next': 'onNextClick',
- 'click .button': 'onClickUploadButton'
- } ),
- /**
- * @inheritdoc
- * @cfg {Object} defaults Default options hash.
- * @cfg {String} defaults.slideLeftButton HTML of the slide
left button.
- * @cfg {String} defaults.slideRightButton HTML of the slide
right button.
- * @cfg {Boolean} defaults.inBeta Whether the user is a beta
group member.
- * @cfg {Array} defaults.pages Array of {Object}s that will be
used as options to
- * create pages. Defaults to the following pages:
- * * Informative statement about where images come from.
- * * Guidance on avoiding copyright materials shown to first
time users on
- * [[Special:Uploads]].
- * * Question asking user if they understood the tutorial.
- */
- defaults: {
- slideLeftButton: new Icon( {
- name: 'previous-invert'
- } ).toHtmlString(),
- slideRightButton: new Icon( {
- name: 'next-invert'
- } ).toHtmlString(),
- inBeta: context.isBetaGroupMember(),
- pages: [
- {
- caption: mw.msg(
'mobile-frontend-first-upload-wizard-new-page-1-header' ),
- text: mw.msg(
'mobile-frontend-first-upload-wizard-new-page-1' )
- },
- {
- caption: mw.msg(
'mobile-frontend-first-upload-wizard-new-page-2-header' ),
- text: mw.msg(
'mobile-frontend-first-upload-wizard-new-page-2' )
- },
- {
- caption: mw.msg(
'mobile-frontend-first-upload-wizard-new-page-3-header' ),
- button: buttonMsg
- }
- ]
- },
-
- /** @inheritdoc */
- postRender: function () {
- var $button = this.$( '.button' ),
- photoUploaderButton;
-
- if ( this.options.funnel ) {
- photoUploaderButton = new
LeadPhotoUploaderButton( {
- el: $button,
- buttonCaption: buttonMsg,
- funnel: this.options.funnel
- } );
- }
-
- this.page = 0;
- this.totalPages = this.options.pages.length;
- this._showCurrentPage();
- Overlay.prototype.postRender.apply( this );
- },
-
- /**
- * Show current page inside the upload tutorial
- * @method
- * @private
- */
- _showCurrentPage: function () {
- this.$( '.slide' ).removeClass( 'active' ).eq(
this.page ).addClass( 'active' );
- this.$( '.prev' ).toggle( this.page > 0 );
- this.$( '.next' ).toggle( this.page < this.totalPages -
1 );
- },
-
- /**
- * Event that is fired when clicking the final button at the
end of the tutorial.
- * @method
- */
- onClickUploadButton: function () {
- this.emit( 'hide' );
- // FIXME: this is a hack. Not sure why this is needed
but without it
- // when escaping the upload interface you will still
see it.
- this.$el.hide();
- },
-
- /**
- * Show next page of the tutorial
- * @method
- */
- onNextClick: function () {
- this.page += 1;
- this._showCurrentPage();
- },
-
- /**
- * Show previous page of the tutorial
- * @method
- */
- onPreviousClick: function () {
- this.page -= 1;
- this._showCurrentPage();
- }
- } );
-
- M.define( 'modules/uploads/UploadTutorial', UploadTutorial );
-
-}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploads/init.js
b/javascripts/modules/uploads/init.js
deleted file mode 100644
index 75d964a..0000000
--- a/javascripts/modules/uploads/init.js
+++ /dev/null
@@ -1,75 +0,0 @@
-( function ( M, $ ) {
-
- var
- funnel = $.cookie( 'mwUploadsFunnel' ) || 'article',
- LeadPhotoUploaderButton = M.require(
'modules/uploads/LeadPhotoUploaderButton' ),
- user = M.require( 'user' ),
- skin = M.require( 'skin' ),
- isSupported = LeadPhotoUploaderButton.isSupported;
-
- /**
- * Checks whether there is no suitable image in the container.
- * Judges this based on selector in wgMFLeadPhotoUploadCssSelector
- *
- * @param {jQuery.Object} $container
- * @return {Boolean}
- * @ignore
- */
- function needsPhoto( $container ) {
- return $container.find( mw.config.get(
'wgMFLeadPhotoUploadCssSelector' ) ).length === 0;
- }
-
- // reset the funnel cookie as it is no longer valid
- if ( funnel ) {
- $.cookie( 'mwUploadsFunnel', null );
- }
-
- /**
- * Initialise interface would uploading an image to the top of the
current page.
- *
- * @ignore
- */
- function initialize() {
- var
- page = M.getCurrentPage(),
- $lead = page.getLeadSectionElement(),
- inFileNamespace = page.inNamespace( 'file' ),
- validNamespace = ( page.inNamespace( '' ) ||
page.inNamespace( 'user' ) || inFileNamespace );
-
- // Only show upload page action in File namespace if page
doesn't already exist.
- if ( inFileNamespace ) {
- if ( mw.config.get( 'wgArticleId' ) ) {
- $( '#ca-upload' ).remove();
- }
- } else {
- if ( !page.isEditable( user ) || !validNamespace ||
- // FIXME: Anonymous users cannot upload
but really this should also check rights of user via getRights
- // (without triggering an additional
HTTP request)
- user.isAnon() ||
- mw.util.getParamValue( 'action' ) ||
!needsPhoto( $lead ) || mw.config.get( 'wgIsMainPage' ) ) {
- $( '#ca-upload' ).remove();
- }
- }
-
- new LeadPhotoUploaderButton( {
- funnel: funnel
- } );
- skin.emit( 'changed' );
- }
-
- if ( isSupported ) {
- $( initialize );
- } else {
- // FIXME: We want to enable it to these users however we must
first deal with what to show
- // to users who haven't uploaded anything to make the page
useful.
- $( function () {
- // FIXME: Move to MainMenu.js
- $( 'nav li.menu-item-upload' ).remove();
- } );
- }
-
- M.define( 'modules/uploads/_leadphoto', {
- needsPhoto: needsPhoto
- } );
-
-}( mw.mobileFrontend, jQuery ) );
diff --git a/javascripts/modules/uploads/routes.js
b/javascripts/modules/uploads/routes.js
deleted file mode 100644
index ef40b36..0000000
--- a/javascripts/modules/uploads/routes.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Defines all possible routes in MobileFrontend and where to find the code to
provide them. */
-( function ( M, $ ) {
- var lastFile,
- overlayManager = M.require( 'overlayManager' ),
- loader = M.require( 'loader' );
-
- // FIXME: this is hacky but it would be hard to pass a file in a route
- M.on( '_upload-preview', function ( file ) {
- lastFile = file;
- } );
-
- // Upload Tutorial
- overlayManager.add( /^\/upload-tutorial\/?(.*)$/, function ( funnel ) {
- var result = $.Deferred();
- loader.loadModule( 'mobile.uploads' ).done( function () {
- var UploadTutorialNew = M.require(
'modules/uploads/UploadTutorial' );
- result.resolve( new UploadTutorialNew( {
- funnel: funnel || null
- } ) );
- } );
- return result;
- } );
-
- // Upload Preview
- overlayManager.add( /^\/upload-preview\/?(.*)$/, function ( funnel ) {
- var result = $.Deferred();
- loader.loadModule( 'mobile.uploads' ).done( function () {
- var PhotoUploadOverlay = M.require(
'modules/uploads/PhotoUploadOverlay' );
- result.resolve( new PhotoUploadOverlay( {
- page: M.getCurrentPage(),
- // FIXME: Remove this and use page option
instead
- pageTitle: mw.config.get( 'wgTitle' ),
- file: lastFile,
- funnel: funnel,
- // When the funnel is uploads you are on
Special:Uploads
- insertInPage: funnel === 'uploads' ? false :
true
- } ) );
- } );
- return result;
- } );
-
-} )( mw.mobileFrontend, jQuery );
diff --git a/javascripts/specials/userlogin.js
b/javascripts/specials/userlogin.js
deleted file mode 100644
index 319f5be..0000000
--- a/javascripts/specials/userlogin.js
+++ /dev/null
@@ -1,11 +0,0 @@
-( function ( M, $ ) {
- var browser = M.require( 'browser' );
-
- if ( !browser.isWideScreen() ) {
- // Most people on mobile devices are on a personal device so
this property should be assumed.
- $( function () {
- $( '#wpRemember' ).prop( 'checked', true );
- } );
- }
-
-} )( mw.mobileFrontend, jQuery );
--
To view, visit https://gerrit.wikimedia.org/r/210084
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I29ae18e2b8cd8e9b91d20c4f85d42c79dc70d6fd
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