Wednesday, October 28, 2009

Re: [BLUG] Any PHP devs on this list?

On Wed, 28 Oct 2009 21:10:50 -0400, Mark Krenz <mark@slugbug.org> wrote:

> On Thu, Oct 29, 2009 at 01:01:30AM GMT, Aaron W. Hsu
> [arcfide@sacrideo.us] said the following:
>> On Wed, 28 Oct 2009 20:41:33 -0400, Mark Krenz <mark@slugbug.org> wrote:
>>
>> > Aaron, what language do you usually code in?
>>
>> Scheme, for web and otherwise.
>>
>
> Whoa, really? That's cool. Can you show us some small sample web program
> written in scheme?

Well, For the simplest sites, I just write them in SXML and generate
static content. There's a script for doing that attached (make sure to set
your editor to two-space tab widths). For dynamic sites, I use mod_lisp +
SXML + Apache. You can see two current sites in development (they're not
fully complete) at:

http://www.usa1911.com
http://descot.sacrideo.us

The code for Descot is available publicly. Here's how an example one page
website might be made:

(let ()
(import (chezscheme)
(arcfide modlisp)
(oleg sxml-to-html))

(define (index-handler req)
(make-html-response
(with-output-to-string
(lambda ()
(write-html-doctype)
(sxml->html (compose-page))))))

(define (compose-page) ---)

(register-request-hanlder! (modlisp-subtree-matcher "/scm/index")
index-handler)
(start-modlisp-server 3000)

)

Where 'compose-page' would return some SXML. That's where you could say,
read in your header, footer, and other content in dynamically, or do
whatever other processing you wanted to do. You could also use the 'req'
to get information about the URL and other request information.

This is all based on the modlisp library that I have written. It's part of
the Arctic Repository, which is a collection of software libraries. For
now they work on Chez Scheme (one or two libraries need to be compiled
before they can be used in Petite Chez Scheme, but otherwise they all work
in Petite as well as in fully Chez, and I provide compiled versions for
some platforms).

You can check out more at <http://www.sacrideo.us>, where you can find the
archive (via Gopher [written in Scheme]), or the latest and greatest via
Monotone VCS.

I've also written some old blogging software that hasn't been moved from
MIT Scheme to the new mod-lisp library, which is called Slogger, and is
also available through the same places. Even older, there is a Magic v2
based calendaring software in Scheme48, but I don't know how much that
still works now or not.

Aaron W. Hsu

--
Of all tyrannies, a tyranny sincerely exercised for the good of its
victims may be the most oppressive. -- C. S. Lewis

No comments: