Extension talk:RawMsg

From MediaWiki.org
Jump to navigation Jump to search

pre and p tags are added to the code[edit]

I tried to use this extension to insert Google AJAX Search API to a wiki, but there were some pre and p tags generated and spaces were turned into & nbsp ; which stopped the code from working. Any idea to get REAL RAW msg?

Use {{msgnw:pagename}}
For example
<code style="white-space:pre">
{{msgnw:Template:!}}
</code>

gives:

|<noinclude>{{documentation}}</noinclude>

But note that if msgnw effectively pastes the raw characters, theyr are still feeding the MediaWiki parser, which will compress blanks in its output (because these blanks are parsed and will generate paragraphs, lists (you cannot disable this unless you use "nowiki" tags around it, but then the msgnw function is also not interpreted and you don't get its output result);

<code style="white-space:pre">
{{msgnw:Template:t}}
</code>

gives:

<span class="phui-tag">[https://phabricator.wikimedia.org/T{{{1}}} T{{{1}}}]</span><noinclude> <templatedata> { "description": "Link to a Phabricator task (e.g. T1234)", "params": { "1": { "label": "Task ID", "type": "string", "required": true, "description": "Task ID (NNNNN) in Wikimedia's Phabricator, without the 'T'" } } } </templatedata> == Usage == <pre>Example {{T|1234}} link.</pre> Example {{T|1234}} link. == See also == * [[Template:Phabricator]] * [[Template:Tracked]] - right-floating box for specific tasks * [[Template:PhabT]] - similar to <code><nowiki>[[phab:n]]</nowiki></code> but without the "T" * [[Template:Ptag]] - page-top indicators for overall #projects and #tags [[Category:External link templates|{{PAGENAME}}]]

There's still no way to force msgnw to output its result in a nowiki section that it generates itself, you'll have to use a Lua module to reencode the output of msgnw with a "mwencode" function to change the problematic characters into numeric entities; the alternative is to use "urlencode" to see that the result of msgnw was effectively raw (a NEWLINE will be shown as %0A, a SPACE will be "+", most punctuations are %nn-encoded, and non-ASCII characters are %nn-encoded byte per byte in hexadecimal, according to their UTF-8 encoding) so

<code style="white-space:pre">
{{urlencode:{{msgnw:Template:t}}}}
</code>

gives:

%26%2360%3Bspan+class%26%2361%3B%26%2334%3Bphui-tag%26%2334%3B%26%2362%3B%26%2391%3Bhttps%26%2358%3B%2F%2Fphabricator.wikimedia.org%2FT%26%23123%3B%26%23123%3B%26%23123%3B1%26%23125%3B%26%23125%3B%26%23125%3B+T%26%23123%3B%26%23123%3B%26%23123%3B1%26%23125%3B%26%23125%3B%26%23125%3B%26%2393%3B%26%2360%3B%2Fspan%26%2362%3B%26%2360%3Bnoinclude%26%2362%3B%0A%26%2360%3Btemplatedata%26%2362%3B%0A%26%23123%3B%0A%26%239%3B%26%2334%3Bdescription%26%2334%3B%3A+%26%2334%3BLink+to+a+Phabricator+task+%28e.g.+T1234%29%26%2334%3B%2C%0A%26%239%3B%26%2334%3Bparams%26%2334%3B%3A+%26%23123%3B%0A%26%239%3B%09%26%2334%3B1%26%2334%3B%3A+%26%23123%3B%0A%26%239%3B%09%09%26%2334%3Blabel%26%2334%3B%3A+%26%2334%3BTask+ID%26%2334%3B%2C%0A%26%239%3B%09%09%26%2334%3Btype%26%2334%3B%3A+%26%2334%3Bstring%26%2334%3B%2C%0A%26%239%3B%09%09%26%2334%3Brequired%26%2334%3B%3A+true%2C%0A%26%239%3B%09%09%26%2334%3Bdescription%26%2334%3B%3A+%26%2334%3BTask+ID+%28NNNNN%29+in+Wikimedia%26%2339%3Bs+Phabricator%2C+without+the+%26%2339%3BT%26%2339%3B%26%2334%3B%0A%26%239%3B%09%26%23125%3B%0A%26%239%3B%26%23125%3B%0A%26%23125%3B%0A%26%2360%3B%2Ftemplatedata%26%2362%3B%0A%26%2361%3B%26%2361%3B+Usage+%26%2361%3B%26%2361%3B%0A%26%2360%3Bpre%26%2362%3BExample+%26%23123%3B%26%23123%3BT%26%23124%3B1234%26%23125%3B%26%23125%3B+link.%26%2360%3B%2Fpre%26%2362%3B%0AExample+%26%23123%3B%26%23123%3BT%26%23124%3B1234%26%23125%3B%26%23125%3B+link.%0A%26%2361%3B%26%2361%3B+See+also+%26%2361%3B%26%2361%3B%0A%26%2342%3B+%26%2391%3B%26%2391%3BTemplate%3APhabricator%26%2393%3B%26%2393%3B%0A%26%2342%3B+%26%2391%3B%26%2391%3BTemplate%3ATracked%26%2393%3B%26%2393%3B+-+right-floating+box+for+specific+tasks%0A%26%2342%3B+%26%2391%3B%26%2391%3BTemplate%3APhabT%26%2393%3B%26%2393%3B+-+similar+to+%26%2360%3Bcode%26%2362%3B%26%2360%3Bnowiki%26%2362%3B%26%2391%3B%26%2391%3Bphab%3An%26%2393%3B%26%2393%3B%26%2360%3B%2Fnowiki%26%2362%3B%26%2360%3B%2Fcode%26%2362%3B+but+without+the+%26%2334%3BT%26%2334%3B%0A%26%2342%3B+%26%2391%3B%26%2391%3BTemplate%3APtag%26%2393%3B%26%2393%3B+-+page-top+indicators+for+overall+%23projects+and+%23tags%0A%26%2310%3B%26%2391%3B%26%2391%3BCategory%3AExternal+link+templates%26%23124%3B%26%23123%3B%26%23123%3BPAGENAME%26%23125%3B%26%23125%3B%26%2393%3B%26%2393%3B

MediaWiki 1.19a fatal error[edit]

On MediaWiki 1.19a I'm seeing the following code fail with a fatal error, effectively shutting down the entire wiki:

# Add system messages
 global $wgMessageCache;
 $wgMessageCache->addMessage('rawmsg-missing-params', 'Error: <nowiki>{{#rawmsg:}}</nowiki> is missing a required parameter.');
 $wgMessageCache->addMessage('rawmsg-missing-article', 'Error: RawMsg cannot find the article [[MediaWiki:rawmsg-$1]].');

failing with:

PHP Fatal error: Call to a member function addMessage() on a non-object in /home/sophia/domains/extensions/RawMsg.php on line 73

$wgMessageCache is deprecated with a big fat This feature was removed completely in version 1.18.0 in the manual. This extension is therefore now broken, short of removing these lines and creating MediaWiki:rawmsg-missing-params, MediaWiki:rawmsg-missing-article manually. --Carlb 01:54, 14 February 2012 (UTC)

I added a RawMsg.i18n.php file with the contents

<?php
$messages = array();
$messages['en'] = array(
    'rawmsg-missing-params' => 'Error: <nowiki>{{#rawmsg:}}</nowiki> is missing a required parameter.',
    'rawmsg-missing-article' => 'Error: RawMsg cannot find the article [[MediaWiki:rawmsg-$1]].',
);

commented out the three lines with $wgMessageCache, and added this line to RawMsg.php (after the $wgExtensionCredits part):

$wgExtensionMessagesFiles['RawMsg'] = dirname( __FILE__ ) . '/RawMsg.i18n.php';
::

This seems to work nicely (1.18.1). --Tgr (talk) 09:40, 26 February 2012 (UTC)

$messages['ru'] = array(
    'rawmsg-missing-params' => 'Ошибка: <nowiki>{{#rawmsg:}}</nowiki> параметр отсутствует.',
    'rawmsg-missing-article' => 'Ошибка: RawMsg не может найти статью [[MediaWiki:rawmsg-$1]].',
);

--2nd 12:56, 30 June 2014 (UTC)