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

Re: Best Practices: CGI.pm & CSS2 ???

My two cents.

I agree that using a template driven system is much better than CGI.pm, especially if you are
using CSS. Whether you do a roll your own template processor or use HTML::Template, it works
to allow the design of the site to be separated from the function of it. I create some of the
worlds ugliest web sites, but I'm a pretty good Perl hacker. So, I build an functional, but
ugly, template, then give it to someone who has some artistic sense. They make it look pretty,
then I have a pretty and functional site.

I also use CSS, but mainly to make the site compatible across platforms. It really allows the
end user to see it in the way best for them. I try to stay away from positioning with CSS.
But, it rocks as far as make a site-wide look-and-feel. I usually test my stuff on Netscape,
Opera, Explorer and Lynx.

If you want to see a site that uses poor HTML/CSS, view http://www.buybordenmilk.com (it's a
site my company designed and we host, so I can slam it if I want). The designer did some good
stuff, but she also did absolute positioning with the CSS. Try it at 1280x1024. (We're getting
ready to do a re-write).


> CSS is not deprecated. It is not reliable for positioning but it is quite
> usable for defining text and character styles.   If you have ever
> changed all the font tags in a web site, you will be a CSS fan.
> If you attempt to validate your HTML against w3.org's validator, you
> are required to be a fan.
> 	http://validator.w3.org/
> It is probably not a good idea to use CGI.pm to produce HTML output. Why
> learn another HTML syntax ? Something like HTML::Template or even a HERE
> document will serve you better.
> However it is very foolish to **Not** use CGI to parse input from a form.
> It is much, much easier and safer than parsing the raw query string or
> reading STDIN or escaping shell charactors or otherwise doing the job by
> hand.
> #!/usr/bin/perl -wT
> use strict;
> use CGI;
> use CGI::Carp;
> my $q    = new CGI;
> my $name = $q->param('first_name') || 0;
> my $result = <<HERE;
> Content-Type: text/html; charset=ISO-8859-1\n\n
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
> <html>
> <head><title>Hello $name</title></head>
> <body><p>hello $name</p> </body>
> if ($name) {
>     print $result;
> }
> else {
>     print <DATA>;
> }
> # see perldoc perldata for __DATA__ file handle info
> __DATA__
> Content-Type: text/html; charset=ISO-8859-1
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
> <html>
> <head>
> <title>simple form</title>
> </head>
> <body>
> <form action="/cgi-bin/foo.pl" method="get">
> <p>Name:<input type="text" name="first_name"></input></p>
> <p><input type="submit"></input></p>
> </form>
> </body>
> </html>
> #########
> On Tue, 30 Dec 2003, Chris Wagner wrote:
>> I can tell you some stuff about that right now.  CGI.pm is just a quick and
>> dirty module that will save on some typing in your perl script.  Emphasis on
>> some.  If you're doing anything more than basic html tags it quickly becomes
>> not worth it anymore.  Writing tag attributes takes up more time and space
>> than just writing out the html itself.  The one thing it's really good for
>> is writing out tables.  If you have an array with all your row data you can
>> write something like print Tr( td(\@array) ).  That saves a lot of typing.
>> The perldoc has most of the gritty details.
>> Cascading Style Sheets.  Deprecated.  I have seen so many bad uses of style
>> sheets it makes me want to cry out in anger.  So just don't use them unless
>> there's no other way to do it.  They are almost guaranteed to cause
>> compatibility problems.  The problem is that some bonehead writes a style
>> sheet that makes a webpage look good on *their* computer.  To hell with
>> everybody else who doesn't have the same monitor, resolution, fonts,
>> browser, etc.  The one thing they are "good" for is making themes but be
>> careful that it's still ledgible on other machines.  I have them turned off
>> in my browser.
>> At 10:50 PM 12/29/03 -0600, Michael D Schleif wrote:
>> >Please, somebody point me to URL's that provide examples and best
>> >practices of using CSS2, CGI.pm and XHTML v1.x.
>> >
>> >--
>> >Best Regards,
>> --
>> REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
>> "...ne cede males"
>> 00000100
> --
> To UNSUBSCRIBE, email to debian-isp-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

The man who sets out to carry a cat by its tail learns something that will always be useful
and which never will grow dim or doubtful.
                -- Mark Twain

Reply to: