From: Alberto Santini
Subject: Quick (or quasi-quick) start for a UnCommon Web (and Lisp) newbie...
Date: 
Message-ID: <1130842329.075195.126570@g14g2000cwa.googlegroups.com>
-*- outline -*-

* Quick (or quasi-quick) start for a UnCommon Web (and Lisp) newbie
* (release 0.1 - 01-Nov-2005)

** Abstract

This document describes how to configure a new application in the
UnCommon Web framework, using portableaserve as web server backend.
This document is NOT an introduction to Lisp language and is NOT a
tutorial to UnCommon Web.

** Introduction

The author of UnCommon Web (UCW) is Marco Baringer.
The homepage of UCW is http://common-lisp.net/project/ucw/.

You can download UCW from ftp://ftp.common-lisp.net/pub/project/ucw.

There are two movies (sic!) about Slime and UCW:

    http://common-lisp.net/torrents/slime.torrent (~150Mb/~60mins)
    http://common-lisp.net/torrents/hello-world.torrent (~50Mb/~20mins)

You need a Lisp implementation and an interface development
environment.
I use OpenMCL 1.0, GNU Emacs 22.0.50.1 and Slime 1.2.1 on Mac OS X with
Tiger 10.4.2.

    OpenMCL         http://openmcl.clozure.com/
    Emacs Official  http://www.gnu.org/software/emacs/emacs.html
    Emacs for Mac   http://bluebeard.org/software/emacs_osx/
    Slime           http://common-lisp.net/project/slime/

Please, before to start the UCW adventure, you have to have a Lisp
environment working: I mean, when you are in Emacs, pressing 'M-x
slime', it displays the REPL (Read Eval Prompt Loop) window. A good
introduction about Slime and Emacs is the Baringer's movie.

** Installation

I installed UCW in the directory ~/My/Dev/Lisp/ucw_0.3.9, unzipping the
compressed file, but, of course, you can install UCW where you want. I
will name that directory as UCW_HOME.

** Read the README

First, read the README in UCW_HOME directory.

You can find some dependencies: asdf, slime, arnesi, iterate, rfc2388,
yaclml, a web server backend (allegroserve, portableaserve, araneida,
apache).

Another System Definition Facility (asdf) is included in OpenMCL. For
instance, you can try (require 'asdf) to verify the existence.

Is Slime configured, isn't? Remember to download it by CVS, because the
snapshot doesn't contain the 'swank.asd' file, needed in the UCW
configuration.

arnesi and yaclml are included in UCW, see UCW_HOME/libs directory.

Download iterate, rfc2388 and a web server backend. I use the
portableaserve web server.

** Download the libraries

- iterate        http://common-lisp.net/project/iterate/releases/
- portableaserve http://sourceforge.net/projects/portableaserve/
- rfc2388        ftp://common-lisp.net/pub/project/rfc2388/

I unzipped those library in UCW_HOME/libs. So the skyline of the
UCW_HOME/libs directory is:

drwxr-xr-x   10 albertos  albertos  340 May  9 19:34 arnesi
-rw-r--r--    1 albertos  albertos  133 May  9 19:33 config
drwxr-xr-x   16 albertos  albertos  544 Oct 29 23:52 iterate_1.4
drwxr-xr-x   17 albertos  albertos  578 Oct 29 15:05 portableaserve
drwxr-xr-x    8 albertos  albertos  272 Oct 29 23:52 rfc2388
drwxr-xr-x   10 albertos  albertos  340 May  9 19:34 yaclml

** Configure UCW server

Before to start the UCW server we have to configure the file
'start.lisp' in the directory UCW_HOME/bin. Why? You have to inform UCW
where the dependencies are and what kind of web server backend we are
using.

[CUT]
;;;; * UCW server initialization "script"
(require 'asdf)
(push #p"UCW_HOME/systems/" asdf:*central-registry*)
[CUT]
;;;; 2) Choose and setup a backend

;(use-httpd-backend)
;(use-mod-lisp-backend)
(use-aserve-backend)
;(use-araneida-backend)
[CUT]

Note the path added to the *central-registry*: please, remember to
modify UCW_HOME with the path of your UCW installation.
Now we can add in UCW_HOME/systems all the links to the library
downloaded.

In UCW_HOME/systems there are arnesi, ucw, and yaclml links. You have
to
add the others with the command 'ln -s dest link'. For instance, if you
are in UCW_HOME/systems directory:

    ln -s ../libs/portableaserve/aserve/aserve.asd aserve.asd

In the UCW_HOME/systems directory you create the links:

    acl-compat.asd -> ../libs/portableaserve/acl-compat/acl-compat.asd
    arnesi.asd -> ../libs/arnesi/arnesi.asd
    aserve.asd -> ../libs/portableaserve/aserve/aserve.asd
    cl-ppcre.asd -> ../libs/portableaserve/libs/cl-ppcre/cl-ppcre.asd
    htmlgen.asd -> ../libs/portableaserve/aserve/htmlgen/htmlgen.asd
    iterate.asd -> ../libs/iterate_1.4/iterate.asd
    puri.asd -> ../libs/portableaserve/libs/puri-1.3.1/puri.asd
    rfc2388.asd -> ../libs/rfc2388/rfc2388.asd
    swank.asd -> /Users/albertosantini/.emacs.d/slime/swank.asd
    ucw.asd -> ../ucw.asd
    yaclml.asd -> ../libs/yaclml/yaclml.asd

** Start UCW server

Now you can start the UCW server from the directory UCW_HOME with the
command:

    ~/My/Apps/ccl/dppccl -l bin/start.lisp

'dppccl' is the command line REPL of OpenMCL. Verify if there is a
variable CCL_DEFAULT_DIRECTORY set to ~/My/Apps/ccl directory, the
installation directory of OpenMCL. You can set that variable in
~/.profile. You can use the 'openmcl' script in ~/My/Apps/ccl/scripts
directory. If you start UCW server from a shell inside Emacs, you have
to set again the environment variable CCL_DEFAULT_DIRECTORY:

    (setenv "CCL_DEFAULT_DIRECTORY"
"/Users/albertosantini/My/Apps/ccl")

Please remember to modify the path of CCL_DEFAULT_DIRECTORY.

** Test UCW server

The server is started and you see the welcome message of OpenMCL.

To test the UCW server you use the url

  http://localhost:8000/ucw/examples/index.ucw

where the examples application is deployed. The port 8000 is the
default
port for the portableaserve web server backend.

If the server is up and running you can see the UCW Examples page with
the counter, component transaction, form demo, presentations,
etc. examples.

** Write Hello application

Now you can write a new (and simple) application, the classical Hello
World. Put the next code in a file hello.lisp and save it in
UCW_HOME/examples.

-------- cut --------
(in-package :it.bese.ucw-user)

(defvar *hello-world*
  (make-instance 'cookie-session-application :url-prefix "/hello/"))

(register-application *default-server* *hello-world*)

(defentry-point "index.ucw" (:application *hello-world*) ()
  (loop
     (let ((name (call 'hello-world-home-page)))
       (call 'personalized-greeting :name name))))

(defcomponent hello-world-home-page (simple-window-component)
  ()
  (:default-initargs :title "Hello, World!"))

(defmethod render-on ((res response) (hello hello-world-home-page))
  (<:p "Hello, World!")
  (let ((name ""))
    (<ucw:form
     :action (ok hello name)
     (<ucw:input :type "text" :accessor name)
     (<:submit))))

(defcomponent personalized-greeting (simple-window-component)
  ((name :accessor name :initarg :name))
  (:default-initargs :title "Greetings!"))

(defmethod render-on ((res response) (greeting personalized-greeting))
  (<:p "Hi, " (<:as-html (name greeting)) ", how are you?")
  (<ucw:a :action (ok greeting) "Done."))
-------- cut --------

** Configure Hello application

In the UCW_HOME directory there is the file 'ucw.asd' containing the
default application setup. I added the line

  (:file "hello" :depends-on ("examples")) ; new component

[CUT]
(defsystem :ucw.examples
    :components ((:module :examples
		  :components ((:file "examples")
			       (:file "counter" :depends-on ("examples"))
			       (:file "hello" :depends-on ("examples"))
                               (:file "forms" :depends-on ("examples"))
			       (:file "presentations" :depends-on ("examples"))
			       (:file "sum" :depends-on ("examples")))))
[CUT]

Of course, it would be better to create another .asd file and to add it
to the *central-registry* path. This is a quick solution. :)

Quit UCW server and restart. Now UCW server load the Hello application,
from the UCW_HOME/examples directory, reading 'hello.lisp' file.

** Test Hello application

To test the Hello application you go to the url

    http://localhost:8000/hello/index.ucw

and the "Hello, World!" is there, I hope.

** Conclusions

Of course, this document is not exaustive about the UCW
configuration. The audience target is the people with very little
experience of Lisp, downloading for the first time UCW and asking
"Well,
and now?". UCW is a wonderful framework.

** Getting help

You can get help on IRC too. You can use ERC, an IRC implementation for
Emacs. You can download at the url

    http://sourceforge.net/projects/erc/

And you can find help at the url

    http://www.emacswiki.org/cgi-bin/wiki/EmacsIRCClient

You can join to the channel #ucw or #lisp on irc.freenode.net server.

** Thanks

- Marco Baringer (UCW author)
- asbjxrn (#ucw)

** History

- 01-Nov-2005 rel. 0.1 initial release

** Disclaimer

;; THIS DOCUMENT IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR
;; A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
COPYRIGHT
;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL,
;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE,
;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY
;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE
;; OF THIS DOCUMENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

** About me

Alberto Santini, http://www.albertosantini.it/

From: Lars Brinkhoff
Subject: Re: Quick (or quasi-quick) start for a UnCommon Web (and Lisp) newbie...
Date: 
Message-ID: <85zmoo1ufp.fsf@junk.nocrew.org>
"Alberto Santini" <··············@gmail.com> writes:
> * Quick (or quasi-quick) start for a UnCommon Web (and Lisp) newbie
> * (release 0.1 - 01-Nov-2005)

Thanks for this.

While browsing your home page, I found what would seem to be a typo in
your CV web page at

  http://www.albertosantini.it/me/curvitae.html

"Mistery" should probably be "Mystery".
From: Surendra Singhi
Subject: Re: Quick (or quasi-quick) start for a UnCommon Web (and Lisp) newbie...
Date: 
Message-ID: <k6fr7fk8.fsf@netscape.net>
"Alberto Santini" <··············@gmail.com> writes:

> You are welcome.
>
> About the typo, I copied the title from the book:
>
>   "Entanglement: The Greatest Mistery in Physics"
>
> I verified again on the book and it seems correct.
> There is the type in the book too. :)
>
> But you are right: the Oxford Dictionary reports "mystery".
> I suppose it's a spelling matter between american and english language.

I don't know where and in what context you used the word 'mistery'.

But it has a different meaning from 'mystery' (and AFAIK mystery is spelled as
mystery all over the world UK, USA, AUS, SA, etc.).

http://dictionary.reference.com/search?q=mistery

-- 
Surendra Singhi
http://www.public.asu.edu/~sksinghi/index.html

,----
| WHY SHOULD WE SAVE TIGER?  	
| Ans: Saving the tiger means saving mankind..	
| 
| Help http://pudang.tripod.com/
| or https://secure.worldwildlife.org/forms/tiger_appeal_1.cfm
`----