beegod

ramblings from the hive mind

Going Nanoc

11 June 2011 | View comments
Damien Austin-Walker

I decided to convert my blog from Habari. I like habari but I was getting a bit bored, there didn’t seem enough development of it and it was too much of a pain for me to upgrade.

I wanted a simple blog and I decided to go for a static site generator for it’s speed, security and to be honest, the geek factor. After some reading and a couple of recommendations I chose nanoc.

As the site is static I am using disqus to handle the comments. To import the comments from my old blog I wrote the following SQL:

SELECT CONCAT('<item><title>', posts.title, '</title>'), CONCAT('<link>    http://beegod.org/',posts.slug, '</link>'), CONCAT('<content:encoded><![CDATA[',    comments.content, ']]></content:encoded>' ), CONCAT('<dsq:thread_identifier>', `post_id`, '</dsq:thread_identifier>'), CONCAT('<wp:post_date_gmt>', FROM_UNIXTIME(posts.pubdate), '</wp:post_date_gmt>' ), '<wp:comment_status>open</wp:comment_status>', CONCAT('<wp:comment><wp:comment_id>',comments.id,'</wp:comment_id>'), CONCAT('<wp:comment_author>', `name`, '</wp:comment_author>'), CONCAT('<wp:comment_author_email>', `email`, '</wp:comment_author_email>'), CONCAT('<wp:comment_author_url>', `url`, '</wp:comment_author_url>'), CONCAT('<wp:comment_author_IP>', INET_NTOA(ip), '</wp:comment_author_IP>'), CONCAT('<wp:comment_date_gmt>', FROM_UNIXTIME(date), '</wp:comment_date_gmt>'), CONCAT('<wp:comment_content><![CDATA[', comments.content, ']]></wp:comment_content>'), '<wp:comment_approved>1</wp:comment_approved><wp:comment_parent>0</wp:comment_parent></wp:comment></item>' FROM `comments` INNER JOIN posts ON (comments.post_id = posts.id) WHERE comments.status=1

and ran it on my old Habari blog database. I exported the output to a text file then topped it with

<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:dsq="http://www.disqus.com/"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wp="http://wordpress.org/export/1.0/">
  <channel>

and tailed it with:

</channel>
</rss>

This generic WXR XML format could then easily be imported into Disqus.

Finally to make the comments apear on each blog post I had to go to Tools > Migrate Threads > Redirect Crawler (Advanced) in Discus to update the threads.



blog comments powered by Disqus