[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]

Re: question wml 1.4.6



Hello Viorel Anghel, in a previous mail you wrote:

> Sorry for bothering you with that (it would be better if you set-up a
> mailing list wml-(l)users ;-)...

There is a mailing list: sw-wml@engelschall.com. You can subcribe
via majordomo@engelschall.com.

> I can't find an easy way to include in all files something like apache
> <!--#echo var=DOCUMENT_URI>.
> I want to have an footer in base directory and then all files to include
> that (i do that), but how can i tell in that footer to print the current
> URL of the file?
> 
> As a comment, for now i use wml mostly in the purpose of avoiding
> server-side-includes and defining same headers and footers in all pages.

A very good question. I've thought about it and the general
solution is the following:

1. Define the URL base in a .wmlrc in the base dir of your WML page area via
   ``-DBASE_URL=http://www.domain.dom/~myself'' and additionally define
   ``-DBASE_DIR~.'' This way all pages below this area get the URL to the base
   dir and the relative dir to the base dir.

2. Use the wml::std::info from the coming WML 1.4.12 (where I've added
   this function now) or define it somewhere in your own include files:

   | #use wml::sup::path
   | <define-tag document_url>
   | <:{
   |    my ($baseurl, $basedir, $dir, $file, $url);
   |    $baseurl = '<get-var BASE_URL>';
   |    $basedir = '<get-var BASE_DIR>';
   |    $cwd = `pwd`;
   |    $cwd =~ s|\n$||;
   |    $dir = &relpath(&canonpath("$cwd/$basedir"), $cwd);
   |    $file = '<get-var WML_SRC_FILENAME>';
   |    $file =~ s|\.wml$|.html|;
   |    $file =~ s|^index\.html$||;
   |    $url = "$baseurl/$dir/$file";
   |    $url = &canonpath($url);
   |    print $url;
   | }:>
   | </define-tag>

3. Now you are ready: Just use 

   | #use wml::std::info     <-- or your own include file
   | <document_url>

   and you get the correct absolute URL to your page.
   
Greetings,
                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com
______________________________________________________________________
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com