[cgiapp] CGI::Application + javascript + http server + icons

Arsen Hayrapetyan ahairape at gmail.com
Wed Nov 19 10:01:15 EST 2008


2008/11/19 Michael Peters <mpeters at plusthree.com>

> Arsen Hayrapetyan wrote:
>
>  When I am running my application, it does not see the image files. Firefox
>> plugin shows that the following file is requested: *
>> URL_base/cgi-bin/app-images/bullet.gif*
>> I.e., my application sees *cgi-bin* instead of *htdocs*.
>>
>
> This is an apache configuration issue not really related to C::A. You might
> get more help on an apache specific mailing list.

May be, I don't know.


> But just for kicks, what does you httpd.conf file look like?
>
It ScriptAlias-es */cgi-bin/* to appropriate directory and document root is
set to *htdocs/*. Do you need any other details?


>
>
>  I tried also other ways of referring to the image files in js code, such
>> as:
>> */app-images/bullet.gif*,* htdocs/app-images/bullet.gif*, but none of them
>> worked.
>>
>
> If your document root is in htdocs/ then that's where all of your media
> assets belong (image files, css, js and .html).

Yes, everything is as you say at the moment.


> And you reference it without mentioning the document root using an absolute
> path (like /images/bullet.gif). This should work and if it isn't then
> something's amiss in your apache configuration.
>

No, it doesn't.



>
>  Putting the images under *cgi-bin* (bad idea by itself) didn't work also,
>> as
>> httpd server recognised the image files as scripts and tried to execute
>> them.
>>
>
> That's probably because you have it set up to execute anything in cgi-bin/
> which is probably not what you want anyway.

Why not? I indeed want cgi-bin/ to contain cgi applications only (BTW, that
is the default httpd configuration.)
Here are some more details:


Application module:
===================================
sub s01 : StartRunmode {
        my $self = shift;
        my $q = $self->query( );
        my $tmpl = $self->load_tmpl( );

        return $tmpl->output;
}
===================================

Corresponding template (relevant part only):
==========================================
<head>
     <title>Knowledgebase</title>
     <link href="/kb.css" rel="stylesheet" type="text/css">
     <script src="/kb.js" type="text/javascript"></script>
   </head>
===========================================

Java Script file (relevant parts only):
=======================================================================================
      var imdir = 'app_images/'; // or */app_images*, does not work either
      var bulletRight = new Image();
      bulletRight.src = 'bullet_right.gif';
...
      img_name = imdir + bulletRight.src; // that is: *
app_images/bullet_right.gif* (or */app_images/bullet_right.gif*)
      a.innerHTML = '<img src="' + img_name + '" width="10" height="10"
border="0" valign="middle" alt="" />&nbsp;'
========================================================================================

<img> tag causes donload of the image file from the server, but instead of
fetching *http://myserver.com/app_images/bullet_right.gif*, the browser
fetches *http://myserver.com/cgi-bin/**app_images/bullet_right.gif*


Arsen.


=============================================

===================================




>
>
> --
> Michael Peters
> Plus Three, LP
>
>
> #####  CGI::Application community mailing list  ################
> ##                                                            ##
> ##  To unsubscribe, or change your message delivery options,  ##
> ##  visit:  http://lists.openlib.org/mailman/listinfo/cgiapp    ##
> ##                                                            ##
> ##  Web archive:   http://lists.openlib.org/pipermail/cgiapp/   ##
> ##  Wiki:          http://cgiapp.erlbaum.net/                 ##
> ##                                                            ##
> ################################################################
>
>


More information about the cgiapp mailing list