Yes, R in mediawiki achieves this quite nicely, and it's open source so you can see how they did it.
I have played extensively with the source myself, it's really simple and shouldn't take you long to adapt it.
Of course you can't use it as-is unless you plan to use mediawiki
on your server as well. Also, watch out for security.