Migration of my blog

A while back I switched my blog from a database-backed dynamic site to static HTML generated by Sphinx and Tinkerer. This weekend I finished migrating eight years of old posts (with their comments) to the new blog. And I configured my new blog and home page to support HTTPS. Hello, 2015.

You may, when visiting old posts, experience browser warnings because of embedded HTTP resources. Images mainly, but also the odd script here and there. I have also not yet implemented the redirect rules that will get you from old style number/slug URLs to the new YYYY/MM/DD/slug URLs, though I have mapped them all out. Please bear with me, I'll address these issues soon.

Doing this lets me retire my last dedicated server. My blog now runs on a very cheap ($5 per month) virtual server provisioned (Nginx, SSL certs and keys, the works) using Ansible. I build my blog HTML on my laptop and rsync it with the server also using Ansible.

I'm pretty sure this blog migration is the final chapter of my Zope story. The following is very likely my final Zope external method, ever.

import json


def dumper(context):
    """Dump Python blog posts to JSON"""
    for result in context.searchResults(
            meta_type='COREBlog Entry', sort_on='created',
            sort_order='descending'):
        post = result.getObject()

        doc = {}
        doc['id'] = post.id
        doc['slug'] = post.entry_slug()
        doc['title'] = post.title_or_id()
        doc['body'] = post.body
        doc['categories'] = post.categories()
        doc['published'] = post.published()
        doc['html'] = (post.format == 2)

        coms = []
        for comment in post.comment_list():
            com = {}
            com['title'] = comment.title
            com['author'] = comment.author
            com['url'] = comment.url
            com['body'] = comment.body
            coms.append(com)
        doc['comments'] = coms

        date = post.published().split('T')[0]
        date = date.replace('-', '')

        outfilename = '/tmp/blog/{0}-{1}-{2}.json'.format(
            date, post.id, post.entry_slug())

        with open(outfilename, 'w') as f:
            json.dump(doc, f, indent=2)