1. Euphoria as Apache Module

Rob, what would it take and why wouldn't you make this possible?

I've come to a circumstance where I want a link to appear conditional on some
variable. How would you (or anybody else) handle this? In PHP (as an example),
you could do something like

<?
   if(test,"HTML code","")
?>

(That might not be syntactically correct, but it's semantically correct.)

That code is embedded in the HTML. With Euphoria, you can't do that (yet).
So I'd either have to program the entire page (no thanks!), or...?

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » topic index » view message » categorize

2. Re: Euphoria as Apache Module

On Mon, 08 Aug 2005 14:59:50 -0700, cklester <guest at RapidEuphoria.com>
wrote:

>Rob, what would it take and why wouldn't you make this possible?
>
>I've come to a circumstance where I want a link to appear conditional on some
>variable. How would you (or anybody else) handle this? In PHP (as an example),
>you could do something like
>
><?
>   if(test,"HTML code","")
>?>
>
>(That might not be syntactically correct, but it's semantically correct.)
>
>That code is embedded in the HTML. With Euphoria, you can't do that (yet).
>So I'd either have to program the entire page (no thanks!), or...?
>
Can you explain what that means? Are you asking why PHP (etc) do not
support embedded Euphoria code, or why Euphoria does not support
embedded PHP (etc) code, or what?

I once got ?Peter Blue?'s webserver to execute Eu code on demand, but
that was hand-coded in, not dynamic. If I know a little more about
what you are really after (OK, a conditionally appearing link, but
details, details) then I can look that up for you if you want.

Pete

new topic     » goto parent     » topic index » view message » categorize

3. Re: Euphoria as Apache Module

cklester wrote:
> Rob, what would it take and why wouldn't you make this possible?
> 
> I've come to a circumstance where I want a link to appear conditional on some
> variable. How would you (or anybody else) handle this? In PHP (as an example),
> you could do something like
> 
> <?
>    if(test,"HTML code","")
> ?>
> 
> (That might not be syntactically correct, but it's semantically correct.)
> 
> That code is embedded in the HTML. With Euphoria, you can't do that (yet).
> So I'd either have to program the entire page (no thanks!), or...?

I think I know what you mean.
I've run into that myself.
You have a big chunk or maybe a whole large page of HTML to
output, but with a bit of variable stuff mixed in.
It gets a bit tiresome to have to say:
   puts(1, " blah blah blah ... \n")
   puts(1, " yada yada yada ... \n")
   etc.

You'd like to put a large multi-line literal string into your program
without having to add quotes, new-lines, brackets etc. 
everywhere. i.e. just:
 blah blah blah ... 
 yada yada yada ... 

Normally Euphoria limits strings to one line (though you can
use & to get around that).

I guess we could invent some new syntax for that situation.
I'm open to suggestion. I don't think it would be hard to implement.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

4. Re: Euphoria as Apache Module

cklester wrote:
> Rob, what would it take and why wouldn't you make this possible?
> 
> I've come to a circumstance where I want a link to appear conditional on some
> variable. How would you (or anybody else) handle this? In PHP (as an example),
> you could do something like
> 
> <?
>    if(test,"HTML code","")
> ?>
> 
> (That might not be syntactically correct, but it's semantically correct.)
> 
> That code is embedded in the HTML. With Euphoria, you can't do that (yet).
> So I'd either have to program the entire page (no thanks!), or...?

If you didn't want to embed the HTML in the Euphoria program,
you could have the Euphoria program read the HTML, 
look for a special marker, and replace it. 
It would be a kind of preprocessor, just as Apache/PHP is
a preprocessor for the file before it's sent to the Web browser.

You wouldn't (easily) be able to embed general Euphoria statements 
into the HTML, but you probably just need a simple way 
of choosing "link" or "no link".

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

5. Re: Euphoria as Apache Module

As far as I know, the PHP interpreter replaces any text *not* between
<? ?> with echo %that text%;
Additionally, where a <?= exists, the interpreter outputs the value of
the expression following the '=' sign.
That is,
<? function sayHello() { return "hello world"; } ?>
<html><body>
<? echo "hello world"; ?><br>
<?=sayHello()?>
</body></html>

Is identical to:
<?
function sayHello() { return "hello world"; }
echo "\n<html><body>\n";
echo "hello world";
echo "<br>\n";
echo sayHello();
echo "\n</body></html>";
?>

I would recommend following the PHP system of escaping code from
inline text, as it's used for a few other languages as well, and
everyone's familiar with it.

The main point is - this feature is accomplishable with a
preprocessor... So perhaps an 'apache version' of Euphoria should
behave this way? To be a standard interpreter, with an official
pre-processor attached to it to achieve the above behaviour. The files
containing inline html like the PHP above would not be compatible with
normal code, so perhaps a different extension should be used, and the
apache Euphoria could interpret them accordingly.

On 8/9/05, Robert Craig <guest at rapideuphoria.com> wrote:
>
>
> posted by: Robert Craig <rds at RapidEuphoria.com>
>
> cklester wrote:
> > Rob, what would it take and why wouldn't you make this possible?
> >
> > I've come to a circumstance where I want a link to appear conditional o=
n some
> > variable. How would you (or anybody else) handle this? In PHP (as an ex=
ample),
> > you could do something like
> >
> > <?
> >    if(test,"HTML code","")
> > ?>
> >
> > (That might not be syntactically correct, but it's semantically correct=
.)
> >
> > That code is embedded in the HTML. With Euphoria, you can't do that (ye=
t).
> > So I'd either have to program the entire page (no thanks!), or...?
>
> I think I know what you mean.
> I've run into that myself.
> You have a big chunk or maybe a whole large page of HTML to
> output, but with a bit of variable stuff mixed in.
> It gets a bit tiresome to have to say:
>    puts(1, " blah blah blah ... \n")
>    puts(1, " yada yada yada ... \n")
>    etc.
>
> You'd like to put a large multi-line literal string into your program
> without having to add quotes, new-lines, brackets etc.
> everywhere. i.e. just:
>  blah blah blah ...
>  yada yada yada ...
>
> Normally Euphoria limits strings to one line (though you can
> use & to get around that).
>
> I guess we could invent some new syntax for that situation.
> I'm open to suggestion. I don't think it would be hard to implement.
>
> Regards,
>    Rob Craig
>    Rapid Deployment Software
>    http://www.RapidEuphoria.com
>
>
>
>
>


--
MrTrick
----------

new topic     » goto parent     » topic index » view message » categorize

6. Re: Euphoria as Apache Module

On 8/9/05, Patrick Barnes <mrtrick at gmail.com> wrote:
> The main point is - this feature is accomplishable with a
> preprocessor... So perhaps an 'apache version' of Euphoria should
> behave this way? To be a standard interpreter, with an official
> pre-processor attached to it to achieve the above behaviour. The files
> containing inline html like the PHP above would not be compatible with
> normal code, so perhaps a different extension should be used, and the
> apache Euphoria could interpret them accordingly.

One last thing, is that users are being told constantly to be careful
about programs on the 'net that might try and take over their
computer. I have seen in a few places a url
http://somesite.com/index.exe <-- the program that outputs html is in
fact a windows executable. I'd be very wary of that sort of thing, and
problem is; ex, exu, exw are all similar enough that it may throw
people off. If a new extension were to be made for euphoria-embedded
html files, perhaps something like "ehtml", or "eml" would be a good
idea? A euphoria apache module can be made to automatically recognise
these extensions and execute them properly, so none of the problems
with headers and MIME-types would arise, and no shebang is needed.

>
> On 8/9/05, Robert Craig <guest at rapideuphoria.com> wrote:
> >
> >
> > posted by: Robert Craig <rds at RapidEuphoria.com>
> >
> > cklester wrote:
> > > Rob, what would it take and why wouldn't you make this possible?
> > >
> > > I've come to a circumstance where I want a link to appear conditional=
 on some
> > > variable. How would you (or anybody else) handle this? In PHP (as an =
example),
> > > you could do something like
> > >
> > > <?
> > >    if(test,"HTML code","")
> > > ?>
> > >
> > > (That might not be syntactically correct, but it's semantically corre=
ct.)
> > >
> > > That code is embedded in the HTML. With Euphoria, you can't do that (=
yet).
> > > So I'd either have to program the entire page (no thanks!), or...?
> >
> > I think I know what you mean.
> > I've run into that myself.
> > You have a big chunk or maybe a whole large page of HTML to
> > output, but with a bit of variable stuff mixed in.
> > It gets a bit tiresome to have to say:
> >    puts(1, " blah blah blah ... \n")
> >    puts(1, " yada yada yada ... \n")
> >    etc.
> >
> > You'd like to put a large multi-line literal string into your program
> > without having to add quotes, new-lines, brackets etc.
> > everywhere. i.e. just:
> >  blah blah blah ...
> >  yada yada yada ...
> >
> > Normally Euphoria limits strings to one line (though you can
> > use & to get around that).
> >
> > I guess we could invent some new syntax for that situation.
> > I'm open to suggestion. I don't think it would be hard to implement.
> >
> > Regards,
> >    Rob Craig
> >    Rapid Deployment Software
> >    http://www.RapidEuphoria.com
> >
> >
>
>
> --
> MrTrick
> ----------
>
>


--
MrTrick
----------

new topic     » goto parent     » topic index » view message » categorize

7. Re: Euphoria as Apache Module

Robert Craig wrote:
> 
> cklester wrote:
> > 
> > I've come to a circumstance where I want a link to appear conditional on
> > some
> > variable. How would you (or anybody else) handle this? In PHP (as an
> > example),
> > you could do something like
> > 
> > <?
> >    if(test,"HTML code","")
> > ?>
> > 
> > (That might not be syntactically correct, but it's semantically correct.)
> > 
> > That code is embedded in the HTML. With Euphoria, you can't do that (yet).
> > So I'd either have to program the entire page (no thanks!), or...?
> 
> I think I know what you mean.
> I've run into that myself.
> You have a big chunk or maybe a whole large page of HTML to
> output, but with a bit of variable stuff mixed in.
> It gets a bit tiresome to have to say:
>    puts(1, " blah blah blah ... \n")
>    puts(1, " yada yada yada ... \n")
>    etc.
> 
> You'd like to put a large multi-line literal string into your program
> without having to add quotes, new-lines, brackets etc. 
> everywhere. i.e. just:
>  blah blah blah ... 
>  yada yada yada ...

Well, PHP can be embedded in an HTML file, like so:

(I'm using square brackets 'cuz I don't know if the lt/gt will mess things up.)

[html]
[body]

[p]This is HTML.[/p]
[? this is where PHP would go and it would be preprocessed before being sent to
output?]
[/body]
[/html]

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

8. Re: Euphoria as Apache Module

Pete Lomax wrote:
> On Mon, 08 Aug 2005 14:59:50 -0700, cklester <guest at RapidEuphoria.com>
> wrote:
> >I've come to a circumstance where I want a link to appear conditional on some
> >variable. How would you (or anybody else) handle this? In PHP (as an
> >example),
> >you could do something like
> >
> ><?
> >   if(test,"HTML code","")
> >?>
> >
> >(That might not be syntactically correct, but it's semantically correct.)
> >
> >That code is embedded in the HTML. With Euphoria, you can't do that (yet).
> >So I'd either have to program the entire page (no thanks!), or...?
> >
> Can you explain what that means? Are you asking why PHP (etc) do not
> support embedded Euphoria code, or why Euphoria does not support
> embedded PHP (etc) code, or what?

No, I'm asking why can't we embed Euphoria code into HTML so the Apache
server can preprocess it with the Euphoria interpreter, just like there
is a PHP module that Apache preprocesses with the PHP module.

Sample PHP/HTML:

<html>
<body>
<?php
  // Hello World in PHP
  echo 'Hello World!';
?>
</body>
</html>

That would create a page that simply says "Hello World!"

I'd like something like this:

<html>
<body>
<eu
   -- this part the Apache server passes to the Eu interpreter
   -- so it can be processed...
   puts(1,"Hello, world!")
eu>
</body>
</html>

Is that clear?

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

9. Re: Euphoria as Apache Module

Robert Craig wrote:
> cklester wrote:
> > I've come to a circumstance where I want a link to appear conditional on
> > some
> > variable. How would you (or anybody else) handle this? In PHP (as an
> > example),
> > you could do something like
> 
> If you didn't want to embed the HTML in the Euphoria program,
> you could have the Euphoria program read the HTML, 
> look for a special marker, and replace it. 

Rob, that's exactly what I do right now. But I want to stop doing that
because it seems to be getting more complicated in certain cases.

> You wouldn't (easily) be able to embed general Euphoria statements 
> into the HTML, but you probably just need a simple way 
> of choosing "link" or "no link".

I'm setting up database management stuff and it might be easier if I could
do the inline... I'm still doing a study and might come up with something
clever, but I wanted to put it out for discussion.

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

10. Re: Euphoria as Apache Module

Patrick Barnes wrote:
> 
> <? function sayHello() { return "hello world"; } ?>
> <html><body>
> <? echo "hello world"; ?><br>
> <?=sayHello()?>
> </body></html>
> 
> Is identical to:
> <?
> function sayHello() { return "hello world"; }
> echo "\n<html><body>\n";
> echo "hello world";
> echo "<br>\n";
> echo sayHello();
> echo "\n</body></html>";
> ?>

But you don't have to do that. You can just do this:

<html>
<body>
  <?
    $hw="hellow world";
    echo $hw;
  ?>
</body>
</html>

The code is embedded into an HTML file.

> The main point is - this feature is accomplishable with a
> preprocessor... So perhaps an 'apache version' of Euphoria should
> behave this way?

Yes, I'd love to have a Euphoria Apache module... I've made do without
one thus far (the many web sites I've got up and running are all being
served with Euphoria and some have EDS in the background)... but I'm
getting into more complicated database stuff and it *might* be more useful
to have the Euphoria code embedded.

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

11. Re: Euphoria as Apache Module

Patrick Barnes wrote:

> fact a windows executable. I'd be very wary of that sort of thing, and
> problem is; ex, exu, exw are all similar enough that it may throw
> people off.

I use "esp" (Euphoria served pages). :)

See http://www.cklester.com/euphoria/index.esp

> If a new extension were to be made for euphoria-embedded
> html files, perhaps something like "ehtml", or "eml" would be a good
> idea?

With Euphoria embedded, you could use the same html extension you've always
used (I think)...  although now that I think about it, I see files with the
"php" extension all the time.

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

12. Re: Euphoria as Apache Module

cklester wrote:
r.com/euphoria/index.esp">http://www.cklester.com/euphoria/index.esp</a>
> 
> > If a new extension were to be made for euphoria-embedded
> > html files, perhaps something like "ehtml", or "eml" would be a good
> > idea?
> 
> With Euphoria embedded, you could use the same html extension you've always
> used (I think)...  although now that I think about it, I see files with the
> "php" extension all the time.
> 
You can use mod_rewrite to hide or change the extension to whatever you want. 
You don't even need any extension.

For example, this site:

http://www.smartasscookie.com

100% of the pages are dynamically generated by Euphoria, but none of the URLs
show any extension at all...

new topic     » goto parent     » topic index » view message » categorize

13. Re: Euphoria as Apache Module

On 8/9/05, cklester <guest at rapideuphoria.com> wrote:
> Patrick Barnes wrote:
> >
> > <? function sayHello() { return "hello world"; } ?>
> > <html><body>
> > <? echo "hello world"; ?><br>
> > <?=sayHello()?>
> > </body></html>
> >
> > Is identical to:
> > <?
> > function sayHello() { return "hello world"; }
> > echo "\n<html><body>\n";
> > echo "hello world";
> > echo "<br>\n";
> > echo sayHello();
> > echo "\n</body></html>";
> > ?>
>
> But you don't have to do that. You can just do this:
>
> <html>
> <body>
>   <?
>     $hw="hellow world";
>     echo $hw;
>   ?>
> </body>
> </html>

Huh? My example was showing two different ways of embedding inline php
code into the HTML markup. Your code is indirectly the same as the
first example...

--
MrTrick
----------

new topic     » goto parent     » topic index » view message » categorize

14. Re: Euphoria as Apache Module

CK, you once asked me (here or at UBoard) why I created 'Kanarie Template
System',
and how it works. Well, this is one situation where you could use KTS.

You make a template with HTML-code and Kanarie-tags, and you make a simple
Euphoria-application to read and process that template.

Here's an example of how it works:

template.knr:
<html>
<head><title>{title}</title></head>
<body>
<div id='navigation'>{$nav.inc}</div>
{*
   the content of the file nav.inc is inserted above,
   this block of comments is stripped off when generating HTML.
 *}
<h1>{title}</h1>
<p>{content}</p>
</body>
</html>

page.ex:
include kanarie.e

-- 1. Load the template
sequence template
template = loadTemplate("template.knr")

-- 2. Assemble the data
integer data
data = createData()
setValue(data, "title", "The title of the page")
setValue(data, "content", "The content of the page")

-- 3. Generate the HTML from the template and the data
sequence html
html = generate(data, template)


This is just a simple example, but KTS has a lot more options.
There are list tags (for repeating a block multiple times), conditional
tags, include-tags (for including entire files), etc.

You can also use 1 data-component with different templates (to create
different outputs of 1 set of data) or reuse a template in multiple
applications.

You can download it from http://users.telenet.be/tommycarlier/eu
It has some examples, and documentation. The only thing that's missing
is a 'Powered by Kanarie'-image blink

--
The Internet combines the excitement of typing 
with the reliability of anonymous hearsay.

tommy online: http://users.telenet.be/tommycarlier
tommy.blog: http://tommycarlier.blogspot.com

new topic     » goto parent     » topic index » view message » categorize

15. Re: Euphoria as Apache Module

Andy Serpa wrote:
> 
> 
> For example, this site:
> 
> <a href="http://www.smartasscookie.com">http://www.smartasscookie.com</a>
> 
> 100% of the pages are dynamically generated by Euphoria, but none of the URLs
> show
> any extension at all...

Andy, is that a site you put together? Nice! :)

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

16. Re: Euphoria as Apache Module

Patrick Barnes wrote:
> 
> On 8/9/05, cklester <guest at rapideuphoria.com> wrote:
> > Patrick Barnes wrote:
> > >
> > > <? function sayHello() { return "hello world"; } ?>
> > > <html><body>
> > > <? echo "hello world"; ?><br>
> > > <?=sayHello()?>
> > > </body></html>
> > >
> > > Is identical to:
> > > <?
> > > function sayHello() { return "hello world"; }
> > > echo "\n<html><body>\n";
> > > echo "hello world";
> > > echo "<br>\n";
> > > echo sayHello();
> > > echo "\n</body></html>";
> > > ?>
> >
> > But you don't have to do that. You can just do this:
> >
> > <html>
> > <body>
> >   <?
> >     $hw="hellow world";
> >     echo $hw;
> >   ?>
> > </body>
> > </html>
> 
> Huh? My example was showing two different ways of embedding inline php
> code into the HTML markup. Your code is indirectly the same as the
> first example...

I was just showing that you don't have to define a function and then call
the function... you can just put straight PHP into the HTML.

-=ck
"Programming in a state of EUPHORIA."
http://www.cklester.com/euphoria/

new topic     » goto parent     » topic index » view message » categorize

17. Re: Euphoria as Apache Module

cklester wrote:
> 
> Andy Serpa wrote:
> > 
> > 
> > For example, this site:
> > 
> > <a href="http://www.smartasscookie.com">http://www.smartasscookie.com</a>
> > 
> > 100% of the pages are dynamically generated by Euphoria, but none of the
> > URLs show
> > any extension at all...
> 
> Andy, is that a site you put together? Nice! :)
> 
Yes it is, thank you.  I should also mention that the pages are generated via a
template system using Kanarie.

For that project I created an EDS database server which stays running 24/7 with
an persistently open handle to the product database.  So when someone requests a
page, the Euphoria script that generates the page connects to the server and the
server accesses the database.  This model eliminates any possible locking
problems when the database is being updated and also speeds things up because the
database just stays open all the time with indexes loaded for fast access...

new topic     » goto parent     » topic index » view message » categorize

18. Re: Euphoria as Apache Module

It should be noted that Bach allowed this with the following syntax:

    #" This is an out string"

Defined a string that was output to stdout when the code executed

   $(cmd)

Defined code embedded in a string.

So:
    sequence module = "Main"
    atom  version = 2.3

    ?"Module $(module)  Version: $(version + 2)"  -- show version in dos box
    #"Module $(module)  Version: $(version + 2)"  -- CGI output (stdout)

The #" string was multiline & embedded code was nestable  so:

    #"
    <b> HTML Code </b>
    $(if euflag == TRUE then
        #"Brought to you by Eu Version $(version)"
      else
       -- skip greeting)
      end if )
    ...
    "




A further refinement for speed freaks would be to implement the 'resident'
process. I'm not sure what this is in apache, but Xitami (an excellent
server by the way -- simple, very fast, small (kinda like Euphoria!))
calls this an LRWP, for 'Long Running Web Process'.
The idea is that the CGI program remains running, rather than being started
and stopped each time the server encounters a bit of CGI code.

Karl
www.catexa.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu