Yawn - Server-side includes


Server-side includes are essentially processing directives embedded in an HTML file which are read by the server software prior to sending a requested document and substituted with information described in the directive. This way a document fragment may be included into a larger file (e.g. in order to easily control a repeated section of a document set, like a navigation bar), an environment variable may be echoed, a page counter may be displayed.

Yawn uses the format of includes used in the NCSA httpd and Apache servers:

<!--#command tag="value" -->

As you can see, the directive is embedded in an overloaded HTML comment. The hash sign (#) signals that the comment should be interpreted by the server.

Here's a test page using all of the includes shown below - every information put in bold type was dynamically linked to the document before serving it.

Note: for the mechanism to work, the file in question must be recognized by server as a parsed (interpreted) one. This is done by saving the file with an .xtm extension. The configuration file contains a definition of a server-internal MIME type text/x-server-parsed-html which binds the type to the above extension. Below you'll find examples of the use of includes. Illustrations of SSI syntax are followed by their actual use.


[Top of the page]

Included external files

This paragraph is included into the main file by means of the following directive:

<--#include virtual="/yawn/include.htm"-->

You can have a look at the inluded file here. For the difference between the tags "virtual" and "file", see here. You can also include parsed files containing includes themselves, to the maximum of four levels.


Variables and counters

[Top of the page]

This is the set of variables that can be displayed using the server-side include mechanism of Yawn:


NW_ includes

[Top of the page]

Includes starting with NW_ use NetWare-specific variables describing in detail the configuration of your NetWare server. Their meaning is fairly self-explanatory. For details, check your NetWare documentation.


Configuration includes

[Top of the page]

To configure the output of some includes, you can use the configuration directive:

<!--#config ... -->

There are three tags that you can use with the directive:

  1. <!--#config sizefmt="bytes | abbrev" -->

    This configuration directive is used with the fsize include (i.e. it should precede fsize in an .xtm file). "Bytes" causes a file size to be represented as the exact number od bytes, while "abbrev" shows each started kilobyte/megabyte of the size.

    Example:

    <!--#config sizefmt="bytes" -->
    Size of this file: 19257

    <!--#config sizefmt="abbrev" -->
    Size of this file: 18 KB

  2. <!--#config intervalfmt="%D %H %M %S" -->

    This is used with the directives that echo server_up_time and NW_SERVER_UP_TIME. The abbreviations given above stand for - respectively - days, hours, minutes, and seconds. In the configuration string you can embedd any text you want to apppear as the output of the directive and the abbreviations in any order.

    Example:

    <!--#config intervalfmt="%D days, %H hrs, %M mins, %S secs" -->
    The uptime of this httpd server is: 22 days, 16 hrs, 36 mins, 25 secs

  3. <!--#config timefmt="..." -->

    This directive can be used with all includes which echo time data (LAST_MODIFIED, flastmod, DATE_LOCAL, DATE_GMT). Like intervalfmt, it allows you to mix text and embedded codes (abbreviations) to specify the exact format of the date/time that will be echoed. The codes used here are exactly the same as used by the C system function strftime, which are:

    %S 2-digit second
    %M 2-digit minute
    %I 2-digit hour
    %H 2-digit hour
    %p AM or PM
    %w Weekday: 0 = Sunday
    %a Abbreviated weekday name
    %A Full weekday name
    %d 2-digit day of month
    %j 3-digit day of year
    %U 2-digit week number: Sunday = 1st day of week
    %W 2-digit week number: Monday = 1st day of week
    %m 2-digit month, decimal
    %b Abbrev. month name
    %B Full month name
    %y 2-digit year, no century
    %Y Year with century
    %x Date
    %X Time
    %c Date and time
    %Z Time zone name, or no chars if no time zone
    %% the character %

    Example:

    <!--#config timefmt="%A, %B %d, %H:%M %p (%Z)" -->
    This file was last modified on: Monday, June 03, 15:00 PM (MEST)


[Top of the page]

"Virtual" and "file"

Some of the directives (include, fsize, flastmod, counter) allow you to specify the name of the file the output data refer to. This can be done by using one of the following tags:


[Home - Overview - Downloading - Installation - Configuration -
Implementation notes - License - Registering - Contacts]