<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lior Gradstein's Blog &#187; mediawiki</title>
	<atom:link href="http://www.gradstein.info/category/software/mediawiki/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gradstein.info</link>
	<description></description>
	<lastBuildDate>Thu, 13 May 2010 09:46:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Python snippet to get Mediawiki/Wikipedia Recent Changes externally</title>
		<link>http://www.gradstein.info/python/python-snippet-to-get-mediawikiwikipedia-recent-changes-externally/</link>
		<comments>http://www.gradstein.info/python/python-snippet-to-get-mediawikiwikipedia-recent-changes-externally/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 23:37:35 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[mediawiki]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[rc]]></category>
		<category><![CDATA[recent changes]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[wikipedia]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=94</guid>
		<description><![CDATA[Mediawiki allows one to send Recent Changes (RC) to a UDP port.
The ip address is defined by the variable wgRC2UDPAddress, and the port by the variable wgRC2UDPPort. It&#8217;s a really good idea that it&#8217;s a UDP transfer, since there is no need for any ACK, so Mediawiki doesn&#8217;t block if there is nothing listening on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mediawiki.org/" class="liexternal">Mediawiki</a> allows one to <a href="http://wikitech.wikimedia.org/view/IRCD" class="liexternal">send Recent Changes</a> (RC) to a UDP port.<br />
The ip address is defined by the variable wgRC2UDPAddress, and the port by the variable wgRC2UDPPort. It&#8217;s a really good idea that it&#8217;s a UDP transfer, since there is no need for any ACK, so Mediawiki doesn&#8217;t block if there is nothing listening on that port.</p>
<p>These parameters must be set in the LocalSettings.php file, like this, for example.</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">$wgRC2UDPAddress = <span style="color: #483d8b;">&#8216;127.0.0.1&#8242;</span>;<br />
$wgRC2UDPPort = <span style="color: #ff4500;">9390</span>;</div>
<p>I wrote a really simple python program (more a proof of concept) that receives the data, cleans it, and then prints it to stdout :</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span><br />
<span style="color: #808080; font-style: italic;"># -*- coding: utf-8 -*-</span><br />
<span style="color: #808080; font-style: italic;">#</span><br />
<span style="color: #808080; font-style: italic;"># vim:syntax=python:sw=4:ts=4:expandtab</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">SocketServer</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span></p>
<p>HOST,PORT = <span style="color: #483d8b;">&#8221;</span>, <span style="color: #ff4500;">9390</span></p>
<p><span style="color: #ff7700;font-weight:bold;">class</span> MyUDPHandler<span style="color: black;">&#40;</span><span style="color: #dc143c;">SocketServer</span>.<span style="color: black;">BaseRequestHandler</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">def</span> handle<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">sub</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&#8216;<span style="color: #000099; font-weight: bold;">\x</span>03<span style="color: #000099; font-weight: bold;">\d</span>{0,2}&#8217;</span>, <span style="color: #483d8b;">&#8221;</span>, <span style="color: #008000;">self</span>.<span style="color: black;">request</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></p>
<p><span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&#8216;__main__&#8217;</span>:<br />
&nbsp; &nbsp;server = <span style="color: #dc143c;">SocketServer</span>.<span style="color: black;">UDPServer</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>HOST, PORT<span style="color: black;">&#41;</span>, MyUDPHandler<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp;server.<span style="color: black;">serve_forever</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div>
<p>I plan to make it into a complete project that will send the data/notifications using Jabber(XMPP).</p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.gradstein.info/software/how-to-skip-the-useless-you-are-now-logged-in-page-in-mediawiki/" title="How to skip the useless &#8220;you are now logged in&#8221; page in Mediawiki (January 18, 2009)">How to skip the useless &#8220;you are now logged in&#8221; page in Mediawiki</a> (0)</li>
	<li><a href="http://www.gradstein.info/hardware/how-to-automatically-run-a-script-after-inserting-a-usb-device-on-ubuntu/" title="How to automatically run a script after inserting a USB device on Ubuntu? (April 13, 2008)">How to automatically run a script after inserting a USB device on Ubuntu?</a> (2)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/python/python-snippet-to-get-mediawikiwikipedia-recent-changes-externally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to skip the useless &#8220;you are now logged in&#8221; page in Mediawiki</title>
		<link>http://www.gradstein.info/software/how-to-skip-the-useless-you-are-now-logged-in-page-in-mediawiki/</link>
		<comments>http://www.gradstein.info/software/how-to-skip-the-useless-you-are-now-logged-in-page-in-mediawiki/#comments</comments>
		<pubDate>Sat, 17 Jan 2009 23:47:38 +0000</pubDate>
		<dc:creator>Lior Gradstein</dc:creator>
				<category><![CDATA[mediawiki]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[hook]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[redirect]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.gradstein.info/?p=57</guid>
		<description><![CDATA[You installed Mediawiki some time ago, and now something bothers you: aren&#8217;t you tired of having an intermediate page named &#8220;Login successful&#8221; saying &#8220;You are now logged in to&#8221; before being allowed to go to the page you wanted to go? I am.
I found there&#8217;s a hook that is called just when a user successfully [...]]]></description>
			<content:encoded><![CDATA[<p>You installed Mediawiki some time ago, and now something bothers you: aren&#8217;t you tired of having an intermediate page named &#8220;Login successful&#8221; saying &#8220;You are now logged in to&#8221; before being allowed to go to the page you wanted to go? I am.<br />
I found there&#8217;s a hook that is called just when a user successfully logs on (<a href="http://www.mediawiki.org/wiki/Manual:Hooks/UserLoginComplete" class="liexternal">UserLoginComplete</a>), and even an extension named <a href="http://www.mediawiki.org/wiki/Extension:RedirectOnLogin" class="liexternal">RedirectOnLogin</a> that does the redirection for you, BUT to a fixed one. It seems the hook doesn&#8217;t give you the page you previously were before the login request.</p>
<p>So to correct this, I just found a dirty hack. That means you&#8217;ll have to patch the source, meaning also that you&#8217;ll loose some flexibility when upgrading Mediawiki :-(<br />
Anyway, if you still want to do this, here is the magic stuff:</p>
<p>Edit the file mediawiki/includes/specials/SpecialUserlogin.php and look for the function successfulLogin().<br />
At the end of it, just add (it&#8217;s just one line):</p>
<div class="python" style="font-family: monospace;color: #000066; border: 1px solid orange; margin: 5px; padding: 5px; background-color: #ffffff;">header<span style="color: black;">&#40;</span><span style="color: #483d8b;">&#8216;Location: ./index.php?title=&#8217;</span> . $this-&gt;mReturnTo<span style="color: black;">&#41;</span>;</div>
<p>That&#8217;s it. You&#8217;ll get redirected to the previously accessed page automatically! Really cool.</p>
<p><em>This has been successfully used on a Mediawiki 1.13.</em></p>

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.gradstein.info/python/python-snippet-to-get-mediawikiwikipedia-recent-changes-externally/" title="Python snippet to get Mediawiki/Wikipedia Recent Changes externally (January 28, 2009)">Python snippet to get Mediawiki/Wikipedia Recent Changes externally</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.gradstein.info/software/how-to-skip-the-useless-you-are-now-logged-in-page-in-mediawiki/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
