Index: trunk/extensions/UploadWizard/SpecialUploadWizard.php |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | public function addJS() { |
96 | 96 | global $wgUser, $wgOut; |
97 | 97 | global $wgUseAjax, $wgAjaxLicensePreview, $wgEnableAPI; |
98 | | - global $wgEnableFirefogg, $wgFileExtensions; |
| 98 | + global $wgEnableFirefogg, $wgFileExtensions, $wgCanonicalNamespaceNames; |
99 | 99 | |
100 | 100 | $wgOut->addScript( Skin::makeVariablesScript( array( |
101 | 101 | // uncertain if this is relevant. Can we do license preview with API? |
— | — | @@ -106,8 +106,14 @@ |
107 | 107 | 'wgFileExtensions' => $wgFileExtensions, |
108 | 108 | |
109 | 109 | // our edit token |
110 | | - 'wgEditToken' => $wgUser->editToken() |
| 110 | + 'wgEditToken' => $wgUser->editToken(), |
111 | 111 | |
| 112 | + // URL prefixes in this MediaWiki, e.g. images under Image: |
| 113 | + 'wgCanonicalNamespaceNames' => $wgCanonicalNamespaceNames |
| 114 | + |
| 115 | + // 'wgFilenamePrefixBlacklist' => UploadBase::getFilenamePrefixBlacklist(); |
| 116 | + |
| 117 | + |
112 | 118 | // in the future, we ought to be telling JS land other things, |
113 | 119 | // like: requirements for publication, acceptable licenses, etc. |
114 | 120 | |
Index: trunk/extensions/UploadWizard/UploadWizardPage.js |
— | — | @@ -4,24 +4,49 @@ |
5 | 5 | */ |
6 | 6 | |
7 | 7 | mw.ready( function() { |
| 8 | + |
| 9 | + // The namespace for media files. We use this to look up what the URL prefix is on this MediaWiki, usually |
| 10 | + // 'Image:' or something like that. Defined in defines.php |
| 11 | + var NS_FILE = 6; |
| 12 | + |
8 | 13 | mw.load( 'UploadWizard.UploadWizard', function () { |
9 | 14 | mw.setConfig( 'debug', true ); |
10 | 15 | |
11 | 16 | mw.setDefaultConfig( 'uploadHandlerClass', null ); |
12 | | - mw.setConfig( 'userName', wgUserName ); |
13 | | - mw.setConfig( 'userLanguage', wgUserLanguage ); |
14 | | - mw.setConfig( 'fileExtensions', wgFileExtensions ); |
15 | | - mw.setConfig( 'token', wgEditToken ); |
16 | | - mw.setConfig( 'thumbnailWidth', 120 ); |
17 | 17 | |
18 | | - // not for use with all wikis. |
19 | | - // The ISO 639 code for the language tagalog is "tl". |
20 | | - // Normally we name templates for languages by the ISO 639 code. |
21 | | - // Commons already had a template called 'tl', though. |
22 | | - // so, this workaround will cause tagalog descriptions to be saved with this template instead. |
23 | | - mw.setConfig( 'languageTemplateFixups', { tl: 'tgl' } ); |
24 | | - mw.setConfig( 'defaultLicenses', [ 'cc_by_sa_30', 'gfdl' ] ); |
| 18 | + mw.setConfig( { |
| 19 | + debug: true, |
| 20 | + userName: wgUserName, |
| 21 | + userLanguage: wgUserLanguage, |
| 22 | + fileExtensions: wgFileExtensions, |
| 23 | + token: wgEditToken, |
| 24 | + thumbnailWidth: 120, |
| 25 | + smallThumbnailWidth: 60, |
25 | 26 | |
| 27 | + // not for use with all wikis. |
| 28 | + // The ISO 639 code for the language tagalog is "tl". |
| 29 | + // Normally we name templates for languages by the ISO 639 code. |
| 30 | + // Commons already had a template called 'tl: though. |
| 31 | + // so, this workaround will cause tagalog descriptions to be saved with this template instead. |
| 32 | + languageTemplateFixups: { tl: 'tgl' }, |
| 33 | + defaultLicenses: [ 'cc_by_sa_30' ], |
| 34 | + |
| 35 | + // usually, but not always, File: |
| 36 | + fileNamespace: wgCanonicalNamespaceNames[NS_FILE], |
| 37 | + |
| 38 | + |
| 39 | + // XXX this is horribly confusing -- some file restrictions are client side, others are server side |
| 40 | + // the filename prefix blacklist is at least server side -- all this should be replaced with PHP regex config |
| 41 | + // |
| 42 | + // we can export these to JS if we so want. |
| 43 | + // filenamePrefixBlacklist: wgFilenamePrefixBlacklist, |
| 44 | + // |
| 45 | + // filenameRegexBlacklist: [ |
| 46 | + // /^(test|image|img|bild|example?[\s_-]*)$/, // test stuff |
| 47 | + // /^(\d{10}[\s_-][0-9a-f]{10}[\s_-][a-z])$/ // flickr |
| 48 | + // ] |
| 49 | + }); |
| 50 | + |
26 | 51 | var uploadWizard = new mw.UploadWizard(); |
27 | 52 | uploadWizard.createInterface( '#upload-wizard' ); |
28 | 53 | |