Handle static-root better.

This commit is contained in:
David Botton 2021-01-18 15:11:38 -05:00
parent 6adcb731f5
commit 9c7c112e22
3 changed files with 19 additions and 7 deletions

10
FAQ
View file

@ -1,4 +1,10 @@
Q) I start my application and I don't see anything? It worked before!
A) Did you start the application / emacs and slime in the directory of clog?
By default that is /common-lisp/clog?
A) If running a tutorial or demo:
Did you start the application / emacs and slime in the directory of clog?
By default that is /common-lisp/clog?
Or you can use (defparameter clog::*overide-static-root* #P"~/common-lisp/clog/static-files/")
to overide the static path in (clog:initialize)
If running your own app. Make sure the :static-file key is set correctly on (clog:initialize)

View file

@ -34,7 +34,8 @@
"Inititalize 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. If CLOG was already initialized and not shut
down, this function does the same as set-on-new-window."
down, this function does the same as set-on-new-window. If the variable
clog:*overide-static-root* is set STATIC-ROOT will be ignored."
(if *on-new-window*
(set-on-new-window on-new-window-handler)
(progn
@ -44,7 +45,9 @@ down, this function does the same as set-on-new-window."
:host host
:port port
:boot-file boot-file
:static-root static-root))))
:static-root (if (boundp '*overide-static-root*)
*overide-static-root*
static-root)))))
;;;;;;;;;;;;;;;;;;;;;;;
;; set-on-new-window ;;

View file

@ -15,7 +15,6 @@
;; and added CLOG's boot.js script line. It was neccesary to add an id to the
;; form (id='form1') as the generator did not add one.
;;
;; - We tell clog to use the boot file "/tutorial/tut-11.html"
;; - We set a blank on-submit to overide the behavior in the bootstrap
;; buttons to submit the from HTML style.
;; - We are going to attach to the "Good Button" an on-click handler
@ -24,6 +23,10 @@
;; value for and query them
;; - We attach an on-click handler that resets the form to the
;; "Scary Button"
;;
;; - We go in the browser to the file
;; "http://127.0.0.1:8080/tutorial/tut-11.html"
(defpackage #:clog-user
(:use #:cl #:clog)
@ -68,5 +71,5 @@
(defun start-tutorial ()
"Start turtorial."
(initialize #'on-new-window :boot-file "/tutorial/tut-11.html")
(open-browser))
(initialize #'on-new-window)
(open-browser :url "http://127.0.0.1:8080/tutorial/tut-11.html"))