Saké Customization

Structure
The interface that a Saké application exposes to end-users is entirely defined by a set of template files that describe the HTML that Saké produces. Say that a user accesses, for instance, the initial login page of Saké Mail. First, Saké will check to see if the template corresponding to the login page (called "t_nf_login" in this case, the "NF" indicating "no-frames") has already been loaded, processed, and cached. If it has, then Saké Mail will modify the template on-the-fly with necessary information such as error messages or user data, and spit out the HTML-based login page to the user's browser. If the template has not been loaded already then Saké will automatically locate the template file, load it into memory, parse it, and cache the results. This way, the loading operation only happens once and future invocations of Saké Mail that call for a display of the login page will finish in a fraction of the time that it took to initially load the template. See Figure 1:


Figure 1: Saké uses template files, stored on the disk of the web server that Saké is installed on, to define its entire interface.

Since the entire interface works this way, you can completely customize the look of the entire application by modifying the template files that are stored on disk as part of your Saké installation. If you would like to change the background color of an entire application, for instance, you can simply open the template file and locate the specification for the background color and change it. The next time that Saké loads the modified template to create a page, it will produce output with your new background color instead of our original 'out-of-the-box' colors. If you want to change the layout of the frames, add advertising banners, translate the interface into Slovenian, anything that you like, all of these tasks can be accomplished simply by modifying template files.

Saké template files come in two different flavors, and you can use whichever you are more comfortable with. The simplest option of the two is simple HTML templates. With HTML templates, each template file that is stored in your Saké installation is a valid HTML file that can be edited with any standards-compliant HTML editor. As you make modifications to the HTML files, you can restart Saké and see the results. Using simple HTML file templates is very similar to 'normal' web development with a web server. See figure 2:


Figure 2: HTML template files take a fairly simple path to the end user.

The other option is to use XML/XSL templates. If you use the mechanism, then Saké will combine each interface template with a single XSL style sheet called "style.xsl" to create an HTML template on-the-fly. (See Figure 3) This is a bit more complex than using simple HTML files primarily because if you use XML templates then you will probably not be able to use the off-the-shelf HTML editing tools that you are used to. The benefit of using XML templates is that you can use the XSL style sheet to make application-wide changes by editing a single file. To change the background color or image of every single page in the entire application, for instance, all that you need to do is edit a few lines in the XSL style sheet, and the next time that the Saké application loads its templates your changes will affect every single page in the application. We have made every effort to centralize style elements into the XSL style sheet in our out-of-the-box template set, to demonstrate the power of server-side XSL.


Figure 3: XML template files are combined with XSL style sheets on-the-fly to create HTML templates.

In order to actually modify the interface for a Saké application, first specify whether you are going to be using XML or HTML templates. Most people prefer using XML templates, and we highly recommend them, so the default is XML. If you want to change the type of template, modify the "sake.templatetype" setting in the initialization file for the application. For more information on this and other settings in the initialization file, see the configuration documentation.

Figure 4: The "templates" directory under the Saké installation tree.

Once you have selected the type of template that you would like to use, locate the templates that you will be modifying. The default templates will be located under the "templates/default" directory of your Saké installation, in a directory named for the particular application that you are modifying. For example, the default templates for Saké Mail will be in the "templates/default/mail" directory of your Saké installation. If you are using XML templates, then your templates will be files called "t_*.xml" in the "xml" directory of your application's templates, and if you are using HTML templates then your templates will be files called "t_*.htm" in the "html" directory. If you are using XML templates, then the contents of the "html" directory will be completely ignored. Likewise, if you are using HTML templates, then the contents of the "xml" directory will be ignored. Images used by Saké will be files that begin with "i_", located in the "images" directory. See Figure 4.

We provide a template set in our "out-of-the-box" style (Endymion colors) in both XML and HTML formats. We generated the HTML files automatically from the XML files before we packed your distribution. For obvious reasons, we recommend making a backup of your template files before making any modifications.


Figure 5: Three new skins in addition to the "default" skin: a skin for "xcorp", a skin for "ycorp", and one for "zcorp".

Skins
In some situations, it may be necessary for a single Saké installation to provide several different interfaces to different people. If a web hosting company, for example, wishes to resell the functionality of some Saké application to their own clients, then they may also wish to have the option of customizing the interface of a Saké application differently for each client. Saké provides this functionality through a mechanism known as "skins". A skin is simply a name for a set of templates that a Saké application can use to generate output at runtime. By default, a Saké application uses the skin called "default", which is why the templates for a directory are stored in the "templates/default" directory of your Saké application. In order to use a different skin, create a set of templates and store them in a directory adjacent to "templates/default" under the name that you would like to give your new skin. For example, in Figure 5, we have created three new skins in addition to the "default" skin, a skin called "xcorp", one called "ycorp", and one called "zcorp". Note that these skins contain only an "xml" directory, which of course works fine as long as you are using XML templates.

In order to use the different template sets, specify the "sake.skin" parameter to your application when you initially run it. For example, if you have a Saké Mail installation set up at "http://www.yourserver.com/mail", then you would invoke the default template set with the URL "http://www.yourserver.com/mail" as usual. You would invoke the "xcorp" skin at the same installation with "http://www.yourserver.com/mail?sake.skin=xcorp", the "ycorp" skin with "http://www.yourserver.com/mail?sake.skin=ycorp", and so on. Ordinary end-users generally can't be expected to remember such an explicit URL, but in most cases your Saké applications will be accessed via a link anyway. Simply encode the parameter in the link from your static site that leads users to your application.

Saké licenses limit the number of skins for a Saké installation in most cases, but adding new skins to an additional installation is much cheaper and simpler than setting up an installation for each company. You can think of skins as being similar to virtual domains for a web server.

Copyright © 1999 - 2002 Endymion Corporation
All rights reserved.
Carpe Noctem