Yoz Grahame's Unresolvable Discrepancy

I came here to apologise and eat biscuits, and I'm all out of biscuits

Moving from Greymatter to MovableType, with inbound links intact

Posted: November 18th, 2003 | 1 Comment »

Pointless Things I Learned The Hard Way #2: That moving a
Greymatter blog to
MovableType is a href="http://www.movabletype.org/docs/mtmanual_importing.html#exporting%20greymatter%20entries">pain
in the arse, unless of course the Greymatter install is broken
in some insidious way which it refuses to divulge (despite all its nice diagnostics
and repair features), in which case it is such a pain in the
arse that it’s quicker to just write some code to do it.

Here is
the code.
Edit the constants, then drop it in your GM folder and
chmod it to 755. You can
run it either on the command line or via CGI (in which case you’ll
want to give it a .cgi suffix), and it will spit out a file ready to be imported into MT.
It turns out that this
is a considerably quicker method than following the MT docs.

The cause behind all this was the migration of href="http://www.harpold.com/">Leslie Harpold‘s fantastic
500 project, which I heartily
recommend that you all go and enjoy now, rather than finishing this
utterly dull blog entry since she’s several orders of magnitude more
interesting a writer than I am. Existing fans may note that it looks completely
identical to how it did before, in which case I thank them because that
was the other hard part.

The hardest part of that was keeping all the inbound archive
links working. I had various ideas involving Apache redirects and the
like before realising that getting MT just to output the pages with
the same filenames as before was probably going to be easier, and it was.
To do this, I had to persuade MT to number the individual entry archives
according to the entry’s position in the blog entry sequence, so that
entry #1 in the blog would be 00000001.html, entry #2 would be
00000002.html, etc.
There’s no easy way of doing that in the base install; the
<$MTEntryID$>
tag returns the entry’s position in the MT database as a whole, and
if there are other blogs pre-existing, then the IDs won’t start from 1.

I figured there was probably a plugin out there to do this already,
and I was right: Lummox
JR’s EntryNumber plugin
. So I installed it and set the Individual
Entry Archive’s href="http://www.movabletype.org/docs/mtmanual_weblog_config.html#archiving">Archive
File Template value to this:

<$MTEntryNumber zero_pad="8"$>.html

However, that didn’t quite do it, since the archive for this
blog is missing a few corrupted entries and so the numbers jump at points.
To fix this, I padded the generated export file with blank entries
and set them to Draft status after the import. Then, I made a
tweak to the EntryNumber plugin to make it include Draft entries in its
number sequence by adding the incdraft="1" attribute to the tag:

unless($count=$cache->{$entry->id}) {
    my %terms = ( blog_id => $entry->blog_id );
    $terms{author_id}=$entry->author_id if $args->{author};
    $terms{status} = MT::Entry::RELEASE() unless $args->{incdraft};

I’ve submitted these changes back to Lummox JR, so he might have
included them in the code by the time you read this and you won’t need
to make the tweak. If you’re trying to do this. Which hopefully you aren’t.

Coming up next: Something remotely relevant to anyone else, I hope…


One Comment on “Moving from Greymatter to MovableType, with inbound links intact”

  1. 1 Steve said at 11:56 pm on May 4th, 2006:

    I don’t suppose you have the EntryNumber plugin lying about somewhere do you. I want to use it, however the site it comes from is no longer available :( While on my extensive search to find the plugin I found this post which is the closest I’ve come to finding the code!

Archive

The complete list of posts lives here.

yoz's bookmarks

  • Lee Maguire – WikiLeaks and the future Hydra
    Lee on the similarities between WikiLeaks and comic-book villainous organisations.
  • WebGL Inspector
    Lovely Firebug/Web Inspector-alike for WebGL, usable either as an extension (for the top WebGL-enabled browsers) or embedded JS. Under rapid development.
  • ge.tt
    Gorgeous hack: web-based file sharing service where the link to your file works while it's still uploading. Instant, super simple and free. (via DMM)
  • Async.js (Caolan McMahon)
    One of the many flow-control packages for Javascript, of which at least 3 are called async.js. This one has some really nice tricks, especially auto() which fires off function calls as soon as their dependencies are met.
  • Adequately Good - JavaScript Module Pattern: In-Depth
    Really good explanations of several useful function and module patterns to use when building your own
  • News flash: Deadly terrorism existed before 9/11 - Ask the Pilot - Salon.com
    The quantity of air-travel-targeting terrorist attacks between 1985 and 1989 would be unthinkable today; yet the presented danger and precautions taken are far worse
  • 100 Free High Quality WordPress Themes: 2010 Edition - Smashing Magazine
    Some really nice minimal ones here, along with good theme tools and a bunch of things that I didn't know WordPress could do
  • Lenore Skenazy: 'Stranger Danger' and the Decline of Halloween - WSJ.com
    Despite American parents' increasing paranoia, Halloween may be the safest day of the year for kids. (via schneier)
  • becoming the alien: apartheid, racism and district 9 « a subtle knife
    Superb essay on District 9's relevance. "It confronts us with our complicity with racism, by making us identify with the perspective of the racist, inviting us to feel the revulsion of the xenophobe – and then pulling the carpet from under our feet." (via kevin marks)
  • Music Hack Day: The Uninterrupter - Andrew Shearer's Other Blog
    "For an increasing number of us, the same device we use to play music also handles email and GPS directions." The presented solutions are as brilliant as they are ludicrous. (via extensionfm blog)

yoz on twitter

    follow me on Twitter

    Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org

    Content licensed under the Creative Commons (Attribution - Share Alike) | Theme based on Clean Room by Columbia, MO Web Design