Restart easier and tutorial

This commit is contained in:
David Botton 2021-01-05 19:10:06 -05:00
parent 347e5c2723
commit 75f1d78209
2 changed files with 39 additions and 7 deletions

View file

@ -33,14 +33,18 @@
(static-root #P"./static-files/"))
"Inititalze CLOG on a socket using HOST and PORT to serve BOOT-FILE as
the default route to establish web-socket connections and static files
located at STATIC-ROOT."
(setf *on-new-window* on-new-window-handler)
located at STATIC-ROOT. If CLOG was already initialized and not shut
down, this function does the same as set-on-new-window."
(if *on-new-window*
(set-on-new-window on-new-window-handler)
(progn
(set-on-new-window on-new-window-handler)
(cc:initialize #'on-connect
:host host
:port port
:boot-file boot-file
:static-root static-root))
:static-root static-root))))
;;;;;;;;;;;;;;;;;;;;;;;
;; set-on-new-window ;;
@ -56,4 +60,5 @@ located at STATIC-ROOT."
(defun shutdown ()
"Shutdown CLOG."
(set-on-new-window nil)
(cc:shutdown-clog))

27
tutorial/01-tutorial.lisp Normal file
View file

@ -0,0 +1,27 @@
(defpackage #:clog-user ; Setup a package for our work to exist in
(:use #:cl #:clog) ; Use the Common Lisp language and CLOG
(:export start-tutorial)) ; Export as public the start-tutorial function
(in-package :clog-user) ; Tell the "reader" we are in the clog-user package
;; Define our CLOG application
(defun on-new-window (win) ; define a function to be called
(create-child win "<h1>Hello World!<h1>"))
(defun start-tutorial () ; Define the function called start-tutorial
"Start turtorial." ; Optional docstring to describe function
;; Initialize the CLOG system
(initialize #'on-new-window)
;; Set the function on-new-window to execute
;; everytime a browser connection to our app.
;; #' tells common lisp to pass the function
;; to intialize and not to execute it.
;; Open a browser to http://12.0.0.1:8080 - the default for CLOG apps
(open-browser))