Skip to content
andreacampi edited this page Oct 7, 2011 · 10 revisions

This document explains how to get started using Plain Curry to get a head start writing a customized theme for Treesaver.

I will assume you are already familiar with Treesaver, and you have at least followed its walkthrough to learn how to create the markup. I will be referring to the current release of Treesaver (0.9.2), but there is no reason why master should be any different. If you find any differences, please let me know.

Knowledge of ruby is not required, but I will assume you have a working ruby installation. If you develop on a Mac (Snow Leopard or Lion) that will be good enough; otherwise look for a ruby package for your platform, or just use RVM.

Initial setup

To get started, you need to install the plugin, which will take care of installing compass:

$ gem install curry-plain
Fetching: compass-0.11.5.gem (100%)
Successfully installed compass-0.11.5
Successfully installed curry-powder-0.4.0
Successfully installed curry-plain-0.4.0
3 gems installed
Installing ri documentation for compass-0.11.5...
Installing ri documentation for curry-powder-0.4.0...
Installing ri documentation for curry-plain-0.4.0...
Installing RDoc documentation for compass-0.11.5...
Installing RDoc documentation for curry-powder-0.4.0...
Installing RDoc documentation for curry-plain-0.4.0....

Create the project

Let's create a new project:

$ compass create walkthrough -r curry -r curry-plain -u curry-plain
directory walkthrough/ 
directory walkthrough/sass/ 
directory walkthrough/stylesheets/ 
   create walkthrough/config.rb 
   create walkthrough/sass/style.scss
   create walkthrough/stylesheets/style.css
Nothing to compile. If you're trying to start a new project, you have left off the directory argument.
Run "compass -h" to get help.

This command has created a few directories for us, as well as a compass source file ready for inclusion in our project. First though, we need some markup. Let's get some sample content (if you don't want to trust me to run a script on your computer, just go to the URL below to verify its content):

$ cd walkthrough
$ bash < <(curl -sL http://goo.gl/IAMhj)

This gives us a few files to play with:

$ find public
public
public/01-down-the-rabbit-hole.html
public/img
public/img/01-rabbit-280.jpg
public/img/02-alice-door-280.jpg
public/img/02-alice-door-600.jpg
public/img/03-alice-bottle-280.jpg
public/img/horizontal-rule.png
public/resources.html
public/treesaver-0.9.2.js

Let's look at what we have so far:

$ compass compile --css-dir public
$ open public/01-down-the-rabbit-hole.html # (on a Mac; otherwise open this page in your browser)

Not bad, isn't it?

Edit and rebuild

Plain Curry gives you reasonable defaults to get you started. For instance, editorial teams can use it while the UI team is still working on the final stylesheet. This means some choices have already been made for you, but you can still customize the style quite a bit.

Let's make some changes.

  • open the sass/style.scss file;

  • before the @import line, add the following:

      $curry-line-height: 22px;
      $curry-plain-grid-outer-width: 280px;
      $curry-plain-grid-margin: 25px;
    
  • now run the following to rebuild the CSS:

      compass compile --css-dir public
    

If you reload the page now, you will see it's changed quite a bit. How did it happen?

Plain Curry (and most Compass plugins too; this is not really specific to this plugin) sets a few variables to default values, and then runs several macros based on those values. These are just defaults; if you set those variables before including the plugin, the defaults will not be applied. All the available variables are documented in their own page.

To see this in action in a more involved case, let's try to increase the header size. At the bottom of the file, add this line and rebuild:

h2 { font-size: 32px; }

As you can probably expect, this will look really ugly, given that our line-height is set to 20px! Normally you would have to do some math, and manually set a line-height for the h2. However the plugin takes care of that for you; just try this instead:

$curry-plain-h2-font-size: 32px;

This time it will look much much better and in fact, as an inspector can confirm, Plain Curry figured out a line-height of 40px is needed and generated it for us.

Easier rebuild

Of course you can use everything you already know about SASS and CSS. Go back to sass/style.scss and add (at the end of the file):

.column.col-3 {
  background-color: #eee;
}

Remember to rebuild! And speaking of that, manually rebuilding the CSS all the time gets boring pretty fast. Luckily Compass has a solution for this: in your shell, run:

compass watch --css-dir public

As you make changes and save your work, you will now notice that Compass will realize that and rebuild automatically.

Finishing touches

You may have noticed the controls bar at the bottom of the screen is kind of ugly. Plain Curry is not magic: it has no real knowledge of what you have in your resources.html, it just expects some reasonable conventions.

The good news is, with most of the hard work done you just need to apply some finishing touches. Let's add some styling to the controls bar, and center the page numbers while we are at it; at the end, it should look like this gist.

Looking at it, I think you can agree we got pretty far for a few minutes of work, and in under 40 lines of stylesheet!

You should now trying making more changes; you can change other configuration variables (check their documentation for details), or just add SCSS or even plain CSS styles.

Create your own curry

Unless your project has a very limited scope, at some point you will outgrow Plain Curry and start wishing for better control of your stylesheet. Curry Powder is the gem that powers Plain Curry and provides a rich set of mixins for the most common tasks you will encounter when styling a Treesaver project.

You can find more about Curry Powder (or just Curry) on its wiki.

Clone this wiki locally