For the curious casual visitor to a Wiki, a “Did You Know?” section can be a great way of learning random factoids. Such trivia can be astonishing or fascinating, and tend to interest a lot of people.
It doesn’t surprise, then, that the main page of Wikipedia and the Main portal at Memory Alpha do feature this. What does surprise is the amount of manual labor they employ to make this work.
I didn’t expect to see this information pulled automatically from articles, though it would be nice; it would probably have huge performance implications. (Then again, something like this could easily be cached, with the cache only refreshed when edits are made where factoids are added/edited/removed, or even only manually, so I’m not sure that argument rings particularly true.)
I did, however, expect the visible result to be automatically, randomly rotated from a list. At neither site, this is the case; Memory Alpha uses a weekly process of collecting up to five items (which every now and then fails to collect anything at all), and Wikipedia, well, they’re just weird.
A manual selection has two flaws: readers see the exact same list each time they visit the site , boring themselves to death while waiting for new submissions (or, in Memory Alpha’s case, having to wait an entire week hoping submissions do come in), and, obviously, editors have to create this list to begin with — on top of the actual gathering work.
MYSTlore, therefore, takes a different approach. It only took me a few hours to work on, and that’s with very limited knowledge of MediaWiki’s internals, and an outdated version (in newer versions, additional hooks exist to potentially make this a lot easier to implement), so it can’t be for technical reasons that other sites have chosen to do it manually; it must be simply a difference of opinion, but Tay and Capella completely agreed with me that my approach is not only more obvious, but also preferable.
We have a template which has a simple bullet-point list of such items. The template page itself, through “noinclude” tag trickery, adds some simple documentation so editors know how to get started, and a link to a mere list so visitors don’t get too confused. That list simply uses template inclusion.
The main page is a little trickier. Right now, the syntax for it looks like this:
=== Did You Know? ===
<small>
This section is in progress. A total of <DidYouKnowCount>{{Did You Know}}</DidYouKnowCount> factoids has been collected.
<DidYouKnowPurgeLink></DidYouKnowPurgeLink> • [[MYSTlore:Did You Know|List all]] • [[Template:Did You Know|Contribute]]
</small>
<DidYouKnow>
{{Did You Know}}
</DidYouKnow>
It goes without saying that those DidYouKnow* tags are custom. I wrote an extension that implements these three tags. The most important one is DidYouKnow itself, and as you can see, it wraps the template.
The tag uses MediaWiki’s parser to pull the list by including the template, to transform internal Wiki links, and finally to also support the apostrophe syntax for bold and italic emphasis.
Then, it breaks down the list (which is still a bullet-point one, otherwise unparsed, i.e. with each line starting with an asterisk) into an array and removes the first character from each item (i.e., the asterisk). Finally, PHP’s convenient array_rand() function helps us pick a random item from the array (read: a random factoid). After putting the result (read: the factoid, with only internal Wiki links and apostrophe-based emphasis parsed) inside a div with the custom mlDidYouKnow class (which currently does nothing), we return the result. Though it may sound straightforward, and though the result is really just a few lines, getting this to work as intended was nowhere near as simple as it should have been, but in all fairness, I simply wasn’t that familiar with MediaWiki’s structures. Perhaps I’ll do better next time.
The second tag, DidYouKnowPurgeLink, follows a recommendation from MediaWiki’s authors for the rare case (such as this one) where you want to avoid caching as best as possible (in this case, because it would obviously mess with the randomness). The tag merely appends not only action=purge, but also rand=(some random integer) to the URL, thus resulting in a URL that is slightly different just about every single time, making it extremely unlikely the browser will want to cache it (since it will assume it is a different page altogether).
Finally, DidYouKnowCount creates the array the same way, but just counts the amount of items and returns that. I could possibly optimize this a little by only creating the array once, but this isn’t a big deal. After all, it’s cached… oh wait.
I had a lot of fun working on this, and the result seems quite nice. Now all we need is for people to add stuff to this; JohnLynch already tried last night while I was working on implementing it, only to find that what he tried didn’t work (yet) as he had hoped. It now does!
Others' Thoughts
Comment on December 8th, 2006 at 11:33 pm
I didn’t get it. I read some wiki-articles about Myst (never played the game) and the sequels and I am rather puzzled about your enthusiasm and the community around it. I also don’t understand what Uru live really is: Something like a MMORPG only with puzzle solving instead of Orc whacking?
Comment on December 8th, 2006 at 11:52 pm
It’s personal bias. I’m friends with some of the developers/artists/etc., and 90% of my friendships these days (and, thus far, 100% of my romantic relationships) are based on the Myst fandom.
Yes. It is an MMOG, but it focuses on puzzle solving, mini-games, community interaction, etc. There’s no levels, no hierarchy, no fighting, etc.
To answer why I’m so much into this community to begin with would necessite a rather comprehensive entry pretty much explaining why I’m still alive to begin with
When I get around to it, I guess. I’ll certainly acknowledge it’s not everyone’s thing, and I’m not out to “convince and convert” anyone.
Your Own Thoughts
I'd love to hear your input. Just try to stick to a few rules:
Before you comment for the first time (or, after you have deleted cookies), you will have to answer a little challenge to prove that you are not a spammer.
Comments are written in Markdown.