MediaWiki Statistics and Panic’s Status Board

I’m a big fan of Panic Inc. I use Coda daily and am an advent follower of the smart dudes out of Portland.

They have a new app out called Status Board that allows you to mix different data sources to provide at-a-glance information on your iPad. What is even better is that it can output to a HD display for big screen status board updates.

At work I help manage a MediaWiki environment that we use to document stuff.¹ Lately I’ve been trying to figure out how to leverage the MediaWiki API and the External Data Extension to manipulate data from external sources and content within the wiki.

With a few minutes time I figured out how display statistics from MediaWiki on a Status Board!

Basically I use the MediaWiki API to return some XML into a wiki page. That page is then in turn included as an HTML widget in Status Board. The result is something that looks like this:

mediawiki-status-board

Here’s the secret sauce. First create a wiki page to house your content. Then use the #get_web_data function of the External Data extension to pull in a xml feed from the MediaWiki API. Here’s what my code looks like for query of the number of jobs currently in queue.

{{#get_web_data:
url=http://yourwiki/wiki/api.php?action=query&meta=siteinfo&siprop=statistics&format=xml
|format=XML
|data=Jobs=jobs,Pages=pages
}}</pre>
<div style="width: 100%; text-align: center;"><span style="font-size: 42px;">Jobs in Queue</span>

<span style="font-size: 74px;">{{#external_value:Jobs}}</span></div>
<pre>

Then in Status Board enter in the address for your wiki page using the &action=render² attribute.

http://yourwiki/wiki/index.php?title=wikipagetitle&action=render

Some other examples, as you can see in the screenshot above, are a list of the N newest articles, most recent edits, or even additions to specific categories (at the bottom). The sky is the limit!

¹Hints are apparent across my posts as to what we use it for, but needless to say it’s cool.

²Which is suppose to be depreciated, but has been around for many versions now.

Creating a Navigable list of Property Values in Semantic MediaWiki

One of the great things about Semantic MediaWiki (SMW) is the auto-generated fact box at the bottom of any wiki page that has any values for semantic properties.

Screen Shot 2013-05-01 at 10.25.12 AM

It’s also relatively easy to create a list of all defined values for a given property. In fact, this idea uses this template as a basis for what follows.

However, I found that it’s not very intuitive to navigate to a list of all values of a property and see what other articles have that same property value. In order to see a list of all articles that have a particular property value you’d have to navigate to an existing page with that property and then perform a semantic search from there. Or know that there’s a page called Special:SearchByProperty that you could use.

Screen Shot 2013-05-01 at 10.04.58 AM

Example of Special:SearchByProperty results

I wasn’t satisfied with that, so I made a fancy list that’s actually really easy to implement and can be used across an entire SMW for other property values too.

The result is a list of all values for a given property that provide hyperlinks to a list of all wiki articles with that property value. It uses the Special:SearchByProperty page for displaying results.

First, I created a template called Property Values Columns. You can use it like so:

{{Property Values Columns|<em>Name of Property Here</em>}}

Here’s the contents of the “Property Values Columns” template¹:

<noinclude>Use this template to list all the unique values for a given property.

== Template code ==
</noinclude><includeonly>
*{{#arraymap:{{#arraydefine: valuess
 | {{#ask: [[{{{1|}}}::+]] | mainlabel =- | headers = hide |? {{{1|}}} | limit = 10000 }}
 |,| print=list, sort=asc, unique
}}|,|@@|[[Special:SearchByProperty/{{Space|{{{1}}}/@@}}{{!}}@@]]|<li>}}
</includeonly>

This is what it does.

1. Gets a comma separated list of property values for whatever property you’ve requested.
2. Parses the name of the property and each unique value to build a URL.
Example: http://wikiname.com/wiki/index.php/Special:SearchByProperty/Property Name/Property Value
3. The secret sauce is another template called ‘Space’ which uses the #replace function to replace all spaces ” ” with the “-20″ syntax used in the Special:SearchByProperty query.
3a. The “Space” template contains the following:
{{#replace:{{{1}}}| |-20}}
4. Return the results as a series of list items.

The result is an list of all unique property values that when clicked will query the wiki for all pages containing that property value. You can then use some custom styling to format the results. In the example below I wrapped the template in a div creating two columns.²

<div class="twoColumns">{{Property Values Columns|Accounting Unit}}</div>

Screen Shot 2013-05-01 at 10.13.18 AM

Pretty cool huh?

—-

¹The template has a weird name, I know. You can obviously change the name to something more fitting for your use.
²The div styling in my demo is stored in common.css and looks like this: .twoColumns li {width: 35em;float: left;padding-right: 20px;}

Responsive WordPress Theme and Advanced Custom Fields

This is a rather simple little hack, but came in handy with a site I recently I built.

By default, editing theme options are limited to Administrator accounts in WordPress. For themes like Responsive this means that you must have all your clients logging in as administrators. The admin-level dashboard clutters the navigation with many things most clients should never touch. Another solution would be to modify permissions and create custom permission levels to access those theme options.

Neither seemed very elegant to me. After training with the client, she asked why couldn’t they edit the “Home” page under Pages. Which makes sense. If you manage all of your other pages there, why not the home page!?

Here’s a quick tutorial on how you can use the very awesome Advanced Custom Fields in conjunction with the default Responsive home page layout to manage your homepage content.

First, install ACF if you haven’t already.

Second, create a new page and call it Home.

Because you’re using a child theme you’ll want to copy front-page.php from the Responsive theme into your child theme directory.

Open it up in your favorite editor and look for this section:

<div id="featured" class="grid col-940">
	
		<div class="grid col-460">




			<h1 class="featured-title"><?php echo $responsive_options['home_headline']; ?></h1>
			
			<h2 class="featured-subtitle"><?php echo $responsive_options['home_subheadline']; ?></h2>
			
			<p><?php echo $responsive_options['home_content_area']; ?></p>
			
			<?php if ($responsive_options['cta_button'] == 0): ?> &nbsp;
&nbsp; &nbsp;
				<div class="call-to-action">




					<a href="<?php echo $responsive_options['cta_url']; ?>" class="blue button">
						<?php echo $responsive_options['cta_text']; ?>
					</a>
				
				</div><!-- end of .call-to-action -->




			<?php endif; ?> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
			
		</div><!-- end of .col-460 -->




		<div id="featured-image" class="grid col-460 fit">&nbsp;
							
			<?php echo do_shortcode( $responsive_options['featured_content'] ); ?>
									
		</div><!-- end of #featured-image -->&nbsp;
	
	</div><!-- end of #featured -->

Notice all those echo $responsive_options calls? Those are the hooks the Responsive theme uses to pull the information you put on the homepage under Appearance->Theme Options->Home Page. We want to move those to the page called Home along side all of our other pages.

What we’ll do is create a Field Group in ACF for all the fields on the homepage.

  • Title
  • Subtitle
  • Content
  • Video Link
  • Call to Action Button Text
  • Call to Action Button Link

Here’s and example of what your field group should look like.

Screen Shot 2013-04-04 at 2.09.34 PM

Make sure you also set this field group to show up only on the Home page you created earlier.

Screen Shot 2013-04-04 at 2.18.34 PM

Depending on your preferences you might also hide other fields on the screen – such as the Content Editor, Discussion and Comments.

Now from here you simply replace the responsive_option references with calls to your new ACF fields.

For example:

<?php echo $responsive_options['home_headline']; ?>

becomes

<?php the_field('home_title'); ?>

and

<?php echo $responsive_options['cta_url']; ?>

becomes

<?php the_field('home_call_to_action_button_link'); ?>

The end result is something that looks like this:

<div id="featured" class="grid col-940">
	
		<div class="grid col-460">




			<h1 class="featured-title"><?php the_field('home_title'); ?></h1>
			
			<h2 class="featured-subtitle"><?php the_field('home_subtitle'); ?></h2>
			
			<p><?php the_field('home_content'); ?></p>
			
			<?php if ($responsive_options['cta_button'] == 0): ?> &nbsp;
&nbsp; &nbsp;
				<div class="call-to-action">




					<a href="<?php the_field('home_call_to_action_button_link'); ?>" class="blue button">
						<?php the_field('home_call_to_action_button_text'); ?>
					</a>
				
				</div><!-- end of .call-to-action -->




			<?php endif; ?> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
			
		</div><!-- end of .col-460 -->




		<div id="featured-image" class="grid col-460 fit">&nbsp;
							
			<?php&nbsp;
				
				$video_url = get_field('home_video_link');
				echo wp_oembed_get( $video_url, array( 'width' => 440, 'height' => 440 ) );
				
			?>
												
		</div><!-- end of #featured-image -->&nbsp;
	
	</div><!-- end of #featured -->

You’ll notice that I’m also using WordPress’ wp_oembed_get function to embed the YouTube URL in the featured image section. This way all the folks managing content have to do is insert the YouTube URL and WordPress handles the rest.

Once you’re done all you have to do is visit your Home page and update the fields!

Screen Shot 2013-04-04 at 2.28.22 PM

Most Anticipated Games from PAX East

PAX East

A few weeks ago we traveled to Boston to attend PAX (Penny Arcade Expo) East. It was awesome and I’m still reeling from all the amazing things we saw. Kari had a great time, got tons of swag, and even won some pretty cool prizes.

While there I kept a running list of some of the games that I’m most looking forward to. In no particular order here are a few worth checking out when they release in the near future.

 

Zombie Tycoon II (PS3 and Vita)

This is by the very talented Frima Studios, makers of the throwback bullet hell shooter “A Space Shooter for Two Bucks” that came out on the PSP a few years back. As always, the production quality is top-notch with unique designs and animation. This is a RTS where you control a horde of zombies, a mobile base and a special monster as you try to not only take over a town, but keep the opposing zombies at bay. Kari and I played a round with her on the PS3 and I on a Vita. She liked it a lot. (We also won a PS Vita in a drawing, but that only sweetened the deal.)

 

Mercenary Kings (PC)

Paul Robertson (NSFW) is an insanely talented artist, known primarily for his over the top pixel art. He did the sprite work for the recent Scott Pilgrim game. It’s a 2D 4 player Metal Slug-esque shoot-em-up.

 

A.N.N.E. (PC)

Reminds me of Cave Story with some heavy and deliberate Super Metroid influences. The guys manning the booth were super cool and the playable version at PAX was promising. (are you noticing a trend of awesome retro gaming?)

 

Tearaway (PS VIta)

Media Molecule, the genius behind Little Big Planet have a new game coming out this October that revolves around a little messenger in a land made of paper. You have to help guide him along his journey using all sorts of input methods. Not only an amazing looking game, but their booth was top-notch as well. The booth is made of paper for a game about a world made of paper where you can print out objects in the game with paper – infinity.

Tearaway

 

Super T.I.M.E Force (PC)

Yeah, nuff said.

 

Mighty Switch Force 2 (3DS)

I really enjoyed the first one on the 3DS. Here’s to hoping this one is bigger and badder than the first. You play as Patricia Wagon, who in this go round is now trying to save the reformed criminals from the first game with her unique powers. Wayforward, the makers of this game, are also in charge of the remaster of the SNES classic Ducktales!

 

Monsters Invade (iOS)
This is on the list mainly for the crazy inflatable they were handing out. LOLWUT?

Awesome.

 

This list doesn’t include tons of big triple-A titles like Hawken, Luigi’s Mansion – Dark Moon and The Last of Us. These should be at the top of everyone’s list already.

I should also mention a few games that were on display that I’ve already play and recommend as well.

Major Magnet (for iPhone)

 

Beautiful animation, spot-on chiptune soundtrack and the level designs take me back to Sonic and the 16 bit Sega Genesis. The devs are two young guys who were nice to talk to and I wish them all the best.

Major Magnet

 

Ridiculous Fishing (also for iOS)

Imagine an arcade-y fishing simulator where you have to see how deep you can cast your line. Then imagine that you have to catch as many fish on the way back up. Then, on top of that, imagine that as you reel the fish from the water you have to shoot them as fast as you can. Oh, and all the imagery is in weird 45 degree parallelogram shapes. Did I mention that your lure has a chainsaw attached to it? It’s, well, ridiculous.

Oh, and anything by Double Fine, including the release of Brutal Legend for PC!