You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mod Perl <on...@yahoo.com> on 2002/02/01 19:24:24 UTC

[QUESTION]PerlHandler and PerlLogHandler Phase

Hi!
I am been working on modperl for some time this is the
first time I am posting a question on the mailing
list. Please bear with me if I miss something or give
too much information.

I have been working on a project that can be described
as an online library. The modperl portion of it adds a
header,navigation bar and a footer and display the
content file of the book which I shall try to draw
below. 
The URI is used to determine what ModPerl nav. bar to
generate. These URI are always in the format 
/en/book/bookname/ch01p01.html. I have used the
following in my configuration file
<Location /en/book>
PerlHandler MyApache::StartBook
PerlLogHandler MyApache::ActivityLogger
</Location>

Things would have been great if the ch01p01.html was
just one long html file without images,stylesheets and
a number of <script src=.....> calls.  The general
format of these html files are as follows.
<script>
Javascript Global Variables set,
the content file to open.
chapterNum=01
chapterPage=01
</script>
<tr><td>
<script scr="js/bookconfig.js">
<script scr="js/"+chapterNum+"P"+chapterPage+".js">
<script scr="js/chapnav.js">
<script scr="js/footer.js">
</td></tr>

Here is the layout....
------------------------------------------------------
ModPerl Gen Header(Nav. Bar for suhjects in library)
-------------------------------------------------------
ModPerl        |  Contents of the course
Gen.           |  which contains html,stylesheets,
Nav Bar        |  images,audio files,java class files
for selected   |  in a directory below the html file
book           |  [<-JS Nav bar mainly images>]
               |  [<!-Footer with current page number]
------------------------------------------------------
ModPerl Footer (Copyrights info.)
-----------------------------------------------------

Here are the problems/Questions that I face:
1. Since in this case each requests for a html file
has multiple files that need to be downloaded by the
client. Am I right to assume that the handler will act
on each and every file requested file below my
/en/course URI?

2.If the answer to the above question is YES? The
Handler will add headers,footers for everything. What
do I need to do to apply the handler logic just to the
requested page and return the remaining files that are
needed to complete the requested page as they are?  

3. When I move these JS files outside the /en/course
URI they seem to work? But now when I put them with
in? It just displays the Javascript code like simple
text on the browser.

4. In the Logging Phase, I need to store the last
requested page as a bookmark. So if the user logs out,
and logs back in it takes him to the same page. Since
the html files are made up of some many requests to
other files, it stores the last file it requested. It
may be path to an image file,style sheet file etc...
Is there any way I can circumvent this problem?

Thank You very much for you help in advance. I
apologize if the email is too detailed.

Mark

__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

RE: [QUESTION]PerlHandler and PerlLogHandler Phase

Posted by Mod Perl <on...@yahoo.com>.
Thanks Rob for your reply.
--- Rob Bloodgood <ro...@empire2.com> wrote:
Question:
> > 2.If the answer to the above question is YES? The
> > Handler will add headers,footers for everything.
> >What do I need to do to apply the handler logic 
> >justto the requested page and return the remaining 
> >files that are needed to complete the requested 
> >page as they are?
Answer:
> In the Eagle book (as well as a Perl Journal
> article) there is an example of a 
>Apache::Header/Apache::Footer.  CPAN doesn't show
> them right now.  But you could implement them as 
>filters using Apache::Filter to mark up each
> document on its way out, based on URI.
Reply:
I shall look into this.  There is some database
entries that have to take place as the web pages are
being servered. 
Question:
> > 3. When I move these JS files outside the
> >/en/course URI they seem to work? But now when I 
> >put them with in? It just displays the Javascript 
> >code like simple text on the browser.
Answer:
> <SCRIPT SRC="/en/course/one.js"></SCRIPT>
> ... or you could template them in directly, since
> you're playing w/ the content already.
Reply: Most of the books are already existing in that
format. To Change them would be a lot of code
rewriting,testing and deploying. 

Question:
> > 4. In the Logging Phase, I need to store the last
> > requested page as a bookmark. So if the user logs
> >out, and logs back in it takes him to the same
page.
> >Since the html files are made up of some many 
> >requests to other files, it stores the last file it
requested.
> > It may be path to an image file,style sheet file
> >etc... Is there any way I can circumvent this
problem?
Answer: 
> You could use a cookie, issued with each document,
> noting what url they are on right now??  Logging it
(storing it) and then  reading it back are bound
> to be waaaaay too much work.
Reply: I kind of figured this portion out. Though its
is not a clean way to do it. In the ActivityLogger.pm,
I plan to use $r->the_request instead of $r->uri. 

The PerlLogHandler being called on every request will
be overwriting the same data in the database.  Let us
assume that the web page request has 5 more files that
it depends. Would not the PerlLogHandler be called
when each file is being server.
> 
> HTH!
> 
> L8r,
> Rob
> 


__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

RE: [QUESTION]PerlHandler and PerlLogHandler Phase

Posted by Rob Bloodgood <ro...@empire2.com>.
> 2.If the answer to the above question is YES? The
> Handler will add headers,footers for everything. What
> do I need to do to apply the handler logic just to the
> requested page and return the remaining files that are
> needed to complete the requested page as they are?

In the Eagle book (as well as a Perl Journal article) there is an example of
a Apache::Header/Apache::Footer.  CPAN doesn't show them right now.  But you
could implement them as filters using Apache::Filter to mark up each
document on its way out, based on URI.

> 3. When I move these JS files outside the /en/course
> URI they seem to work? But now when I put them with
> in? It just displays the Javascript code like simple
> text on the browser.

<SCRIPT SRC="/en/course/one.js"></SCRIPT>
... or you could template them in directly, since you're playing w/ the
content already.

> 4. In the Logging Phase, I need to store the last
> requested page as a bookmark. So if the user logs out,
> and logs back in it takes him to the same page. Since
> the html files are made up of some many requests to
> other files, it stores the last file it requested. It
> may be path to an image file,style sheet file etc...
> Is there any way I can circumvent this problem?

You could use a cookie, issued with each document, noting what url they are
on right now??  Logging it (storing it) and then reading it back are bound
to be waaaaay too much work.

HTH!

L8r,
Rob