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

Discussion in 'Ruby' started by Josef 'Jupp' Schugt, Mar 5, 2005.

  1. -----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.mozdev.org

    iD8DBQFCKiRPrhv7B2zGV08RAtM6AKDGYDpSzpED5gf9KzxI53eJLuIG4QCg57wU
    mJd6huQiGEU1lXdZrb5bjVc=
    =RNpu
    -----END PGP SIGNATURE-----
    Josef 'Jupp' Schugt, Mar 5, 2005
    #1
    1. Advertising

  2. Josef 'Jupp' Schugt

    Jim Weirich Guest

    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.rubyforge.org/

    --
    -- Jim Weirich http://onestepback.org
    -----------------------------------------------------------------
    "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)
    Jim Weirich, Mar 5, 2005
    #2
    1. Advertising

  3. 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-scharpf.de
    Bertram Scharpf, Mar 6, 2005
    #3
  4. Josef 'Jupp' Schugt

    Lee Braiden Guest

    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.
    Lee Braiden, Mar 6, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin Maurer
    Replies:
    3
    Views:
    4,782
    Peter
    Apr 19, 2006
  2. TheDustbustr
    Replies:
    1
    Views:
    436
    Sami Hangaslammi
    Jul 25, 2003
  3. Replies:
    9
    Views:
    529
  4. Chris Withers

    Problems with email.Generator.Generator

    Chris Withers, Sep 11, 2006, in forum: Python
    Replies:
    20
    Views:
    1,671
    Max M
    Sep 12, 2006
  5. Terry Reedy

    Generator functions subclass generator?

    Terry Reedy, Jun 18, 2009, in forum: Python
    Replies:
    0
    Views:
    448
    Terry Reedy
    Jun 18, 2009
Loading...

Share This Page