Release 0.9.1

Release 0.9.1 adds one new significant feature and fixes some bugs. The big new feature is the ability to generate multiple output files from a single content page. See below for more information.

Multiple Output Files

What’s that, you say? Multiple output files, you say?

Why, yes!

Let’s take the example of a photo gallery containing a page of thumbnails that each link to a larger picture with a title and a description. To make such a creation in webby would require each “large picture” page to have it’s own file in the content directory, but the only difference between these files would be the title and the description.

A better way to handle such a beastie would be a single file in the content folder that contains the titles and descriptions of all the photos in the meta-data. The content of this page would be filled in differently for each specific photo page generated.

This is now possible in webby by specifying the specifics for each photo in separate meta-data blocks at the top of the page. One output file will be generated for each meta-data block.

--- 
title:       First Photo
created_at: 2008-09-10 19:33:47.822421 -06:00
filter:
  - erb
  - textile
filename:    photo-1
photo:       IMG001.jpg
description: This is the first photo
--- 
title:       Second Photo
filename:    photo-2
photo:       IMG002.jpg
description: This is the second photo
--- 
title:       Thrid Photo
filename:    photo-3
photo:       IMG003.jpg
description: This is the thrid photo
---
h1. <%= @page.title %>

!<%= @page.photo %>!

p(desc). <%= description %>

The example above will result in three output files being generated. The output destination is generated by combining the directory / filename . extension One of those must be different in each meta-data block, otherwise the resulting output files will overwrite one another. In the example, I have chose to modify the filename.

The first meta-data block defines the base set of meta-data for the page. Each subsequent meta-data block modifies the meta-data of the first block. So, each resulting output file will be processed by the erb and textile filters (because they appear in the first meta-data block) without having to explicitly specify those filters in each block. Meta-data defined in the second block does not affect the third or subsequent blocks; only the first meta-data block defines inheritable parameters.

Another Example

Let’s say you want to generate an HTML file and a PDF file for a single page. This is easily done by specifying different filters.

--- 
title:      Downloadable Instructions
created_at: 2008-09-10 19:33:47.822421 -06:00
filter:
  - erb
  - textile
--- 
extension: pdf
layout: none
filter:
  - erb
  - textile
  - htmldoc
--- 

content goes here ...

In this example, the first meta-data block generates an HTML page in the standard webby fashion — render the page and insert into the default layout. The second meta-data block adds the “htmldoc” filter1 to the end of the filter stack. This uses the htmldoc program to convert HTML into PDF format.

Again, we specify a different output file by changing the extension from the default to “pdf”, and we prevent site navigation and headers / footers from appearing in the generated PDF by setting the layout to none. The title is inherited from the first meta-data block.

1 This filter does not exist, but the htmldoc program does exist. So the filter is not out of the question, and it most likely will make an appearance in a later release of webby.