Posts about github

WP Biographia Is But A Quarter Of The Way To WP Mappa

Matt Whatsit's fault; he writes very profane and very funny blog posts and reading his recent The Five Stages Of P****d Wife (which you should read if you haven't already, err, read it) made me laugh, hell, it made me ROFL and LMAO at the same time but it also made me think, though not necessarily about wives or drunkenness ...

Now background reading and general swotting up on a topic is all very well but to really learn how to do something you just have to roll your sleeves up and do it yourself. Though it's probably stretching a comparison too far, you don't learn to drive a car through reading the highway code; you actually get behind the wheel (preferably under supervision) and ... drive. You don't learn about what food tastes good from a recipe book; you ... taste the stuff yourself.

And so it is with writing code and using new and unfamiliar APIs. It was definitely the case with my recent (reacquaintance of, and) foray into JavaScript and the addition of support for Nokia's Ovi Maps API to the Mapstraction project, with the added benefit of having to teach myself how to move from my (by now very dated) knowledge of version and revision control under CVS to git.

In a way, this was all Matt Whatsit's fault; he writes very profane and very funny blog posts and reading his recent The Five Stages Of P****d Wife (which you should read if you haven't already, err, read it) made me laugh, hell, it made me ROFL and LMAO at the same time but it also made me think, though not necessarily about wives or drunkenness ...

Now background reading and general swotting up on a topic is all very well but to really learn how to do something you just have to roll your sleeves up and do it yourself. Though it's probably stretching a comparison too far, you don't learn to drive a car through reading the highway code; you actually get behind the wheel (preferably under supervision) and ... drive. You don't learn about what food tastes good from a recipe book; you ... taste the stuff yourself.

And so it is with writing code and using new and unfamiliar APIs. It was definitely the case with my recent (reacquaintance of, and) foray into JavaScript and the addition of support for Nokia's Ovi Maps API to the Mapstraction project, with the added benefit of having to teach myself how to move from my (by now very dated) knowledge of version and revision control under CVS to git.

May the source code be with you

So, first JavaScript and Mapstraction and the Nokia Maps API and now to PHP and the WordPress API. There's a lot of WordPress plugins that do geo-related stuff with your blog but none of them actually do what I want. WP Geo comes close, but it uses Google Maps and Google Maps only. Now I have nothing against Google Maps or the Google Maps APIs but I want maps from the company I work for on my blog.

When I came to add Nokia's Maps API to Mapstraction I at least had a head start. I'd done some JavaScript and I was at least familiar with the Mapstraction API. But writing a WordPress plugin was another thing entirely. Despite hosting my blog on WordPress since 2004 and being able to hack a moderate amount of PHP, I'd never needed to use the WordPress API. Until now.

Bearing in mind the old adage about walking before you can run I decided the best way to tackle this was to write a WordPress plugin for something much more simplistic and this is where Matt Whatsit comes in. At the foot of each post is a nice little biography; in Matt's case it read "Stole some Chewits in 1979. The guilt still haunts me".

So I searched for a plugin that would give me this capability. There's lots. But as with the desire for a geo-related plugin, none of them did exactly what I wanted. The closest I could find was Jon Bishop's WP About Author plugin. So, as all WordPress plugins are licensed under the version 2 of the GNU Public License, I took Jon's plugin and hacked it to do what I wanted it to do. The result is what I've called WP Biographia and you should be able to see the results of it at the foot of this post, if you're reading it from this URL.

I now know, or at least understand at a conceptual level with much web searching of the WordPress Codex, how to write and structure a WordPress plugin. I still need to know how to write and structure a WordPress widget but that will form part of the next version of WP Biographia. By then, I should be armed with enough WordPress API knowledge to start to write what I really wanted to write, which is my geo-related plugin, which may, or may not be called WP Mappa. I'm only a quarter of the way there, but it's a quarter more than when I started this.

In the meantime, WP Biographia is now part of the official WordPress plugin repository and is also up on github as well. It also now has a resident page here on my blog which I'll update as and when I make sufficient changes and improvements to warrant a new version.

Starting to code again is addictive and I seem to have managed to rack up a few github repositories of recent. WP Biographia is but one of what I've christened, in line with the theme of Gary's Bloggage, Gary's Codeage. For now, it's a holding pen for those code projects that live in github but for which I've yet to write a formal page on. These may appear sometime in the not too distant future as and when time permits.

Photo Credits: ficek1618 on Flickr.

Mapstraction, Maps and Me

Nokia has been taking up almost all of my time and what little time has been left has been spent with my family. But in between day job and family time there's evenings spent in a hotel room and hours spent on a plane, mainly between London's Heathrow and Berlin's Tegel airports. It's in these periods of time that a combination of my MacBook Pro, running a combo of Apache/MySQL/PHP with MAMP and TextMate has allowed me to rediscover the pleasure of what I used to do for my day job before Yahoo! and before Nokia ... and that's to write code.

It's been a while since my last blog post; my day job at Nokia has been taking up almost all of my time and what little time has been left has been spent with my family. But in between day job and family time there's evenings spent in a hotel room and hours spent on a plane, mainly between London's Heathrow and Berlin's Tegel airports. It's in these periods of time that a combination of my MacBook Pro, running a combo of Apache/MySQL/PHP with MAMP and TextMate has allowed me to rediscover the pleasure of what I used to do for my day job before Yahoo! and before Nokia ... and that's to write code.

As a fully unreconstructed maps nerd, I love the variety and richness of the mapping APIs available on today's internet. One of the best books on how to use these mapping APIs is the "does just what it says on the label" Map Scripting 101 by Adam DuVander. While the book touches on the power of the APIs from Google, from Yahoo, and from Bing (amongst others) its main focus in on Mapstraction, the JavaScript mapping abstraction library.

Brain Map

As the name suggest, Mapstraction abstracts, or wraps, the differences between the variety of approaches that each JavaScript mapping API uses into a single consistent interface. With Mapstraction, the API methods to create a map, to change the zoom level, to centre the map, to add a marker or push pin to the map are the same, regardless of which underlying mapping API you use.

Mapstraction allowed you to use the mapping APIs from Google, Yahoo, Bing, Cloudmade, GeoCommons, Cartocuidad, Yandex and MapQuest. But not Nokia's Ovi Maps API, which was released in February 2011. This is where my local Apache installation, TextMate and the aforementioned hotel room and flight time comes back into the story. Cue a frantic crash course to reacquaint myself with JavaScript, some trial and error, some swearing and some background reading to convert my slightly outdated knowledge of CVS into how to use git and Mapstraction now supports the Ovi Maps API. No, really. It's on github right now.

There's a demo of some of the major features of both Mapstraction and the Ovi Maps API over at maps.vicchi.org and, in the spirit of social coding, the source for that is on github as well.

I'm not suggesting for one moment that if the current geo day job falls through I can happily pick up a replacement role coding JavaScript, or coding anything for that matter, but it's oddly reassuring that I still have the vague ability to continue the profession of coding software that earnt me a living for almost 25 years.

Photo Credits: Infidelic on Flickr.