Site Rewrite Complete

Site Rewrite Complete

I believe the site conversion/rewrite is now complete. It’s taken longer than I expected and it’s certainly been a bumpier ride than I thought it’d be, but it was a ton of fun and I learned a lot along the way.

(I apologize for the RSS craziness over the past few days. Those guid’s were kicking my ass. It’s all settled now and shouldn’t happen again.)

I was initially inspired by Brent Simmons’s publishing system. I’d grown weary of WordPress and knew I needed something less intensive and easier to control. I’d become spooked by the number of plugins I’d added to the site over the years. I didn’t like the idea that my data was locked away in a database when simple text files would suffice. Long story short, I wanted something simpler. Brent’s post pushed me over the edge.

I set about with the following goals:

  1. All files must exist on Dropbox for ease of access.
  2. As far as possible, everything should be automated. This includes:

    a. Image resizing when necessary;

    b. Proper file and image placement within the directory structure.

  3. Everything must be HTML. No PHP and no database.
  4. The system should keep a copy of the original markdown files for backup purposes, along with all images.
  5. Minimal Perl modules.

So I exported all of my data from WordPress, downloaded it, and set about coding my own site.

I created the directory structure on Dropbox so everything would be available to me no matter where I was. One directory contains all of the files necessary to create a post (scripts, templates, etc.). Another directory contains the actual site. This directory is rsync’d to the remote location that houses the site.

I then wrote a Perl script to parse the Wordpress backup and recreate the website in a static format. All files are pure HTML. There’s no PHP or database. The script also, using Aaron Swartz’s excellent html2text script, converts the existing HTML to Markdown and archives it in the proper directory.

Once the conversion was completed, I wrote scripts to create new posts, create the index.html page, and create the RSS feed. These three scripts are the core of the system.

I incorporated a few AppleScripts for FlyingMeat’s Acorn. This made verifying and modifying image sizes a breeze.

Along the way, I looked to Daring Fireball, Marco.org, and inessential.com for design and “how the hell do I do this” inspiration and instruction. Standing on the shoulders of giants, if you will.

For the automation part, I rely on Noddlesoft’s Hazel. I’ve configured it to watch a directory and, when it sees a file with the extention .markdown, it fires off the new post script. This allows me to spend as much time as necessary on a post and, when done, rename it to .markdown. Once done, the system kicks off. The machine that runs the script is an iMac that’s not always in the same building as I am. Thanks to Dropbox, this is easily accomplished. I can write and post from where ever I’m at as long as I have a wireless connection.

Once the script has finished processing the new post, it creates the updated index.html page and the index.xml page for RSS feeds. It then rsyncs the site to my remote host and sends out a tweet to Twitter (using Marc Mims’ Net::Twitter::Lite module). Lastly, using Masayoshi Sekimura’s excellent WebService::Prowl module and the iOS Prowl app, it sends a notification to my iPhone letting me know the post has been made. (I also have the script send error notifications to my iPhone in case something went wrong.)

So basically, my workflow is now this:

  1. Write a post.
  2. Rename the post with the “.markdown” extension.
  3. Check my iPhone when the notification comes in to see the post was successfully made.

And that’s it.

I’m not 100% satisfied with the Hazel solution. I’d prefer to use Dropbox to handle the remote sync and I might one day implement that. But for now it’s good enough and it works. So until it breaks, I’m not going to concern myself with fixing it.

I now have a completely grep-able website, it’s stable and fast, backups are automatic, and my workflow is stupidly simple. And, as I said, I had a blast doing it. All told, I’m quite satisfied.

Like Brent, I don’t intend to release any of this code. It’s highly specific to my site and my needs. Making it more generic is not something I’m interested in doing. If you’re wanting to do something similar, check out Marco’s Second Crack or any of the other many available options. Or just roll your own.

My next goal is to learn more CSS and see what can be done there. I love the site layout, but like all tweakers and hackers, I think it could be better.