Using External Data and the MediaWiki API to Build a List of Popular Wiki Pages

popular

For one of our internal MediaWiki installations we used the DynamicPageList extension to show a list of the most popular page on our wiki’s main page. We found it to be handy to have an at-a-glance view into what’s the most utilized content. However, we recently upgraded to a newer version of MediaWiki (1.23) and were having issues with DPL. As such our list disappeared while I worked on another solution.

What I discovered is that you can use the External Data extension paired with the MediaWiki API to produce a dynamic list of Special:PopularPages1

First to understand what the API query looks like. Here’s what I’m using:

https://yourwiki.org/w/api.php?action=query&list=querypage&qppage=Popularpages&qplimit=10&format=xml

Breaking that down, we’re asking to query (action=query) the API, return a list from a page (list=querypage) and defining which page (qppqge=Popularpages). Then we set some limits and formats (qplimit=10 and format=xml). Note: You can even use an offset (qpoffset=5) to display multiple selections of data combined with the limits.

Then, on the page you want the list to appear add the following External Data syntax.

{{#get_web_data:url=https://yourwiki.org/w/api.php?action=query&list=querypage&qppage=Popularpages&qplimit=10&format=xml
|format=XML
|data=Title=title
}}

<div>{{#display_external_table:
template=PopularPagesExtAPITable
|data=title=Title}}</div>

That syntax says get the data from the API query, format it as XML, and match up the value for Title to a local variable of title.

Then, we use #display_external_table to format the results using a template. The <div> and other syntax is for styling the results.

In the template, this case named PopularPagesExt, we have the following:

<li style="list-style-type: none;">[[{{{title}}}|{{{title}}}]]</li>

This says for each result returned in our #get_web_data query make it a list item, apply some styles (in this case removing bullets), and then use the returned value as a standard wiki link – [[Page Name|Link Text]]

The link text is the same as the name of the page. Makes sense, no?

The result is a dynamic list of Popular pages that you can place on any wiki page.


  1. .In fact by using “list=querypage” from the API you can query information from a number of Special pages.

Seth Godin on Being Satisfied Creatively

“Are you satisfied creatively?

 

Not even close. That’s a very dangerous place to be and it would truly depress me if that happened and I would get very scared as well. I think if your goal is for everything to be okay, that’s a mistake. To achieve that goal, the only obstacle you’d have to face tomorrow is to eliminate all risk so that everything would be okay. I’ve made the decision that I’m never trying to make everything okay. I’m trying for there to be more loose ends, not fewer loose ends.”

https://thegreatdiscontent.com/seth-godin

Today I’m making motion graphics in After Effects, tomorrow I’m setting up a new site for a client in WordPress, the day after, who knows!? While it does afford a certain level of discomfort, I’d much rather be pushing myself than complacent with just one domain.

 

 

Mills Baker on Design and Solving Human Problems

“Using Paper, I have a sense of anxiety: what if this is what designers make when not yoked to “product thinking”? What if Matas et alia sans Jobs or Forstall are capable of impossibly perfect physics in UIs, of great elements of design, but not of holistic product thinking, of real product integrity? What if design uses its seat at the table to draw pretty things, but otherwise not pay much attention to the outcomes, the user behaviors, the things enabled?”

“In order to avoid losing its place atop organizations, design must deliver results. Designers must also accept that if they don’t, they’re not actually designing well; in technology, at least, the subjective artistry of design is mirrored by the objective finality ofuse data. A “great” design which produces bad outcomes —low engagement, little utility, few downloads, indifference on the part of the target market— should be regarded as a failure.”

http://mokriya.quora.com/Designer-Duds-Losing-Our-Seat-at-the-Table

Mills Baker has some great thoughts about the role of design and its impact on the success of a product. It reminds me of an old adage. “If you can’t measure it, you can’t manage it”. If design is to assist in the utility and usefulness of a product, then you should have some specific goals around what success looks like. Otherwise, you’re just spinning your wheels.

Update: Mills added some followup on Quora. He also posted it on Medium. Worth an additional read.

People Skills for Web Workers

“This is the era of cross-platform digital services, fast networks, and mobile devices. Sounds like the ideal time to be a person who makes websites. So why do we feel frustrated so often? Why do we experience burnout or depression? What makes it difficult to do work that has meaning, that satisfies us? The problem is that we need to collaborate, but we haven’t focused on developing our people skills.”

http://alistapart.com/article/people-skills-for-web-workers

Matt Mullenweg on holding “Auditions”

“…every final candidate to work with us for three to eight weeks on a contract basis. Candidates do real tasks alongside the people they would actually be working with if they had the job…The goal is not to have them finish a product or do a set amount of work; it’s to allow us to quickly and efficiently assess whether this would be a mutually beneficial relationship. They can size up Automattic while we evaluate them.

http://hbr.org/2014/04/the-ceo-of-automattic-on-holding-auditions-to-build-a-strong-team/ar/pr

Automattic seems like a cool place to work.