##
##  wml::std::info - Page Information
##  Copyright (c) 1997-2001 Ralf S. Engelschall, All Rights Reserved. 
##

#  The <preserve>/<restore> tags with multiple arguments require WML 2.0.3
#use wml::mod::version
<require 2.0.3 />

#use wml::std::tags
#use wml::sup::path

#
#  The `info' tag
#
<define-tag info>\
<preserve style copyright created keywords description domainname />\
<set-var %attributes />\
<defvar style=comment />\
<defvar domainname "<get-var WML_GEN_HOSTNAME />" />\
<when <string-eq <get-var style /> comment />>\
<nostrip>\
<!--
     <if <get-var copyright /> "Copyright (c) <get-var copyright />
     " />\
     Author:   <get-var WML_SRC_REALNAME /> (<get-var WML_SRC_USERNAME />@<get-var domainname />)
     Modified: <get-var WML_SRC_ISOTIME />.
     <if <get-var created /> "Created:  <get-var created />
     " />\
     Generated from ``<get-var WML_SRC_FILENAME />'' via WML <get-var WML_VERSION />.
               by <get-var WML_GEN_REALNAME /> (<get-var WML_GEN_USERNAME />@<get-var domainname />) 
               on <get-var WML_GEN_ISOTIME />.

     DO NOT EDIT THIS FILE DIRECTLY! INSTEAD EDIT ``<get-var WML_SRC_FILENAME />''.
-->\
</nostrip>\
</when>
<when <string-eq <get-var style /> table />>
<pre>
<when <get-var copyright />><b>Copyright:</b> &copy; <get-var copyright />
</when>\
<b>Author:</b>    <get-var WML_SRC_REALNAME /> \
<a href="mailto:<get-var WML_SRC_USERNAME />@<get-var domainname />">\
&lt;<get-var WML_SRC_USERNAME />@<get-var domainname />&gt;\
</a>
<b>Generator:</b> WML <get-var WML_VERSION />
<b>Modified:</b>  <get-var WML_SRC_ISOTIME />
<when <get-var created />><b>Created:</b>   <get-var created />
</when>\
</pre>
</when>
<when <string-eq <get-var style /> meta />>
<when <get-var copyright />><meta name="Copyright" content="<get-var copyright />" />
</when>\
<nostrip>\
<meta name="Author"    content="<get-var WML_SRC_REALNAME />, <get-var WML_SRC_USERNAME />@<get-var domainname />" />
<meta name="Generator" content="WML <get-var WML_VERSION />" />
<meta name="Modified"  content="<get-var WML_SRC_ISOTIME />" />
<when <get-var created />><meta name="Created"   content="<get-var created />" />
</when>\
<when <get-var keywords />><meta name="Keywords"  content="<get-var keywords />" />
</when>\
<when <get-var description />><meta name="Description" content="<get-var description />" />
</when>\
</nostrip>\
</when>
<when <string-eq <get-var style /> oneline />>
<when <get-var copyright />>Copyright &copy; <get-var copyright /><br /></when>
Last modified by <get-var WML_GEN_REALNAME /> (<get-var WML_GEN_USERNAME />) on <get-var WML_GEN_ISOTIME /> via WML <get-var WML_VERSION />.
</when>
<restore  style copyright created keywords description domainname />\
</define-tag>

#
#  Insert a fully qualified URL for this document
#
<define-tag info:document-url>
<preserve baseurlvar basedirvar />
<set-var %attributes />
<defvar baseurlvar BASE_URL />
<defvar basedirvar BASE_DIR />
<perl>
{
    my ($cwd, $baseurl, $basedir, $subdir, $page, $url);

    #   determine current working directory
    $cwd = '<get-var WML_SRC_DIRNAME />';

    #   determine base URL
    $baseurl = '<get-var <get-var baseurlvar /> />' || 'file://';

    #   determine base directory
    $basedir = '<get-var <get-var basedirvar /> />'
        || '<get-var WML_SRC_DIRNAME />';
    $basedir = &canonpath("$cwd/$basedir") if ($basedir !~ m|^/|);

    #   determine subdir from base dir to current working dir
    $subdir = &relpath($basedir, $cwd);

    #   determine page name
    $page = '<get-var WML_SRC_BASENAME />' . '.html';
    $page =~ s|^index\.html$||;

    #   construct final URL
    $url = "$baseurl/$subdir/$page";
    $url = &canonurl($url);

    #   replace this tag with the constructed URL
    <perl:print: $url />
}
</perl>
<restore  baseurlvar basedirvar />
</define-tag>

##EOF##
