chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] News from the Barnyard


From: Kirill Lisovsky
Subject: Re: [Chicken-users] News from the Barnyard
Date: Thu, 12 Jun 2003 11:03:10 -0400 (EDT)

Hello!


On Thu, 12 Jun 2003, Felix Winkelmann wrote:

> I'm currently working on a (simple - hm... I'm using the
> word like an apology... ;-) web-server, that uses the
> HTTP extension. The performance is so-so, about twice as
> fast as the SUnet server (considering raw requests-per-second)
> but still no match for the PLT server. Anyway, it works and
> is quite easy to use. I have thought about a simple method
> of embedding scheme in HTML and now something a la PHP came
> out, so you would have, say,
>
> <html><head><title>Hello</title><head>
> <?scheme
> (printf "<h1>This is ~A, on ~A</h1>"
>    (http:request-url (spiffy:current-request))
>    (get-host-name) )
> ?>
> <body>
> </body>
> </html>
>
IMHO, SXML and quasiquote provide an elegant and Schemish solution:
`(html
     (head
       (title "Hello"))
     (body
       (h1 "I'm running on: " (i ,(get-host-name)))
       )))

It may be XSLT/SXSLT transformed, SXPath queried or just
serialized as HTML.
This very simple example, implemented on top of example web server
from Chicken distro, is available at:
http://pair.com/lisovsky/download/barnyard/

csi -case-sensitive web.scm

BTW: what's this spiffy current-request?

> So everything in "<?scheme ...?>" or "<?...?>" is taken
> verbatim and everything else is transformed into
> a chunk of code that outputs the raw HTML.
> When the page is first loaded (has a ".shp" extension) or
> when it changes, a translation is generated and
> interpreted via `load' to produce the HTTP response.
> Actually one could even compile the page to native code in the
> background.
>
An HTML (or better yet XHTML) page with <?scheme ... ?>
can be parsed from HTML above to SXML above using SSAX, but for some
(code extensive) pages SXML sources may be more reasonable than (X)HTML.
I've experienced this with XSLT stylesheets extended with Scheme.
And vice versa, for markup-extensive pages with a few code
(X)HTML is often preferable.

> If anybody is interested, I can put it on the web-site.
>
I'd like to look at it.

Best regards,
         Kirill.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]