Don't you want a convoluted blog like mine?

1 January 2015

Let me first start by saying Happy New Year and as a treat to myself (because I like pain); I migrated my blog from BlogEngine .NET to my own special flavour.

I bought a Raspberry PI and wanted to stop it from gathering dust and use it in the interim to host my blog. I decided that; heck with it; let's do something a little bespoke which will force me to look at things of interest.

What was I using?

I settled on BlogEngine.NET for awhile. It saved the blog articles to the file system and I could publish using Microsoft Writer from the essentials pack. I used a hosting provider called CyberhostPro.

It did not fit my working style

When writing articles I used Evernote to capture my notes and images during my work activities. I would then assemble this information to produce a blog article in the evening.

I found I got distracted by with the WYSIWYG editor; then spending vast amounts of time in the HTML editor to adjust some tags to fit some formatting and flow nuances of the blog theme.

So, enough was enough.

My working style

While I work, I capture screen-shots using the windows snipping tool and write my blog in notepad++ using markdown. This means I don't have to spend minutes messing with formatting in my content.
Instead, I can choose how my markdown content is represented.

What am I using now?

My blog is now running in my home pulling markdown content from a Bitbucket git repository. Here is a quick list of everything I have used:

  • Mono 3.2.8: I love .NET; slowly developing a rapport with Mono and Linux.
  • Jenkins-CI: Builds and deploys my .NET applications.
  • Raspberry PI running Raspbian Wheezy.
  • nginx: Serves static pages, redirects obsolete paths and caching headers.
  • Skeljs: A responsive layout framework. I like the elegance of zooming.
  • jQuery: JavaScript made easier.
  • Disqus: Comment on my resources.
  • xUnit: My new favourite testing library.
  • Bitbucket: Somewhere to store my private code.
  • Markdown Editor via Dillinger: Why bother running your own WYSIWYG editor?
  • Dropbox: Online storage for my markdown drafts linked with Dillinger.
  • MarkdownDeep.NET: .NET Markdown Parser with my own local customisations to format code.
  • SyntaxHighlighter: An awesome client-side syntax highlighter.
  • HtmlAgility: For manipulating the Html.
  • Koala: Parse Sass and output Css.

The Gist of my solution

In essence, Jenkins-CI is my fancy CRON .NET console application runner. It produces Html output on a weekly basis from a mixed source of markdown and razor style documents.

When working on the Raspberry PI, processor power becomes an issue. When initially starting out with OWIN/Katana (OWIN runs on mono btw) I found that the response times were slow and I started to think about caching. I get concerned when I start to think about caching and I like to reconsider my approach. Parsing markdown seemed to me to be an expensive operation followed by some Html manipulation with HtmlAgility.

I flipped to using static pages which are periodically generated; rather than lazily generating the resource at request time. Nginx serves these static pages. I applied some config changes to serve the Html files without their extensions.

server {
  listen 80;
  access_log /var/log/nginx/myblog.access.log;
  index Index.html;
  root /var/www/myblog;
  location / {
    expires 7d;
    add_header Cache-Control "public";
    try_files $uri $uri.html $uri/ =404;
  # adapt legacy blog uri's e.g. /post/2015-01-01/Foo-bar to /article/Foo-bar
  rewrite ^/post/\d+/\d+/\d+/(.*)$ /article/$1 permanent;

To give you an idea; it takes 56 minutes to output my ~60 articles running on my Raspberry PI. It takes seconds on my dev box! This peeks my interest because I want to know why it is slow and maybe I can improve this...when I have time :)

.NET CI Jenkins-CI MyBlogPlatform