hayley.ws


yelyah.com redux

yelyah.com is now up to version 5. And it has version 3’s design. But I’m calling it version 1.

I have tech ADD you see. Self-diagnosed. I tend to fall in love with software/platforms/languages/whatever for short periods of time. So really, I’m already wondering how long v5 will last.

And the sad bit is this. The ADD doesn’t lead to upgrades, it leads to crossgrades. Generally, I’m just chucking the last version and starting over from scratch with a new system and getting to the same place I already was with the last version.

The history

v1 was just a plain old xhmtl/css site whose design was largely based on a web design tutorial.

v2 was my first from-scratch design and was the first dynamic version (powered by Django). I had grand plans for the site, but I never got the backend up to where it should be in order to complement everything I built into the original design mockup, so I ended up chucking it for something simpler.

v3 was a complete redesign of the site using 960.gs and Helvetica. No mockups, just grid experimentation. The site was a combination of my custom django code for the music related stuff and someone’s open source blog code. Which I think might have been part of the problem: since it was someone else’s code, I never fully “owned” the blog part in my mind, so the blog there kind of stagnated. And back then I was way more interested in working on my music than on my site. So it stagnated in general.

There was a pseudo v3.5 in there somewhere when I started blogging on a wordpress system, separate from yelyah.com, for my “24 songs in 24 days” project as part of 50/90 (50 songs in 90 days). Which I’m sure was one of the reasons I ended up with:

v4 was a wordpress site with a premium theme. The premium theme was supposed to make it easier to build a design without having to dig into the code and properly learn CSS. But I knew there was a fatal problem going into it: if I ever decided I wanted to build something custom, I was screwed. I’m not sure quite when it started (probably when better alternatives appeared), but I hate PHP these days. So I knew that if I wanted to write any custom functionality, I flat out wouldn’t, because I wouldn’t be willing to touch PHP to do it.

In the meantime, I kept active on my yelyah tumblr on a daily basis, but I just didn’t bother with my main site. And that’s just wrong.

Back to the present

You know that syndrome where you get a hammer and everything looks like a nail?

Jekyll is my new hammer.

I started using Jekyll in September, and wrote all of 2 posts with it for the new hayley.ws. I meant to use it more, but I was more focused on learning Ruby on Rails at that point because the Rails Rumble was coming up. I never got around to actually changing hayley.ws over to jekyll so I basically forgot about it.

But some things happened recently, such as deciding that, for my next ruby rumble (my personal version of the rails rumble), I was going to set up the ruby rumble site itself.

I also decided to finally go through the steps to make the jekyll site the official hayley.ws site (I had been using posterous, which had replaced tumblr, which replaced a custom django thing, which replaced wordpress, which replaced a whole bunch of PHP blogs, all the way back to a now defunkt german blog system (sunlog). See? I have ADD).

Originally, I was looking at both jekyll and nesta for the ruby rumble site. I originally heard about nesta through the excellently designed peepcode blog.

At this point, I still haven’t used nesta directly, but the impression I got was that, for what I was wanting to do, jekyll and nesta would both work. So basically jekyll won out because it generated a static site, which meant less work in figuring out how to deploy it, and I can host it anywhere that hosts static files (cheap!).

I decided to start playing with jekyll the night before the rumble, and I realized that I was setting the bar way too low. I’d be able to knock out the ruby rumble site in way fewer than 48 hours.

So going with the whole I-have-a-hammer-and-I’m-not-afraid-to-use-it, I decided that turning yelyah.com into a jekyll site might be the perfect experiment in seeing just how far I could extend jekyll.

jekyll-ifying yelyah.com

I’d say my biggest complaint with jekyll is the documentation. There’s all sorts of interesting stuff you can do with it, without even forking it, that’s just not clearly documented. This is, of course, where all of the jekyll sites with code help out greatly. Real world examples are great, but it’s still far from optimal.

For instance, categories are mentioned here and here, but I didn’t know how to really use them in the context of my site until I saw someone else’s example code.

As a hint, here is how I pull all of the “music” posts on my site:

{% assign category_posts = site.categories.music %}
{% include category_page.html %}

As an aside, read the footnote to see how I got the liquid template code into this document without having liquid actually try to interpret it. 1

And a double aside. 2

So, as far as I know, you have to make an html file for every single category you want to cover. This isn’t handled automagically.

This could be seen as a plus though, because then you’re more than free to handle each category’s page differently, rather than being stuck with one standard template.

how I’m hosting on nearlyfreespeech.net for nearly free

I’ve known about nearlyfreespeech.net for ages and even had a test wordpress site for however long my dollar lasted, but this will be my first public site that’s hosted there.

Static sites are nearly free on nearlyfreespeech. You just pay for transfers and storage.

If you choose to host a jekyll site at NFSN, make sure you change your site to static under the “Change Server Type” page after you create it - otherwise, you’ll be paying a penny/day for PHP access when you don’t need it.

installing jekyll on NFSN

Installing your own gems on the nearlyfreespeech servers is fairly straight forward once you know all of the environment variables to set:

export GEM_HOME=/home/private/gems
export GEM_PATH=/home/private/gems:/usr/local/lib/ruby/gems/1.8/
export PATH=$PATH:/home/private/gems/bin
export RB_USER_INSTALL='true'

For reasons unknown to me, NFSN’s FreeBSD servers require that last variable, otherwise they still try to make root the owner of the gems when you install them (which will fail).

Though I haven’t actually tested it yet, pygments seems to already be installed (the pygmentize binary exists on the server), so bonus there.

And git was pre-installed too, so installing the jekyll-related gems were all I had to worry about on NFSN. And if I had been generating the site locally (which I did do for the very first deploy), I wouldn’t have had to worry about any of that stuff.

But having to copy the _site directory over. By hand. Every time? No thanks.

Which led me to…

the post-receive git hook

Big credit goes to the jekyll deployment page where I got the core of the script that handles automatically deploying the updated site when I update the git repo.

I had never touched git hooks before (heck, I’ve hardly touched any of the advanced git features), but my understanding now is this: there is no magic to a git hook script. It’s just something that runs as whatever user account is tied to your remote git repo.

And luckily, I figured this out pretty quickly before I did a bunch of ridiculous git commits in an attempt to figure out why the script was broken. So what’s the alternative to senseless commits? Run your post-receive script like so:

ssh [email protected] /path/to/repo.git/hooks/post-receive

Granted, I haven’t looked it up, but this seems to be exactly what happens when you push something to the repo.

So after getting everything working, here’s what my nearlyfreespeech-tailored script looks like:

#!/bin/sh

# set up environment for nfs

#without export it doesn't "stick"
export GEM_HOME=/home/private/gems
#GEM_PATH=/home/private/gems:/usr/local/lib/ruby/gems/1.8/

PATH=$PATH:/home/private/gems/bin


GIT_REPO=$HOME/git/yelyah.com.git
TMP_GIT_CLONE=$HOME/tmp_deploy/yelyah.com
PUBLIC_WWW=/home/public

git clone $GIT_REPO $TMP_GIT_CLONE
jekyll --no-auto $TMP_GIT_CLONE $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit

the scraping of the tumblr

One of the things that has really bothered me is how much content that I have on the yelyah tumblr that isn’t anywhere else.

Right now, I’m still posting to tumblr first and then coming in afterwards to duplicate the content on yelyah.com, but ultimately, my goal is to post to yelyah.com first and duplicate the content to tumblr, not the other way around.

For now, I’ve managed to snag all of the audio posts with this hack of a tumblr scraping script written in ruby with httparty as the go between.

The script is a work in progress, but at least it’s a start. I literally went through doing this:

@posts = HTTParty.get('http://t.yelyah.com/api/read?filter=none&type=audio&num=50')['tumblr']['posts']['post']
load '/Users/hayley/frozen/scripts/tumblr_scraper.rb'
@posts = HTTParty.get('http://t.yelyah.com/api/read?filter=none&type=audio&num=50&start=50')['tumblr']['posts']['post']
load '/Users/hayley/frozen/scripts/tumblr_scraper.rb'
# rinse and repeat

Until I ran out of posts.

It wasn’t real great, but it was way better than having to go through each one of the 317 posts by hand.

So from here, I still have to figure out how to get all of my non-audio posts ported over. And then those posts that were on the wordpress site. And then try to figure out what I’ll do for all of the songs I’ve written that didn’t have posts associated with them. A mess? Maybe. But a start.

In conclusion

So that’s it. For now.

Brain dead I am.

  1. I couldn’t figure out a good way to print the liquid template code without liquid wanting to interpret it. So, I used the character code 123 for the left curly brace, but then markdown wanted to print it verbatim since it was seeing it as code. So the workaround for that, was just to scrap the markdown formatting and instead just manually wrap the code in <pre> tags. If someone has a better way, let me know.

  2. I got the footnotes via kramdown’s extras. Yes, I switched from rdiscount to kramdown just for footnotes.