neverpanic.de

Shiny New Blog

| Comments

This blog has been overhauled completely. My old website had not been updated in three years and was beginning to fall apart in some places. Note that I have not completely moved all content from the old site, which made this move easier and quicker.

First things first: If you were subscribed to the old blog’s RSS feed, please check and update, if necessary, your feed URL from http://www.neverpanic.de/blog/atom/ or http://www.neverpanic.de/blog/rss2/ to https://neverpanic.de/atom.xml. The old URLs now are permanent redirects to the correct new URL, so if you see this post in your feed reader you’re probably fine and don’t have to touch anything.

This blog was previously using the free 1.9.x version of ExpressionEngine from EllisLabs called ExpressionEngine Core. The software had been giving me update notices for quite a while, but when I wanted to update it to the latest version I noticed the free version had been pulled from the downloads page. It’s back in version 2.x now, but I’m not going to make the same mistake of relying on closed source software again. I switched to Octopress, a static site generator based on Jekyll. I don’t particularly like software written in Ruby because most Ruby projects aren’t even trying to get into the standard Linux/BSD/OS X package managers, and this one is no exception, but it works reasonably well for me. I didn’t follow the installation instructions where it says to use rbenv or RVM but just installed ruby 1.9 and bundler from MacPorts and ran

Install Octopress dependencies using bundler
1
bundle install --binstubs --path=vendor/bundle

That puts all the dependencies self-contained into vendor/bundle (no, I don’t want to install gems as root into system locations or install yet another package manager) and creates a series of wrapper scripts for binaries in ./bin. Now I just have to remember to use bin/rake $command instead of rake $command to work with Octopress.

I chose to selectively pick the posts I moved from the previous blog software and completely removed the separate “About me” and “Portfolio” sections. I felt most of the stuff I removed didn’t represent very well what I’m currently doing, since I’m not really into websites anymore. I made sure all old URLs either redirect to the new versions or return a proper HTTP 410 Gone page.

While converting my posts, I noticed that Jekyll’s post_url tag to link to other posts independent of their URL didn’t work for Octopress. Googling suggested a solution that provided a Octopress-compatible post_url tag which would however no longer work because it conflicts with the tag provided by Jekyll. I fixed that by renaming the tag to opost_url:

Octopress post_url Liquid tag (2014-03-19-shiny-new-blog-octo_post_url.rb) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module Jekyll

  class OctoPostComparer
    MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)$/

    attr_accessor :date, :slug

    def initialize(name)
      _, _, date, slug = *name.match(MATCHER)
      @slug = slug
      @date = Time.parse(date)
    end

    # Octopress creates dates with hours and crap in them which are not in the file name
    # so just compare based on the date parts
    def ==(post)
      cmp = self.date.strftime('%Y-%m-%d') <=> post.date.strftime('%Y-%m-%d')
      if 0 == cmp
        cmp = self.slug <=> post.slug
      end
      return 0 == cmp
    end
  end

  class OctoPostUrl < Liquid::Tag
    def initialize(tag_name, post, tokens)
      super
      @orig_post = post.strip
      @post = OctoPostComparer.new(@orig_post)
    end

    def render(context)
      site = context.registers[:site]

      site.posts.each do |p|
        if @post == p
          return p.url
        end
      end

      puts "ERROR: opost_url: \"#{@orig_post}\" could not be found"

      return "#"
    end
  end
end

Liquid::Template.register_tag('opost_url', Jekyll::OctoPostUrl)

While writing the “About Me” section for the sidebar I wanted a way to automatically update my age without manually changing the file every year. So I wrote another plugin to achieve that:

Jekyll age Liquid tag (2014-03-19-shiny-new-blog-myage.rb) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Jekyll

  class MyAge < Liquid::Tag
    def initialize(tag_name, post, tokens)
      super
    end

    def render(context)
      site = context.registers[:site]

      year = site.config['age']['bday_year']
      month = site.config['age']['bday_month']
      day = site.config['age']['bday_day']

      age = site.time.year - year
      if site.time - Time.new(site.time.year, month, day) < 0
        age -= 1
      end

      return age
    end
  end
end

Liquid::Template.register_tag('myage', Jekyll::MyAge)

To use it, add an entry to your _config.yml as follows:

myage plugin configuration
1
2
3
4
age:
  bday_year: 1990
  bday_month: 1
  bday_day: 1

I’m planning to add comments using Isso later, but I wanted to get this out ASAP and improve the site gradually rather than making it perfect but a never-ending project. For now, I welcome any feedback via email.

Comments