X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.jqueryMsg%2Fmediawiki.jqueryMsg.js;h=846deb95e1d21965043630931487e81abdb6a263;hb=1c7c9bdf1f;hp=ebb469f4b8bc5b7269bc2eb8af992cd785df4a27;hpb=b9333ae6557b86e4b074025c43e77e745610b345;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js b/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js index ebb469f4b8..846deb95e1 100644 --- a/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js +++ b/resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js @@ -14,13 +14,14 @@ var oldParser, slice = Array.prototype.slice, parserDefaults = { + // Magic words and their expansions. Server-side data is added to this below. magic: { PAGENAME: mw.config.get( 'wgPageName' ), PAGENAMEE: mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ) }, // Whitelist for allowed HTML elements in wikitext. // Self-closing tags are not currently supported. - // Can be populated via setParserDefaults(). + // Filled in with server-side data below allowedHtmlElements: [], // Key tag name, value allowed attributes for that tag. // See Sanitizer::setupAttributeWhitelist @@ -56,6 +57,9 @@ format: 'parse' }; + // Add in server-side data (allowedHtmlElements and magic words) + $.extend( true, parserDefaults, require( './parserDefaults.json' ) ); + /** * Wrapper around jQuery append that converts all non-objects to TextNode so append will not * convert what it detects as an htmlString to an element. @@ -297,7 +301,7 @@ * @return {jQuery} */ parse: function ( key, replacements ) { - var ast = this.getAst( key ); + var ast = this.getAst( key, replacements ); return this.emitter.emit( ast, replacements ); }, @@ -306,16 +310,22 @@ * Note that we pass '⧼' + key + '⧽' back for a missing message here. * * @param {string} key + * @param {Array} replacements Variable replacements for $1, $2... $n * @return {string|Array} string of '⧼key⧽' if message missing, simple string if possible, array of arrays if needs parsing */ - getAst: function ( key ) { + getAst: function ( key, replacements ) { var wikiText; if ( !Object.prototype.hasOwnProperty.call( this.astCache, key ) ) { - wikiText = this.settings.messages.get( key ); - if ( typeof wikiText !== 'string' ) { - wikiText = '⧼' + key + '⧽'; + if ( mw.config.get( 'wgUserLanguage' ) === 'qqx' ) { + wikiText = '(' + key + '$*)'; + } else { + wikiText = this.settings.messages.get( key ); + if ( typeof wikiText !== 'string' ) { + wikiText = '⧼' + key + '⧽'; + } } + wikiText = mw.internalDoTransformFormatForQqx( wikiText, replacements ); this.astCache[ key ] = this.wikiTextToAst( wikiText ); } return this.astCache[ key ]; @@ -1275,7 +1285,7 @@ * @param {Array} nodes List of nodes * @return {string} Other message */ - 'int': function ( nodes ) { + int: function ( nodes ) { var msg = textify( nodes[ 0 ] ); return mw.jqueryMsg.getMessageFunction()( msg.charAt( 0 ).toLowerCase() + msg.slice( 1 ) ); },