Migrating to WordPress from Movable Type

I wrote this about a year ago as a sort of log of my trials migrating from movable type blogging to wordpress. It’s somewhat tongue in cheek / stream of consciousness so take it for what it’s worth, a little insight into the mind of a developer 😉

Moving from movable type (old ass version) to brand spanking new wordpress.

who wants to deal with cgi-bins, I mean really

movable type has an export feature, yay. Seems like it’s supported with some old version of wordpress. Let’s see, ok, generates proprietary format but it makes sense, does an export, looks like this:

AUTHOR: ChefQuix
TITLE: A little bit of everything…
STATUS: Publish
ALLOW COMMENTS: 1
CONVERT BREAKS: __default__
ALLOW PINGS: 1
PRIMARY CATEGORY: Armageddon
CATEGORY: Armageddon

DATE: 09/14/2003 10:52:19 PM
—–
BODY:
I’ve always wanted to write a blog,

Alright, so quickly install wordpress.

Let’s play around, old ass instructions say modify some file called import-mt.php.

http://codex.wordpress.org/Importing_from_Movable_Type_to_WordPress

Uhoh, this does not exist in the new wordpress. Not suprising, who’s really dealing with legacy shit like this anymore?

Ok, let’s see what new WP can do. Look, import from movable type is built into the tools, yay, wait what’s this, send out FTP credentials to some 3rd party site so they can FTP stuff in? Or WP can FTP stuff in? Is this really the best and most secure way to import files? Yikes.

Grab files manually, install plugin, match up old username with new username, yes, look at that, lots of imports, everything is working great! Closer inspection though..

Cut off blog entries! The old poor quote handling, poor quote exporting situation. And the IDs, not the same, how can I make an .htaccess rule to map from old to new? Not good enough!

Truncate wp_posts, wp_comments tables, lets do this again.

First things first – change old Movable Type export to include the ID.

in <mt>/lib/MT/ImportExport.pm add line in the export function:

POSTID: <$MTEntryID$>

Totally guessed at the template tag and it worked

now import.txt file as ID, will plugin work out of the box? probably not, but lets take a look

ok, import doesn’t support ID out of the box. Fair enough, it’s hard after all.

Add new case for the importer (in process_posts function):

} else if ( ‘POSTID:’ == $line ) {
$post->ID = trim( substr($line, strlen(‘POSTID:’)) );

Modify save_post function – post is saved using wp_insert_post function. Let’s take a look at what this function does and see how we can manually set the ID.

https://codex.wordpress.org/Function_Reference/wp_insert_post

Uhoh:

IMPORTANT: Setting a value for $post[‘ID’] WILL NOT create a post with that ID number. Setting this value will cause the function to update the post with that ID number with the other values specified in $post. In short, to insert a new post, $post[‘ID’] must be blank or not set at all.

Always roadblocks, so how do we work around this.

Lets take a stab in the dark, we’ll manually insert an empty table row with just the ID, then put the ID in the post variable and hope that wp_insert_post updates everything properly. Probably have to set post_date and post_date_gmt, I’m sure this is going to break a bit but oh well.

global $wpdb;

if (!empty($post->ID)) {
$wpdb->insert($wpdb->prefix . ‘posts’,array(‘ID’ => $post->ID),array(‘%d’));
}

scratch that, does wp_insert_post allow us to try to import the ID with the optional import_id parameter? Let’s try that less hacky way first
change modification back to:

} else if ( ‘POSTID:’ == $line ) {
$post->import_id = trim( substr($line, strlen(‘POSTID:’)) );

before we start the import up again, let’s try to clean up the file and fix some of these character encoding issues. Same old problem we always end up having – ‘,”,-,… – these characters always break. What’s the easiest solution? Load up the file in a trusty editor, find an offending character and search and replace. Get rid of the bad characters this way, then save it and do the import.

Ok, so the import runs again, but the IDs, they’re not matching up? What’s going on, time to dig deeper…

Add some debug code..

if (!empty($post->import_id)) {
printf(__(‘converting import_id %s’, ‘movabletype-importer’),$post->import_id);
$post->import_id = intval($post->import_id);
} else {
printf(__(‘wtf missing import_id’, ‘movabletype-importer’));
}

WTF? Importing post Are you also divergent, friend?…wtf missing import_id (2 comments)

Ok so that’s a problem it seems.

Ugh, bad code! Copy pasta from the wrong type of tag, of course it didn’t work. One more try, remove old POSTID bit and put in this:

} else if ( 0 === strpos($line, ‘POSTID:’) ) {
$post->import_id = trim( substr($line, strlen(‘POSTID:’)) );

Duhhhh think before writing code kiddos. Truncate wp_posts, wp_comments, and run one last time, this should fix everything for everyone in all instances…
And it works! Now that the IDs are normalized, I can htaccess example in old link from moving from MT to wordpress to make sure all pages get redirected to the new proper pages. Hoorray!

To make the redirects from the old URLs to the new ones, you just need to do a mysql query and copy and paste it into the WordPress .htaccess file:

mysql -u root -p -N -B -e “select concat(‘Redirect 301 /archives/000′, LPAD(ID,3,’0’), ‘.html /’, DATE_FORMAT(post_date, ‘%Y/%m/%d’), ‘/’, post_name, ‘/’) FROM perceptionalism_2.wp_posts”

(changing of course the user, database and what not for yourself).

This produces an output of:

Redirect 301 /archives/000005.html /2003/09/20/is-there-anybody-else-out-there-thinking/
Redirect 301 /archives/000007.html /2003/09/21/inspiration/
Redirect 301 /archives/000008.html /2003/09/29/wonder/
Redirect 301 /archives/000009.html /2003/09/23/are-you-a-bright/

….

And you’re done!

Denial is Religion

Denial is a what allowed us to evolve as a species, more specifically denial of the end of life via the afterlife with religions, however religions are now holding us back as a species because the assumption that there’s a better life leads humanity to follow a dangerous path. It leads us away from a theory of mind of those around us, and keeps us focusing on our own perceptions and realities. By understanding that there is no more life but this, we come to find it all the more precious. By believing in a life beyond this one, we put off changing our ways and end up convincing ourselves that our adverse behaviours are not dangerous to the the survival of our species. That’s a problem because our denial of the way we treat our planet will eventually lead to the grand pillaging of the resources this fragile biome affords us. And then we all die, in a painful unpleasant existence, one full of strife and indignity, as we use our vast intelligence to create efficient weapons and coerce other civilizations to give up their precious resources so we can suffer less, and our existence less painful. That is not the way I want humanity to end up. That seems like an awful fate for such a promising species.
The problem is our addiction to over consumption. I think that we could peacefully live on this planet, all of us, if we just tailored back our rampant consumerism. If we directed that singular desire to want something into a less destructive resource. At least that’s what I think anyway.

QRB.ca – mobile landing pages

It’s been a while since I’ve posted, but I thought I might do a little update on what I’ve been up to for the none of you that visit this site 🙂 My buddy stungeye and I have launched another web product, this one is specifically designed for mobile phones. At QRB.ca, you can build mobile landing pages with location specific directions for events, locations, or attractions. This is perfect for tourism, small and medium sized businesses, or event planning. Think of how many out of town guests will appreciate knowing where they are and how they can get to your wedding, or tourists in town trying to find the local attractions. It’s perfect for mobile advertising campaigns as a destination page for mobile ads. Anyway, that’s enough spiel! It’s free to try out!

Manitoba Election Website

Last year, for the Winnipeg civic election, I helped develop Winnipeg’s premier election website: WinnipegElection.ca. We were exceptionally pleased with how that turned out, so we’re doing the same thing for the Manitoba Provincial Election. So today, I’m proud to announce our launching of ManitobaElection.ca, the most trusted source of information for the upcoming 2011 Provincial Election. Many new features are in the works, but we’re launching with what we have today to get the word out.

The who of you are

It’s been a while since I’ve written anything, but a post on reddit about memory got me thinking, so I put down some thoughts about how memory works, and memristors!
* * *
I think the reason you have nobody answering is that there is no definitive answer to your question. Memory and consciousness are the big unknowns in philosophy and neuroscience, endlessly debatable and almost impossible to prove. It’s all just theories, which are little more than mental ‘what ifs’.. However, I’ll take a stab and tell you my theory.
So our brains, the most complex object that we know of in existence, are just neural networks of neural networks of neural networks. Think about how we learn, from babies to adults. I imagine that a baby’s brain is a mass of unconnected and pre-mapped out neural networks. Some of these networks will have been formed as a result of our DNA, things like controlling your breathing and heart-rate to the medulla, the thalamus and hypothalamus, probably pre-wired to route information to and from different areas of your brain. The cerebellum is probably hard-wired to control your limbs, but all of these things are connected via pathways to the cerebrum, which I’m betting is mostly unmapped.
So you have a baby, he’s born, he’s basically raw-unmapped sensations, stimulation coming in from all over the place and probably no way to process it properly. All this baby knows is that things are hot, things are cold, he’s hungry, he’s tired, he’s warm, he’s safe, he’s scared, just these raw emotions that are built in for survival. Once he starts growing, he starts learning. He sees that if he moves his hand, he can see his fingers, and if he wiggles his fingers, they move. You start getting these feedback networks getting burnt into the cerebrum, this cause and effect portions of the brain – if he cries, there’s comfort, he see’s his mom, she tickles him, little networks getting formed in the cerebrum. As the child grows up, more and more actions and stimulus are getting defined in the cerebrum. Walking, running, making sound, tying the sounds together to make speech, networks building upon networks. As the child is learning, he’s starting to chain these networks together. Associations between networks. Saying something that’s unintentionally funny to all the adults in the room, and watching them burst into laughter. Important events are getting written into the cerebrum, things that are different are getting saved for future use.
Now as he grow up, and his consciousness is forming and solidifying, he starts to see associations with stuff that happened in the past. He see’s a child saying something funny and everybody laughing, and that get’s hashed back to the time when he was a child doing the same thing. Whatever part of his brain that has evolved to be his consciousness rolls back over those networked connections that were saved in his cerebrum, and it’s played out again in his internal movie theatre guy. What exactly the nature of that internal movie theatre guy is, that’s another question and much more philosophical / spiritual.
Anyways, that’s my interpretation of how memory works. Whenever your consciousness is rolling back over the network that formed a different or important or rewarding point in your life. Most of your day to day stuff seems to be ignored, because it’s not eventful, and it doesn’t change the who of you are.
As for memristors, yes, I’m pretty sure that if they actually get developed, we’re going to see a whole new level of processing. They really do seem to be made for neural networks, however keep in mind the physiology of a computer neural network and a wetware neural network are very different – with our neurons, you have tens if not hundreds of incoming connections to the dendrites of a neuron, which is then in turn connected to hundreds of other neurons. Memristors are single input single output, but I bet that you could possibly emulate the same behaviour using a bunch in parallel or something. Anyways, that’s my two cents.

I’m proud to introduce BabyLolly.com

So over the course of the last year and a half, my friends and I have been developing a new social networking site aimed at families. Specifically, it’s an online, private babybook where mothers and fathers can safely upload pictures, videos, notes and other information about their children to an online space where only invited people can view. Some more details:

  • Photo/Video Gallery: no more cumbersome emailing of baby photos. Store and organize all your photos and videos and share them with family and friends.
  • Baby Journal: keep an online journal of your baby’s experiences and developments.
  • Baby Milestones, Firsts & Favourites: never forget an important milestone again! Capture and share all your baby’s important firsts & favourites.
  • Connect & Collaborate: give family and friends the opportunity to fully contribute to the babybook by leaving notes, uploading photos & videos, and sharing in each and every precious moment.
  • It’s a private site (so only people you invite will see your babypage) and best of all: it’s 100% free!

So if you have a family, or know someone who has a family and would like them to share their photos in an easy manner, go to BabyLolly.com and sign up! Any feedback would be appreciated.

Truth Nodes

Truth is sacrosanct to the human character. The only way we can build a philosophical construct of our identity is through cornerstones of truth, upon which we build more complex structures of truth for the purposes of explaining our reality. We all share one, indivisible truth – the acceptance of our unique perception. Everyone inately understands that the person watching the movie screen of our life is a unique individual, and something that we alone possess. But we also understand that everyone else out there is witness to their own showing, their own unique perception of the events unfolding in their life. Well we may not acknowledge it, at a fundamental level we all understand that our own reality is ours, and ours alone.
The problem lies in reconciling diametrically opposed truths. There are easy examples of this, say one person may believe devoutly in the existence of god, and one may not. These are irreconcilable, as they’re both taken on faith of their own character, and would destroy any truth structures that have been built on top. So how do you tell which perception is right?
Truth is not a democracy. The majority is not always right, as has been seen countless times in the study of science. Once an idea becomes entrenched in a society, it takes a monumental effort to prove it otherwise, as the opposing perception of truth has such momentum within the people which form that societal group. At the same time, one cannot be so plastic as to attach equal importance to each new fad idea that comes along, for it may not be grounded in truth, as much as the person promoting it may wish and believe it to be so.
This is the delicate balance, between falsehoods and truth, that we all wage in our day to day lives. It seems that few of us have the wherewithal to examine our beliefs logically, and change them accordingly and without bias towards that truth that is more truthy than the rest.

Are you also divergent, friend?

I’m fat, and getting fatter. I can feel myself puffing up over time, the rolls around my neck getting larger and my shirts getting tighter. I observe this with all the other observations in my life, with a sense of detachment, of it not really happening to me. The air is sticky with fall humidity. It’s raining outside, a slow steady trickle of daytime culmination. When I took my bike to work I was suprised to see the ground wet with rain from the night before – tomorrow I won’t be so suprised. On the first day of fall the weather is never surprising.
There is something so comforting about alcohol and cigarettes. Even though it’s irritating getting harassed, I can never begrudge the drunks who stumble by my work begging for smokes. I can see how easily it would be to slip into that mindset, fuck it, bottoms up and lets see how far I can take this. Alcohol dulls the ache, cigarettes give you something to do. It’s a pathetic life but at least it’s living. Is it any worse then going to a boring job at a failing company, saving up money to blow on inconsequential pleasures? Is a memory really so precious I wonder. Are purchased things really so substantial?
I’m lonely, lonely lonely lonely. I read, see, watch, hear about love all the time, yet it’s never happened to me, for me. Some people say your one true love is out there, some people say that it’s all about finding someone compatible, but in all the stories there are always two halfs to a whole and yet here I sit alone. I wonder about that, why at 30 I still haven’t found someone, either a soulmate or even someone to just pass the time with. Those kind of thoughts are dangerous, they’re filled with pity, remorse and longing. And yet how much of the story of humanity is a story of love, the pursuit of love, the loss of love. I can’t be human without love, so it seems.
So here I sit, the observer, the watcher, the reader. All I have left is the unfolding drama of humanity as it crumbles around us, as we take that word humanity and rape it, tear it up and spit it on the ground. All of the progress that we sit on top of with no real understanding of the sacrifices that were made to get us here, and us, this generation so willing to throw it away out of fear. I keep thinking of history, how in history books the periods of time are judged so heavily, and the actions of the people in history are lauded or lambasted. How will history judge us, the pundits say. I think deep in our hearts we all know how history will judge us, but nobody really cares when we’re so deep in the orgy of the now, the revelation of the consumation. For all of the progress, the scientific discoveries, the humanitarian efforts that are being done in isolated pockets, the reality of the situation is that we’re the most spoiled and pampered generation that our history has produced, and we glory in the excess of our gilded prison.

Don’t mock me my friend. It’s a condition of mental divergence. I find myself on the planet Ogo, part of an intellectual elite, preparing to subjugate the barbarian hordes on Pluto. But even though this is a totally convincing reality for me in every way, nevertheless Ogo is actually a construct of my psyche. I am mentally divergent, in that I am escaping certain unnamed realities that plague my life here. When I stop going there, I will be well. Are you also divergent, friend?

The real problem is population. Nobody in power will say that, but they’re all thinking it, or at least they should be, if their advisors are any worth. We’re approaching some really serious problems soon, problems that will make this piffle with the stock markets seem inconsequential. We have dire water problems. Water is the root of all our economies, water is the thing that we as humans need most to surivive, and water is rapidly getting consumed faster then it’s replenished. Water which we need for irrigation, which we need to grow our crops, which we need to feed our livestock, which we don’t need but induldge in anyways because meat tastes better than alfalfa any day. The amount of water that our population requires for this system is accelerating with our population, as more and more of us get a taste for meat. Water shortages while people water their lawn. Asia draining their water table to feed 3 billion people. I can’t help but wonder if anyone out there is really paying attention to these problems, while we breed like rabbits and glorify growth.
There is the big problem, the ironic tumour at the heart of our society. Why do we worship growth so much? I can’t fathom it. Growth leads to boom and bust, predictable like the so called business cycle. The only problem is that the bust that will eventually happen because of our population boom will be unlike anything we’ve ever encountered. It’s so sad, all the suffering and wasted potential. The thought of all the starving people, grabbing their swollen bellies as their life agonizingly ebbs away. We will see this in our lifetime, and I can only hope that those of us who survive learn a valuable lesson. Unfortunately, the cynic in me realizes that the saying “those who don’t observe history are doomed to repeat it” is still around, for a reason.