r105972 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105971‎ | r105972 | r105973 >
Date:02:46, 13 December 2011
Author:neilk
Status:deferred (Comments)
Tags:
Comment:
add feedback link to visual editor
Modified paths:
  • /trunk/extensions/VisualEditor/SpecialVisualEditorSandbox.php (modified) (history)
  • /trunk/extensions/VisualEditor/VisualEditor.i18n.php (modified) (history)
  • /trunk/extensions/VisualEditor/VisualEditor.php (modified) (history)
  • /trunk/extensions/VisualEditor/modules/sandbox/special.js (added) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/SpecialVisualEditorSandbox.php
@@ -17,7 +17,7 @@
1818 public function execute( $par ) {
1919 global $wgOut;
2020
21 - $wgOut->addModules( 'ext.visualEditor.sandbox' );
 21+ $wgOut->addModules( 'ext.visualEditor.special.sandbox' );
2222 $this->setHeaders();
2323 $wgOut->setPageTitle( wfMsg( 'visualeditor-sandbox-title' ) );
2424 $modeWikitext = wfMsgHtml( 'visualeditor-tooltip-wikitext' );
@@ -26,6 +26,10 @@
2727 $modeRender = wfMsgHtml( 'visualeditor-tooltip-render' );
2828 $modeHistory = wfMsgHtml( 'visualeditor-tooltip-history' );
2929 $modeHelp = wfMsgHtml( 'visualeditor-tooltip-help' );
 30+
 31+ $feedbackPrompt = wfMsgHtml( 'visualeditor-feedback-prompt' );
 32+ $feedbackDialogTitle = wfMsgHtml( 'visualeditor-feedback-dialog-title' );
 33+
3034 $out = <<<HTML
3135 <!-- VisualEditor Sandbox -->
3236 <div id="es-docs">
Index: trunk/extensions/VisualEditor/VisualEditor.php
@@ -46,6 +46,19 @@
4747 );
4848
4949 $wgResourceModules += array(
 50+ 'ext.visualEditor.special.sandbox' => $wgVisualEditorResourceTemplate + array(
 51+ 'scripts' => array(
 52+ 'sandbox/special.js',
 53+ ),
 54+ 'messages' => array(
 55+ 'visualeditor-feedback-prompt',
 56+ 'visualeditor-feedback-dialog-title',
 57+ ),
 58+ 'dependencies' => array(
 59+ 'ext.visualEditor.sandbox',
 60+ 'mediawiki.feedback',
 61+ )
 62+ ),
5063 'ext.visualEditor.sandbox' => $wgVisualEditorResourceTemplate + array(
5164 'scripts' => array(
5265 'sandbox/sandbox.js',
Index: trunk/extensions/VisualEditor/modules/sandbox/special.js
@@ -0,0 +1,31 @@
 2+( function( $, mw, undefined ) {
 3+
 4+ $(document).ready( setupSpecial );
 5+
 6+ function setupSpecial() {
 7+
 8+ var api = new mw.Api( {
 9+ url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php'
 10+ } );
 11+
 12+ var title = new mw.Title( 'VisualEditorFeedback' );
 13+
 14+ var feedback = new mw.Feedback(
 15+ api,
 16+ title,
 17+ 'visualeditor-feedback-dialog-title'
 18+ );
 19+
 20+ $feedbackLink = $( '<a></a>' )
 21+ .attr( { 'href': '#' } )
 22+ .text( mw.msg( 'visualeditor-feedback-prompt' ) )
 23+ .click( function() { feedback.launch(); } );
 24+
 25+ // Right before the line with the test "documents" we prepend a float-right
 26+ // div, which puts it on the same line as the documents at right.
 27+ $( '#es-docs' ).before(
 28+ $( '<div></div>' ).css( { 'float': 'right' } ).append( $feedbackLink )
 29+ );
 30+ }
 31+
 32+} )( jQuery, window.mediaWiki );
Property changes on: trunk/extensions/VisualEditor/modules/sandbox/special.js
___________________________________________________________________
Added: svn:eol-style
133 + native
Index: trunk/extensions/VisualEditor/VisualEditor.i18n.php
@@ -15,6 +15,8 @@
1616 'visualeditor-tooltip-render' => 'Toggle preview',
1717 'visualeditor-tooltip-history' => 'Toggle transaction history view',
1818 'visualeditor-tooltip-help' => 'Toggle help view',
 19+ 'visualeditor-feedback-prompt' => 'Leave feedback',
 20+ 'visualeditor-feedback-dialog-title' => 'Leave feedback about VisualEditor Sandbox',
1921 );
2022
2123 /** Message documentation

Follow-up revisions

RevisionCommit summaryAuthorDate
r105997unnecessary to define messages here, followup r105972neilk09:34, 13 December 2011
r106003change args for feedback and api -- all optional, in array.neilk10:26, 13 December 2011
r106004change args for feedback and api -- all optional, in array.neilk10:28, 13 December 2011

Comments

#Comment by Nikerabbit (talk | contribs)   05:57, 13 December 2011

You can probably use mw.util.wikiScript( 'api') for this:

+url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php'
#Comment by NeilK (talk | contribs)   10:29, 13 December 2011

I'm reluctant to add a dependency on mw.util, and I think I want to insist that API urls include hostname usually (it will change how the API works if it has to be remote).

But, I used similar code in mw.Api instead, with wgServer prepended, so at least it's kind of centralized. I think this isn't too bad. (r106003, r106004)

#Comment by Nikerabbit (talk | contribs)   05:59, 13 December 2011

Why did you also add them into SpecialVisualEditorSandbox.php? Look unused there to me.

#Comment by NeilK (talk | contribs)   09:35, 13 December 2011

It was an earlier attempt to add the feedback link. Thanks for the catch. fixed in r105997

Status & tagging log