GeoURL Mapping BookMarklet

Announcing the GeoURL Mapping BookMarklet release 0.1. As mentioned in my last post, I thought it would be neat if you could easily call up a map when you were looking at a web page that had a geocode — that is, a page in which the author had embedded global latitude/longitude coordinates using the conventions outlined by GeoURL or GeoTags. There aren’t all that many pages that are tagged like this, but hopefully more people will be doing it in the future. If the tool finds a tag and can parse it, it opens a new window and loads a MapQuest map centered on the page’s latitude and longitude; otherwise it pops up an alert telling you that it failed.
The JavaScript itself turned out to be not that hard to write, although I have no idea which browsers it works on. Well, I know that when it’s embedded in a test HTML page, it works on Safari and Mozilla Firebird. It just uses W3C DOM, so most newer browsers should support it. The real hassle, however, was getting the javascript to move happily into Safari’s menu bar — boy, it would be cool if browsers gave bookmarklet-type extensions first class support. As it is, you have to monkey around with URL encoding to end up with something like this:
javascript:var%20metatags%20%3D%20document.getElementsByTagName(%22meta%22);var%20geoloc%3Dnull;for(var%20i%3D0;i%3Cmetatags.length;i%2B%2B)%7Bif%20(metatags.item(i).getAttribute(%22name%22))%7Bvar%20name%3Dmetatags.item(i).getAttribute(%22name%22);if((name%3D%3D%22ICBM%22%7C%7Cname%3D%3D%22geo.position%22)%26%26metatags.item(i).getAttribute(%22content%22))%7Bgeoloc%3Dmetatags.item(i).getAttribute(%22content%22);break;%7D%7D%7Dvar%20re%3D/(.%2B)%5B,;%5D(.%2B)/i;if(geoloc)%7Bif(re.test(geoloc))%7Bvar%20lat%3DRegExp.$1;var%20lon%3DRegExp.$2;var%20win%3Dwindow.open();var%20mqURL%3D%22http://www.mapquest.com/maps/map.adp?latlongtype=decimal%26latitude=%22+lat+%22%26longitude=%22+lon+%22%26zoom=8%22;win.document.location=mqURL;%7Delse%7Balert(%22couldnt%20parse%20location:%20%22%20%2B%20geoloc)%7D%7Delse%7Balert(%22no%20location%20meta-tag%20found%22);%7D
Here is the same code without the URL-encoding, in case it helps you read it or otherwise manipulate it:

var metatags = document.getElementsByTagName("meta");
var geoloc=null;
for(var i=0;i<metatags.length;i++){
  if (metatags.item(i).getAttribute("name")){
    var name=metatags.item(i).getAttribute("name");
    if( (name=="ICBM"||name=="geo.position")
         && metatags.item(i).getAttribute("content")) {
      geoloc=metatags.item(i).getAttribute("content");break;
    }
  }
}
var re=/(\S+)\s*[,;]\s*(\S+)/;if(geoloc){
  if(re.test(geoloc)){
    var lat=RegExp.$1;var lon=RegExp.$2;
    var win=window.open();
    var mqURL="http://www.mapquest.com/maps/map.adp?latlongtype=decimal&latitude="+lat+"&longitude="+lon+"&zoom=8";
    win.document.location=mqURL;
  }else{
    alert("couldnt parse location: " + geoloc)
  }
} else { alert("no location meta-tag found"); }
It works pretty well on GeoURL pages — I have tried a sampling of my neighbors and it works on most that I’ve tried. It failed on the one or two GeoTags pages I tried, but that project seems to have a lot less activity that GeoURL. You are encouraged to use the above, but I make no offer of support at all — the reasons it is likely to break are the most tedious and boring problems to solve. I copied and pasted the above into a Safari Bookmark and it worked; however, I did the same with Mozilla Firebird and it didn’t. Fortunately, I use Safari a lot more than I use Mozilla.

Finding Bloggers by Location

Sébastien Paquet writes on Many-to-Many:

Brian Montopoli writes on what one can learn about particular city areas by paying a virtual visit to local bloggers. Of course, finding them is an issue, but thanks to the emergence of blogmaps such as the dcmetroblogmap or the New York City blogger map and theuber-global, RSS-enabled GeoURL server , it gets a lot easier.

I’m more interested in GeoURL and GeoTags, which tap into data encoded in web pages — the manual nature of the city blog-maps means that the place-data doesn’t extend past that site. It also makes for cleaner and more readable maps, of course.
Next project: a bookmarklet which parses the current page and if it finds GeoURL or GeoTags location, passes to MapQuest to get a map of that location. This would be so easy to do that it’s kind of ridiculous that MapQuest or MapBlast (now MSN MapPoint) doesn’t offer it already.
For me to do it, the main question is whether you can really do that kind of thing in JavaScript, or if I’d have to pass the page URL back to a server for parsing. I’ve been so javascript averse after the horrors of cross-browser variations, but I think that those things have cooled out a bit. Any JavaScript mavens reading this feel free to comment before I hit the reference books. It’ll be a piece of cake to do on the server side, but it would be more elegant to do it all on the browser.

Spotlight Update

?

Like you really care about all my little Python explorations…
Anyway, I’ve made some small changes to the Spotlight feature introduced yesterday. Most usefully, I’ve switched to using Mark Pilgrim’s “ultraliberal” RSS parser instead of Orchard since, well, I needed a liberal RSS parser.
Ironically, according to Mark’s post, this was created in part for Aaron Swartz, about six months after the date on Aaron’s post which pointed me to Orchard in the first place.
I also took the time to make it just a bit more tidily organized, with functions and all. I really love the interactive Python interpreter.

California Crisis

Meg Hourihan points to a good Economist article, California in Crisis: Is the Golden State governable?
Lest you think “not my problem,” the article concludes with the recognition that this is just the most visible facet of a national problem:

California is an extreme case of something happening all over America. A combination of voter apathy and partisan redistricting—the ability to draw constituency boundaries to make seats safer—has made politicians more responsive to table-bangers than to voters.

What to do?

Song of the Day: Yo La Tengo, “Nuclear War”

Thank you, Epitonic. Some time ago, I visited their Yo La Tengo page and downloaded an MP3 of their cover of Sun Ra’s “Nuclear War” (from an EP that has four versions of the song.) I guess I never really listened to it, but today it popped up on the ol’ iTunes random play, and it really made me happy. And it can make you happy too, if you just go download it.
If a chorus of children singing “Whatcha gonna do without your ass?” offends, save yourself the trouble, though.
Just in case you care, I came across this not-so-glowing review of the EP while looking for the cover art to add to my MP3. But their main objection, I think, is the fact that the EP is four versions of the same song. The “second version” which they seem to appreciate the most, is the one that Epitonic serves.

New Feature: Spotlight

Hey, this Python stuff is pretty cool.
Just for an exercise, I added another chunk to the front-page margin (which will soon collapse under its own weight.) This one selects one random site from my blogroll and, if the site has an RSS feed, it grabs the feed and produces a list of the entry titles, with links back to the full pages, of course.
Based on Aaron Swartz’ recommendation, I used Orchard to do the RSS processing.
Getting the basics was easy, but this one may bring up some more wrinkles than the blogroll excerpt project. This is mainly because I’m consuming XML from any of a large number of different sources, each of which may be more or less in tune with the specs (or more to the point, more or less in tune with what my heap of code is expecting). In my testing I’ve already seen some pretty ugly breakups, but since I haven’t yet explored exception handling in Python, I figure I’ll just make this thing live and use whatever errors crop up as a motivation to figure it out. There are also some aesthetic questions — should I limit the number of items? Some feeds have 15 or more. Also, are titles themselves that interesting? I’d kind of like to present excerpts, but some RSS feeds include a lot of text, so unless I excerpted it myself, I could end up with a totally uncontrollable mess over there — when the margin is already feeling kind of overstuffed. And I haven’t even seen a case yet when my script couldn’t grab the expected RSS feed, but it’s certain to happen.
Anyway, hopefully you’ll stumble across something interesting in the margins.

Sprung for Spring: Supreme Court Justices

So, my fascination with the idea of tidily bundled conceptual objects led me to spring for a copy of Spring.
As an experiment, I’ve created Spring objects for the current members of the Supreme Court of the United States. This is mostly because I used to work on the Oyez Project, so I have a familiarity with the “concepts” around Supreme Court justices and cases. And, I know where to find some decently structured information about them.
I’m not entirely sure what anyone will do with these, but if you come up with anything interesting (or have suggestions on how I might expand these) let me know. Note that the links below will only do anything interesting if you’ve installed Spring, and Spring only runs on Mac OS X. Click on the tiny ‘Spring’ button to add the given justice to a Spring canvas:
User Creations' SpringChief Justice William Rehnquist
User Creations' SpringJustice John Paul Stevens
User Creations' SpringJustice Sandra Day O’Connor
User Creations' SpringJustice Antonin Scalia
User Creations' SpringJustice Anthony Kennedy
User Creations' SpringJustice David H. Souter
User Creations' SpringJustice Clarence Thomas
User Creations' SpringJustice Ruth Bader Ginsburg
User Creations' SpringJustice Stephen G. Breyer

Turn the Tables: Total Government Awareness


On Independence Day, the MIT Media Lab announced their Government Information Awareness project. After being slashdotted, boinged, and covered in Wired (not necessarily in that order), the site today warns that several features are currently disabled because of high traffic.
The core idea is brilliant, of course, and not too far from the visions of many folks from the early days of the internet. And, of course, it’s not the first government tracking project. But it’s refreshing that they frame their inspiration firmly in the context of the Total Information Awareness (TIA) System.
They lead with this quote, from James Madison:

“Knowledge will forever govern ignorance, and a people who mean to be their own governors, must arm themselves with the power knowledge gives. A popular government without popular information or the means of acquiring it, is but a prologue to a farce or a tragedy or perhaps both.”