TGLMAN

New Blog

Hi All, I usually like to build things almost from scratch, but this time i tryed to do an exception,my old blog was written in php, night time, with my limited knowled of design, it didn’t really have an engine behind,it was more a few line of php for merge together a few html(5) hand written posts, it was quite hard to maintain and my focus was more on make it work, than actully put some content in it

So at the end i was not posting at all becasue it was not working ;).

Now i finally choosed to use a tool for build my blog, the choice of the tool was driven by few needs i had, one was i want to write posts in markdown, second i need something quite simple that doesn’t need an huge server for run, so i just opened a console and typed “apt-cache search blog markdown”, i know that for most people that’s not the way to search for new things, but for me it is!

So it come out a list of few options, and checking out the websites (yes i use also the web sometime) i choosen nanoc is a simple static site generator written in ruby, it look quite clean and it support markdown, and actully if i don’t remember wrong, someone suggested to me this tool while i was in a hackday, but as i usually do i didn’t considered the suggestion straigth.

So i just installed the software and look for a first basic tutorial, was quite easy to set up, and i got out with a result in the first 20 minutes, but i struggled a bit refatoring the complex design you see :P.

Another point of struggling was actully for let the engine parse properly the markdown and the code blocks, and at the end i finished with this nanoc Rules:

 1
 2compile '*' do
 3  if item[:extension] == 'md'
 4     filter :kramdown, :input => 'GFM'
 5     layout 'default'
 6  elsif item[:extension] == 'css'
 7    # don’t filter stylesheets
 8  elsif item.binary?
 9    # don’t filter binary items
10  else
11    filter :erb
12    filter :colorize_syntax, :colorizers => {:java => :coderay}, :coderay => {:line_numbers => :inline}
13    layout 'default'
14  end
15end
16
17route '*' do
18  if item[:extension] == 'css'
19    # Write item with identifier /foo/ to /foo.css
20    item.identifier.chop + '.css'
21  elsif item.binary?
22    # Write item with identifier /foo/ to /foo.ext
23    item.identifier.chop + '.' + item[:extension]
24  else
25    # Write item with identifier /foo/ to /foo/index.html
26    item.identifier + 'index.html'
27  end
28end
29
30layout '*', :erb

that is almost the basic Rules generated by default with github style markdown(see :input=> 'GFM' where GMF= Github Flavored Markdown ) support that is the one i know ;), and some code highligth for html
nothing to complex

after i couple of days playing with nanoc i also discovered that has a few blogging specialized plugins, so i enabled them just creating a file lib/includes.rb with this content:

1include Nanoc::Helpers::Blogging 
2include Nanoc::Helpers::Tagging        
3include Nanoc::Helpers::LinkTo 

and what you see now is the final result, i’m quite satisfied, there are some limitations, like is not possible to comment the posts but if you want to comment it feel free to figure out my email address and send me an email, i’ll be happy to put your comment here.

and finally all of this written with vim and versioned with git, quite happy, and sorry for eventual Enlgish mistakes ;)

Posts

New Blog
14 April 2014

Primitive Boxing Problem
20 november 2012

DDD Query Way
20 october 2012

Refs

Twitter
Github
StackOverflow
OpenHub
SourceForge

Projects

Object Query