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.

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.

 

 

Greg Hoy on the Cycle of Agency Life

“Time and time again, ideas were presented to various internal stakeholders, all of whom had their own agendas and budgets. Pushing ideas through the maze of red tape and exhausting levels of buy-in was usually a soul-sucking effort in futility. Even though everyone was theoretically working for the greater good, everyone was working against each other at the same time. Great ideas became mediocre ideas that became ghosts of ideas put on the back burner.”

https://the-pastry-box-project.net/greg-hoy/2014-april-17

Having only worked with and for large internal shops I’m always curious as to what the other side of the table (at a dedicated agency) would be like.

Put Your Phone Away

“I would often catch myself pulling out my phone to merely check the time (and then check the time again since I never actually remembered it the first time). This frequent ‘time check’ reenforced the habit of constantly pulling out my phone and undoubtedly led to unnecessary browsing if a waiting notification piqued my interest. Buy a watch. Wear it.”

https://medium.com/p/15308056cfae

Speaking of distractions, put your damn phone away.

Matt Griffin on Working with Email

“And when you’ve finished that batch of email responses and are ready to return to your work? Close that email client, friend! Don’t open it back up until you’re ready to dedicate your attention to it again. Otherwise, it’s just a distraction. I find it useful to set times for checking my email throughout the day, for instance 10 a.m., 1:30 p.m., and 4 p.m.”

http://alistapart.com/column/my-life-with-email

Some good tips here. Email is one of those deceptively simple things that everyone misuses.