Re: template path problems

Tim Janik:
> > Well xslt templates can already handle multiple directories, IIRC, ie.
> > a file in /cgi-bin/ can use the stylesheet and images in ../html/ if
> > the correct prefix is supplied (in the browser's point of view, like
> > ../, but that's just a detail ;)

> eh? how do the templates know what directory a file lives in?

They accept parameters for them, ie. --images=../cvs-images if you are
using texitheque :)  Well, templates are not intelligent, but at least
they can be taught how to behave.

> hm, you want the templates to sit in the cgi-bin/ dir as well?

Yes, I don't see a problem with that, ie. a script having its template
with itself.

> what makes me wonder is that you don't have a --prefix or similar argument
> to texitheque here, so how would it figure it's got to translate your paths?

We initially decided that html files won't end up in sub directories,
so it will only prepend '../' (for cgi-bin).  It's not an issue
though, to change this (to add a new parameter).

> but anyway, making a few slight modifications to your suggestion:
> - we add @htmlprefix{} to our macros, and add to our template sources:
>   @htmlprefix{cgi-bin/} so the xslts know the final basepath

Hm, no, we can't do that.  We have to use ../ instead of cgi-bin/
because files do not need to know where they end up, but they need to
know where stylesheets and images ended up (in a browser's point of
view, since the requests will be made by a browser).  For example
a file has @htmlprefix{../}, then the stylesheet location will become
../css/default.css (instead of css/default.css).  We can then put that
file in cgi-bin/ or html/foo/; browsers will find the stylesheet in
both locations.  (Remember, html/ directory is invisible to browsers,
so they are /foo/ and /cgi-bin/ .)

> - we add @cgitemplate to the macro set that just generates "\n@CGITEMPLATE@\n"
>   in the html output, which is good enough to be matched by a perl script.
> - the template file names are hard coded in the cgi scripts,
>   e.g. ../browse.html, they just cat and susbtitute @CGITEMPLATE@  if
>   that's there.

I was planning to use $0 for template names.  So you can use the same
script (ie. gallery) for two different pages (ie. logo-submissions vs.

In httpd.conf:
  ScriptAlias /cgi-bin/logo-submissions /web/beast/cgi-bin/gallery

But it's not a problem, ../html/$0.html as the template name is ok.

> that way, we don't need any extra rules, there're no non-scripts cluttering
> up the cgi-bin/ dir, and the html files effectively being browsed as
> cgi-bin/* is taken care of by xslt magic based on @htmlprefix{}.

Let me try how things will work in practice tonight.

> that sounds cool, how are you going to do that? replace both
> and with dynamic content generation scripts?

Yes.  Actually they share a very big portion of similar code.


Alper Ersoy

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