public
Description: a lightweight, feature-rich blogging platform
Home | Edit | New

DevelopingThemes

Themes in Canticore were designed to be simple and effective to create. Not only do you use a simple, clean templating language for markup (HAML), but you can (theoretically) provide your own code to be used as helpers and such for your theme.

Screenshots

The filename static/snapshot.png in your gem is reserved for a screenshot of the theme to display in the canticore.org Refinery and the administrative interface of Canticore installations. It hasn’t been decided what the standards are for the interface, although a 1024×768 full shot of the theme (with no browser chrome) will probably be the preferred method.

Code Example

This example is for the file _entry.haml in your theme’s view directory. _entry.haml is for displaying entries of your blog in a list. You can choose to just have a link to the post and the title, or the entire post! The following snippet is an example entire _entry.haml file. It creates a <div> with several class names: post, post- followed by the post ID, and post-slug- followed by the URL slug of the post. Then it creates a <h2> header with the title of the entry in it.

.post{ :class => "post-#{entry.id} post-slug-#{entry.slug}" }
  %h2= entry.title

Settings

Settings are pieces of data that are saved to the database. These settings contain things you might want to include in your themes. Any setting can be accessed by displaying the output of settings[name], where name is a string with namespaces separated by periods.

For example, in most themes you’re going to want the title of the blog in the <title> tag of the layout.haml file. This is accomplished like so:

  %title= settings['blog.name']

A list of settings follows:

Namespace Setting Description
blog name The name of the blog.
blog active_theme The name of the currently activated theme.

Internals you can use in themes

Post#latest_posts retrieves the latest published posts in reverse publishing order. Is automatically provided on index.haml as the variable posts. You can then use your _entry.haml partial in the following way:

= partial :entry, :collection => posts
Last edited by ardekantur, Sun Dec 21 16:01:33 -0800 2008
Home | Edit | New
Versions: