Rename mw.util.wikiGetlink to getUrl
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 18 Oct 2013 17:02:59 +0000 (19:02 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 7 Nov 2013 15:40:11 +0000 (16:40 +0100)
Old name still works, but is deprecated.

The new one has the nice property of being the same as a function
defined on mw.Title which does the same thing.

Replaced all occurences throughout the codebase.

Bug: 55764
Change-Id: I8704a6620ece44d374e199c05464b8a553e12e74

RELEASE-NOTES-1.23
resources/mediawiki.page/mediawiki.page.watch.ajax.js
resources/mediawiki/mediawiki.Title.js
resources/mediawiki/mediawiki.jqueryMsg.js
resources/mediawiki/mediawiki.util.js
tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js

index efb0805..74a5905 100644 (file)
@@ -48,6 +48,8 @@ changes to languages because of Bugzilla reports.
 
 === Other changes in 1.23 ===
 * The global variable $wgArticle has been removed after a lengthy deprecation
+* mediawiki.util: mw.util.wikiGetlink has been renamed to getUrl. (The old name still
+  works, but is deprecated.)
 
 == Compatibility ==
 
index 545cd07..e9afa4a 100644 (file)
                                        cleanTitle = title.replace( /_/g, ' ' );
                                        link = mw.html.element(
                                                'a', {
-                                                       href: mw.util.wikiGetlink( title ),
+                                                       href: mw.util.getUrl( title ),
                                                        title: cleanTitle
                                                }, cleanTitle
                                        );
index 4a64566..dde5abf 100644 (file)
                /**
                 * Get the URL to this title
                 *
-                * @see mw.util#wikiGetlink
+                * @see mw.util#getUrl
                 * @return {string}
                 */
                getUrl: function () {
-                       return mw.util.wikiGetlink( this.toString() );
+                       return mw.util.getUrl( this.toString() );
                },
 
                /**
index b634917..70b9be9 100644 (file)
                        var page, anchor, url;
 
                        page = nodes[0];
-                       url = mw.util.wikiGetlink( page );
+                       url = mw.util.getUrl( page );
 
                        // [[Some Page]] or [[Namespace:Some Page]]
                        if ( nodes.length === 1 ) {
index 4334a9f..259f1c8 100644 (file)
                 *     e.g. { action: 'edit' }. Optional.
                 * @return {string} Location for a page with name of `str` or boolean false on error.
                 */
-               wikiGetlink: function ( str, params ) {
+               getUrl: function ( str, params ) {
                        var url = mw.config.get( 'wgArticlePath' ).replace( '$1',
                                util.wikiUrlencode( typeof str === 'string' ? str : mw.config.get( 'wgPageName' ) ) );
                        if ( params && !$.isEmptyObject( params ) ) {
                }
        };
 
+       /**
+        * @method wikiGetlink
+        * @inheritdoc #getUrl
+        * @deprecated since 1.23 Use #getUrl instead.
+        */
+       mw.log.deprecate( util, 'wikiGetlink', util.getUrl, 'Use mw.util.getUrl instead.' );
+
        mw.util = util;
 
 }( mediaWiki, jQuery ) );
index 13c0efc..f0bb0fc 100644 (file)
                mw.config.set( 'wgArticlePath', '/wiki/$1' );
 
                title = new mw.Title( 'Foobar' );
-               assert.equal( title.getUrl(), '/wiki/Foobar', 'Basic functionally, toString passing to wikiGetlink' );
+               assert.equal( title.getUrl(), '/wiki/Foobar', 'Basic functionally, getUrl uses mw.util.getUrl' );
 
                title = new mw.Title( 'John Doe', 3 );
                assert.equal( title.getUrl(), '/wiki/User_talk:John_Doe', 'Escaping in title and namespace for urls' );
index e0e823d..be362e2 100644 (file)
@@ -585,7 +585,7 @@ QUnit.test( 'HTML', 26, function ( assert ) {
 
        assert.htmlEqual(
                formatParse( 'jquerymsg-italics-with-link' ),
-               'An <i>italicized <a title="link" href="' + mw.html.escape( mw.util.wikiGetlink( 'link' ) ) + '">wiki-link</i>',
+               'An <i>italicized <a title="link" href="' + mw.html.escape( mw.util.getUrl( 'link' ) ) + '">wiki-link</i>',
                'Italics with link inside in parse mode'
        );
 
@@ -625,7 +625,7 @@ QUnit.test( 'HTML', 26, function ( assert ) {
        mw.messages.set( 'jquerymsg-script-link-msg', '<script>[[Foo|bar]]</script>' );
        assert.htmlEqual(
                formatParse( 'jquerymsg-script-link-msg' ),
-               '&lt;script&gt;<a title="Foo" href="' + mw.html.escape( mw.util.wikiGetlink( 'Foo' ) ) + '">bar</a>&lt;/script&gt;',
+               '&lt;script&gt;<a title="Foo" href="' + mw.html.escape( mw.util.getUrl( 'Foo' ) ) + '">bar</a>&lt;/script&gt;',
                'Script tag text is escaped because that element is not allowed, but link inside is still HTML'
        );
 
index 502b55b..bd4d1d2 100644 (file)
                );
                assert.htmlEqual(
                        mw.message( 'mediawiki-italics-with-link' ).parse(),
-                       'An <i>italicized <a title="link" href="' + mw.util.wikiGetlink( 'link' ) + '">wiki-link</i>',
+                       'An <i>italicized <a title="link" href="' + mw.util.getUrl( 'link' ) + '">wiki-link</i>',
                        'Italics with link inside in parse mode'
                );
 
index 08adb93..2be8044 100644 (file)
                assert.equal( mw.util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' );
        } );
 
-       QUnit.test( 'wikiGetlink', 4, function ( assert ) {
+       QUnit.test( 'getUrl', 4, function ( assert ) {
                // Not part of startUp module
                mw.config.set( 'wgArticlePath', '/wiki/$1' );
                mw.config.set( 'wgPageName', 'Foobar' );
 
-               var href = mw.util.wikiGetlink( 'Sandbox' );
+               var href = mw.util.getUrl( 'Sandbox' );
                assert.equal( href, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' );
 
-               href = mw.util.wikiGetlink( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' );
+               href = mw.util.getUrl( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' );
                assert.equal( href, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage',
                        'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' );
 
-               href = mw.util.wikiGetlink();
+               href = mw.util.getUrl();
                assert.equal( href, '/wiki/Foobar', 'Default title; Get link for current page ("Foobar")' );
 
-               href = mw.util.wikiGetlink( 'Sandbox', { action: 'edit' } );
+               href = mw.util.getUrl( 'Sandbox', { action: 'edit' } );
                assert.equal( href, '/wiki/Sandbox?action=edit',
                        'Simple title with query string; Get link for "Sandbox" with action=edit' );
        } );