the further adventures of

Mike Pirnat

a leaf on the wind

Next Page »

How I Deploy My Blogofile Blog on Webfaction

This is partly to help anyone else, but mostly so I don't forget...

Installing Git

Before you do anything, you'll need some git binaries, since they aren't yet installed by default on Webfaction. See Webfaction's git setup docs for how to do this.

Make a Webapp

Use Webfaction's panel to create a new static html web app (assume we'll call it "my_blog").

Making Directories

A little directory setup will be nice:

mkdir $HOME/src
mkdir $HOME/src/my_blog.git
mkdir $HOME/tmp
mkdir $HOME/tmp/my_blog

Getting & Installing Blogofile

I'm a nerd/Blogofile contributor, so I like to roll with the head of the repo.

In my case, I'm getting my own personal fork:

git clone https://mpirnat@github.com/mpirnat/blogofile.git $HOME/src/blogofile
cd $HOME/src/blogofile
python2.6 setup.py develop

You'll want to do this on Webfaction and on your local machine (so that you can do offline builds to test).

Initializing the Repo

cd $HOME/src/my_blog.git
git init --bare

Clone it Down

On your local machine:

git clone ssh://username@yourdomain/~/src/my_blog.git

On Webfaction:

git clone ~/src/my_blog.git ~/tmp/my_blog

(After all, we need somewhere to automatically freshen and build from!)

Init the Blog

Locally:

cd my_blog
blogofile init simple_blog
git add _config.py _controllers _filters index.html.mako _posts _templates
git commit -m "Initial checkin of new blog"

First Push

Git really wants a branch to push into, and we don't have one of those yet. Just doing git push will cause git to shit its pants. So instead we have to do the oh-so-obvious:

git push origin master

Did that work?

Create Post-Receive Hook

On Webfaction:

cd $HOME/src/my_blog.git/hooks
vim post-receive

My (very basic!) post-receive hook looks like this:

#!/bin/sh

HOME=/home2/username
BUILD_DIR=$HOME/tmp/my_blog
SITE_DIR=$BUILD_DIR/_site/
DEPLOY_DIR=$HOME/webapps/my_blog/

unset GIT_DIR cd $BUILD_DIR git pull blogofile build -v && rsync -a --delete-after $SITE_DIR $DEPLOY_DIR

This makes sure that:

  1. We get a fresh copy of the blog source
  2. We don't build inside our live site (in case anything goes wrong!)
  3. We don't rsync if the build died
  4. We sync all our changes into place and remove anything that we shouldn't have any more

TODO: I really, really, really need to rearrange this so that we don't do the build at all if the build area's checkout (in ~/tmp/my_blog) was up to date/didn't get any changes. Maybe not a big deal for everybody, but I've got like 1400 blog entries and it takes a while to regenerate all that HTML. I mostly dislike shell scripting, so I will probably write a small amount of Python here at some point.

Also it would probably be good to check any new/changed _posts items to see if they are drafts, because again it sucks to do a bunch of work that we don't have to. Hmm...

Compose a New Post

Locally:

cd my_blog
vim _posts/hello-world.markdown

Push It!

Locally:

git add _posts/hello-world.markdown
git commit -m "First post, woot"
git push

And hopefully it all Just Works!

  1. git pushes to remote repo
  2. post-receive hook fires
  3. tmp checkout is freshened
  4. blog is rebuilt
  5. blog is rsynced into place

Write Compelling Content

Now it's time to crank out that undying prose that will forever change the world... get to it!

Read and Post Comments

Why I Switched to Blogofile

Looking back at my blogging history over the past couple of years, I'm almost embarassed by how sporadic my writing has been. It started to taper out as my daughter, then just a newborn, absorbed most of my free time; then it was largely annihilated by "Links for XYZ Date" delicious auto-posts and, to an even larger degree, a plague of "Yesterday's Tweets". I remember tweeting at one point that

the problem with microblogging is that after a while you only have micro-thoughts

and it's really true; as my own worst critic, I get angry at myself for not having anything worth saying. Then my frustration with the Wordpress upgrade cycle really kept me from wanting to write--I kept spending all my time managing updates, and that's too much like my day job...

Meanwhile, the cool kids latched onto Jekyll and static site generators, and I thought to myself Maybe that's the ticket, just pure writing that's easily transformed into something that won't have critical security flaws discovered every couple of weeks. But I wanted a tool that I could be relatively happy working with and extending as needed, and really don't care for the look or feel of Ruby--nor did I like the sound of Gary Bernhardt's reports of Jekyll's silent failures and poor error messaging)--so I stalled for months and eventually decided that I might as well just write my own in Python. But just in case, I thought, I'd better take one last quick look around to see if anyone else is thinking the same thing.

And that's when I found Blogofile--a static site generator that's more or less exactly what I wanted.

I also discovered that converting your blog to a whole different paradigm is another great way to put off writing. There's all the fun of experimentation, data export, cleanup, styling, contributing fixes back upstream... Who needs to write when you can fill your time making a perfect shell for all those words to live in?

But, at long last, I've ripped off the band-aid and forced myself to switch over. I've got a lot of cleanup yet to do--I need to migrate the old static content (various downloads, presentation slides, and so forth) as well as audit my logs for 404s to rewrite into 301s--but I'm pretty pleased so far.

Reasons I like Blogofile so far:

  • Pure text files; just me and vim and source control
  • An excuse to try out git
  • No Wordpress upgrade cycle
  • No plugins clamoring for updates
  • A receptive project owner; Ryan is great to chat with and is quite hospitable to patches and suggestions
  • A friendly (albeit relatively small and quiet) community--the mailing list is pretty low on traffic (also low on noise), and the #blogofile IRC channel on freenode is a nice place to have useful discussions
  • Supports multiple markup styles--most of my exported data is html, while my recent posts are written in markdown; restructured text is available too, and it's pretty straightforward to plug in other parsers if you want
  • Syntax highlighting with Pygments
  • A simpler site means a reduced attack surface
  • Managing everything with a DVCS means I can work offline as much as I need
  • DVCS also means I can shift easily between computers and not lose any work

Potential drawbacks to be aware of:

  • It feels a little inefficient to regenerate the entire site when a single entry is changed (it's not too bad until you have 8 years of blog posts)
  • More disk space than I'm used to using (though still modest compared to what my hosting plan allows)
  • No on-the-fly on-site searching or slicing of data (speaking of which, I should add a search box...)
  • Managing everything with DVCS means whatever you're writing with has to be able to do git, have a filesystem, etc.--so no easy route to blogging from an iPhone or iPad, post-by-email, or that sort of thing (one could presumably craft a solution for this, but it's a lot more DIY effort than I want right now)
  • Publishing is a bit DIY as well--if you're used to just clicking the "publish" button in Wordpress, you might chafe a bit at the idea of setting up remote git post-receive hooks or assembling fabric scripts to make your life easier
  • Still evolving--you definitely want to use the master branch from github rather than the 0.6 release; it's ready for an 0.7 release IMO

This is my first real experience with git, and I'm not sure whether I want to call it a benefit or a pain--it seems like it's a bit of both.

On the whole, though, I'm really liking using and contributing to Blogofile, and I recommend checking it out if you're looking for a different way to approach blogging.

Read and Post Comments

Hello World

This is a test to see if my shmancy git post-receive hook does all the building and rsyncing that it's supposed to.

If so--then huzzah! I can go get some sleep.

If not... Crankiness shall abound.

Read and Post Comments

Configuring Wordpress SSL Login and Admin on Webfaction

image: bike covered in bike locks

I finally got fed up with not having SSL for my Wordpress instance on Webfaction and decided to rectify it today. I ran into a couple of surprises along the way that were really irritating, so once I sorted them out I figured I owed the internet an explanation so that things would be easier for anyone else wanting to do the same thing.

Assumptions

I'm going to assume that you already have a Webfaction account with a Wordpress instance running on it. If not, the control panel screencast is an oldie-but-goodie that'll get you started. I'm also going to assume that you're on one of the basic, shared hosting plans, and that you'll be running your secure stuff on the same box as your non-secure site. And I'm also assuming that you'll be okay using Webfaction's default SSL certificate rather than your own--this will throw warnings in many browsers, but saves you the cost of purchasing your own cert and the time required to request a private IP from Webfaction. And this only applies to Wordpress 2.6 and above. (You really should upgrade, you know.)

Create a secure site

In the Webfaction world, a single "site" can only be non-secure or secure, so you need to create a new site that will largely mirror your existing, non-secure site. To do this:

  1. Log into the Webfaction control panel.
  2. From the Domains/websites menu, pick Websites.
  3. Click the little green + icon at the bottom-right of the websites panel to begin creating a new site.
  4. Give your new site a meaningful name (I like it to be the same as the non-secure site, but with "_secure" or something similar tacked onto the end).
  5. Choose the same IP as the non-secure site that you're adding SSL to. Unless you are fancy enough to have multiple IPs, this shouldn't really be a choice at all.
  6. Check the HTTPS checkbox. (This is important.)
  7. Choose the same subdomains as the non-secure site that you're adding SSL to--so if your site is at http://www.yoursite.com, you might want to make sure that you select yoursite.com and www.yoursite.com subdomains so that both will be connected to this configuration.
  8. In the Site apps section, add your existing Wordpress instance with the same URL path that it has in your non-secure site. If you've got an app called my_blog at /blog, make sure you do the same thing here.
  9. Click Create.

Fix your Wordpress URL configuration

If you visit your blog now (in non-secure/http mode), depending on your browser, you might see a complete and total failure to load your stylesheets--meaning that your site is now probably fairly ugly. If you view source, you'll see that, even though you aren't loading your page from over HTTPS, Wordpress is generating HTTPS links for all your content--stylesheets, images, everything.

To fix this:

  1. Log into your Wordpress instance and go into the Dashboard.
  2. Go to the General Settings page.
  3. Change the WordPress address (URL) and Blog address (URL) fields to begin with http instead of https.
  4. Don't forget to Save Changes.

Now try your site on its non-secure/http link. When you view source, all your resources should be coming from URLs that start with http.

Update your wp-config.php

Edit your wp-config.php. Depending on what you want to do, you'll add one or the other of the following two lines.

To require only login to be secured:

define('FORCE_SSL_LOGIN', true);

To require login and admin pages (my preference) to be secured:

define('FORCE_SSL_ADMIN', true);

Profit!

Log out of your Wordpress instance, then hit your login link. You should now see that your login and registration pages are served up via https links. If you chose to use FORCE_SSL_ADMIN, you should also see https in all of the URLs as you navigate around your Wordpress admin area.

Things should be hunky-dory now. I hope it worked out all right for you!

Read and Post Comments

Well That Was No Fun

Thought I'd be all spiffy and upgrade to the shiniest new Wordpress tonight. I did my little svn switch/bzr add/bzr merge trick to get all the new files in the right place, upgraded the database, and felt pretty awesome... Then my blog started throwing miles upon miles of "transport errors" and 500s, as did a couple others that I hadn't even touched with upgrades. The common factor seemed to be WP instances that were nested off of subdirectories of one of my domains, rather than WP instances at the root level of the domain. That smells like some kind of configuration problem in Webfaction panel-land, but I was too impatient to open a ticket (and trying to focus on something, anything other than Mama Mia that my wife was watching), so I ended up doing a mysql dump, blew away my old blog instance, dropped a new one into place (which magically worked, thanks a lot, universe), and restored from my backup.

So... Upgrade done (good) but not how I planned it (bad).

On the plus side, I was kind of getting sick of the theme anyway. :-P

Read and Post Comments

In Which Google Continues its Takeover of My Entire Life

I've found my Livejournal "friends page" to be increasingly cumbersome as a feed aggregation and reading service. Liz has fallen in love with Pulp Fiction and uses it religiously. PF is great for reading JL friends--since it can remember cookies, one can see all of one's friends' friends-only posts. But Liz tends to live entirely on one computer, whereas I am sometimes at my Mac Pro, sometimes on the hand-me-down Powerbook, and sometimes (okay, usually) at work. This variety of machines is where PF falls down, as there's no easy way to keep track of what I have and haven't read across all of them.

And then I remembered that Google had released a Google Reader a while back to solve this problem, so I've decided to give it a whirl. So far it's proven to be tremendously convenient and useful, with the only downside that it's unsuitable for reading content that is protected or otherwise requires authentication.

What is anyone else doing to make life in RSS-land less painful and tedious?

Read and Post Comments

Better Living Through Photoshop

I've been totally stressed out by work lately, which means that, at some point, my head exploded and I found myself with a desperate need to play with Photoshop for a while. Thus: a crapload of new LJ icons!

Art of Noise x3
Mike Oldfield x5
Firefly/Serenity x9
Princess Bride x17

Art of Noise
(because I had no music-related icons)

Mike Oldfield
(because I had no music-related icons)

Firefly/Serenity
(because I just can't get enough)

The Princess Bride
(in honor of Valentine's Day)

Typical LJ netiquette applies--please credit me in your userpic keywords or comments if you snag any. Enjoy!

Read and Post Comments

January Link-o-Rama Redux

Some part of today managed to melt what's left of my brain, so I settled for skimming rather than chiseling away at my reading, and that has degenerated into a need to close browser tabs and assault you all with another installment of...

LINNcircle k(idd valley)One Letter / ORAmA

My cool flickr-based link du jour is Spell with flickr, which lets you spell words using letter images found on flickr, just like what you see here. Nifty!

Some geek reading: Joel Spolsky on "Great Design" and Michal Zalewski on "Cross-Site Cooking" (potentially dangerous shortcomings of how cookies have been implemented by pretty much every browser).

While we're on blogs, who would have ever thought Chewbacca needed his own blog? I guess you could consider it a scathing satire of "the blogosphere" (a term I really loathe), asserting that any random bloggish drivel is about the same as Chewy grunting and growling unintelligibly (and you probably wouldn't be too wrong). It's really, really daft, but it makes me giggle. What a Wookiee!

Artie attempts to scan your iTunes library, find tracks that are missing album art, and fetch covers from Amazon for you to review and drop into iTunes if they are what you're looking for. As my iTunes library--currently closing in on the 45 GB mark--continues to grow, this seems like an utterly brilliant solution that will save me much time, hassle, and pain... Too bad it doesn't seem to like my increasingly ungainly iTunes Library.xml file. Mostly it seems to time out trying to upload or process the data. Your mileage may vary--let me know if you have success!

Which leads me to the obligatory Mac geek section... I have a new favorite browser: Shiira, a nifty treat from Japan that so far seems lighter and faster than Safari and Firefox, and which sports some wicked visuals (I particularly enjoy the page forward/back that peels the webpage away like a piece of paper). I also ran across a pretty good list of must-have Mac software.

Some amusement for the gamers among us: a library of video game endings for those of us (like me) who were too lame to ever finish most of their games, and, when you have eleven minutes to kill, perhaps this short film will help you conquer your "Fear of Girls". (I'm glad to say I overcame that a long, long time ago!)

Finally, something to get us all ready for lovey-dovey season: SVU Valentine cards. Gosh. Um. Yeah. That's not creepy or anything.

Next time, I promise some real content, even if it's lame, or pictures of the cats doing stupid things.

Read and Post Comments

Next Page »