diff --git a/tutorial/03-tutorial.lisp b/tutorial/03-tutorial.lisp new file mode 100644 index 0000000..d9e01ad --- /dev/null +++ b/tutorial/03-tutorial.lisp @@ -0,0 +1,33 @@ +(defpackage #:clog-user + (:use #:cl #:clog) + (:export start-tutorial)) + +(in-package :clog-user) + +(defun on-new-window (body) + "On-new-window handler." + + (setf (title (html-document body)) "Tutorial 2") + + (let ((hello-element + (create-child body "
Clicked ~A times.
" x)) + (sleep x))))))) + +;; Running this version of the last tutorial and clicking quickly on the (click me!) +;; will demonstrate an important aspect of CLOG, events can happen in _parallel_. +;; This means that appropriate precautions to thread protect data should be taken +;; and that events do not wait for previous event handlers to complete. + +(defun start-tutorial () + "Start turtorial." + + (initialize #'on-new-window) + (open-browser)) diff --git a/tutorial/README.md b/tutorial/README.md new file mode 100644 index 0000000..ef3c082 --- /dev/null +++ b/tutorial/README.md @@ -0,0 +1,39 @@ +To run a tutorial, start emacs/slime or your CL Lisp in the common-lisp/clog directory: + +``` +CL-USER> (ql:quickload :clog) +To load "clog": + Load 1 ASDF system: + clog +; Loading "clog" +........................... +(:CLOG) +``` + +Load the demo: + +``` +CL-USER> (load "/Users/dbotton/common-lisp/clog/tutorial/01-tutorial.lisp") +#P"/Users/dbotton/common-lisp/clog/tutorial/01-tutorial.lisp" +``` + +Start the demo: + +``` +CL-USER> (clog-user:start-tutorial) +Hunchentoot server is started. +Listening on 0.0.0.0:8080. +HTTP listening on : 0.0.0.0:8080 +HTML Root : static-files/ +Boot file default : /boot.html +``` + +Most demos startup a browser, if not use http://127.0.0.1:8080 + + +Tutorial Summary + +01-tutorial.lisp - Hello World +02-tutorial.lisp - Closures in CLOG +03-tutorial.lisp - Events fire in parallel +