##
##  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##
__END__

=head1 NAME

wml::std::info - Page Information

=head1 SYNOPSIS

 #use wml::std::info

 <info style={comment,table,meta,oneline} domainname="..."
       copyright="..." created="..." keywords="..." description="...">

 <info:document-url [baseurlvar=VARNAME] [basedirvar=VARNAME]>

=head1 DESCRIPTION

This include file provides the C<E<lt>infoE<gt>> tag to insert page
filename, author, copyright, generator (WML version) and modification time
information in various formats and styles. 

Additionally it defines a C<E<lt>document-urlE<gt>> tag which inserts the
absolute URL of the generated page. This URL is constructed out of the URL
base given in the variables named C<BASE_URL> and C<BASE_DIR> (or the
specified one with attributes C<baseurlvar> and C<baseurldir>). Usually you
define these in your F<.wmlrc> file at the base directory of your WML page
area:

  -D BASE_URL=http://www.mysite.dom/~myself
  -D BASE_DIR~.

=head1 AUTHOR

 Ralf S. Engelschall
 rse@engelschall.com
 www.engelschall.com

=head1 REQUIRES

 Internal: P1, P2
 External: --

=head1 SEEALSO

wml(1)

=cut

