Home page: http://plig.net/~ture/rubyphoto/ |
Authors: Mark Hulme-Jones <ture@plig.netg> Adam Spiers <adam@spiers.net> |
RubyPhoto is a program for creating image galleries for the web. It recurses through a directory tree creating album index files for each sub-directory and image index files and thumbnails of specified sizes for each image. The generated HTML is completely customisable via templates. All configuration and image/album information is supplied in XML files.
Examples of the type of output the program can generate can be found on Adam's photo page.
RubyPhoto was inspired by the swigs program, written in Perl, though RubyPhoto is a complete, from-scratch re-write. There are a couple of scripts provided with RubyPhoto that allow you to convert the album and image files used by swigs over to the format used by RubyPhoto. You can find these in the swigs-converters/ directory of the RubyPhoto distribution.
All you need to do if you want to be up and running really quickly is to change to the directory with your images in it and run:
/path/to/rubyphoto/ruby_photo.rb
RubyPhoto should do all the rest of the work for you. However, this does not take advantage of many of the more advanced possibilities open to you with RubyPhoto. For details of each of these, see below.
For more information on running RubyPhoto, invoke ruby_photo.rb with the --help command line option.
The config file (see the example in sample_input/config.xml in the RubyPhoto distribution directory) is a reasonably simple XML file. In addition to the global config file (~/.rubyphoto-conf) you can also override the global configuration on a per-directory basis, by including a file called config.xml in a particular directory. You can also point RubyPhoto at a configuration file with the --config command-line option.
The top-level environment in a RubyPhoto config file is <config>, and within this are three different sections:
This is where you can configure all of RubyPhoto's runtime options. For a full reference to all of these options, see Config Option Reference below.
Here you can name all of the fields that you want to be valid inside the individual image XML files. The defaults are probably enough for most people, but you might disagree.
RubyPhoto creates smaller versions of each of the photos that you want to appear in your albums. By default, it creates a Small image of 320x200 pixels, and a Medium image of 640x480 pixels. If most of your images are very small (or maybe very large) you may want to tweak these sizes a bit, or even introduce some new sizes altogether.
Each image category has six attributes:
Each directory, or sub-album, may contain an album.xml file, allowing you to configure things like the title to be used in links to that album. For an example album XML file see sample_input/album.xml in the RubyPhoto distribution. Inside the top-level <album> environment there are four valid elements:
Each image in your album may have an associated XML file containing details about the image. The exact fields that are valid in these files are specified in the <photofields> section of the configuration file (see Configuration File, above). See sample_input/example.jpg.xml in the RubyPhoto distribution for an example.
Ignore files enable you to tell RubyPhoto to ignore particular files and/or directories. RubyPhoto allows you to specify both a global ignore list file, and an ignore list for each directory (sub-album). The global ignore file is usually called ~/.rubyphoto-ignore (though this can be changed with the ignore_file configuration option). Per-directory ignore lists are called the same thing, only you put them in a particular album's directory instead of in your home directory.
RubyPhoto uses four different template files to generate its final HTML output. These are all kept in the ~/.rubyphoto-templates directory. Template files consist of XML element pairs for each part of the page (eg. <pageheader> for the header of an image page). In order to include HTML inside these XML element pairs, XML CDATA sections are used (see the template files for an example of how this works).
The four template files are:
In the first three of these files, text to be replaced appears inside brackets, [ and ], and should be upper-case. For example, in image.xml, the text [TITLE] will be replaced with the title of the image for which the page is being generated.
The best thing to do to get a feel for the template files is to take a look at them yourself. A full template reference may follow some time in the future...
In the swigs-converters/ sub-directory are some scripts for converting from swigs format album and image files over to RubyPhoto ones, and in the xml-generators/ sub-directory are some Zsh scripts you can use to create album and image XML files. Note that the Zsh scripts probably require a recent-ish version of Zsh.
<a href="blah/blah/foo/">Foo</a>rather than
<a href="blah/blah/foo/index.html">Foo</a>
The former makes for cleaner links, but will only work if your images are only being viewed from a webserver which is configured to interpret such links as references to the index page (this should be true by default on virtually all webservers).
The order in which to display the photo and subalbum thumbnails respectively on an album page. date sorts lexically by the contents of the date field, and order_field numerically (you can use non-integers) by the contents of the order field. If a photo is missing the order field, it will come after all photos which have the order field. You can reverse the sense of the sorting order by including an order="reverse" attribute.
For each of these <option> tags, you may also specify an inherit="no" attribute, which inhibits subdirectories from inheriting this particular setting.