Home > Archive > PERL CGI Beginners > December 2004 > Using a CSS file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Graeme St. Clair 2004-12-08, 3:55 pm |
| I have code like this in a Windows XP sys, w. apache 1.3.27 and Perl 5.6.1:-
$formData = new CGI();
print $formData->header( -expires => 'now');
print $formData->start_html( -title => $title,
# -style => { 'src' => 'blah.css' },
-style => { 'code' => $css }, #
pre-filled with style specs
-bgcolor => '#FFFFCC',
-leftmargin => '30',
-topmargin => '20'
);
print $formData->h2( $title );
print $formData->h3( $message );
Using $css works fine, the new HTML page comes up with the desired styles.
But when I try the 'src' way instead, I get un-styled o/p, and two entries
in apache error.log:-
[Wed Dec 08 10:30:01 2004] [error] [client ###.###.###.###] c:/program
files/perl_apache/apache/cgi-bin/fred/blah.css is not executable; ensure
interpreted scripts have "#!" first line
[Wed Dec 08 10:30:01 2004] [error] [client ###.###.###.###] couldn't spawn
child process: c:/program files/perl_apache/apache/cgi-bin/fred/blah.css
'blah.css' is in the same folder 'fred' as the script with the code snippet
above. I tried 'src' => '../blah.css', but that simply brought up the same
error, only in 'htdocs' iso 'fred'.
1) is there some appointed place for 'blah.css' other than where it is?
2) 'blah.css' contains only the CSS specs, nothing else. Is that as it
should be?
Rgds, GStC.
| |
| David Dorward 2004-12-08, 3:55 pm |
| On Wed, Dec 08, 2004 at 07:47:09AM -0800, Graeme St. Clair wrote:
> [Wed Dec 08 10:30:01 2004] [error] [client ###.###.###.###] c:/program
> files/perl_apache/apache/cgi-bin/fred/blah.css is not executable; ensure
> interpreted scripts have "#!" first line
Looks like your server is configured to treat all files in cgi-bin as
CGI scripts.
> 1) is there some appointed place for 'blah.css' other than where it is?
Somewhere where the server won't try to execute them. This probably
means "Anywhere but in the cgi-bin" :)
> 2) 'blah.css' contains only the CSS specs, nothing else. Is that as it
> should be?
Yes
--
David Dorward http://dorward.me.uk
| |
| Sean Davis 2004-12-08, 3:55 pm |
|
On Dec 8, 2004, at 10:52 AM, David Dorward wrote:
> On Wed, Dec 08, 2004 at 07:47:09AM -0800, Graeme St. Clair wrote:
>
> Looks like your server is configured to treat all files in cgi-bin as
> CGI scripts.
>
>
> Somewhere where the server won't try to execute them. This probably
> means "Anywhere but in the cgi-bin" :)
Many servers have a htdocs or Documents directory that is readable from
the server.
Sean
| |
| Lawrence Statton 2004-12-08, 3:55 pm |
| >
>
> Yes
>
Well -- or not :)
Just as we can use Perl to produce valid HTML, we can use Perl to
produce valid CSS. I use it often to produce dynamic CSS based on
User-Agent to work around gross deficiencies in some browsers (*cough*,
Internet Explorer, *cough*).
However, if you wish to do that - and more power if you do - you are
going to have to produce valid output:
............................ BEGIN PERL PROGRAM .........................
#!/usr/bin/perl
# file /usr/local/apache/cgi-bin/style.css mode 755
use strict;
use warnings;
use CGI;
our $query = new CGI;
print $query->header('text/css');
print <<'EOF'
BODY { background: url("/images/ruff.jpg"); font-family: "Helvetica", sans; }
TABLE { margin: auto; border-collapse: collapse; font-weight: bold; border: double 3px; border-color: black; }
TR { border: double 3px;}
TD { border: solid 1px; }
TD.category { text-align: center; font-size: 120%; }
TD.red { color: red; border-color: black; }
EOF
;
............................. END PERL PROGRAM ..........................
Doing soemthing useful is left as an exercise to the reader ;>
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer software consists of only two components: ones and
zeros, in roughly equal proportions. All that is required is to
sort them into the correct order.
| |
| Graeme St. Clair 2004-12-08, 3:55 pm |
| David & Sean: the hints about cgi-bin and htdocs (plus my own unfollowed-up
attempt at 'src' => '../blah.css' were enough. I simply moved blah.css to
htdocs, and bingo.
Lawrence: you seem to be suggesting something close to my $css approach, but
as I have a couple of other pages to bring into line, the simpler the
parameters to ->start_html the happier I shall be. So I'll pinch your hint
of using body { css stuff }, and plunk it into blah.css too. Also, I see
you're using lots of table style, and I'll pinch that as well, since the
only way I'd found to get a nice appearance was <table border="1"
bordercolor="color">.
Thanks to all, rgds, G.
"When in doubt plagiarise; let no-one else's work evade your eyes" ( very
loosely, from Tom Lehrer).
|
|
|
|
|