Not long ago, I took advantage of a nifty WordPress plugin to enable XML sitemaps for the blog. For those who’ve never heard of XML sitemaps (I hadn’t for quite a while), they are little XML files in a specific format that give search engines like Google hints on how to index your site. They don’t necessarily improve your search rankings per se, but they help the search engine better decide what to index, when it was last updated, relative priorities of different pages, etc. You then throw a special line into your robots.txt file or directly submit the file to the search engine to let it know the file is available. Once the engine knows about it, it will check it periodically to optimize how the site is indexed.
The plugin, of course, makes this ridiculously easy for WordPress. However, GPF gets orders of magnitude higher traffic than the blog does, so finding a way to generate sitemaps there would be ideal. I toyed with the idea for a while until I finally sat down, examined the sitemap specification, and figured out how to roll my own code. It now successfully runs via cron each morning and gives a pretty thorough census of what’s available on the GPF server. The problem is that the GPF site is divided into several parts that are largely autonomous and self-contained:
Ignoring the forum, that left me three major sub-projects for creating sitemaps. It’s easy enough to segregate these into separate files and tie them together using a “sitemap index” file, so that wasn’t a problem. The archive would just be a formatted dump of the archive database, deriving approximate update times from the posting date. The bulk of the rest of the site could be done by stepping through the file structure of the site and taking note of every HTML or PHP file and its last modification time (conveniently ignoring certain files and directories that don’t need to be counted, like access-restricted Premium pages). And that leaves the wiki.
I managed to come up with a decent wiki sitemap routine that I thought I’d share, just in case someone else might be interested. Of course, it’s not likely to be useful for massive wikis like Wikipedia—sitemaps are restricted to 10MB in size and 50,000 URLs—but something small like the GPF Wiki would be easy to submit and index. It was built using MediaWiki 1.12.0; I am uncertain what database changes may be needed for older or newer versions. Here’s my current process:
I only want to index relevant pages, including category pages. The relevant database table for this is “page”. (How… convenient). Unfortunately, this table also contains things like redirects and images. Each image has its own “page” assigned to it; try clicking on an image in Wikipedia or in the GPF Wiki to see what I mean. The time stamp of the latest revision, however, is stored in the “revision” table, joined to the page table by the latest revision ID number. So a good starting bit of SQL would be:
select p.page_title, r.rev_timestamp from page p, revision r where p.page_latest = r.rev_id and p.page_is_redirect = 0 and p.page_title not like '%.gif' and p.page_title not like '%.png' and p.page_title not like '%.jpg';
Unfortunately, this also returns a few meta pages like the sidebar and editing pages. Before selecting, I define a look-up hash of titles I want to avoid and as I loop through the results I just skip those.
The title, of course, is both the displayed title and the input portion of the URL that uniquely identifies the page. Thus, knowing the base URL (
http://www.gpf-comics.com/wiki/) I can easily reconstruct the public URL of any article from the title. As with Wikipedia links, spaces have already been converted to underscores, but the rest of the string needs to be be URL encoded. This is easy enough, so we can quickly build the full URL as required by the XML schema.
The time stamp is a little bit tougher. MediaWiki stores time stamps as a 14-digit number in YYYYMMDDHHMMSS format, always in UTC time. In Perl (in which almost all my crons are coded) this is easy enough to break apart and turn into a UNIX time stamp. I then output the date in W3C ISO 8601 format as required by the schema. A sample of a resulting entry would be:
<url> <loc>http://www.gpf-comics.com/wiki/Nick</loc> <lastmod>2008-08-22T06:00:07Z</lastmod> <changefreq>monthly</changefreq> <priority>0.3</priority> </url>
Change frequency and priority are purely guesses and fudges for mine. According to the sitemap specification, priorities are purely relative to other parts of the site. I rated the wiki pages as relatively low since the wiki at GPF is considered a “supporting” page and subordinate to things like the archive. As for change frequency, the sitemap specification includes a number of predefined choices (hourly, daily, weekly, monthly, etc.). Monthly was a purely off-the-cuff guess; some pages may update more or less frequently, but monthly would be a good average. It is entirely possible to rate select pages as higher priority or frequency than others, but I decided to take the easy route and rate everything the same. To apply different values, you just need to pay special attention to the title and assign a non-default value when that title crops up.
Well, I hope someone out there might find this helpful. I’m not sure if it really helps anyone find anything at GPF, but it was a fun little exercise nonetheless.
My wife recently bought a Wii Fit. She’s been coveting the device ever since she first heard about it. I would say I’ve caught her looking into the window of the local gaming stores as much as I have lately, but she actually plays more computer games than I do. The Wii Fit has just made her look even more frequently. So it wasn’t really much of a surprise when she announced to me via e-mail a week or so ago that while she was at a toy store during lunch looking for birthday presents for Ben (who recently turned two), she snatched up a Fit just as they were opening a new case.
I’ve been mildly skeptical of the device. I’ve known enough fitness nuts and I’ve got enough head knowledge about fitness matters to know that a wireless scale that talks to your game console isn’t likely to be a good substitute for a membership at the local gym. And it’s not. But it’s certainly better than nothing, and right now between my day job, a 1.5 hour commute each day, chasing after a toddler entering his Terrible Twos, and squeezing in three new comics per week plus site updates… well, nothing is about all the exercise I’ve been getting.
The Wii Fit is far from perfect. As stated above, it’s essentially a wireless scale that is sensitive enough to detect shifts in weight. Thus, it knows not only how much you weigh but where you’ve placed your feet, where your center of balance is, and with some sophisticated guesstimation, where your body is in space relative to the device. Believe it or not, that gives it an incredible amount of flexibility as a game controller. For example, there are a number of balance games included, such as a ski slalom course that you control by shifting your weight just like a real skier would, and a “table tilt” game where you try to roll little balls into the holes of a disembodied table by shifting your weight to tilt the table this way and that. It looks to have a lot of interesting potential as a controller beyond the Fit game, especially for sports games like skiing, snowboarding, surfing, etc. The sensitivity is a little questionable sometimes; there’s a step aerobics “game” where you almost have to stomp on the device to get multiple foot presses to register. But all in all, it expands Nintendo’s Wii game play innovations in a new direction.
Another beef I have is its use of body mass index as a general gauge of health. BMI is a better indicator than weight alone, but a good read over the linked Wikipedia article will give you tons of reasons why BMI alone isn’t very useful. OK, I know I’m overweight; I’ve already come to terms with that, and that’s one of the reasons I’ve been using the thing pretty religiously for the past week or so. But your weight (and thus BMI) can fluctuate all over the place during a given day and even day to day. One good Sunday dinner with the in-laws was enough to blow the previous week’s progress according to the all mighty Fit. Unfortunately, it actually gets worse as you improve. Muscle is more dense than fat, so a fit person might have a higher BMI than and overweight person of comparable height and weight. Of course, it would probably have been too difficult (and not to mention spooky) to have little robotic arms with calipers come out to actually measure your true body fat, so I suppose this is better than nothing.
I’m also mildly annoyed with the Fit’s preoccupation with posture and balance. I know my posture isn’t the best in the world. There was concern when I was a child that I might have mild or borderline scoliosis, and my right foot actually turns outward a bit when I stand naturally and comfortably. Both of these, probably combined with years of desk sitting and (admittedly) weight gain, have made my posture less than ideal. The Fit constantly chastises that my center of balance is off-center or, worse, that it can’t get a good measurement because I’m constantly “fidgeting”. Of course I’m fidgeting; I’m constantly readjusting myself to stand perfectly straight just so you can take your blasted measurements. Sigh….
Probably the most useless thing about the Fit is the “Wii Fit Age”. This is some magical, arbitrary calculation based on your real age and BMI that is supposed to determine your overall wellness relative to your true age. In reality, it’s completely pointless and has no basis on anything useful. My Fit Age has bounced around from the mid-50s down to the mid-20s, sometimes within a day of each other. For a man in his mid-30s, that’s a big range. As previously stated, my sense of balance isn’t the best in the world and the Fit Age calculation is based in part on how well you perform on two arbitrarily chosen balance tests such as balancing on one foot, shifting your weight to certain pre-determined ratios, or simply whether or not you favor one leg over another as you walk. Thus, I stink at these games and they throw my Fit Age out the window. I’ve learned to mostly ignore it, as the minor buzz you get from a negative difference between it and your real age is easily offset by the buzz kill when it swings positive the next day, just because you’re tired.
But enough dumping. Let’s say what’s positive here. The big plus is that the Wii Fit has gotten me off the couch and doing something, anything, rather than plopping on my rear every evening after Ben goes to bed. It’s cut somewhat into my comic production time, but not any more than regular household chores. It has a nice balance of different types of activities so it’s extremely hard to get bored of the same old routine. There are yoga exercises (which I pretty much ignore), aerobics (my primary focus for trimming the fat right now), strength exercises, and balance games. Many exercises make combined use of the Fit board and the standard controller; for example, the synchronized boxing has you stepping off and on the board to “block” while the Wii remote and the Nunchuck are used to throw punches. Since the board is a sensitive electronic device, the running activities use the accelerometers in the Wiimote (you stick it in your back pocket) rather having you smash the board with your feet. Unfortunately, it is possible to cheat on such activities, i.e. you can “run” perfectly fine by sitting on the couch and shaking the Wiimote with your wrist. However, you’re on the honor system in that regard and having someone else playing with you can keep you honest.
As stated, I’ve been concentrating on the aerobics portion at the moment. Aerobics are all about burning fat, and I’ve got plenty of fat to burn. At the least, I want to turn that spare tire from a full-size to a compact. So I start by doing a regimine of step aerobics (first the easy beginner mode, then advanced). (You would find this hilarious if you had seen me join my wife’s aerobics class several years ago; it’s quite a mental picture.) I follow this with a nice long run then the sychronized boxing. Once I’ve done all this, I’ve done a good 25-28 minutes of real aerobic exercise. I pad this with a little bit of balance games or strength training to make sure I’m over 30 minutes. Some of the little things it does to encourage you are cheesy, like having other Miis stand on the sidelines and cheer you on while running or by participating in big group step aerobics sessions. This is particularly funny for me because in addition to friends and family running or stepping beside me, I’ll occasionally see some of the GPF Miis my wife created. It’s mildly disheartening to see Dexter run past me at three times my speed, but equally enjoyable to see him trip and land on his face.
The Wii Fit isn’t a suitable substitute for a serious diet and exercise regime by any means. But it’s a fun, entertaining way to get started. I’ve started and stopped many exercise plans over the years, and this is perhaps the first one that really has made me want to get started each evening. Some of the scoring seems arbitrary at times, but each time you beat a previous record you get that sense of gaming accomplishment that motivates you to keep trying. I’m hoping it will be a gateway to a more serious exercise plan, but for now it’s at least getting me to do something more with my evenings than watch TV.