Re: apache::sandwich
Nick Tonkin wrote: On Mon, 10 Mar 2003, Brent Baude wrote: I recently uprgaded from a pre-RedHat8 system to RedHat 8. I used the Apache::Sandwich module to specify a directory and footer filename in the directives to allow me to include footer files dynamically (without having to specify an include statement in each file served). Is there something like this module or an alternative for Apache 2 versions? mod_perl 2 supports output filtering, which could provide a streamlined way of doing what Apache::Filter does fairly trivially AFAIK. But you'd have to read up on filters and implement it yourself. Another option would be for you to port Apache::Filter to run under mp2. Then your code as well as anyone else's who uses that module would run unchanged under mp2. That would be a Good Thing and you'd be a mod_perl hero. People on this list would help if you got stuck, and the documentation for porting is getting quite extensive. This doc: http://perl.apache.org/docs/2.0/devel/porting/porting.html is what you want. What Nick said and make sure to also read: http://perl.apache.org/docs/2.0/user/compat/compat.html ;) __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: apache::sandwich
D'oh, please s/Apache::Filter/Apache::Sandwich/ in my earlier reply. Sorry. - nick -- Nick Tonkin {|8^)>
Re: apache::sandwich
On Mon, 10 Mar 2003, Brent Baude wrote: > I recently uprgaded from a pre-RedHat8 system to RedHat 8. I used the > Apache::Sandwich module to specify a directory and footer filename in the > directives to allow me to include footer files dynamically (without having > to specify an include statement in each file served). Is there something > like this module or an alternative for Apache 2 versions? mod_perl 2 supports output filtering, which could provide a streamlined way of doing what Apache::Filter does fairly trivially AFAIK. But you'd have to read up on filters and implement it yourself. Another option would be for you to port Apache::Filter to run under mp2. Then your code as well as anyone else's who uses that module would run unchanged under mp2. That would be a Good Thing and you'd be a mod_perl hero. People on this list would help if you got stuck, and the documentation for porting is getting quite extensive. This doc: http://perl.apache.org/docs/2.0/devel/porting/porting.html is what you want. Good luck, - nick -- Nick Tonkin {|8^)>
Re: Apache::Sandwich, etc
On Mon, 12 Nov 2001, Mark Maunder wrote: > Jie Gao wrote: > > > Hi All, > > > > I am wondering if it is possible to add a footer to dynamic pages, > > server-wide, like the subject module does to static pages. > > > > One apparent way to me is to add another content handler, but > > I am not sure how that'll work. > > > > Any suggestion is appreciated. > > > > Jie > > When you say 'dynamic pages' what do you mean? Are you using standard > CGI scripts under Apache::Registry? Or have you written your app as > handlers? > > If you've written your app as a handler, then If you're going to use > Multiple handlers that each contribute content to the final document > (i.e. first hander processes the request and the second adds header and > footer info), you should check out Apache::Filter. On 12 Nov 2001, Vivek Khera wrote: > Date: 12 Nov 2001 12:26:41 -0500 > From: Vivek Khera <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Newsgroups: ml.apache.modperl > Subject: Re: Apache::Sandwich, etc > > >>>>> "JG" == Jie Gao <[EMAIL PROTECTED]> writes: > > JG> I am wondering if it is possible to add a footer to dynamic pages, > JG> server-wide, like the subject module does to static pages. > > Apache::Sandwich will work with whatever content handler you want, > including dynamic ones. See the docs. What I am trying to do is to add a footer to the _html_ output by perl scripts running under perl_run. After delving into the camel book, I found I could try "stacked handler pipelining". I need to find out first what content type the script output is, and if it is html, the footer will be added. I'll give the idea a go now. Thanks for the replies. Regards, Jie
Re: Apache::Sandwich, etc
> "JG" == Jie Gao <[EMAIL PROTECTED]> writes: JG> I am wondering if it is possible to add a footer to dynamic pages, JG> server-wide, like the subject module does to static pages. Apache::Sandwich will work with whatever content handler you want, including dynamic ones. See the docs. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROTECTED] Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/
Re: Apache::Sandwich, etc
Jie Gao wrote: > Hi All, > > I am wondering if it is possible to add a footer to dynamic pages, > server-wide, like the subject module does to static pages. > > One apparent way to me is to add another content handler, but > I am not sure how that'll work. > > Any suggestion is appreciated. > > Jie When you say 'dynamic pages' what do you mean? Are you using standard CGI scripts under Apache::Registry? Or have you written your app as handlers? If you've written your app as a handler, then If you're going to use Multiple handlers that each contribute content to the final document (i.e. first hander processes the request and the second adds header and footer info), you should check out Apache::Filter.
Re: Apache::Sandwich and DirectoryIndex
> "CG" == Clint Gilders <[EMAIL PROTECTED]> writes: CG> CG> SetHandler perl-script CG> PerlHandler Apache::Sandwich CG> PerlSetVar HEADER "/body.html" CG> PerlSetVar FOOTER "/bottom.html" CG> You should Sandwich based on a Files rather than Location, or else you're gonna end up trying to sandwich images and possibly your header/footer recursively. I'd also recommend *not* naming your headers/footers with the same extension as your files being sandwiched. I think what your immediate problem comes from is that you're telling Apache to use a different handler on everything inside /test and that means that the default handler that converts directory accesses to the "index.html" file doesn't get run. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROTECTED] Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/
Re: Apache::Sandwich and DirectoryIndex
Clint, That is because the Sandwich module only works against html extention files, or shtml if you do the Files directive. You need to modify the module to assume the Diretory Index of your choice. Thanks At 03:19 PM 1/10/01 -0500, Clint Gilders wrote: >Hi > I have installed Apache::Sandwich on FreeBSD 3.4/Apache 1.3.12/mod_perl >1.24 and have noticed in working with it that if I call a URL like: >http://www.domain.com/test/index.html , it works fine and puts the >header and footer on the file. But, if I call: >http://www.domain.com/test/ , I get: >-- >Not Found > >The requested URL /test/ was not found on this server. >-- >My perl.conf file contains: > > > SetHandler perl-script > PerlHandler Apache::Sandwich > PerlSetVar HEADER "/body.html" > PerlSetVar FOOTER "/bottom.html" > > >Another curious thing is that the 404 error is not being logged in my >error log. > >Is there a way to allow directory indexes with Apache::Sandwich? > >Thanks >-- >Clint Gilders >Servermaster Onlinehobbyist Inc. >[EMAIL PROTECTED] > - Will Wiley Sr. Web Technologist Wind River Systems, Platform Engineering Tel : +1(510)749-2476 Fax : +1(510)749-2010 mailto:[EMAIL PROTECTED] http://www.windriver.com
Re: Apache::Sandwich and CGI scripts
> "HJE" == Hackett, Jonny E <[EMAIL PROTECTED]> writes: HJE> I'm attempting to incorporate Apache::Sandwich into a site I'm working on HJE> and I'm having some problems getting sandwich to work with cgi scripts. What shows up in your error logs? Did you read the section in the Apache::Sandwich docs about sandwiching mod_perl programs? If you are trying to sandwich plain old CGI's (which it doesn't seem like) then you can set SandwichHandler to cgi-handler and let it do the work. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROTECTED] Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/
Re: Apache::Sandwich - how can I put the right page title
> What the HTML spec does not require is for the HEAD section to come > first. So if you must include the HEAD section at the end of the > document, that would be fine. That's incorrect, the standard does indeed require the HEAD section to preceed the BODY. In http://www.w3.org/TR/REC-html40/struct/global.html#h-7.3 an HTML document is defined by the following DTD snippet: Refering to http://www.w3.org/TR/REC-html40/intro/sgmltut.html#h-3.3.3 the comma between "HEAD" and "BODY" indicates that "both A and B occur, in that order". ELB -- Eric L. Brine | Chicken: The egg's way of making more eggs. [EMAIL PROTECTED] | Do you always hit the nail on the thumb? ICQ# 4629314 | An optimist thinks thorn bushes have roses.
Re: Apache::Sandwich - how can I put the right page title
> "JB" == Jeffrey Baker <[EMAIL PROTECTED]> writes: JB> Vivek Khera wrote: >> >> > "SM" == Shay Mandel <[EMAIL PROTECTED]> writes: >> SM> p.s. - the header file I'm getting is the same for all the pages, thus SM> it does not resides in the same directory as the page itself. >> >> Conveniently, Netscape recognizes the html tag anywhere in the >> document, not just in the section. I didn't test if it worked >> for other browsers, though. JB> That would not amount to valid HTML. According to the HTML 4.0 JB> recommendation, "Every HTML document must have a TITLE element in the JB> HEAD section." True, which is another reason I don't use this "trick".
Re: Apache::Sandwich - how can I put the right page title
Vivek Khera wrote: > > > "SM" == Shay Mandel <[EMAIL PROTECTED]> writes: > > SM> p.s. - the header file I'm getting is the same for all the pages, thus > SM> it does not resides in the same directory as the page itself. > > Conveniently, Netscape recognizes the html tag anywhere in the > document, not just in the section. I didn't test if it worked > for other browsers, though. That would not amount to valid HTML. According to the HTML 4.0 recommendation, "Every HTML document must have a TITLE element in the HEAD section." Further, the TITLE element is required. Every document must have exactly one TITLE element. http://www.w3.org/TR/REC-html40/struct/global.html#h-7.4.2 What the HTML spec does not require is for the HEAD section to come first. So if you must include the HEAD section at the end of the document, that would be fine. Experiment to ensure that this does not break user agents. -jwb -- Jeffrey W. Baker * [EMAIL PROTECTED] Critical Path, Inc. * we handle the world's email * www.cp.net 415.808.8807
Re: Apache::Sandwich - how can I put the right page title
> "SM" == Shay Mandel <[EMAIL PROTECTED]> writes: SM> p.s. - the header file I'm getting is the same for all the pages, thus SM> it does not resides in the same directory as the page itself. Conveniently, Netscape recognizes the html tag anywhere in the document, not just in the section. I didn't test if it worked for other browsers, though.
Re: Apache::Sandwich and SSI problems
> "Shay" == Shay Mandel <[EMAIL PROTECTED]> writes: Shay> # Shay> # To use server-parsed HTML files Shay> # Shay> AddType text/html .shtml AddHandler server-parsed .shtml Shay> AddHandler server-parsed .html Shay> Shay> SetHandler perl-script Shay> PerlHandler Apache::Sandwich Shay> # use these documents as header and footer Shay> PerlSetVar HEADER /.includes/header2.shtml PerlSetVar Shay> FOOTER /.includes/footer.shtml Shay> # parse ssi after sandwiching the page Shay> PerlSetVar SandwichHandler server-parsed Shay> # Options Includes # shayman - it doesn't seem to work Shay> Try using a different file suffix for the files to be handled by Apache::Sandwich. Something like this works for me: SetHandler perl-script PerlHandler Apache::Sandwich Then for various directories, I have the following: PerlSetVar HEADER /includes/brc/unix_header.shtml PerlSetVar FOOTER /includes/brc/general_trailer.shtml Note the 'shtml' suffix is handled as: AddType text/x-server-parsed-html .shtml SetHandler perl-script PerlSendHeader Off Options ExecCGI PerlHandler Apache::SSI Everything in HEADER and FOOTER is parsed as expected. I'm opting to use the Apache::SSI module as opposed to the mod_ssi, but it should not make a difference. HTHYO. Peace.
Re: Apache::Sandwich and SSI problems
> "SM" == Shay Mandel <[EMAIL PROTECTED]> writes: SM> Hi, SM> Thank you very much for your response. SM> I've changed my configs, so that the sandwich will work only on .html file, SM> and set them not to be SSI parse by default. SM> Still, the header file, which has .shtml extension is not parsed. When you go to http://your.server.com/.includes/header.shtml does it display what you expect? I suspect not, otherwise it would work with your current setup.
Re: Apache::Sandwich and SSI problems
Hi, Thank you very much for your response. I've changed my configs, so that the sandwich will work only on .html file, and set them not to be SSI parse by default. Still, the header file, which has .shtml extension is not parsed. My sandwich version : 2.2 the httpd.conf details : # # To use server-parsed HTML files # AddType text/html .shtml AddHandler server-parsed .shtml # AddHandler server-parsed .html . # shayman - enable sandwich module # for all files which ends with .html SetHandler perl-script PerlHandler Apache::Sandwich # use these documents as header and footer PerlSetVar HEADER /.includes/header.shtml PerlSetVar FOOTER /.includes/footer.shtml # parse ssi after sandwiching the page PerlSetVar SandwichHandler server-parsed # Options Includes # shayman - it doesn't seem to work The header.shtml file is located in a directory which is allowed for including (Option Includes). What else should I check ? Thanks in advance. Shay. Vivek Khera wrote: > > "SM" == Shay Mandel <[EMAIL PROTECTED]> writes: > > SM> Hi, > SM> I am trying to use your Sandwich module, which is really great and > SM> helpful. So first of all I want to thank you for the great job you've > SM> done. > > Try making your sandwiched documents NOT be *.[s]html. You're forcing > all your documents to be sandwiched, including your header files. > > It seems you expect your .shtml and .html files to go through the > sandwich handler *and* be left along when pulled through as the actual > header/footer. This cannot work. -- Shay Mandel IT Group - WebMaster Galileo Technology Moshav Manof, D.N. Misgav 20184, ISRAEL. E-mail: [EMAIL PROTECTED] Phone : +972-8-9247555 ext. 354 Fax : +972-8-9247554 Phone@home: +972-2-6528550 Cellular : +972-52-339342 WWW Pagehttp://www.galileot.com
Re: Apache::Sandwich and SSI problems
> "SM" == Shay Mandel <[EMAIL PROTECTED]> writes: SM> Hi, SM> I am trying to use your Sandwich module, which is really great and SM> helpful. So first of all I want to thank you for the great job you've SM> done. Try making your sandwiched documents NOT be *.[s]html. You're forcing all your documents to be sandwiched, including your header files. It seems you expect your .shtml and .html files to go through the sandwich handler *and* be left along when pulled through as the actual header/footer. This cannot work.
Re: Apache::Sandwich question
> "JB" == Jason Bodnar <[EMAIL PROTECTED]> writes: JB> Can somebody tell me why Apache::Sandwich will only work with GET JB> requests? I took a quick look at the code and am not picking it JB> up. I'm guessing that the post parameters aren't set up for the JB> subrequest and that's the problem? Wouldn't it be as simple as JB> setting the subr content to the original requests content after JB> lookup_uri() is called? Sounds plausible. I never really put any thought into it, though. I just punted and manually sandwich my programs that need "POST" with a function like this: # insert header/footer parts for *.perl programs (like Sandwich module would) # MUST RUN UNDER mod_perl ENVIRONMENT. # # $which is one of "HEADER" or "FOOTER". # Use PerlSetVar in httpd.conf to set these values. sub insert_document_parts ($) { my ($which) = @_; my $r = Apache->request; my(@parts) = split /\s+/, $r->dir_config($which); for my $uri (@parts) { #warn "inserting $uri " . $r->method() . "\n"; my $status = Apache::Include->virtual($uri, $r) if $uri; #bail if we fail! return $status unless $status == DOCUMENT_FOLLOWS; } return 0; } Then in the program, I call insert_document_parts("HEADER") at the top, and insert_document_parts("FOOTER") at the bottom. One day I might actually stick this function into Sandwich.pm, as it is basically stolen from there anyhow.