How about this CGI-script solution to embed REBOL into HTML ?

Installation:
Put the cgi script anywhere from where you can run cgi-scripts

Usage:
http://the.server.you.are.using/script-location/rebol.cgi/full-path-to/test.rhtml

In the .rhtml file, you can give some parameters to the cgi script:
<SCRIPT language="REBOL" rebolbin="/beta/rebol/rebol" temppath="/tmp">

where "rebolbin" is the full path to the REBOL executable (default is
"rebol", which the should be located in the same directory as the rebol.cgi
script)

and "temppath" is where the temporary rebol script should be stored when
running it.

/PeO


> Carlos wrote:
> > The documentation of REBOL says that REBOL can be embedded into other
> types of text including HTML files.
> 
> > I'm trying to make the following work out but have no success because
> I see nothing printed on the browser. Do I have to first put REBOL to
> run on local machine? Do I have to address REBOL somewhere else on the
> HTML document or what?.
> > Need some help, please.
> 
>       Unfortunately, REBOL doesn't run on browsers yet. No "plug-in" (needed
> to run languages the browser maker hasn't thought to include) has been
> announced by the REBOL crew, yet.
> 
> Of course, this doesn't help you much.
> 
>       An alternative is use a local web server, written in REBOL (there's
> some on http://www.rebol.org), and write REBOL software to generate
> HTML so that the browser can understand it.
> 
> Andrew Martin
> [EMAIL PROTECTED]
> http://members.xoom.com/AndrewMartin/
> Online @ 33,600 Baud!
> -><-
> 
> 
#!/usr/local/bin/perl

$rebolhtml_file = $ENV{'PATH_TRANSLATED'};

print "Content-type: text/html", "\n\n";

if ($rebolhtml_file =~ /\.\./ || $rebolhtml_file !~ /$.rhtml/)
{
  print "You have entered illegal characters in the filename.", "\n";
  print "Please check your specification and try again.", "\n";
}
else
{
  if (open (FILE, "<" . $rebolhtml_file))
  {
    $inscript = 0;
    while (<FILE>)
    {
      if (/\s*<SCRIPT\s+language=\"REBOL\".*>/i)
      {
        $temppath = ".";
        if (/\s*temppath=\"(\S*)\".*>/i)
        {
          $temppath = $1;
        }
        $tempscript = "$temppath/$$" . time();

        $rebolbin = "rebol";
        if (/\s*rebolbin=\"(\S*)\".*/i)
        {
          $rebolbin = $1;
        }
        $inscript = 1;
        if (! open (SCRIPT, ">" . $tempscript))
        {
          print "Could not open $tempscript for writing<BR>\n";
        }
        next;
      }

      elsif (/\s*<\/SCRIPT>/i)
      {
        $inscript = 0;
        close (SCRIPT);
        $rebolresult = `$rebolbin -c -q $tempscript`;
        print $rebolresult;
        unlink($tempscript);
        next;
      }

      if ($inscript == 1)
      {
        print SCRIPT unless (/\s*<!--$/ || /\s*\/\/-->/);
      }
      else
      {
        print;
      }
    }

    close (FILE);
  }
  else
  {
    print "Could not open the specified file ($rebolhtml_file).", "\n";
  }
}

exit (0);
<HTML><HEAD><TITLE>REBOL test from within HTML</TITLE></HEAD>
<BODY BGCOLOR="white">
<H2>some REBOL code</H2>

<SCRIPT language="REBOL"  rebolbin="/beta/rebol/rebol" temppath="/tmp"   >
<!--
REBOL []
print "This output is the result from the first REBOL script...<BR>"
print now
//-->
</SCRIPT>

<H2>some more REBOL code</H2>

<SCRIPT language="REBOL"  temppath="/tmp" rebolbin="/beta/rebol/rebol">
<!--
REBOL []
print "...and this comes from the second script within the test.rhtml file...<BR>"
print now
//-->
</SCRIPT>

</BODY>
</HTML>

Reply via email to