<!-- #something -->and should occur on a line by themselves with no leading white space. The second form is considered more SGML friendly by many as <?WN something > indicates a processing instruction specific to WN rather than a comment. For historical reasons this manual describes the other form, but either may be used. With the first form the '#' is required but with the other you may use either
or
<?WN something >
<?WN #something >Also <?wn #something > is fine. The case of the WN is not significant.
or
<?WN something >
<!-- #if some_condition -->Which will insert the conditional text only if some_condition is satisfied. The <!-- #else > is optional. In all the examples below the use of the equal-tilde string =~ to indicate a matching regular expression can be replaced with the two characters !~ in which case the if clause will be true when the regular expression fails to match.
Some conditional text goes here.
<!-- #else -->
Alternate text.
<!-- #endif -->
Also in the examples of the form <#if accept file="foo"> the file foo is assumed to be relative to the current directory unless it begins with a '/' in which case it is taken relative to the WN data hierarchy root. The format of these files is a list of grep like regular expressions, one per line with any white space being taken as part of the expression. Lines beginning with '#' are taken to be comments. If a regular expression is preceded with the character '!' then that character is skipped but the truth value of any matches with the expression is reversed.
<!-- #if accept =~ "regexp" -->specify that this text segment should be served if (in the first case) the grep like regular expression regexp matches any of the Accept headers supplied by the client. Or for the second line if the file "foo" contains a regular expression matching any of the Accept headers.
or
<!-- #if accept file= "foo" -->
<!-- #if after "date" -->specify that this text segment should be served if the current time is after (or before) the specified date. That is, the line
or
<!-- #if before "date" -->
<!-- #if after "22 Oct 1996 17:41:26" -->will cause the text segment to be served only after 22 Oct 1996 17:41:26 local time. The date format is rather rigid. It must be in precisely the format shown above (specified by RFC 1123) and with a single space between each field. Only local time of the server is supported.
<!-- #if cookie =~ "regexp" -->specifies that this text segment should be served if the grep like regular expression regexp matches any of the Cookie headers supplied by the client.
or
<!-- #if cookie file= "foo" -->
More information about the proposed HTTP Set-Cookie header is available at http://home.netscape.com/newsref/std/cookie_spec.html
<!-- #if field3 =~ "regexp" -->specify that this text segment should be served if the grep like regular expression regexp matches the contents of the user defined field number 3 (in the first case) or if the file "foo" contains a matching regular expression (in the second) case. Any valid field number may be used in place of 3.
or
<!-- #if field3 file= "foo" -->
<!-- #if hostname =~ "regexp" -->specify that this text segment should be served if the grep like regular expression regexp matches the hostname of the client (in the first case) or if the file "foo" contains a matching regular expression (in the second) case. For an alternate method of doing this see the "if accessfile" syntax described below.
or
<!-- #if hostname file= "foo" -->
Be aware that the character '.' (dot) has a special meaning in regular expressions and must be escaped with a '\' to have its usual meaning.
<!-- #if host_header =~ "regexp" -->specify that this text segment should be served if the grep like regular expression regexp matches the contents of the HTTP "Host:" header supplied by the client in its request.
Be aware that the character '.' (dot) has a special meaning in regular expressions and must be escaped with a '\' to have its usual meaning.
<!-- #if IP =~ "regexp" -->specify that this text segment should be served if the grep like regular expression regexp matches the IP address of the client (in the first case) or if the file "foo" contains a matching regular expression (in the second case). For an alternate method of doing this see the "if accessfile" syntax described below.
or
<!-- #if IP file= "foo" -->
Be aware that the character '.' (dot) has a special meaning in regular expressions and must be escaped with a '\' to have its usual meaning.
<!-- #if query =~ "regexp" -->specifies that this text segment should be served if the grep like regular expression regexp matches the 'query string' supplied by the client in the URL (in the first case) or if the file "foo" contains a matching regular expression (in the second case).
or
<!-- #if query file = "foo" -->
<!-- #if request =~ "regexp" -->specify that this text segment should be served if the grep like regular expression regexp matches the contents of the full text of the request supplied by the client (in the first case) or if the file "foo" contains a matching regular expression (in the second case). The full request contains the "method" (GET or POST) followed by the URL requested with the "http://host" part having been removed (by the client).
or
<!-- #if request file = "foo" -->
<!-- #if referer =~ "regexp" -->specify that this text segment should be served if the grep like regular expression regexp matches the contents of the Referer: header supplied by the client or if the file "foo" contains a matching regular expression (in the second case). The Referer: header contains the URL of the document containing the link accessed to obtain the current document.
or
<!-- #if referer file = "foo" -->
<!-- #if UA =~ "regexp" -->specifies that this text segment should be served if the grep like regular expression regexp matches the User-Agent header supplied by the client (in the first case) or if the file "foo" contains a matching regular expression (in the second case).
or
<!-- #if UA file = "foo" -->
<!-- #if false -->specifies that the corresponding text segment should not be served. It may be useful for "commenting out" a part of a document which is under construction. The "#if true" construct is present for logical completeness.
<!-- #if accessfile="/dir/accessfile" -->specifies that the file /dir/accessfile is to be used to determine access priviliges (by hostname or IP address) for this text segment. The path /dir/accessfile is relative to the server root directory. If this path does not begin with a '/' then the path is relative to the directory containing the file with this text. (See the user's manual section: Limiting Access to Your WN Hierarchy.)
<!-- #include -->specifies that the contents of next file listed in the includes or wrappers should be inserted at this point. It is permissible to add the name of this file, as in
<!-- #include foo.txt -->but this acts only as a comment. The actual file inserted depends only on the Includes= and Wrappers= directives in the index file (or more precisely the index.cache file created from it.)
<!-- #section -->specifies that part of the contents of next file listed in the includes or wrappers should be inserted at this point. It is permissible to add the name of this file, as in
<!-- #section foo.txt -->but this acts only as a comment. The actual file inserted depends only on the Includes= and Wrappers= directives in the index file (or more precisely the index.cache file created from it.)
The part of the file actually included is that portion of the document between the special comments <!-- #start --> and <!-- #end --> inserted in that document. This requires that these starting and ending comments occur in the HTML document on lines by themselves and with no preceding white space. For more information see the chapter on parsed documents.
<!-- #start -->mark the beginning and end of the portion of the text to be inserted from an include or wrapper in response to encountering <!-- #section --> in the text of a document being parsed. There can be more than one #start/#end pair in a document. There is more information in the chapter on parsed documents.
and
<!-- #end -->
<!-- #title -->in a parsed document instruct the server to include the title of the current document, the current search term from the client or the value of user defined field #3 for the current document. All of these markers must occur on a line by themselves with no leading white space. There is more information in the chapter on parsed documents.
<!-- #query -->
or
<!-- #field 3 -->
<!-- #environ = "WHATEVER" -->in a parsed document instructs the server to include the contents of the environment variable WHATEVER. This expression should occur on a line by itself. Remember to use an "Attributes=parse" line when using this construct and to use an "Attributes=cgi" when it is a CGI varialble like HTTP_REFERER which is to be included.
<!-- #redirect = "url" -->specifies that if no text has yet been sent the server should send an HTTP redirect to the given URL. This might be used as follows. If the text
<!-- #if hostname =~ "\.uk$" -->is included at the beginning of an HTML document then any request from a UK host will automatically be redirected to the specified URL, the UK_mirror_url in this case. This mechanism could also be used to redirect text only browsers to a text only alternative page, etc.
<!-- #redirect = "UK_mirror_url" -->
<!-- #endif -->
There must be no text sent before the <!-- #redirect = "url" --> is entcountered (not even blank lines) since the server cannot send an HTTP redirect while in the middle of tranmitting a document. Thus the example above would be an error if there are any blank lines before the "#if hostname" line or any blank lines after it before the "#redirect" line. When such an error occurs it is logged in the error file and the "#redirect" line is ignored.
Note however that
<!-- #if hostname =~ "\.uk$" -->is correct since when the #redirect line is encountered no text has been sent.
[Lots of text here]
<!-- #else -->
<!-- #redirect = "some_URL" -->
<!-- #endif -->
Normally the URL in the <!-- #redirect = "URL" --> line is fully qualified, like "http://host/path/foo". However, it can also be simply "foo" referring to a file in the same directory as the file being parsed. In this case an HTTP redirection is not sent, and instead the file "foo" is returned immediately to the client.