Yesterday I quickly wrote up a simple (but awesome) MediaWiki extension that allows you to make use of the Spark library in your wiki.
Spark as described on the Spark website:
The web is not only growing in sheer size, but it also grows in how much it is interconnected. Where once the Web was a set of more or less separated sites, today sites are more and more being connected. More and more data is being offered on the Web in a way that can be further processed, and more and more sites and applications are using external data. More and more mashups are created, where data from different sources is integrated and displayed with novel visualisations.
Spark is a library that enables HTML authors to create mashups more easily than ever before. Using standard Web technologies like SPARQL, RDF, HTML5, and JavaScript, Spark can query external knowledge sources (so called triple stores or SPARQL endpoints), and then visualise the results.
With Spark, website developers can create visually appealing mashups without having to write a single line of JavaScript, but merely using some markup elements describing the source of the data that is to be shown, a query to select the appropriate data, and selecting one from an expandable set of visualisations and their parameters.
Spark is developed by Denny VrandeÄić and Andreas Harth.
This MediaWiki extension, unsurprisingly titled Spark, adds a <spark> tag to MediaWiki which is equivalent to <div class=”spark”> as described in the spark library documentation. All parameters (except the class=”spark” one) can just be copied over between spark divs in web pages, and the <spark> tag in MediaWiki. It is currently at version 0.1, which is a beta release. It includes a still experimental version of the Spark library, so you should probably not use this extension on production websites just yet. The Spark people are looking for developers to help out, so if you want to play around with SPARQL a bit, like I basically did with this extension, be sure to poke them
The extension required MediaWiki 1.17 or above (as it makes use of the new Resource Loader) and PHP 5.2 or later.
Download
Further possibilities
Right now you can embed mashups with SPARQL queries that get their data from some SPARQL endpoint. This opens up a whole bunch of possibilities, but is a bit silly when you are running your own Semantic MediaWiki instance and want to visualize structured data stored by it using Spark. A possible addition to the Spark MediaWiki extension therefore is having support for Spark as a so called SMW result format. For this translation from the SMW ask query language to SPARQL is needed, which is some work. I might implement this at some future point, but have several other things I want to poke at, so it won’t be soonish
A few weeks back I started work on a new MediaWiki extension to provide decent rating functionality. The reason: I got sick of all the crappy rating extensions out there and decided to write one that both works and has sane code. The new extension is called “Ratings“.
The Ratings extension provides a tag extension that when embedded in a page allows users to rate different “properties” of the page. Quite simple. It also adds a votesummary hook which allows embedding a summary as seen below into pages for any property of any page.
The extension is written in such a way it’s easy to add additional types of rating (interface) elements. It exposes 2 API modules, one to obtain all rating data needed on a page, and one to submit votes.
It’s not quite finished yet, as I can’t get the rating interface quite right. I tried 2 jQuery rating star plugins, both messing up their position in the page after onload. Therefore I have not made any release yet, and definitely recommend against using this extension on any production wiki. I’m not planning to put any more time into this issue (I already wasted some hours on it >_>), so feel absolutely free to fix the layout issues (you can contact me for details, or try out the extension yourself and spot the obvious), or to put in your own favourite rating element. (source code)
Yesterday I for some reason decided to have some fun with Python by writing a simple script to Find Dead Translation keys in MediaWiki extensions. The resulting script, titled FDT, can be found on GitHub, and is licenced under the GNU GPL v3+ (yes, the later probably comes as a shock to you!).
What is does, and how
The script works by first obtaining a list of defined language keys from the specified i18n file (which is done via an evil PHP subprocess, to avoid messy parsing of array keys), and then looping over all php files in the directory (recursively ofc) to check if they contain any of the keys, after which a list of not-found keys is returned. If there are not-found keys, the script offers to delete those from the i18n file, which also saves quite some work if they are assigned to for many languages. One important limitation is that the script finds key usage by doing a simple “in string” search on the whole contents of each file, which obviously will miss dynamically constructed strings. An example of the work this script did (for Semantic Maps) can be found in this commit.
Some more points of interest
This was a nice little exercise in Python for me, making me more familiar with the language basics, which after several similar small projects, I now think I pretty much have mastered. Also fun was that this is the first project I did using Apatana Studio 3, which was released very recently. It’s an Eclipse based IDE aimed at Python and Ruby web development, including excellent support for JavaScript and various JS libraries such as jQuery and Ext. It also has some support for PHP, but that’s a bit meagre compared to Zend Studio or PhpStorm, an IntelliJ based IDE I’ve been trying out lately.
More posts to come
Over the past 2 years I’ve changed my blog posting style from posting casual updates about small stuff like this post, to only posting about new MediaWiki extensions or important updates to existing ones. I’ve decided to reverse this trend and post more lightweight for fun things, as opposed to only big release announcements
A few days back I created my second ever Android application, basically a re-do of the first one that was titled “Pamela for Android“, now with the name “PAMELA Widget“. It has the same function: display a list of people at 0×20, the hackerspace in Ghent, or HSB, the space in Brussels,obtained via the PAMELA webservice. More info on PAMELA can be found here.
I couldn’t really get the interface in the previous app quite working as I wanted, and then got inspired by the iRail Liveboard app, created by Christophe Versieux, to write a new version, based on the code of the Liveboard app.
You can get the app from the Android market by searching “pamela widget”. You can also get the code, which is GPL3+ licenced, from GitHub.
Somewhere in the last two weeks I quickly wrote up a small new MediaWiki extension to include content from Wikipedia or some other MediaWiki install into pages on your wiki. It’s titled Include WP.
The extension does not import anything (so nothing is stored), but rather fetches content from the remote wiki every time the page is loaded. This means it takes a second or two for it to actually load, but ensures you got the latest content. Some clean up of the remote content happens and there are several options that allow you to customize how the included content is displayed. It makes use of the Validator extension.
Feature overview:
- Removal of templates (such as infoboxes), ref tags, comments, categories and images.
- Both internal and external links are rendered as plain-text.
- Tables, lists, table of content, section headers and more are retained.
Some screenshots
It’s been a while since the previous release of Validator, but this minor update includes some cool new functionality.
As I was creating the SubPageList extension and it’s documentation (at 27c3!), it occurred to me that to document the usage of the <subpages /> parser hook, all the info I needed was already available via Validator. Since there was no way to get this info out in a meaningful way, I decided to create a new parser hook just for this purpose. It’s titled “describe” and describes one or more parser hooks implemented using the ParserHook class provided by Validator. This description includes a short text about the parser hooks functionality, a table with it’s parameters and their meta-data, syntax examples, a list of aliases (if any) and more. It’s possible to get the description in wikitext, as opposed directly in the page, so you can copy it, and use it (or parts of it) somewhere else. By default it’ll list all parser hooks it knows about directly in the page. An example can be seen here.
Many more not yet implemented features that make use of the parameter handling framework that is Validator can be imagined. One I might implement in the near future is linking to a special page that generates a description of how to use a certain parser hook based on something the user is doing wrong, and link to that from error messages. This can be done easily by building on top of the already existing error message system and the describe parser hook
I think Validator adds a lot of Value when creating parser hooks, and other parameter handling objects. The main problem currently is that when using it’s features in an extension, this extension obviously becomes dependent on Validator. From a technical perspective this does not really matter, but it complicates installation for users (especially since MediaWiki lacks any sort of extension management facilities). I therefore hope to get Validators functionality into MediaWiki core, or at least in the default MediaWiki distribution. I’m rather sceptical to if I can make this happen as a non core-developer, but if I succeed, it would be a great advantage for extension (and core) development, so it’s definitely worth a try.
SubPageList 0.1 comes bundled with an alpha version of Validator 0.4.3, containing most of the new functionality. Maps and Semantic Maps will come bundled with it (or a newer version) on their next release.
Downloads
During 27c3 someone asked me to install an extension to list subpages onto the hackerspace.be wiki. I picked SubPageList3, as it seemed to most decent one. I did a simple test to see if it was working, and immediately found a namespace bug. So I decided to quickly rewrite it and also let it use Validator for additional awesomeness.
Strangely enough, although there where SubPageList2 and SubPageList3 extensions, there was no SubPageList extension to be found anywhere in the WMF SVN repo or the mediawiki.org wiki, so I decided to simply take that name. The extension should be backwards compatible with SubPageList3.
I spend 5 hours or so doing the rewrite, and have released an initial version yesterday. Seems to work fine and is currently in use on hackerspace.be. It requires Validator 0.4.2 or above, and is the first extension making full use of new the auto-documentation functionality Validator 0.4.3 introduces (more on that in a later blog post).
Download
I’m happy to announce the release of a new MediaWiki extension I’ve been working on over the past two weeks. It’s titled Live Translate and allows live page translation via the Google Translate API. It also enables you to define a “dictionary” of certain words or phrases and their translations; any word or phrase in the original text found in the “dictionary” will be translated using that dictionary, instead of using Google Translate.
The main features are:
Some screenshots
A wiki page with the translation control of the Live Translate extension at the right top corner:
The same page after translating it to Dutch:
The dictionary page briefly summarizing how many words and languages it contains:
Editing the special words dictionary works just like editing any other page:
Funding
I created this extension as WikiWorks consultant for Texas Instruments. Thanks to TI for funding this and allowing licensing under the GNU GPL.
Points of interest
For me the most interesting part of creating this extension was figuring out how to walk through the page DOM and send only the actual text to the Google Translate API using JavaScript (and jQuery). This step was needed because the GT API limits translation requests to 500 characters, so it’s not definitely possible to send the whole page. It took me a while to figure this out, and I still think it’s a rather lame limit, as it leads to loss of context, and thus worse translations.
The rest of the extension is rather simple and does not contain anything I haven’t done before. The special words dictionary is stored in a simple db table (fields: word id, word text, word language and word primary) and can be accessed via 2 API modules. One is to query a list of the special words that are defined for a language, the other is to get translations of a set of special words from one language to the other. When you request your first translation of a page, the first API module is hit and the result is used to insert notranslate spans, which make Google Translate ignore stuff, around the special words. After that the other module is hit, the special words are replaced by their translations, and finally the script sends a ton of requests to the GT API.
Ah, and not to forgot, I used a XOR. I kid you not, source code or it didn’t happen (see the last function).
State and future
Live Translate is currently at version 0.2 and contains all the features initially requested by TI. It appears to be stable, and ready for production usage. Of course, if bugs pop up, they will be addressed and a new minor version will be released. A cool new feature I’ve been considering, and might add at some point, is having __LIVETRANSLATE__ and __NOLIVETRANSLATE__ magic words, that allow per-page showing or hiding of the translation control. Yaron suggested also having a per-namespace setting. If you have some cool new features in mind, feel free to suggest them on the Live Translate discussion page (where you also can ask for support and point out bugs). If you want to fund any new functionality, please contact WikiWorks.
You can obtain the latest version of Live Translate here.
I’m happy to announce the release of a new MediaWiki extension I’ve been working on over the past two weeks. As you’ve might already have guessed from it’s name, Push, it enables you to push content of wiki pages to one or more other MediaWiki installs.
The main features are:
The tab interface
When logged in, a new tab or action (on vector based skins) will be added which leads to the push interface for the page you are on. This interface consists of a table listing the available target wikis and also informs you of the status of the target pages. A big push button in each row allows you to do the actual push. When there is more then one target wiki, a convenient ‘Push all’ button will also be shown.Underneath this table the available options will be displayed. With the current version you can choose to include the templates used on the page in the push, as well as transferring the embedded images.
In this screenshot of the tab interface, you can see an actual ‘Push’ tab, rather then an action in the collapsed actions dropdown. You can choose this behaviour, which is useful when you do very frequent pushing, using one of the settings made available by the Push extension.
After initiating the push to one or more targets, the work will happen in the background, and the interface will update to show you progress, completion, and possible errors (such as not having sufficient rights to edit on the target wiki).
Special:Push
Push provides bulk push capabilities via a special page aptly titled ‘Special:Push’. The layout and workings of this page should be familiar to anyone having used MediaWikis native Special:Export, as it’s largely based on this special page. A big textbox allows you to specify the pages you want to push (one per line), and you can choose to add all pages from a category or namespace to it. Under the texbox are the same options as in the tab interface: automatic inclusion of templates and files. Finally you are able to select one or more target wikis.
Note that the file inclusion option was not added yet in the version the below screenshot was taken at. I obtained the above list of pages by entering ‘Locations’ in the category box and submitting it.
When submitting the push request, you’ll be shown the pushing progress in the form of a list to which items get added as pushes complete.
Funding
I created this extension as WikiWorks consultant for Texas Instruments. Thanks to TI for funding this and allowing licensing under the GNU GPL.
Status and future
Push is currently at version 0.5 and contains all the features requested by TI. It appears to be stable, and ready for production usage. Of course, if bugs pop up, they will be addressed and a new minor version will be released. Many useful additions to push can be imagined for various use-cases. Feel free to suggest them on the Push discussion page (where you also can ask for support and point out bugs). If you want to fund any new functionality, please contact WikiWorks.
You can obtain the latest version of Push here.

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 