This is partly to help anyone else, but mostly so I don't forget...
Make a Webapp
Use Webfaction's panel to create a new static html web app (assume we'll call it "
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://email@example.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
git clone ~/src/my_blog.git ~/tmp/my_blog
(After all, we need somewhere to automatically freshen and build from!)
Init the Blog
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"
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
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:
- We get a fresh copy of the blog source
- We don't build inside our live site (in case anything goes wrong!)
- We don't rsync if the build died
- 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
cd my_blog vim _posts/hello-world.markdown
git add _posts/hello-world.markdown git commit -m "First post, woot" git push
And hopefully it all Just Works!
- git pushes to remote repo
- post-receive hook fires
- tmp checkout is freshened
- blog is rebuilt
- 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!