[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ab)using class CGI as non-CGI HTML generator?

Josef 'Jupp' Schugt

3/5/2005 10:13:00 PM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

If not running as CGI, Ruby programs using class CGI expect name=value
pairs on standard input. Is there a way of suppressing this if one is
(ab)using CGI to generate HTML for other purposes than CGI scripts (like
generating HTML mails)?

Before you answer please consider not to start a discussion on HTML
mails. I know what I am doing. The program in question splits the
Freshmeat newsletter into single messages and presently outputs Plain
Text messages. It turned out that the usability of the messages can be
improved by using HTML as a means for formatting the message.

The program will not enforce a certain format but will provide the
choice between Plain Text, HTML only and multipart messages containing
both formats so that you can use what best fits your preferences and the
MUA(s) you use.

Josef 'Jupp' Schugt
- --
The EU commission tries to implement a software patent directive against
the express will of the parliament. That should be an issue to any EU
citizen - even if he or she has not the slightest interest in software.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail....

iD8DBQFCKiRPrhv7B2zGV08RAtM6AKDGYDpSzpED5gf9KzxI53eJLuIG4QCg57wU
mJd6huQiGEU1lXdZrb5bjVc=
=RNpu
-----END PGP SIGNATURE-----



3 Answers

Jim Weirich

3/5/2005 11:42:00 PM

0

On Saturday 05 March 2005 05:13 pm, Josef 'Jupp' Schugt wrote:
> If not running as CGI, Ruby programs using class CGI expect name=value
> pairs on standard input. Is there a way of suppressing this if one is
> (ab)using CGI to generate HTML for other purposes than CGI scripts (like
> generating HTML mails)?

You might consider using Builder::XmlMarkup for generating HTML.

http://builder.ruby...

--
-- Jim Weirich jim@weirichhouse.org http://onest...
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)


Bertram Scharpf

3/6/2005 11:22:00 AM

0

Hi,

Am Sonntag, 06. Mär 2005, 07:13:10 +0900 schrieb Josef 'Jupp' Schugt:
> If not running as CGI, Ruby programs using class CGI expect name=value
> pairs on standard input. Is there a way of suppressing this if one is
> (ab)using CGI to generate HTML for other purposes than CGI scripts (like
> generating HTML mails)?

First, I think CGI handling should be derived from HTML
generation, not vice versa.

Anyway, it should not actually be expensive to do somethig
between `puts "<h1>#{...}</h1>"' and reimplementing
CGI#element_init.

Using brute force you can try:

ENV['REQUEST_METHOD'] = 'GET'
c = CGI.new 'html4'

I wouldn't like doing that but maybe you don't mind.

Bertram


--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...


Lee Braiden

3/6/2005 11:34:00 AM

0

On Sunday 06 March 2005 11:21, Bertram Scharpf wrote:
> First, I think CGI handling should be derived from HTML
> generation, not vice versa.

Hmm... but CGI can generate lots of things besides HTML. PNGs and PDFs, for
instance. Perhaps you're thinking of HTTP?

--
Lee.