http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94644

Revision: 94644
Author:   catrope
Date:     2011-08-16 15:22:35 +0000 (Tue, 16 Aug 2011)
Log Message:
-----------
1.18: Back out mw.Title, which isn't used by anything in 1.18 (AJAXCategories 
was backed out, UploadWizard has its own copy) and which has some strangely 
named public functions we'll probably want to change in 1.19. This reverts 
almost all of r90331 (which introduced mw.Title; the other revs to it were 
post-branch), only the changes to jquery.qunit.completenessTest.js (don't 
descend into a constructor) were left in.

Modified Paths:
--------------
    branches/REL1_18/phase3/RELEASE-NOTES-1.18
    branches/REL1_18/phase3/resources/Resources.php
    branches/REL1_18/phase3/tests/qunit/data/testrunner.js
    branches/REL1_18/phase3/tests/qunit/index.html

Removed Paths:
-------------
    branches/REL1_18/phase3/resources/mediawiki/mediawiki.Title.js
    
branches/REL1_18/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.Title.js

Modified: branches/REL1_18/phase3/RELEASE-NOTES-1.18
===================================================================
--- branches/REL1_18/phase3/RELEASE-NOTES-1.18  2011-08-16 15:17:35 UTC (rev 
94643)
+++ branches/REL1_18/phase3/RELEASE-NOTES-1.18  2011-08-16 15:22:35 UTC (rev 
94644)
@@ -175,7 +175,6 @@
 * (bug 28904) (bug 29773) Update jQuery version from 1.4.4 to 1.6.2 (the 
latest version)
 * (bug 29441) Expose CapitalLinks config in JS to allow modules to properly
   handle titles on case-sensitive wikis.
-* (bug 29397) Implement mw.Title module in core.
 * In MySQL 4.1.9+ with replication enabled, the slave lag should come from
   SHOW SLAVE STATUS instead of SHOW PROCESSLIST.
 * Language codes in $wgDummyLanguageCodes are now excluded on localization

Modified: branches/REL1_18/phase3/resources/Resources.php
===================================================================
--- branches/REL1_18/phase3/resources/Resources.php     2011-08-16 15:17:35 UTC 
(rev 94643)
+++ branches/REL1_18/phase3/resources/Resources.php     2011-08-16 15:22:35 UTC 
(rev 94644)
@@ -448,9 +448,6 @@
        'mediawiki.htmlform' => array(
                'scripts' => 'resources/mediawiki/mediawiki.htmlform.js',
        ),
-       'mediawiki.Title' => array(
-               'scripts' => 'resources/mediawiki/mediawiki.Title.js',
-       ),
        'mediawiki.user' => array(
                'scripts' => 'resources/mediawiki/mediawiki.user.js',
                'dependencies' => array(

Deleted: branches/REL1_18/phase3/resources/mediawiki/mediawiki.Title.js
===================================================================
--- branches/REL1_18/phase3/resources/mediawiki/mediawiki.Title.js      
2011-08-16 15:17:35 UTC (rev 94643)
+++ branches/REL1_18/phase3/resources/mediawiki/mediawiki.Title.js      
2011-08-16 15:22:35 UTC (rev 94644)
@@ -1,316 +0,0 @@
-/**
- * mediaWiki.Title
- *
- * @author Neil Kandalgaonkar, 2010
- * @author Timo Tijhof, 2011
- * @since 1.18
- *
- * Relies on: mw.config (wgFormattedNamespaces, wgNamespaceIds, 
wgCaseSensitiveNamespaces), mw.util.wikiGetlink
- */
-(function( $ ) {
-
-       /* Local space */
-
-       /**
-        * Title
-        * @constructor
-        *
-        * @param title {String} Title of the page. If no second argument given,
-        * this will be searched for a namespace.
-        * @param namespace {Number} (optional) Namespace id. If given, title 
will be taken as-is.
-        * @return {Title} this
-        */
-var    Title = function( title, namespace ) {
-                       this._ns = 0; // integer namespace id
-                       this._name = null; // name in canonical 'database' form
-                       this._ext = null; // extension
-
-                       if ( arguments.length === 2 ) {
-                               this.setNameAndExtension( title 
).setNamespaceById( namespace );
-                       } else if ( arguments.length === 1 ) {
-                               // If title is like "Blabla: Hello" ignore 
exception by setNamespace(),
-                               // and instead assume NS_MAIN and keep prefix
-                               try {
-                                       this.setAll( title );
-                               } catch(e) {
-                                       this.setNameAndExtension( title );
-                               }
-                       }
-                       return this;
-       },
-
-       /**
-        * Strip some illegal chars: control chars, colon, less than, greater 
than,
-        * brackets, braces, pipe, whitespace and normal spaces. This still 
leaves some insanity
-        * intact, like unicode bidi chars, but it's a good start..
-        * @param s {String}
-        * @return {String}
-        */
-       clean = function( s ) {
-               if ( s !== undefined ) {
-                       return s.replace( 
/[\x00-\x1f\x23\x3c\x3e\x5b\x5d\x7b\x7c\x7d\x7f\s]+/g, '_' );
-               }
-       },
-
-       /**
-        * Convert db-key to readable text.
-        * @param s {String}
-        * @return {String}
-        */
-       text = function ( s ) {
-               if ( s !== null && s !== undefined ) {
-                       return s.replace( /_/g, ' ' );
-               } else {
-                       return '';
-               }
-       };
-
-       /* Static space */
-
-       /**
-        * Wether this title exists on the wiki.
-        * @param title {mixed} prefixed db-key name (string) or instance of 
Title
-        * @return {mixed} Boolean true/false if the information is available. 
Otherwise null.
-        */
-       Title.exists = function( title ) {
-               var     type = $.type( title ), obj = Title.exist.pages, match;
-               if ( type === 'string' ) {
-                       match = obj[title];
-               } else if ( type === 'object' && title instanceof Title ) {
-                       match = obj[title.toString()];
-               } else {
-                       throw new Error( 'mw.Title.exists: title must be a 
string or an instance of Title' );
-               }
-               if ( typeof match === 'boolean' ) {
-                       return match;
-               }
-               return null;
-       };
-
-       /**
-        * @var Title.exist {Object}
-        */
-       Title.exist = {
-               /**
-                * @var Title.exist.pages {Object} Keyed by PrefixedDb title.
-                * Boolean true value indicates page does exist.
-                */
-               pages: {},
-               /**
-                * @example Declare existing titles: 
Title.exist.set(['User:John_Doe', ...]);
-                * @example Declare titles inexisting: 
Title.exist.set(['File:Foo_bar.jpg', ...], false);
-                * @param titles {String|Array} Title(s) in strict prefixedDb 
title form.
-                * @param state {Boolean} (optional) State of the given titles. 
Defaults to true.
-                * @return {Boolean}
-                */
-               set: function( titles, state ) {
-                       titles = $.isArray( titles ) ? titles : [titles];
-                       state = state === undefined ? true : !!state;
-                       var     pages = this.pages, i, len = titles.length;
-                       for ( i = 0; i < len; i++ ) {
-                               pages[ titles[i] ] = state;
-                       }
-                       return true;
-               }
-       };
-
-       /* Public methods */
-
-       var fn = {
-               constructor: Title,
-               /**
-                * @param id {Number} Canonical namespace id.
-                * @return {mw.Title} this
-                */
-               setNamespaceById: function( id ) {
-                       // wgFormattedNamespaces is an object of *string* 
key-vals,
-                       var ns = mw.config.get( 'wgFormattedNamespaces' 
)[id.toString()];
-
-                       // Cannot cast to boolean, ns may be '' (main namespace)
-                       if ( ns === undefined ) {
-                               this._ns = false;
-                       } else {
-                               this._ns = Number( id );
-                       }
-                       return this;
-               },
-
-               /**
-                * Set namespace by any known namespace/id pair (localized, 
canonical or alias)
-                * On a German wiki this could be 'File', 'Datei', 'Image' or 
even 'Bild' for NS_FILE.
-                * @param ns {String} A namespace name (case insensitive, space 
insensitive)
-                * @return {mw.Title} this
-                */
-               setNamespace: function( ns ) {
-                       ns = clean( $.trim( ns.toLowerCase() ) ); // Normalize
-                       var id = mw.config.get( 'wgNamespaceIds' )[ns];
-                       if ( id === undefined ) {
-                               throw new Error( 'mw.Title: Unrecognized 
canonical namespace: ' + ns );
-                       }
-                       return this.setNamespaceById( id );
-               },
-
-               /**
-                * Get the namespace number.
-                * @return {Number}
-                */
-               getNamespaceId: function(){
-                       return this._ns;
-               },
-
-               /**
-                * Get the namespace prefix (in the content-language).
-                * In NS_MAIN this is '', otherwise namespace name plus ':'
-                * @return {String}
-                */
-               getNamespacePrefix: function(){
-                       return mw.config.get( 'wgFormattedNamespaces' 
)[this._ns].replace( / /g, '_' ) + (this._ns === 0 ? '' : ':');
-               },
-
-               /**
-                * Set the "name" portion, removing illegal characters.
-                * @param s {String} Page name (without namespace prefix)
-                * @return {mw.Title} this
-                */
-               setName: function( s ) {
-                       this._name = clean( $.trim( s ) );
-                       return this;
-               },
-
-               /**
-                * The name, like "Foo_bar"
-                * @return {String}
-                */
-               getName: function() {
-                       if ( $.inArray( this._ns, mw.config.get( 
'wgCaseSensitiveNamespaces' ) ) !== -1 ) {
-                               return this._name;
-                       } else {
-                               return $.ucFirst( this._name );
-                       }
-               },
-
-               /**
-                * The name, like "Foo bar"
-                * @return {String}
-                */
-               getNameText: function() {
-                       return text( this.getName() );
-               },
-
-               /**
-                * Get full name in prefixed DB form, like File:Foo_bar.jpg,
-                * most useful for API calls, anything that must identify the 
"title".
-                */
-               getPrefixedDb: function() {
-                       return this.getNamespacePrefix() + this.getMain();
-               },
-
-               /**
-                * Get full name in text form, like "File:Foo bar.jpg".
-                * @return {String}
-                */
-               getPrefixedText: function() {
-                       return text( this.getPrefixedDb() );
-               },
-
-               /**
-                * The main title (without namespace), like "Foo_bar.jpg"
-                * @return {String}
-                */
-               getMain: function() {
-                       return this.getName() + this.getDotExtension();
-               },
-
-               /**
-                * The "text" form, like "Foo bar.jpg"
-                * @return {String}
-                */
-               getMainText: function() {
-                       return text( this.getMain() );
-               },
-
-               /**
-                * Set the "extension" portion, removing illegal characters.
-                * @param s {String}
-                * @return {mw.Title} this
-                */
-               setExtension: function( s ) {
-                       this._ext = clean( s.toLowerCase() );
-                       return this;
-               },
-
-               /**
-                * Get the extension (returns null if there was none)
-                * @return {String|null} extension
-                */
-               getExtension: function() {
-                       return this._ext;
-               },
-
-               /**
-                * Convenience method: return string like ".jpg", or "" if no 
extension
-                * @return {String}
-                */
-               getDotExtension: function() {
-                       return this._ext === null ? '' : '.' + this._ext;
-               },
-
-               /**
-                * @param s {String}
-                * @return {mw.Title} this
-                */
-               setAll: function( s ) {
-                       var matches = s.match( 
/^(?:([^:]+):)?(.*?)(?:\.(\w{1,5}))?$/ );
-                       if ( matches.length ) {
-                               if ( matches[1] ) { this.setNamespace( 
matches[1] ); }
-                               if ( matches[2] ) { this.setName( matches[2] ); 
}
-                               if ( matches[3] ) { this.setExtension( 
matches[3] ); }
-                       } else {
-                               throw new Error( 'mw.Title: Could not parse 
title "' + s + '"' );
-                       }
-                       return this;
-               },
-
-               /**
-                * @param s {String}
-                * @return {mw.Title} this
-                */
-               setNameAndExtension: function( s ) {
-                       var matches = s.match( /^(?:)?(.*?)(?:\.(\w{1,5}))?$/ );
-                       if ( matches.length ) {
-                               if ( matches[1] ) { this.setName( matches[1] ); 
}
-                               if ( matches[2] ) { this.setExtension( 
matches[2] ); }
-                       } else {
-                               throw new Error( 'mw.Title: Could not parse 
title "' + s + '"' );
-                       }
-                       return this;
-               },
-
-               /**
-                * Return the URL to this title
-                * @return {String}
-                */
-               getUrl: function() {
-                       return mw.util.wikiGetlink( this.toString() );
-               },
-
-               /**
-                * Wether this title exists on the wiki.
-                * @return {mixed} Boolean true/false if the information is 
available. Otherwise null.
-                */
-               exists: function() {
-                       return Title.exists( this );
-               }
-       };
-
-       // Alias
-       fn.toString = fn.getPrefixedDb;
-       fn.toText = fn.getPrefixedText;
-
-       // Assign
-       Title.prototype = fn;
-
-       // Expose
-       mw.Title = Title;
-
-})(jQuery);

Modified: branches/REL1_18/phase3/tests/qunit/data/testrunner.js
===================================================================
--- branches/REL1_18/phase3/tests/qunit/data/testrunner.js      2011-08-16 
15:17:35 UTC (rev 94643)
+++ branches/REL1_18/phase3/tests/qunit/data/testrunner.js      2011-08-16 
15:22:35 UTC (rev 94644)
@@ -33,10 +33,6 @@
                        tester.methodCallTracker['Map'] = true;
                        return true;
                }
-               if ( val instanceof mw.Title ) {
-                       tester.methodCallTracker['Title'] = true;
-                       return true;
-               }
 
                // Don't record methods of the properties of a jQuery object
                if ( val instanceof $ ) {

Modified: branches/REL1_18/phase3/tests/qunit/index.html
===================================================================
--- branches/REL1_18/phase3/tests/qunit/index.html      2011-08-16 15:17:35 UTC 
(rev 94643)
+++ branches/REL1_18/phase3/tests/qunit/index.html      2011-08-16 15:22:35 UTC 
(rev 94644)
@@ -47,7 +47,6 @@
        <script src="../../resources/jquery/jquery.localize.js"></script>
        <script src="../../resources/jquery/jquery.tabIndex.js"></script>
        <script src="../../resources/jquery/jquery.tablesorter.js"></script>
-       <script src="../../resources/mediawiki/mediawiki.Title.js"></script>
        <script 
src="../../resources/mediawiki.special/mediawiki.special.js"></script>
        <script 
src="../../resources/mediawiki.special/mediawiki.special.recentchanges.js"></script>
 
@@ -73,7 +72,6 @@
        <script src="suites/resources/jquery/jquery.localize.js"></script>
        <script src="suites/resources/jquery/jquery.tabIndex.js"></script>
        <script src="suites/resources/jquery/jquery.tablesorter.test.js" 
charset="UTF-8"></script>
-       <script src="suites/resources/mediawiki/mediawiki.Title.js"></script>
        <script 
src="suites/resources/mediawiki.special/mediawiki.special.recentchanges.js"></script>
 </head>
 <body>

Deleted: 
branches/REL1_18/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.Title.js
===================================================================
--- 
branches/REL1_18/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.Title.js
   2011-08-16 15:17:35 UTC (rev 94643)
+++ 
branches/REL1_18/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.Title.js
   2011-08-16 15:22:35 UTC (rev 94644)
@@ -1,136 +0,0 @@
-module( 'mediawiki.Title.js' );
-
-// mw.Title relies on these three config vars
-// Restore them after each test run
-var _titleConfig = function() {
-
-       mw.config.set({
-               "wgFormattedNamespaces": {
-                       "-2": "Media",
-                       "-1": "Special",
-                       "0": "",
-                       "1": "Talk",
-                       "2": "User",
-                       "3": "User talk",
-                       "4": "Wikipedia",
-                       "5": "Wikipedia talk",
-                       "6": "File",
-                       "7": "File talk",
-                       "8": "MediaWiki",
-                       "9": "MediaWiki talk",
-                       "10": "Template",
-                       "11": "Template talk",
-                       "12": "Help",
-                       "13": "Help talk",
-                       "14": "Category",
-                       "15": "Category talk",
-                       /* testing custom / localized */
-                       "100": "Penguins"
-               },
-               "wgNamespaceIds": {
-                       "media": -2,
-                       "special": -1,
-                       "": 0,
-                       "talk": 1,
-                       "user": 2,
-                       "user_talk": 3,
-                       "wikipedia": 4,
-                       "wikipedia_talk": 5,
-                       "file": 6,
-                       "file_talk": 7,
-                       "mediawiki": 8,
-                       "mediawiki_talk": 9,
-                       "template": 10,
-                       "template_talk": 11,
-                       "help": 12,
-                       "help_talk": 13,
-                       "category": 14,
-                       "category_talk": 15,
-                       "image": 6,
-                       "image_talk": 7,
-                       "project": 4,
-                       "project_talk": 5,
-                       /* testing custom / alias */
-                       "penguins": 100,
-                       "antarctic_waterfowl": 100
-               },
-               "wgCaseSensitiveNamespaces": []
-       });
-};
-
-test( '-- Initial check', function() {
-       expect(1);
-       ok( mw.Title, 'mw.Title defined' );
-});
-
-test( 'Filename', function() {
-       expect(4);
-       _titleConfig();
-
-       var title = new mw.Title( 'File:foo_bar.JPG' );
-
-       equal( title.getMain(), 'Foo_bar.jpg' );
-       equal( title.getMainText(), 'Foo bar.jpg' );
-       equal( title.getNameText(), 'Foo bar' );
-       equal( title.toString(), 'File:Foo_bar.jpg' );
-});
-
-test( 'Transform between Text to Db', function() {
-       expect(6);
-       _titleConfig();
-
-       var title = new mw.Title( 'File:foo_bar.JPG' );
-       title.setName( 'quux pif' );
-
-       equal( title.getMain(), 'Quux_pif.jpg' );
-       equal( title.getMainText(), 'Quux pif.jpg' );
-       equal( title.getNameText(), 'Quux pif' );
-       equal( title.toString(), 'File:Quux_pif.jpg' );
-
-       title.setName( 'glarg_foo_glang' );
-
-       equal( title.toString(), 'File:Glarg_foo_glang.jpg' );
-       equal( title.getMainText(), 'Glarg foo glang.jpg' );
-});
-
-test( 'Initiate from name and set namespace', function() {
-       expect(1);
-       _titleConfig();
-
-       var title = new mw.Title( 'catalonian_penguins.PNG' );
-       title.setNamespace( 'file' );
-       equal( title.toString(), 'File:Catalonian_penguins.png' );
-});
-
-test( 'Namespace detection and conversion', function() {
-       expect(7);
-       _titleConfig();
-
-       var title;
-
-       title = new mw.Title( 'something.PDF' );
-       title.setNamespace( 'file' );
-       equal( title.toString(), 'File:Something.pdf' );
-
-       title = new mw.Title( 'NeilK' );
-       title.setNamespace( 'user_talk' );
-       equal( title.toString(), 'User_talk:NeilK' );
-       equal( title.toText(), 'User talk:NeilK' );
-
-       title = new mw.Title( 'Frobisher' );
-       title.setNamespaceById( 100 );
-       equal( title.toString(), 'Penguins:Frobisher' );
-
-       title = new mw.Title( 'flightless_yet_cute.jpg' );
-       title.setNamespace( 'antarctic_waterfowl' );
-       equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
-
-       title = new mw.Title( 'flightless_yet_cute.jpg' );
-       title.setNamespace( 'Penguins' );
-       equal( title.toString(), 'Penguins:Flightless_yet_cute.jpg' );
-
-       title = new mw.Title( 'flightless_yet_cute.jpg' );
-       raises( function() {
-               title.setNamespace( 'Entirely Unknown' );
-       });
-});


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to