2. Layouts

Layout management in FotoBilder is handled by a template system called S2. S2 is actually a programming language, with syntax and semantics resembling Perl/C+/Java/etc. S2 code is compiled into a lower level language (currently Perl) and run directly when the page is loaded.

2.1. Preparations

Before you begin creating styles, you need to create a new file in $FBHOME/bin/upgrading/ named s2layers-local.dat. The structure of this file is the same as s2layers.dat, which resides in the same directory. The basic premise is: for every new layout you want to make, you create a new folder under $FBHOME/bin/upgrading/s2layers/ that is the same id as your layout. For example, a layout title “FooBar” might have its own unique id of “foo”, and there should be the corresponding directory: $FBHOME/bin/upgrading/s2layers/foo. To make your layout, you'd create the file $FBHOME/bin/upgrading/s2layers/foo/layout.s2

2.2. Writing & Compiling S2 Layouts

Writing Layouts:  There are two documents that deal with the authoring of s2 layers:

The first document is a FotoBilder core-specific guide that outlines how packaged layouts should be written – if you're using FotoBilder on your own website, its a good starting document, and should be used as a reference as to what to include and not include in your layout. If you're developing layouts for the FotoBilder project, than adherence to the “Layout Authoring Guide” is must. The second document explains the syntax of the S2 language, albeit from a LiveJournal-centric viewpoint.

Compiling Layouts:  Before you begin compiling & testing your new layers, you'll probably want to set the $LESS_CACHING variable to 1 in $FBHOME/etc/fbconfig.pl first. This setting saves you the trouble of stopping and starting Apache between each compile and test. Provided you followed the directions on compiling s2compile in the previous section, you can begin compiling your layers by running the included tool: s2make:

$ s2make
If s2make can't compile any of the layers its been given, it will fail with an appropriate error message that should alert you of the problem it encountered.