diff --git a/clog-docs.lisp b/clog-docs.lisp index 1fd859e..c390bc9 100644 --- a/clog-docs.lisp +++ b/clog-docs.lisp @@ -122,25 +122,29 @@ To load \"clog\": (:CLOG) ``` -Next, we need to use the INITIALIZE function to tell CLOG to start up the web -server, what to do when someone connects and where the static HTML files -are located. +Next, we tell clog to start a clog-repl: ```lisp -CL-USER> (clog:initialize (lambda (body)()) :static-root #P\"~/common-lisp/clog/static-files/\") +CL-USER> (clog:clog-repl) Hunchentoot server is started. Listening on 0.0.0.0:8080. HTTP listening on : 0.0.0.0:8080 -HTML Root : /Users/dbotton/common-lisp/clog/static-files/ -Boot file for path / : /boot.html +HTML Root : ~/common-lisp/clog/static-files/ +Boot file for path / : /debug.html + +Use clog-user:*body* to access the clog-repl window. NIL ``` -At this point our CLOG app does very little. To see our CLOG app so far go to -http://127.0.0.1:8008 or in most common-list configurations you can use: +At this point CLOG should open a browser window to + http://127.0.0.1:8008/repl + +We can new enter the clog-user package and hack a way. ```lisp -CL-USER> (clog:open-browser) +CL-USER> (in-package clog-user) +#<\"CLOG-USER\" package> +CLOG-USER> (setf (background-color *body*) :red) ``` Something more than an empty lambda function is needed to do more. The @@ -148,18 +152,6 @@ tutorials are a good place to start with make CLOG apps in code, so here we are going to demonstrate the concepts using some REPL tricks to help developing CLOG apps in general. -We need to give ourselves easier access to CLOG and or an app we are -working one. Let's create a package that uses CLOG and of course -common lisp \"cl\" we will call it \"clog-user\". - -```lisp -CL-USER> (defpackage #:clog-user - (:use #:cl #:clog)) -(in-package :clog-user) -#<\"CLOG-USER\" package> -CLOG-USER> -``` - Since we already initialized CLOG let's use SET-ON-NEW-WINDOW to change our on-new-window handler (handler is just a made up name for a function that will handle an event). @@ -168,23 +160,7 @@ will handle an event). CLOG-USER> (set-on-new-window (lambda (body) (create-div body :content \"Hello World!\"))) ``` -Now go ahead and resresh our browser and you should see the famous first words -of every app. - -This of though is still not very REPL like, CLOG is a 'live' connection to a -browser. So lets redo our on-new-window handler to give us access to the -browser in the REPL. - -```lisp -CLOG-USER> (defparameter *body* nil) -*BODY* -CLOG-USER> (set-on-new-window (lambda (body) (setf *body* body))) -``` - -Reset your browser again (or navigate to http://127.0.0.1:8080 and let's have -some fun. - -(From here on, we will leave out the promps and responses in our quotes of +(From here on, we will leave out the prompts and responses in our quotes of code.) ```lisp diff --git a/clog-helpers.lisp b/clog-helpers.lisp index 96a6826..9d6b23a 100644 --- a/clog-helpers.lisp +++ b/clog-helpers.lisp @@ -8,6 +8,11 @@ (cl:in-package :clog) +(defpackage #:clog-user + (:use #:cl #:clog)) + +(defvar clog-user::*body* nil "clog-repl access to body") + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - CLOG Utilities ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -71,6 +76,19 @@ (load p) (format t "~%~% ---- The demo src is located at: ~A~%" p))) +;;;;;;;;;;;;;;; +;; clog-repl ;; +;;;;;;;;;;;;;;; + +(defun clog-repl () + "Set a path /repl that opens a blank page and sets the global +clog-user:*body* to last window openned to /repl." + (unless *clog-running* + (initialize nil :boot-file "/debug.html")) + (set-on-new-window (lambda (body)(setf clog-user::*body* body)) + :path "/repl") + (open-browser :url "http://127.0.0.1:8080/repl") + (format t "Use clog-user:*body* to access the clog-repl window.")) ;;;;;;;;;;;;;;;; ;; load-world ;; diff --git a/clog.lisp b/clog.lisp index a3e3752..091c026 100644 --- a/clog.lisp +++ b/clog.lisp @@ -759,6 +759,7 @@ embedded in a native template application.)" (load-tutorial function) (run-demo function) (load-demo function) + (clog-repl function) "Functions for Compilation and Documentation" (load-world function) diff --git a/doc/clog-manual.html b/doc/clog-manual.html index f2e2b02..28c3e2e 100644 --- a/doc/clog-manual.html +++ b/doc/clog-manual.html @@ -175,59 +175,39 @@ To load "clog": ................................................ (:CLOG) -
Next, we need to use the INITIALIZE function to tell CLOG to start up the web
-server, what to do when someone connects and where the static HTML files
-are located.
Next, we tell clog to start a clog-repl:
-CL-USER> (clog:initialize (lambda (body)()) :static-root #P"~/common-lisp/clog/static-files/")
+CL-USER> (clog:clog-repl)
Hunchentoot server is started.
Listening on 0.0.0.0:8080.
HTTP listening on : 0.0.0.0:8080
-HTML Root : /Users/dbotton/common-lisp/clog/static-files/
-Boot file for path / : /boot.html
+HTML Root : ~/common-lisp/clog/static-files/
+Boot file for path / : /debug.html
+
+Use clog-user:*body* to access the clog-repl window.
NIL
-At this point our CLOG app does very little. To see our CLOG app so far go to
-http://127.0.0.1:8008 or in most common-list configurations you can use:
+At this point CLOG should open a browser window to
+ http://127.0.0.1:8008/repl
-CL-USER> (clog:open-browser)
+We can new enter the clog-user package and hack a way.
+
+CL-USER> (in-package clog-user)
+#<"CLOG-USER" package>
+CLOG-USER> (setf (background-color *body*) :red)
Something more than an empty lambda function is needed to do more. The
tutorials are a good place to start with make CLOG apps in code, so
here we are going to demonstrate the concepts using some REPL tricks
to help developing CLOG apps in general.
-We need to give ourselves easier access to CLOG and or an app we are
-working one. Let's create a package that uses CLOG and of course
-common lisp "cl" we will call it "clog-user".
-
-CL-USER> (defpackage #:clog-user
- (:use #:cl #:clog))
-(in-package :clog-user)
-#<"CLOG-USER" package>
-CLOG-USER>
-
Since we already initialized CLOG let's use SET-ON-NEW-WINDOW to change our
on-new-window handler (handler is just a made up name for a function that
will handle an event).
CLOG-USER> (set-on-new-window (lambda (body) (create-div body :content "Hello World!")))
-Now go ahead and resresh our browser and you should see the famous first words
-of every app.
-
-This of though is still not very REPL like, CLOG is a 'live' connection to a
-browser. So lets redo our on-new-window handler to give us access to the
-browser in the REPL.
-
-CLOG-USER> (defparameter *body* nil)
-*BODY*
-CLOG-USER> (set-on-new-window (lambda (body) (setf *body* body)))
-
-Reset your browser again (or navigate to http://127.0.0.1:8080 and let's have
-some fun.
-
-(From here on, we will leave out the promps and responses in our quotes of
+
(From here on, we will leave out the prompts and responses in our quotes of
code.)
(create-div *body* :content "Hello World")
@@ -357,13 +337,53 @@ function. If BOOT-FILE is nil path is removed.
Turn on browser console debugging for OBJ's connection.
+
+
+
+[function] OPEN-BROWSER &KEY (URL "http://127.0.0.1:8080")
+
+Open a web browser to URL.
+
+
5 CLOG Utilities
-CLOG utilities
+CLOG-Group - Utility Class for CLOG-Obj storage
+
+
+
+
+- [class] CLOG-GROUP
+
+
+
+
+
+[function] CREATE-GROUP
+
+Return a new CLOG-GROUP object for storing CLOG-OBJs. They are indexed by
+their HTML-ID.
+
+
+
+
+
+[generic-function] ADD CLOG-GROUP CLOG-OBJ &KEY NAME
+
+Add CLOG-OBJ to a CLOG-GROUP indexed by the html-id of
+CLOG-OBJ unless :NAME is set and is used instead.
+
+
+
+
+
+- [generic-function] OBJ CLOG-GROUP NAME
+
+
+CLOG JS utilities
@@ -397,14 +417,6 @@ function. If BOOT-FILE is nil path is removed.
Return "on" if VALUE t or return "off"
-
-
-
-[function] OPEN-BROWSER &KEY (URL "http://127.0.0.1:8080")
-
-Open a web browser to URL.
-
-
@@ -413,6 +425,8 @@ function. If BOOT-FILE is nil path is removed.
Escape STR for sending to browser script.
+CLOG Color utilities
+
@@ -4822,7 +4836,7 @@ on-storage event is fired for changes to :local storage keys.
-- [generic-function] BODY-ELEMENT OBJECT
+- [generic-function] BODY-ELEMENT SELF
@@ -5111,6 +5125,15 @@ on-storage event is fired for changes to :local storage keys.
Load demo NUM - use (clog-user:start-demo)
+
+
+
+[function] CLOG-REPL
+
+Set a path /repl that opens a blank page and sets the global
+clog-user:body to last window openned to /repl.
+
+
Functions for Compilation and Documentation