Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -36,7 +36,9 @@ |
37 | 37 | Also built-in support for distribution through a TestSwarm instance. |
38 | 38 | * (bug 29036) For cascade-protected pages, the mw-textarea-cprotected class is |
39 | 39 | added to the textarea on the edit form. |
| 40 | +* mw.util.getScript has been implemented (like wfScript in GlobalFunctions.php) |
40 | 41 | |
| 42 | + |
41 | 43 | === Bug fixes in 1.19 === |
42 | 44 | * (bug 10154) Don't allow user to specify days beyond $wgRCMaxAge. |
43 | 45 | * (bug 28868) Show total pages in the subtitle of an image on the |
— | — | @@ -72,6 +74,7 @@ |
73 | 75 | also in RTL text. |
74 | 76 | * (bug 29055) Make don't send email on minor edits preference apply to |
75 | 77 | changes to talk page in addition to watchlist edits. |
| 78 | +* (bug 29071) mediawiki.action.watch.ajax.js should pass uselang to API. |
76 | 79 | |
77 | 80 | === API changes in 1.19 === |
78 | 81 | * (bug 27790) add query type for querymodules to action=paraminfo |
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -18,6 +18,33 @@ |
19 | 19 | |
20 | 20 | }); |
21 | 21 | |
| 22 | +test( 'wikiGetlink', function(){ |
| 23 | + |
| 24 | + // Not part of startUp module |
| 25 | + mw.config.set( 'wgArticlePath', '/wiki/$1' ); |
| 26 | + |
| 27 | + var hrefA = mw.util.wikiGetlink( 'Sandbox' ); |
| 28 | + |
| 29 | + equal( hrefA, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' ); |
| 30 | + |
| 31 | + var hrefB = mw.util.wikiGetlink( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' ); |
| 32 | + |
| 33 | + equal( hrefB, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage', 'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' ); |
| 34 | + |
| 35 | +}); |
| 36 | + |
| 37 | +test( 'wikiScript', function(){ |
| 38 | + |
| 39 | + mw.config.set({ |
| 40 | + 'wgScript': '/w/index.php', |
| 41 | + 'wgScriptPath': '/w', |
| 42 | + 'wgScriptExtension': '.php', |
| 43 | + }); |
| 44 | + |
| 45 | + equal( mw.util.wikiScript(), mw.config.get( 'wgScript' ), 'Defaults to index.php and is equal to wgScript.' ); |
| 46 | + |
| 47 | +}); |
| 48 | + |
22 | 49 | test( 'addCSS', function(){ |
23 | 50 | |
24 | 51 | var a = mw.util.addCSS( '#bodyContent { visibility: hidden; }' ); |
— | — | @@ -36,21 +63,6 @@ |
37 | 64 | |
38 | 65 | }); |
39 | 66 | |
40 | | -test( 'wikiGetlink', function(){ |
41 | | - |
42 | | - // Not part of startUp module |
43 | | - mw.config.set( 'wgArticlePath', '/wiki/$1' ); |
44 | | - |
45 | | - var hrefA = mw.util.wikiGetlink( 'Sandbox' ); |
46 | | - |
47 | | - equal( hrefA, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' ); |
48 | | - |
49 | | - var hrefB = mw.util.wikiGetlink( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' ); |
50 | | - |
51 | | - equal( hrefB, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage', 'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' ); |
52 | | - |
53 | | -}); |
54 | | - |
55 | 67 | test( 'getParamValue', function(){ |
56 | 68 | |
57 | 69 | var url = 'http://mediawiki.org/?foo=wrong&foo=right#&foo=bad'; |
Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.watch.ajax.js |
— | — | @@ -80,17 +80,18 @@ |
81 | 81 | } |
82 | 82 | |
83 | 83 | setLinkText( $link, $link.data( 'action' ) + 'ing' ); |
84 | | - |
| 84 | + |
85 | 85 | var reqData = { |
86 | 86 | 'action': 'watch', |
87 | 87 | 'format': 'json', |
88 | | - 'title': $link.data( 'target' ) |
| 88 | + 'title': $link.data( 'target' ), |
| 89 | + // API return contains a localized data.watch.message string. |
| 90 | + 'uselang': mw.config.get( 'wgUserLanguage' ) |
89 | 91 | }; |
90 | 92 | if ( $link.data( 'action' ) == 'unwatch' ) { |
91 | | - reqData['unwatch'] = ''; |
| 93 | + reqData.unwatch = ''; |
92 | 94 | } |
93 | | - $.getJSON( mw.config.get( 'wgScriptPath' ) |
94 | | - + '/api' + mw.config.get( 'wgScriptExtension' ), |
| 95 | + $.getJSON( mw.util.wikiScript( 'api' ), |
95 | 96 | reqData, |
96 | 97 | function( data, textStatus, xhr ) { |
97 | 98 | processResult( data, $link ); |
Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -138,6 +138,28 @@ |
139 | 139 | }, |
140 | 140 | |
141 | 141 | /** |
| 142 | + * Get the link to a page name (relative to wgServer) |
| 143 | + * |
| 144 | + * @param str Page name to get the link for. |
| 145 | + * @return string Location for a page with name of 'str' or boolean false on error. |
| 146 | + */ |
| 147 | + 'wikiGetlink' : function( str ) { |
| 148 | + |
| 149 | + return mw.config.get( 'wgArticlePath' ).replace( '$1', this.wikiUrlencode( str ) ); |
| 150 | + }, |
| 151 | + |
| 152 | + /** |
| 153 | + * Get address to a script in the wiki root. |
| 154 | + * For index.php use mw.config.get( 'wgScript' ) |
| 155 | + * |
| 156 | + * @param str Name of script (eg. 'api'), defaults to 'index' |
| 157 | + * @return str Address to script (eg. '/w/api.php' ) |
| 158 | + */ |
| 159 | + 'wikiScript' : function( str ) { |
| 160 | + return mw.config.get( 'wgScriptPath' ) + '/' + ( str || 'index' ) + mw.config.get( 'wgScriptExtension' ); |
| 161 | + }, |
| 162 | + |
| 163 | + /** |
142 | 164 | * Append a new style block to the head |
143 | 165 | * |
144 | 166 | * @param text String CSS to be appended |
— | — | @@ -191,17 +213,6 @@ |
192 | 214 | }, |
193 | 215 | |
194 | 216 | /** |
195 | | - * Get the link to a page name (relative to wgServer) |
196 | | - * |
197 | | - * @param str Page name to get the link for. |
198 | | - * @return string Location for a page with name of 'str' or boolean false on error. |
199 | | - */ |
200 | | - 'wikiGetlink' : function( str ) { |
201 | | - |
202 | | - return mw.config.get( 'wgArticlePath' ).replace( '$1', this.wikiUrlencode( str ) ); |
203 | | - }, |
204 | | - |
205 | | - /** |
206 | 217 | * Grab the URL parameter value for the given parameter. |
207 | 218 | * Returns null if not found. |
208 | 219 | * Beware! When action paths are enabled (wgActionPaths) using this function |