>From 701ac7028c8f412ade00aee8d9e890f329a3836b Mon Sep 17 00:00:00 2001 From: Neil Jerram
Date: Sun, 7 Mar 2010 22:01:53 +0000 Subject: [PATCH] modlisp wip --- source/modlisp.html | 12 ++ source/modlisp.scm | 32 +++++ source/ossau/template.scm | 211 ++++++++++++++++++++++++++++++ source/server-utils/answer.scm | 38 ++++-- source/server-utils/big-dishing-loop.scm | 32 ++++- source/server-utils/modlisp.scm | 55 ++++++++ source/www | 1 + 7 files changed, 366 insertions(+), 15 deletions(-) create mode 100644 source/modlisp.html create mode 100755 source/modlisp.scm create mode 100644 source/ossau/template.scm create mode 100644 source/server-utils/modlisp.scm create mode 120000 source/www diff --git a/source/modlisp.html b/source/modlisp.html new file mode 100644 index 0000000..cc02e96 --- /dev/null +++ b/source/modlisp.html @@ -0,0 +1,12 @@ + + +Header | Value |
---|---|
$~a (car header)$ | $~a (cdr header)$ |
+Posted data: $~a posted-data$. + + diff --git a/source/modlisp.scm b/source/modlisp.scm new file mode 100755 index 0000000..19a64fc --- /dev/null +++ b/source/modlisp.scm @@ -0,0 +1,32 @@ +#!/usr/bin/env guile +!# + +(set! %load-path (append %load-path '("."))) + +(use-modules (www server-utils big-dishing-loop) + (ossau template)) + +(define (modlisp-get-handler M upath headers) + (write `(upath ,upath)) + (newline) + (M #:use-modlisp-protocol!) + (M #:set-reply-status:success) + (M #:add-header #:Content-Type "text/html") + (M #:add-content (with-output-to-string + (lambda () + (process-template "modlisp.html" + (headers + (posted-data "(none)")) + (guile))))) + (M #:send-reply)) + +(define modlisp-loop + (make-big-dishing-loop #:need-headers #t + #:protocol #:modlisp + #:method-handlers `((GET . ,modlisp-get-handler) + (POST . ,modlisp-get-handler) + (HEAD . ,modlisp-get-handler)) + #:concurrency #:none + #:socket-setup `((,SO_REUSEADDR . 1)))) + +(modlisp-loop 3145) diff --git a/source/ossau/template.scm b/source/ossau/template.scm new file mode 100644 index 0000000..cc8294d --- /dev/null +++ b/source/ossau/template.scm @@ -0,0 +1,211 @@ +;;;; (ossau template) -- template file processor + +;;; Copyright (C) 2005 Neil Jerram +;;; +;; This library is free software; you can redistribute it and/or +;; modify it under the terms of the GNU Lesser General Public +;; License as published by the Free Software Foundation; either +;; version 2.1 of the License, or (at your option) any later version. +;; +;; This library is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser General Public +;; License along with this library; if not, write to the Free Software +;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +(define-module (ossau template) + #:use-module (ice-9 rdelim) + #:use-module (ice-9 regex) + #:export (template->code) + #:export-syntax (process-template)) + +;*****************************************************************************; +;* A template file is a file of content, such as HTML, that is complete *; +;* except for places where the content needs to be filled in *; +;* programmatically. In the case of the template processor code here, the *; +;* code to fill in the dynamic content is written in Scheme and appears *; +;* inline in the template file. *; +;* *; +;* Areas of Scheme code in the template file are delimited by $. For *; +;* example: *; +;* *; +;* This page was processed by Guile $(display (version))$ *; +;* *; +;* here (display (version)) is interpreted and processed as Scheme code; *; +;* the rest is normal (HTML) content. *; +;* *; +;* If either normal content or Scheme code needs to include a $ character, *; +;* it can do so by doubling the $, as in: Price $$10.20. *; +;* *; +;* Fragments of Scheme code do not have to be individually balanced. For *; +;* example: *; +;* *; +;* $(for-each (lambda (x)$ *; +;*