Adding Github Pages Support to Coleslaw

Posted on 2013-04-21

This post wraps up how I hacked coleslaw to add Github pages integration.

What’s missing

  1. Github pages does not support symlinks. Therefore, instead of symlinking index.html to 1.html, I should just copy 1.html as index.html.
  2. I need a way to robustly parse the domain given in ~/.coleslawrc.

Fixing it

For the symlinking problem, I can just change the code from symlinking to copying it over. However, it is safer to change the behavior of the code only when the user explicitly asks for it.

Grepping through the code, I can see that render-indices produces the indices, e.g. 1.html, etc., and symlinking 1.html to index.html. This is where I should make the modification. I added another argument to render-indices to tell the code to make the symlink or not.

Domain

Previously, my ad-hoc solution was to find the first forward-slash in the domain string and substring the domain string from after the second forward-slash. Here’s the previous code.

Now, I can instead use the puri library to parse the URL and extract only the domain. Here’s the new code using puri.

Of course, I need to add puri as a dependency to coleslaw.

Really Wrap Up

All that’s left now is to send a pull request to the original author, which I have already done.

comments powered by Disqus