CGI with html

2007-09-06 Thread Olivier Regnier

Hi everyone,

I try to write CGI scripts but i have a problem on my screen.

Here is my CGI code
# 
#!/usr/bin/perl

use strict;
use warnings;

# MODULES
use CGI qw(:standard);

# VARIABLES
my $style = get_style();

# HTML PAGE
print header,
 start_html (
-title   = '403, Interdit',
-style   = {-code = $style },
 ),
 end_html;

# CSS style
sub get_style {
   my $content = body {\n
 . margin:150px;\n
 . padding:0px;\n
 . padding:0px;\n
 . 'font-family: tahoma, verdana, arial, helvetica;'. \n
 . font-size:80%;\n
 . color:#66;\n
 . }\n
 . #error {\n
 . margin:0 auto 0 auto;\n
 . padding:10px;\n
 . width:370px;\n
 . text-align:left;\n
 . font-size:8pt;\n
 . background-color:#EE;\n
 . }\n
 . #error h1 {\n
 . margin-top:5px;\n
 . margin-bottom:10px;\n
 . font-size:10pt;\n
 . color:#33;\n
 . }\n
 . #error a {\n
 . color:#DC298D;\n
 . }\n
 . #error a:hover {\n
 . color:#FF;\n
 . background-color:#DC298D;\n
 . text-decoration:none;\n
 . }\n;
 return $content;
 }
# 
and here is the result in html:
# 

!DOCTYPE html
PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
html xmlns=http://www.w3.org/1999/xhtml; lang=en-US xml:lang=en-US
head
title403, Interdit/title
style type=text/css
!--/* ![CDATA[ */
body {
margin:150px;
padding:0px;
padding:0px;
font-family: tahoma, verdana, arial, helvetica;
font-size:80%;
color:#66;
}
#error {
margin:0 auto 0 auto;
padding:10px;
width:370px;
text-align:left;
font-size:8pt;
background-color:#EE;
}
#error h1 {
margin-top:5px;
margin-bottom:10px;
font-size:10pt;
color:#33;
}
#error a {
color:#DC298D;
}
#error a:hover {
color:#FF;
background-color:#DC298D;
text-decoration:none;
}
/* ]] */--
/style
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /
/head
body
/body
/html
# 

I would like to have this dtd:
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN 
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
and this meta code, meta http-equiv=Content-Type content=text/html; 
charset=iso-8859-1 / is not at the good place. Logically he is before 
CSS style.


Can you help me please ? Sorry for my english.

Thank you in advance.

Olivier
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: CGI with html

2007-09-06 Thread cpghost
On Fri, 07 Sep 2007 01:33:15 +0200
Olivier Regnier [EMAIL PROTECTED] wrote:

 # MODULES
 use CGI qw(:standard);
 
 # HTML PAGE
 print header,
   start_html (
  -title   = '403, Interdit',
  -style   = {-code = $style },
   ),
   end_html;

[snip]

 # 
 and here is the result in html:
 # 
 
 !DOCTYPE html
   PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml; lang=en-US
 xml:lang=en-US head

[snip]

 I would like to have this dtd:
 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN 
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd;
 and this meta code, meta http-equiv=Content-Type
 content=text/html; charset=iso-8859-1 / is not at the good place.
 Logically he is before CSS style.
 
 Can you help me please ? Sorry for my english.

Uhhh... it's a long time since I've used CGI.pm. But if I remember
correctly, the DTD was hard-coded in CGI.pm itself, and output by
start_html(); but you could override it with a value of your own.

From /usr/local/lib/perl5/5.8.8/CGI.pm:
---

use constant XHTML_DTD = ['-//W3C//DTD XHTML 1.0 Transitional//EN',
  'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'];

...

(And further down)

...

#  Here are some globals that you might want to adjust 
sub initialize_globals {
# Set this to 1 to enable copious autoloader debugging messages
$AUTOLOAD_DEBUG = 0;

# Set this to 1 to generate XTML-compatible output
$XHTML = 1;

# Change this to the preferred DTD to print in start_html()
# or use default_dtd('text of DTD to use');
$DEFAULT_DTD = [ '-//W3C//DTD HTML 4.01 Transitional//EN',
 'http://www.w3.org/TR/html4/loose.dtd' ] ;

...

(scroll down again)

...

 Method: start_html
# Canned HTML header
#
# Parameters:
# $title - (optional) The title for this HTML document (-title)
# $author - (optional) e-mail address of the author (-author)
# $base - (optional) if set to true, will enter the BASE address of
this document #  for resolving relative references (-base) 
# $xbase - (optional) alternative base at some remote location (-xbase)
# $target - (optional) target window to load all links into (-target)
# $script - (option) Javascript code (-script)
# $no_script - (option) Javascript noscript tag (-noscript)
# $meta - (optional) Meta information tags
# $head - (optional) any other elements you'd like to incorporate into
the head tag #   (a scalar or array ref)
# $style - (optional) reference to an external style sheet
# @other - (optional) any other named parameters you'd like to
incorporate into #   the body tag.

'start_html' = 'END_OF_FUNC',
sub start_html {
my($self,@p) = self_or_default(@_);
my($title,$author,$base,$xbase,$script,$noscript,
$target,$meta,$head,$style,$dtd,$lang,$encoding,$declare_xml,@other)
= rearrange([TITLE,AUTHOR,BASE,XBASE,SCRIPT,NOSCRIPT,TARGET,
   META,HEAD,STYLE,DTD,LANG,ENCODING,DECLARE_XML],@p);

$self-element_id(0);
$self-element_tab(0);

$encoding = 'iso-8859-1' unless defined $encoding;

# Need to sort out the DTD before it's okay to call escapeHTML().
my(@result,$xml_dtd);
if ($dtd) {
if (defined(ref($dtd)) and (ref($dtd) eq 'ARRAY')) {
$dtd = $DEFAULT_DTD unless $dtd-[0] =~ m|^-//|;
} else {
$dtd = $DEFAULT_DTD unless $dtd =~ m|^-//|;
}
} else {
$dtd = $XHTML ? XHTML_DTD : $DEFAULT_DTD;
}

(etc. etc. etc...)

So you may want to change stuff in initialize_globals or use
default_dtd(your own DTD) or change the constant XHTML_DTD
itself, if nothing else works.

But are you sure that CGI.pm will generate *strict* XHTML
for you? They're setting the DTD to transitional for some
reason, I think.

Regarding the relative order in the header, try playing
with the parameters of start_html.

Good luck!

 Thank you in advance.
 
 Olivier

Regards,
-cpghost.

-- 
Cordula's Web. http://www.cordula.ws/
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: CGI with html

2007-09-06 Thread David Christensen
Olivier Regnier wrote:
 I try to write CGI scripts but i have a problem on my screen.

You might want to try looking/asking for help on the following newsgroup:

comp.infosystems.www.authoring.cgi


HTH,

David

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]