testtestHome

Keeping post slugs when switching from TypePad to WordPress…

20.03.2007 by Mich
A blogfriend of mine, Damien, announced it a while ago. He too would switch to WordPress, following other bloggers like Vinch, Soph & Ced and Denis. The only difference between Damien and them is that Damien is switching from TypePad, while the others were switching from DotClear.

When you change your blog from one system (TypePad) to another (WordPress), you want to keep your URL’s that are linked by other blogs but also Google. WordPress supports URL rewriting quite well, but the only problem is that Typepad does not export post slugs, so building up the same URL’s might seem like an impossible thing to do. Not true.

In case you are wondering what the post slug is, check this URL:

http://lor.em.ips.um/2007/03/hello_world.html

The post slug here is hello_world. TypePad limits the post slug to 15 characters and replaces spaces by underscores. WordPress does not really have a limit on post slugs and uses dashes to separate words, which, from an SEO point of view, is much better.

You could first think of a script that would regenerate the TypePad-like post slug, but sometimes, for some reason, the post slug totally differs from post title. Not really an option for Damien who wants to keep his URL’s using WordPress, especially when I told him that it would be possible to keep his links. For retrieving his TypePad post slugs I used a somehow amateur yet fun method: JavaScript (through GreaseMonkey)!

Manually, I opened up each month, starting from the most recent, in his archives and extracted all post slugs from his permalinks that I thereafter pasted in a text file, respecting the chronology using this GreaseMonkey script:

var titles = document.getElementsByTagName("h3");
var txt = "" ;

for(i = 0 ; i < titles.length ; i++){
txt+=titles[i].firstChild.href.split("/")[6].split(".")[0]+"<br/>";
}

var resultDiv = document.createElement("div");
resultDiv.innerHTML=txt;

document.documentElement.ownerDocument.body.appendChild(resultDiv);

If you want to use this script, you might have to change it in order to be able to use it on your own site. Your permalink structure might also be a bit different, so keep that in mind.
Click here to download the GreaseMonkey base for this.

Once I had all the post slugs in my text file, I removed all the posts from the freshly installed WordPress installation to remove all ‘default’ posts. After that, I imported in WordPress all posts using the TypePad export file. Once this was done, I ran a query to select all the ID’s in descending order from the blog articles that had the status ‘published’ and exported this to a csv-file:

select ID
from wp_posts
where post_status='publish'
order by ID desc


If all went well, we now have 2 lists of the same length. One list looks like this, containing all post slugs:

belgique_les_pa
la_couleur_de_v_1
la_rumeur_du_jo

The other list contains all post ID’s:


1034
1033
1032

1034 is the ID of the post that has the post slug ‘belgique_les_pa’ and so on. Somehow, I now from these two lists had to do a database update. For this, I first turned the lists into JavaScript arrays. An easy thing to do with an editor such as EditPlus.
The post slug array:

var slug = new Array() ;
slug[slug.length]='belgique_les_pa';
slug[slug.length]='la_couleur_de_v_1';
slug[slug.length]='la_rumeur_du_jo' ;

The id array:

Var ids = new Array() ;
ids[ids.length]=1034;
ids[ids.length]=1033;
ids[ids.length]=1032;

And finally, a script that generates an SQL query from those lists:

for(i = 0 ; i < ids.length ; i++){
document.writeln("update wp_posts set post_name='"+slug[i]+"' where id='"+id+"';<br/><br/>");
}

That script generates queries such as:

update wp_posts set post_name='belgique_les_pa' where ID='1034';

Once all those queries are generated, I run them, and post slugs under WordPress should be ok. You just have to check the way that WordPress rewrites your URL’s in order to match with your old TypePad installation. In Damien’s case:

/bloggingthenews/%year%/%monthnum%/%postname%.html


I know this method is kind of complicated, but it’s a fun thing to do. It would be a lot more easier if TypePad would actually export the post slugs as well. Luckily for Belgian blogs, there aren’t too many TypePad blogs around.
tags: . . .

6 comment(s) - 165 trackback(s)

Wikipedia World and Google Maps/Earth…

20.03.2007 by Mich
Maybe you already noticed Wikipedia had geographic parameters, like latitude and longitude associated to articles. You might even have seen the geographical layer in Google Earth which has a selection of georeferenced Wikipedia-articles.

Concentration of geotagged Wikipedia article (Source: Wikipedia)

I was wondering if there wasn’t a file that gathered all links to geotagged Wikipedia articles. A search on Wikipedia quickly revealed the existence of ‘WikiProjekt Georeferenzierung’, or ‘Wikipedia World’ in English. On this page, an occasionally refreshed dump can be downloaded in CSV and SQL format. It contains links to georeferenced articles in the following languages: English, German, Spanish, French, Italian, Japanese, Dutch, Polish, Portuguese, Russian and also Swedish. I downloaded the file and started playing around with it, because I was wondering at what point articles about places in Belgium (my home country) were georeferenced.

Geotagged Wikipedia articles in Belgium (Google Maps) Geotagged Wikipedia articles in Belgium (Google Earth)


The two maps above show a Google Maps version as well as a Google Earth version (in kml-format) that I wrote. Click on the links to open them. If you decide to show the Google Maps version, I advise you to be patient, because it takes a while (JS is and has always been slow!).

Because I did not really want to load the database with too much data, I limited myself to points located between some latitudes and longitudes and that did not have the Country-ID FR, NL, LU or DE. Limiting me to BE-points would have been a bad idea, because the country-parameter isn’t always filled in!

In case you are interested, here is the SQL-request :

select count(*) from wpgeo
    where lat>49.49 and lat<51.51
    and lon>2.4 and lon<6.46
    and country!='FR' and country!='LU'
    and country!='DE' and country!='NL'


This is giving me a whole lot of mash-up ideas, but unfortunately, the number of georeferenced articles are rather limited at this moment.
tags: . . .

4 comment(s) - 4015 trackback(s)

Google Maps Lightbox…

01.03.2007 by Mich
Maybe you already know the image JS lighbox by Lokesh Dhakar which overlays images on your site. Inspired by that, I decided to program something similar for Google Maps. Ideas and principles are the same:
  • Make a link to a URL with the HTML-tag a.
  • Adding a relation to that tag through the attribute rel.
  • Example: <a href="%google_map_link" rel="gmap">Blabla</a>
Afterwards, a JavaScript will scan all links with the relation ‘gmap’ and add an extra onclick behaviour to it, which will overlay a Google Map on your browser once you click it.

This method has a great advantage as people can access the map even from their RSS-readers. The script will only run inside the site where it will parse the Google Maps URL and build up an embedded and overlaid map.

To see the script in action, just click one of the links underneath:
I’ve been there and there, but would also like to go there too.

Click here to download gmlightbox 0.1
Script has been tested with FF2 and IE7 but I have no idea what it will look like in IE6.

Installation can be done easily in 4 steps:
  1. Unzip the files on your server.
  2. Ask a Google Maps key for use on your server and insert that into your page/templates.
  3. Include the gmlightbox JavaScript (urlbase matches your site):
    <script src="http://%urlbase%/gmlightbox/gmlightbox.js" type="text/javascript"></script></li>
  4. Include the gmlightbox CSS:
    <link href="http://%urlbase%/gmlightbox/gmlightbox.css" rel="stylesheet"/>

Once those four steps are done, you are ready to use gmlightbox. For using it, two easy steps:
  1. Go to Google Maps and find the spot you want to show. Once you've got it, click « Link to this page ».
  2. Replace %google_maps_url% by that Google Maps link:
    <a href="%google_maps_url%" rel="gmap" title="Title">Hellow</a>

Ready!

As this script is not quite perfect yet, please notify me of any bugs or annoyances. I'm open to critic. I will adapt and post updates of it once it has been changed.

PS (12 Dec 07) : I am currently working on an update of this script. It will be released soon, by the end of the year I hope.
tags: . .

32 comment(s) - 1639 trackback(s)

Reactivated, third try…

24.02.2007 by Mich
I really have been neglecting this part of the website for a long while. The last entry is dated from March of last year. I’m going to write in this section again, this time a bit more, because I know what I will post here. It will be mainly about stuff I do on the technical side. That means: stuff I program, site and product reviews.

See you soon!
tags:

Add a comment - 1 trackback(s)

How to link Google Earth to your photoblog…

11.03.2006 by Mich

Haven’t you ever wanted to map all your pictures on the earth surface? There already are some things like Mappr, but it’s only available in the US and is only for those with Flickr accounts. I myself programmed my own photoblog, which makes it more difficult to use a tool like that, especially when I live in Europe.

While I was saving some points of interest in Google Earth, I noticed they had 2 formats: “.kmz” and “.kml”. Since I was curious, I saved the file in both formats and opened them in an editor. The “.kmz” was just a boring binary file where I could not understand a clue of the special characters, while the “.kml” was an xml-file. I googled for some more information and landed on a tutorial page as well as a general reference.

Since I already linked all my pictures with Google Maps by keeping their longitude and latitude, I was only one step away to generate a file that would point out all my pictures in Google Earth. So there I went: I fetched all the rows out of my database that contained longitude and latitude and iterated over the list to generate all the “Placemark” items.

Basically, this is how my PHP-script generates the “<placemark>” items:

<?
        
echo "<Placemark>";
        echo
"<description><![CDATA[<a href="http://visual.emich.be/?picid=$id">$name<br><img src="http://www.emich.be/images/$dir/tmb$file" alt="$name"/></a><br>$description]]></description>";
        echo
"<name>$name</name>";
        echo
"<LookAt><longitude>$ycoord</longitude>";
        echo
"<latitude>$xcoord</latitude>";
        echo
"<range>540.68</range>";
        echo
"<tilt>0</tilt>";
        echo
"<heading>3</heading>";
        echo
"</LookAt>";
        echo
"<Point>";
        echo
"<coordinates>$ycoord,$xcoord,0</coordinates>";
        echo
"</Point>";
        echo
"<Style><IconStyle><Icon><href>root://icons/palette-4.png</href>
        <x>192</x><y>64</y>
        <w>32</w><h>32</h></Icon></IconStyle></Style>"
;
        echo
"</Placemark>";
?>

The result is different placemarks, like this one:

<Placemark>
    <description>
        <![CDATA[ <a href="http://visual.emich.be/?picid=2">Le bout du tunnel<br><img src="http://www.emich.be/images/misc/tmbbrol140505.JPG" alt="Le bout du tunnel"/></a><br>Et tout en haut, il y a Maria
    ]]>
    </description>
    <name>Le bout du tunnel</name>
    <LookAt>
        <longitude>4.36772222222</longitude>
        <latitude>50.8488722222</latitude>
        <range>540.68</range>
        <tilt>0</tilt>
        <heading>3</heading>
    </LookAt>
    <Point>
        <coordinates>4.36772222222,50.8488722222,0</coordinates>
    </Point>
    <Style>
        <IconStyle>
            <Icon>
                <href>root://icons/palette-4.png</href>
                <x>192</x>
                <y>64</y>
                <w>32</w>
                <h>32</h>
            </Icon>
        </IconStyle>
    </Style>
</Placemark>

Finally, I just have to set the central point of my “globe” in the root "<Document>"-tag. In my case, this would be Brussels, Belgium.

<LookAt>
  <longitude>4.351995</longitude>   <latitude>50.846617</latitude>
  <range>5000</range>
  <tilt>0</tilt>
  <heading>3</heading>
</LookAt>

The result is a .kml-file that can be downloaded at this location and will open in Google Earth, so you can see all the spots of which I have a picture. It displays a little camera at each spot, and the description has a thumbnail. If you click on the thumbnail, you'll arrive on the pages on the photoblog.

I am thinking of writing a script for flickr, that works the same way as mappr, but for Google Earth. Using 2 tags and a specific tag and for latitude/longitude. Maybe even more…

The advantage of generating a KML-file is you don't have to do any maintenance on it!

Anyway, I just wanted to share this with others.

tags: . . . .

1 comment(s) - 1 trackback(s)

Brussels, Seen From The Sky…

11.02.2006 by Mich

A few nights ago I went to the opening of Wim Robberechts’ photographic exhibition « Brussels, Seen From The Sky », which is taking place at the Halles St Géry. The exhibition shows pictures of the book, which has the same name, in larger formats, as well as some other pictures not present in the book.

If you want to discover the city from an angle in which you’ve never seen it before, I can really recommend this exhibition to you. It’s taking place there from the 9th of February until the 23rd of April.

tags: . .

Add a comment - 1 trackback(s)

OST: IIs - Next Level

Third type encounters…

07.02.2006 by Mich

When I saw a picture on Cedric’s blog, I realised that I had totally forgotten that I also had a picture to publish about what is believed to be the most customized van of Brussels.

Bhakta Michel's van

On the above picture, you can see that a link was painted on the van. Curious as I am, I could not resist going and having a look at his website. You can’t really find any web pages there, but more scans of articles and other things that are, how should I say, quite special.

Everyone has its convictions, his thoughts, especially in these times of free speech. My target isn’t to make fun out of the guy, but more to inform and share some information with you about this quite special person.

tags: .

2 comment(s) - 2 trackback(s)

It’s been a while…

07.02.2006 by Mich

I remember having spent lots of time making this web site multilingual. For what? I haven’t put an English article on it for months! Well, I will try to do my best now!

tags:

2 comment(s) - 3 trackback(s)

eMich goes English…

14.10.2005 by Mich

Some persons wanted me to make an English section on this web site. Others asked for a Dutch section. I don’t know what I will make out of it, but I will try to do my best. Every message that is published in French won’t be systematically translated to English. It will all depend on my mood at that moment and the language I want to post in.

Well, I believe I have nothing more to say now…

7 comment(s) - 5 trackback(s)

OST: Manu Chao - Mala Vida (live)
next