Skip to content
Me wee li'tle site
JavaScript Ruby CoffeeScript CSS
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.bundle
app
bin
config
data
lib
public
script
tasks
tmp
vendor/javascripts
.components
.gems.old
.gitignore
.ruby-version
.rvmrc
Gemfile
Gemfile.lock
Guardfile
Procfile
README.md
Rakefile
config.ru
config.ru.example

README.md

Lost in Code

This is my web site. The repo holds both the app that runs the site, as well as all of the blog posts I've written.

What blog software are you using?

I'm not using any software. I generally don't like the blog software that exists now: 1) for a simple web site, it's overkill, and 2) I'm kind of opinionated on the tools that I use. So what I have here is a very simple app I've built on top of Sinatra, everyone's favorite microframework for Ruby. I'm using Mustache for views, Sass for stylesheets, and CoffeeScript using an Ender package in place of jQuery. For asset packaging (concatenation and compression), I've integrated Jammit with Sinatra. There's no UI to create posts. Instead, they are written in Markdown and stored as text files within the repo, and these files are read from when a post is shown. I use Kramdown to make the Markdown-to-HTML conversion. This lets me use stuff like tables and tag elements with classes and so forth.

Where everything is

At one point I planned on having two kinds of content -- posts, i.e. temporal content, and pages, i.e. atemporal ("timeless") content. I now no longer expose a list of pages, but the distinction is still there.

That said, all of the posts I write are kept in data/posts/, and the pages are in data/pages/. Both work the same way in that there is a meta section at the top of every file followed by the content for that file. The meta section is treated as YAML, and the rest is treated as Markdown.

Most of the core code is in lib/lic/ -- the Sinatra application itself, as well as different components like Mustache and Kramdown.

Models are in lib/lic/models/. Because of the split, there are three models, Writing, Post, and Page. Writing is the superclass of Post and Page, and as such, has most of the code. Basically, here is where the files are read from data/ and parsed, and there are accessors for things like the title, body, summary, meta section, etc.

There are also presenters in lib/lic/presenters/ which wrap some of the models, in order to clean up the views a little bit.

Finally, the JavaScript files, stylesheets, and Mustache files are kept in app/. Mustache makes a distinction between templates, which are what you are used to thinking of as views, and views themselves, which are actually mini helper classes just for individual views. (The integration between Sinatra and Mustache is admittedly a little weird, perhaps I can go into that further if you want me to.)

JavaScript and CSS files are generated from CoffeeScript and Sass files, respectively, via Guard. There are also Rake tasks in tasks/ to generate these files, and package assets as well.

Can I fork your repo and use it for my blog?

Yes! Fork it, make changes, do your thing. I'm not the first person to use Sinatra for my blog, I claim no intellectual property here.

So I cloned the repo, how do I start the app?

  • bundle install
  • foreman start
  • open http://localhost:5000

Okay, how do I hack on it?

Start the web server as described above, and in another tab, run bundle exec guard. Stylesheets and JavaScript files are compiled to public/stylesheets and public/javascripts, respectively.

Author/Copyright

(c) 2012-2013 Elliot Winkler (elliot.winkler@gmail.com)

License/Support

You are FREE to use any code here as you wish, whether for commercial or personal purposes. Just remember to have fun.

I am not responsible for any bad stuff that happens as a result of using this. It was probably your cat.

I am happy to answer any questions you have, feel free to email me using the address above.

Something went wrong with that request. Please try again.