So, I fully migrated to a self-hosted WordPress blog from my LiveJournal. In the process, I reconfigured WordPress to accommodate the features that I had on LJ.
I like a clean and easy layout, so I selected the Myth theme. I stripped out anything I didn’t need/like, so it’s pretty bare at the moment — just how I like it.
But LJ has some things that WordPress lacks. Most importantly, there is the usericon and the current mood (and the associated images). I wanted to replicate those in WordPress. First step was to create a child theme of Myth and to download all the usericons and the mood icons from LJ and put them in there. WordPress has ‘metadata’ key-value pairs which you can read in the PHP code, so I settled on using that as storage for these items. Using the Advanced Custom Fields plugin, I added a little side-bar for the metadata fields — with user icon and current mood selectable from a list. In my child theme, I read those fields and output the appropriate HTML in the post header.
I used the Easy Spoiler plugin to create something like the equivalent of the LJ-cut: a text you can click on, which then expands part of the post.
There is an official LJ-to-Wordpress migration plugin, but it doesn’t work and I don’t expect it will ever be fixed. So I was on my own.
To migrate, I used ljdump.py to download all my entries — something I had been doing all along anyway. This yields a file for every entry (conveniently numbered L-1, L-2 etcetera) and the comments for that entry. The file is in XML format and contains all the information about the post — so also the usericon used, the mood and mood description, the post security etcetera. The official LJ export page doesn’t provide all this information!
Then I wrote a Python script to parse those XMLs in batches of 200. If a post was public, then the script generated PHP code to create the entry and set the right metadata fields. I decided not to convert the comments — those comments were made by people on LJ, and there is no implicit permission to post those comments elsewhere. Of course, I also converted the LJ-cut tags to the Easy Spoilers.
This yielded 19 PHP files, which I uploaded to the server and executed one by one by requesting their URL. (Yes, I have since removed them from the server, of course…) And after all that, my LJ was imported in WordPress!
But I wanted to keep my LJ too, and crosspost from WordPress to LJ. After using a more generic crossposter, I settled on LiveJournal Crossposter plugin. It allows you to create a link back to the original entry, etcetera. It also supports setting the user icon and security settings, but that did not work to my satisfaction.
I discovered that the plugin relies on post meta-data to set the cross-posting options. That’s not a bad idea at all, but if you immediately publish a post, the metadata may not have been set yet, and so all you get are empty strings! First saving a draft and then publishing works, and it’s an easy enough workaround that I’ve decided to just keep doing that. I also modified the code to use the user icon I set in ‘my’ metadata fields (instead of what was chosen in the plugin frame), and added the ‘current mood’ pair as well! I also added a little function to change the spoiler shortcodes into lj-cut tags!
And that is where we are today. It works to my satisfaction, it’s self-hosted, and it crossposts the entries as if they were written on LJ instead on WordPress.Crossposted from my blog. Comment here or at the original post.