Index: trunk/extensions/UploadWizard/test/jasmine/SpecRunner.html |
— | — | @@ -14,9 +14,9 @@ |
15 | 15 | <script type="text/javascript" src="../../../../resources/mediawiki.language/mediawiki.language.js"></script> |
16 | 16 | <script type="text/javascript" src="../../../../resources/mediawiki/mediawiki.Uri.js"></script> |
17 | 17 | <script type="text/javascript" src="../../resources/mediawiki.language.parser.js"></script> |
18 | | - <script type="text/javascript" src="../../resources/mw.Api.js"></script> |
19 | | - <script type="text/javascript" src="../../resources/mw.Api.edit.js"></script> |
20 | | - <script type="text/javascript" src="../../resources/mw.Title.js"></script> |
| 18 | + <script type="text/javascript" src="../../../../resources/mediawiki/mediawiki.api.js"></script> |
| 19 | + <script type="text/javascript" src="../../../../resources/mediawiki/mediawiki.api.edit.js"></script> |
| 20 | + <script type="text/javascript" src="../../../../resources/mediawiki/mediawiki.Title.js"></script> |
21 | 21 | <script type="text/javascript" src="../../resources/mw.units.js"></script> |
22 | 22 | <script type="text/javascript" src="../../resources/jquery/jquery.pubsub.js"></script> |
23 | 23 | |
Index: trunk/extensions/UploadWizard/test/jasmine/spec/mw.Title.spec.js |
— | — | @@ -1,112 +0,0 @@ |
2 | | -( function( mw ) { |
3 | | - describe( "mw.Title", function() { |
4 | | - |
5 | | - // these are typically initialized as globals... |
6 | | - wgFormattedNamespaces = { |
7 | | - "-2":"Media", |
8 | | - "-1":"Special", |
9 | | - "0":"", |
10 | | - "1":"Talk", |
11 | | - "2":"User", |
12 | | - "3":"User talk", |
13 | | - "4":"CommonsDev", |
14 | | - "5":"CommonsDev talk", |
15 | | - "6":"File", |
16 | | - "7":"File talk", |
17 | | - "8":"MediaWiki", |
18 | | - "9":"MediaWiki talk", |
19 | | - "10":"Template", |
20 | | - "11":"Template talk", |
21 | | - "12":"Help", |
22 | | - "13":"Help talk", |
23 | | - "14":"Category", |
24 | | - "15":"Category talk", |
25 | | - /* testing custom / localized */ |
26 | | - "99":"Penguins" |
27 | | - }; |
28 | | - wgNamespaceIds = { |
29 | | - "media":-2, |
30 | | - "special":-1, |
31 | | - "":0, |
32 | | - "talk":1, |
33 | | - "user":2, |
34 | | - "user_talk":3, |
35 | | - "commonsdev":4, |
36 | | - "commonsdev_talk":5, |
37 | | - "file":6, |
38 | | - "file_talk":7, |
39 | | - "mediawiki":8, |
40 | | - "mediawiki_talk":9, |
41 | | - "template":10, |
42 | | - "template_talk":11, |
43 | | - "help":12, |
44 | | - "help_talk":13, |
45 | | - "category":14, |
46 | | - "category_talk":15, |
47 | | - "image":6, |
48 | | - "image_talk":7, |
49 | | - /* testing custom / localized */ |
50 | | - "antarctic_waterfowl":99 |
51 | | - }; |
52 | | - |
53 | | - |
54 | | - describe( "basic" , function() { |
55 | | - |
56 | | - it( "should initialize from filename", function() { |
57 | | - var title = new mw.Title( "File:foo_bar.JPG" ); |
58 | | - expect( title.getMain() ).toEqual( 'Foo_bar.jpg' ); |
59 | | - expect( title.getMainText() ).toEqual( 'Foo bar.jpg' ); |
60 | | - expect( title.getNameText() ).toEqual( 'Foo bar' ); |
61 | | - expect( title.toString() ).toEqual( "File:Foo_bar.jpg" ); |
62 | | - } ); |
63 | | - |
64 | | - it( "should translate back and forth between human-readable and not", function() { |
65 | | - var title = new mw.Title( "File:foo_bar.JPG" ); |
66 | | - title.setName( "quux pif" ); |
67 | | - expect( title.getMain() ).toEqual( "Quux_pif.jpg" ); |
68 | | - expect( title.getMainText() ).toEqual( "Quux pif.jpg" ); |
69 | | - expect( title.getNameText() ).toEqual( "Quux pif" ); |
70 | | - expect( title.toString() ).toEqual( "File:Quux_pif.jpg" ); |
71 | | - title.setName( "glarg_foo_glang" ); |
72 | | - expect( title.toString() ).toEqual( "File:Glarg_foo_glang.jpg" ); |
73 | | - expect( title.getMainText() ).toEqual( "Glarg foo glang.jpg" ); |
74 | | - } ); |
75 | | - |
76 | | - it( "should allow initialization from filename + namespace", function() { |
77 | | - var title = new mw.Title( "catalonian_penguins.PNG" ); |
78 | | - title.setNamespace( 'file' ); |
79 | | - expect( title.toString() ).toEqual( "File:Catalonian_penguins.png" ); |
80 | | - } ); |
81 | | - |
82 | | - it( "should allow initialization using mediawiki global namespaces", function() { |
83 | | - var title = new mw.Title( "something.PDF" ); |
84 | | - title.setNamespace( 'file' ); |
85 | | - expect( title.toString() ).toEqual( "File:Something.pdf" ); |
86 | | - |
87 | | - title = new mw.Title( "NeilK" ); |
88 | | - title.setNamespace( 'user_talk' ); |
89 | | - expect( title.toString() ).toEqual( "User_talk:NeilK" ); |
90 | | - expect( title.toText() ).toEqual( "User talk:NeilK" ); |
91 | | - |
92 | | - title = new mw.Title( "Frobisher" ); |
93 | | - title.setNamespaceById( 99 ); |
94 | | - expect( title.toString() ).toEqual( "Penguins:Frobisher" ); |
95 | | - |
96 | | - title = new mw.Title( "flightless_yet_cute.jpg" ); |
97 | | - title.setNamespace( "antarctic_waterfowl" ); |
98 | | - expect( title.toString() ).toEqual( "Penguins:Flightless_yet_cute.jpg" ); |
99 | | - |
100 | | - title = new mw.Title( "flightless_yet_cute.jpg" ); |
101 | | - title.setPrefix( "Penguins" ); |
102 | | - expect( title.toString() ).toEqual( "Penguins:Flightless_yet_cute.jpg" ); |
103 | | - |
104 | | - title = new mw.Title( "flightless_yet_cute.jpg" ); |
105 | | - expect( function() { |
106 | | - title.setPrefix( "Entirely Unknown" ); |
107 | | - } ).toThrow( "unrecognized namespace prefix" ); |
108 | | - } ); |
109 | | - |
110 | | - } ); |
111 | | - |
112 | | - } ); |
113 | | -} )( mediaWiki ); |
Index: trunk/extensions/UploadWizard/UploadWizardHooks.php |
— | — | @@ -28,9 +28,15 @@ |
29 | 29 | 'mediawiki.util', |
30 | 30 | 'mediawiki.libs.jpegmeta', |
31 | 31 | 'ext.uploadwizard.mediawiki.language.parser', |
| 32 | + 'mediawiki.api', |
| 33 | + 'mediawiki.api.edit', |
| 34 | + 'mediawiki.api.category', |
| 35 | + 'mediawiki.api.parse', |
| 36 | + 'mediawiki.api.titleblacklist', |
| 37 | + 'mediawiki.Title', |
| 38 | + 'mediawiki.feedback' |
32 | 39 | ), |
33 | 40 | 'scripts' => array( |
34 | | - |
35 | 41 | // jquery interface helpers |
36 | 42 | 'resources/jquery/jquery.tipsy.js', |
37 | 43 | 'resources/jquery/jquery.morphCrossfade.js', |
— | — | @@ -48,13 +54,6 @@ |
49 | 55 | 'resources/mw.canvas.js', |
50 | 56 | 'resources/mw.Log.js', |
51 | 57 | 'resources/mw.UtilitiesTime.js', |
52 | | - 'resources/mw.Api.js', |
53 | | - 'resources/mw.Api.edit.js', |
54 | | - 'resources/mw.Api.category.js', |
55 | | - 'resources/mw.Api.parse.js', |
56 | | - 'resources/mw.Api.titleblacklist.js', |
57 | | - 'resources/mw.Title.js', |
58 | | - 'resources/mw.Feedback.js', |
59 | 58 | 'resources/mw.ErrorDialog.js', |
60 | 59 | 'resources/mw.ConfirmCloseWindow.js', |
61 | 60 | |
Index: trunk/extensions/UploadWizard/resources/jquery/jquery.mwCoolCats.js |
— | — | @@ -12,6 +12,8 @@ |
13 | 13 | */ |
14 | 14 | ( function ( $j ) { $j.fn.mwCoolCats = function( options ) { |
15 | 15 | |
| 16 | + var catNsId = mw.config.get( 'wgNamespaceIds' ).category; |
| 17 | + |
16 | 18 | /** |
17 | 19 | * Get content from our text field, and attempt to insert it as a category. |
18 | 20 | * May require confirmation from user if they appear to be adding a new category. |
— | — | @@ -23,7 +25,7 @@ |
24 | 26 | return; |
25 | 27 | } |
26 | 28 | |
27 | | - var title = new mw.Title( text, 'category' ); |
| 29 | + var title = new mw.Title( text, catNsId ); |
28 | 30 | |
29 | 31 | var insertIt = function() { |
30 | 32 | _insertCat( title ); |
— | — | @@ -228,8 +230,8 @@ |
229 | 231 | }; |
230 | 232 | |
231 | 233 | // initialize with some categories, if so configured |
232 | | - $j.each( settings.cats, function( i, cat ) { _insertCat( new mw.Title( cat, 'category' ) ); } ); |
233 | | - $j.each( settings.hiddenCats, function( i, cat ) { _insertCat( new mw.Title( cat, 'category' ), true ); } ); |
| 234 | + $j.each( settings.cats, function( i, cat ) { _insertCat( new mw.Title( cat, catNsId ) ); } ); |
| 235 | + $j.each( settings.hiddenCats, function( i, cat ) { _insertCat( new mw.Title( cat, catNsId ), true ); } ); |
234 | 236 | |
235 | 237 | _processInput(); |
236 | 238 | } ); |
Index: trunk/extensions/UploadWizard/resources/mw.FirefoggHandler.js |
— | — | @@ -17,13 +17,14 @@ |
18 | 18 | var _this = this; |
19 | 19 | this.upload = upload; |
20 | 20 | this.api = upload.api; |
| 21 | + var fileNsId = mw.config.get( 'wgNamespaceIds' ).file; |
21 | 22 | // pass file to Firefogg after selection |
22 | 23 | this.upload.ui.$fileInputCtrl.bind('change', function(event) { |
23 | 24 | if(_this.upload.ui.$fileInputCtrl[0].files.length) { |
24 | 25 | _this.getFogg().setInput(_this.upload.ui.$fileInputCtrl[0].files[0]); |
25 | 26 | //This is required to get the right requestedTitle in UploadWizardUpload |
26 | 27 | var title = _this.getTransport().getFileName().replace( /:/g, '_' ); |
27 | | - _this.upload.title = new mw.Title( title , 'file' ); |
| 28 | + _this.upload.title = new mw.Title( title, fileNsId ); |
28 | 29 | } |
29 | 30 | }); |
30 | 31 | // update the "valid" extension to include firefogg transcode extensions: |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardLicenseInput.js |
— | — | @@ -14,8 +14,11 @@ |
15 | 15 | * @param {mw.Api} api object; useful for previews |
16 | 16 | */ |
17 | 17 | |
18 | | -( function( $j, undefined ) { |
| 18 | +( function( mw, $j, undefined ) { |
19 | 19 | |
| 20 | +var catNsId = mw.config.get( 'wgNamespaceIds' ).category, |
| 21 | + templateNsId = mw.config.get( 'wgNamespaceIds' ).template; |
| 22 | + |
20 | 23 | mw.UploadWizardLicenseInput = function( selector, values, config, count, api ) { |
21 | 24 | var _this = this; |
22 | 25 | _this.count = count; |
— | — | @@ -542,11 +545,11 @@ |
543 | 546 | // this proceeds synchronously, so we pick up in the next line |
544 | 547 | _this.api.getCategories( title, ok, err, false ); |
545 | 548 | } |
546 | | - |
547 | | - var licenseCategory = new mw.Title( mw.UploadWizard.config.licenseCategory, 'category' ); |
548 | 549 | |
| 550 | + var licenseCategory = new mw.Title( mw.UploadWizard.config.licenseCategory, catNsId ); |
| 551 | + |
549 | 552 | $.each( templates, function( i, t ) { |
550 | | - var title = new mw.Title( t, 'template' ); |
| 553 | + var title = new mw.Title( t, templateNsId ); |
551 | 554 | recurseCategories( licenseCategory, title, 5 ); |
552 | 555 | if ( found ) { |
553 | 556 | return false; |
— | — | @@ -583,4 +586,4 @@ |
584 | 587 | |
585 | 588 | }; |
586 | 589 | |
587 | | -} )( jQuery ); |
| 590 | +} )( window.mediaWiki, jQuery ); |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUpload.js |
— | — | @@ -7,6 +7,8 @@ |
8 | 8 | */ |
9 | 9 | ( function( $j, undefined ) { |
10 | 10 | |
| 11 | +var fileNsId = mw.config.get( 'wgNamespaceIds' ).file; |
| 12 | + |
11 | 13 | /** |
12 | 14 | * Constructor for objects representing uploads. The workhorse of this entire extension. |
13 | 15 | * |
— | — | @@ -155,7 +157,7 @@ |
156 | 158 | var existsFileName = result.upload.warnings.exists; |
157 | 159 | try { |
158 | 160 | code = 'exists'; |
159 | | - info = new mw.Title( existsFileName, 'file' ).getUrl(); |
| 161 | + info = new mw.Title( existsFileName, fileNsId ).getUrl(); |
160 | 162 | } catch ( e ) { |
161 | 163 | code = 'unknown'; |
162 | 164 | info = 'Warned about existing filename, but filename is unparseable: "' + existsFileName + "'"; |
— | — | @@ -226,7 +228,7 @@ |
227 | 229 | $j.each( duplicates, function( i, filename ) { |
228 | 230 | var $a = $j( '<a/>' ).append( filename ); |
229 | 231 | try { |
230 | | - var href = new mw.Title( filename, 'file' ).getUrl(); |
| 232 | + var href = new mw.Title( filename, fileNsId ).getUrl(); |
231 | 233 | $a.attr( { 'href': href, 'target': '_blank' } ); |
232 | 234 | } catch ( e ) { |
233 | 235 | $a.click( function() { alert('could not parse filename=' + filename ); } ); |
— | — | @@ -309,7 +311,7 @@ |
310 | 312 | } |
311 | 313 | |
312 | 314 | try { |
313 | | - this.title = new mw.Title( basename.replace( /:/g, '_' ), 'file' ); |
| 315 | + this.title = new mw.Title( basename.replace( /:/g, '_' ), fileNsId ); |
314 | 316 | } catch ( e ) { |
315 | 317 | fileNameErr( 'unparseable' ); |
316 | 318 | } |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js |
— | — | @@ -13,6 +13,8 @@ |
14 | 14 | */ |
15 | 15 | ( function( mw, $j, undefined ) { |
16 | 16 | |
| 17 | +var fileNsId = mw.config.get( 'wgNamespaceIds' ).file; |
| 18 | + |
17 | 19 | mw.UploadWizardDetails = function( upload, api, containerDiv ) { |
18 | 20 | |
19 | 21 | var _this = this; |
— | — | @@ -469,8 +471,8 @@ |
470 | 472 | var titleString; |
471 | 473 | var errHtml; |
472 | 474 | |
473 | | - try { |
474 | | - titleString = new mw.Title( result.title ).setNamespace( 'file' ).toString(); |
| 475 | + try { |
| 476 | + titleString = new mw.Title( result.title, fileNsId ).toString(); |
475 | 477 | } catch ( e ) { |
476 | 478 | // unparseable result from unique test? |
477 | 479 | titleString = '[unparseable name]'; |
— | — | @@ -1005,9 +1007,11 @@ |
1006 | 1008 | * @return {String} cleaned title with prefix and extension, stringified. |
1007 | 1009 | */ |
1008 | 1010 | setCleanTitle: function( s ) { |
| 1011 | + var ext = this.upload.title.getExtension(); |
1009 | 1012 | var re = new RegExp( '\\.' + this.upload.title.getExtension() + '$', 'i' ); |
1010 | 1013 | var cleaned = $j.trim( s.replace( re, '' ) ); |
1011 | | - return this.upload.title.setNameText( cleaned ).toString(); |
| 1014 | + this.upload.title = new mw.Title( cleaned + '.' + ext, fileNsId ); |
| 1015 | + return this.upload.title; |
1012 | 1016 | } |
1013 | 1017 | |
1014 | 1018 | }; |