Mattflaschen has submitted this change and it was merged. Change subject: Provide the link to the File page after the successfully uploading the pronunciation ......................................................................
Provide the link to the File page after the successfully uploading the pronunciation Bug: 54418 Change-Id: I21b89a0f3c07b6bfb4f6e45ad40c404c9a23426d --- M PronunciationRecording.i18n.php M PronunciationRecording.php M resources/ext.pronunciationRecording.fileDetails.js M resources/ext.pronunciationRecording.pronunciationRecorder.js M resources/ext.pronunciationRecording.specialPage.js 5 files changed, 24 insertions(+), 16 deletions(-) Approvals: Mattflaschen: Verified; Looks good to me, approved diff --git a/PronunciationRecording.i18n.php b/PronunciationRecording.i18n.php index 6c67d2d..8c03525 100644 --- a/PronunciationRecording.i18n.php +++ b/PronunciationRecording.i18n.php @@ -21,7 +21,7 @@ 'pronunciationrecording-toolbar-upload-label' => 'Upload', 'pronunciationrecording-webaudio-not-supported' => 'WebAudio API is not supported for this browser', 'pronunciationrecording-specialpage-error-nologin' => 'You must be [$1 logged in] to record and upload pronunciations.', - 'pronunciationrecording-upload-publish-succeeded' => 'Recording uploaded successfully', + 'pronunciationrecording-upload-publish-succeeded' => 'Recording uploaded successfully: ', 'pronunciationrecording-upload-publish-failed' => 'Recording was not uploaded', 'pronunciationrecording-information-label' => 'Information', 'pronunciationrecording-information-word-label' => 'Word:', diff --git a/PronunciationRecording.php b/PronunciationRecording.php index 063e589..31368cd 100644 --- a/PronunciationRecording.php +++ b/PronunciationRecording.php @@ -54,6 +54,7 @@ 'ext.pronunciationRecording.pronunciationRecorder', 'ext.pronunciationRecording.fileDetails', 'mediawiki.user', + 'mediawiki.util', ), 'messages' => array( 'pronunciationrecording-webaudio-not-supported', diff --git a/resources/ext.pronunciationRecording.fileDetails.js b/resources/ext.pronunciationRecording.fileDetails.js index 056fc14..91862de 100644 --- a/resources/ext.pronunciationRecording.fileDetails.js +++ b/resources/ext.pronunciationRecording.fileDetails.js @@ -1,6 +1,6 @@ ( function ( mw, $ ) { mw.PronunciationRecorderFileDetails = function( word, username, lang_code ) { - var description, date_obj, fulldate, month, source, author, permission, category, wikitext, lang_subst = "{{subst:#language:" + lang_code + "|en}}"; + var description, date_obj, fulldate, source, author, permission, category, lang_subst = "{{subst:#language:" + lang_code + "|en}}"; date_obj = new Date(); description = "Pronunciation of the term '" + word + "' in " + lang_subst; @@ -23,6 +23,13 @@ { var wikitext = '{{Information\n |description = ' + description + '\n |date = ' + fulldate + '\n |source = ' + source + '\n |author = ' + author + '\n |permission = ' + permission + '\n}}\n' + category; return wikitext; + }, + + generateFileName: function() + { + var filename = lang_code + '-' + word + '.wav'; + return filename; + } } } diff --git a/resources/ext.pronunciationRecording.pronunciationRecorder.js b/resources/ext.pronunciationRecording.pronunciationRecorder.js index 81d60a0..8fad64b 100644 --- a/resources/ext.pronunciationRecording.pronunciationRecorder.js +++ b/resources/ext.pronunciationRecording.pronunciationRecorder.js @@ -1,7 +1,7 @@ ( function ( mw, $ ) { mw.PronunciationRecorder = function( ) { - var audioContext, recorder, uploadHandler, uploadWizardUpload, cachedBlob, counter, + var audioContext, recorder, uploadHandler, uploadWizardUpload, cachedBlob, userAgent = mw.message( 'pronunciationrecording-title' ).text(); function startUserMedia( stream ) { $( ".mw-pronunciationrecording-record" ).removeAttr('disabled'); @@ -30,18 +30,13 @@ mw.log( 'No live audio input' ); } - function generateFileName() { - counter = Math.floor( ( Math.random() * 1000000 ) ); - return 'uploadTest' + counter + '.wav'; - } - - function publishUpload( ok, err, wikiText ) { + function publishUpload( ok, err, fileDetails ) { var params = { action: 'upload', filekey: uploadWizardUpload.fileKey, - filename: generateFileName(), + filename: fileDetails.generateFileName(), comment: "User created page with " + userAgent, - text : wikiText + text : fileDetails.generateWikiText() }; function publishOk( response ) { @@ -112,7 +107,7 @@ } }, - startUploading: function( ok, error, wikiText ) { + startUploading: function( ok, error, fileDetails ) { var config, api, uploadWizard, filesDiv; config = { 'enableFormData' : true }; filesDiv = document.createElement( "div" ); @@ -135,7 +130,7 @@ uploadHandler = uploadWizardUpload.getUploadHandler(); uploadHandler.start(); $.subscribeReady( 'thumbnails.' + uploadWizardUpload.index, function() { - publishUpload( ok, error, wikiText ); + publishUpload( ok, error, fileDetails ); } ); } ); diff --git a/resources/ext.pronunciationRecording.specialPage.js b/resources/ext.pronunciationRecording.specialPage.js index 98088dd..a17536f 100644 --- a/resources/ext.pronunciationRecording.specialPage.js +++ b/resources/ext.pronunciationRecording.specialPage.js @@ -23,18 +23,23 @@ $( ".mw-pronunciationrecording-message" ).empty(); }); $( document ).on( "click", ".mw-pronunciationrecording-upload", function() { - var wikiText, pronunciationRecorderFileDetails, word, username, lang_code; + var pronunciationRecorderFileDetails, word, username, lang_code; word = $( ".mw-pronunciationrecording-information-word" ).val(); lang_code = $( ".mw-pronunciationrecording-information-language" ).val(); username = mw.user.getName(); pronunciationRecorderFileDetails = new mw.PronunciationRecorderFileDetails( word, username, lang_code ); - wikiText = pronunciationRecorderFileDetails.generateWikiText(); $( ".mw-pronunciationrecording-upload" ).attr('disabled','disabled'); pronunciationRecorder.startUploading( function() { + var name, $fileLink; + name = 'File:' + pronunciationRecorderFileDetails.generateFileName() ; + $fileLink = $( '<a>' ); + $fileLink.attr( "href", mw.util.wikiGetlink( name ) ); + $fileLink.text( name ); $( ".mw-pronunciationrecording-message" ).text( mw.message( 'pronunciationrecording-upload-publish-succeeded' ).text() ); + $( ".mw-pronunciationrecording-message" ).append( $fileLink ); }, function() { $( ".mw-pronunciationrecording-message" ).text( mw.message( 'pronunciationrecording-upload-publish-failed' ).text() ); - }, wikiText ); + }, pronunciationRecorderFileDetails ); }); $( ".mw-pronunciationrecording-toolbar" ).show(); } -- To view, visit https://gerrit.wikimedia.org/r/85643 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I21b89a0f3c07b6bfb4f6e45ad40c404c9a23426d Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/PronunciationRecording Gerrit-Branch: master Gerrit-Owner: Rahul21 <rahul14...@gmail.com> Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Mdale <md...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits