-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more mw base modules, also update existing
Such as mw.hook, mw.html, mw.Message. To ease maintenance, instead of modifying mediawiki.js directly to stub mw.loader, the existing implementation is left as is and the stubbing is done afterwards.
- Loading branch information
1 parent
7bd8406
commit 033c790
Showing
13 changed files
with
3,149 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
{ | ||
"wgArticleId": 2, | ||
"wgIsRedirect": false, | ||
"wgPageName": "TestPage", | ||
"wgNamespaceNumber": 0, | ||
"wgCanonicalNamespace": "", | ||
"wgRestrictionEdit": [ | ||
"autoconfirmed" | ||
], | ||
"wgPageContentModel": "wikitext", | ||
"wgPageContentLanguage": "en", | ||
"wgCategories": [], | ||
"wgRevisionId": "234234", | ||
"wgRelevantPageName": "TestPage", | ||
"wgRelevantPageIsProbablyEditable": true, | ||
"wgRelevantArticleId": 2, | ||
|
||
"wgUserId": 234, | ||
"wgUserGroups": [ | ||
"sysop", | ||
"*", | ||
"user", | ||
"autoconfirmed" | ||
], | ||
"wgUserName": "Wikiuser", | ||
"wgUserLanguage": "en", | ||
"wgUserEditCount": 4200, | ||
"wgUserRegistration": 1401893192000, | ||
|
||
"wgServer": "http://localhost:8080", | ||
"wgScript": "/index.php", | ||
"wgArticlePath": "/index.php/$1", | ||
"wgScriptPath": "", | ||
"wgContentLanguage": "en", | ||
"wgLegalTitleChars": " %!\"$&'()*,\\-./0-9:;=?@A-Z\\\\\\^_`a-z~+\\u0080-\\uFFFF", | ||
"wgIllegalFileChars": ":/\\\\", | ||
"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", | ||
"100": "Portal", | ||
"101": "Portal talk", | ||
"108": "Book", | ||
"109": "Book talk", | ||
"118": "Draft", | ||
"119": "Draft talk", | ||
"446": "Education Program", | ||
"447": "Education Program talk", | ||
"710": "TimedText", | ||
"711": "TimedText talk", | ||
"828": "Module", | ||
"829": "Module talk", | ||
"2300": "Gadget", | ||
"2301": "Gadget talk", | ||
"2302": "Gadget definition", | ||
"2303": "Gadget definition talk" | ||
}, | ||
"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, | ||
"portal": 100, | ||
"portal_talk": 101, | ||
"book": 108, | ||
"book_talk": 109, | ||
"draft": 118, | ||
"draft_talk": 119, | ||
"education_program": 446, | ||
"education_program_talk": 447, | ||
"timedtext": 710, | ||
"timedtext_talk": 711, | ||
"module": 828, | ||
"module_talk": 829, | ||
"gadget": 2300, | ||
"gadget_talk": 2301, | ||
"gadget_definition": 2302, | ||
"gadget_definition_talk": 2303, | ||
"wp": 4, | ||
"wt": 5, | ||
"image": 6, | ||
"image_talk": 7, | ||
"project": 4, | ||
"project_talk": 5 | ||
}, | ||
"wgContentNamespaces": [0], | ||
"wgCaseSensitiveNamespaces": [], | ||
"pageTriageNamespaces": [ | ||
0, | ||
2 | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* MediaWiki legacy wikibits | ||
*/ | ||
var msg, | ||
loadedScripts = {}; | ||
|
||
function wikiUrlencode( page ) { | ||
return encodeURIComponent( String( page ) ) | ||
.replace( /'/g, '%27' ) | ||
.replace( /%20/g, '_' ) | ||
// wfUrlencode replacements | ||
.replace( /%3B/g, ';' ) | ||
.replace( /%40/g, '@' ) | ||
.replace( /%24/g, '$' ) | ||
.replace( /%21/g, '!' ) | ||
.replace( /%2A/g, '*' ) | ||
.replace( /%28/g, '(' ) | ||
.replace( /%29/g, ')' ) | ||
.replace( /%2C/g, ',' ) | ||
.replace( /%2F/g, '/' ) | ||
.replace( /%7E/g, '~' ) | ||
.replace( /%3A/g, ':' ); | ||
} | ||
|
||
/** | ||
* @deprecated since 1.17 Use jQuery instead | ||
*/ | ||
mw.log.deprecate( window, 'addOnloadHook', function ( fn ) { | ||
$( function () { | ||
fn(); | ||
} ); | ||
}, 'Use jQuery instead.' ); | ||
|
||
/** | ||
* Wikipage import methods | ||
* | ||
* See https://www.mediawiki.org/wiki/ResourceLoader/Legacy_JavaScript#wikibits.js | ||
*/ | ||
|
||
/** | ||
* @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25. | ||
* @param {string} url | ||
* @return {HTMLElement} Script tag | ||
*/ | ||
function importScriptURI( url ) { | ||
var s; | ||
if ( loadedScripts[ url ] ) { | ||
return null; | ||
} | ||
loadedScripts[ url ] = true; | ||
s = document.createElement( 'script' ); | ||
s.setAttribute( 'src', url ); | ||
document.head.appendChild( s ); | ||
return s; | ||
} | ||
|
||
function importScript( page ) { | ||
var uri = mw.config.get( 'wgScript' ) + '?title=' + wikiUrlencode( page ) + | ||
'&action=raw&ctype=text/javascript'; | ||
return importScriptURI( uri ); | ||
} | ||
|
||
/** | ||
* @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25. | ||
* @param {string} url | ||
* @param {string} media | ||
* @return {HTMLElement} Link tag | ||
*/ | ||
function importStylesheetURI( url, media ) { | ||
var l = document.createElement( 'link' ); | ||
l.rel = 'stylesheet'; | ||
l.href = url; | ||
if ( media ) { | ||
l.media = media; | ||
} | ||
document.head.appendChild( l ); | ||
return l; | ||
} | ||
|
||
function importStylesheet( page ) { | ||
var uri = mw.config.get( 'wgScript' ) + '?title=' + wikiUrlencode( page ) + | ||
'&action=raw&ctype=text/css'; | ||
return importStylesheetURI( uri ); | ||
} | ||
|
||
msg = 'Use mw.loader instead.'; | ||
mw.log.deprecate( window, 'loadedScripts', loadedScripts, msg ); | ||
mw.log.deprecate( window, 'importScriptURI', importScriptURI, msg ); | ||
mw.log.deprecate( window, 'importStylesheetURI', importStylesheetURI, msg ); | ||
// Not quite deprecated yet. | ||
window.importScript = importScript; | ||
window.importStylesheet = importStylesheet; | ||
|
||
/** | ||
* Replace document.write/writeln with basic html parsing that appends | ||
* to the <body> to avoid blanking pages. Added JavaScript will not run. | ||
* | ||
* @deprecated since 1.26 | ||
*/ | ||
[ 'write', 'writeln' ].forEach( function ( method ) { | ||
mw.log.deprecate( document, method, function () { | ||
$( document.body ).append( $.parseHTML( Array.prototype.join.call( arguments, '' ) ) ); | ||
}, 'Use jQuery or mw.loader.load instead.', 'document.' + method ); | ||
} ); |
Oops, something went wrong.