diff --git a/README.md b/README.md index a02ed36..4b3656a 100644 --- a/README.md +++ b/README.md @@ -171,11 +171,7 @@ Here is a sample CLOG app: (set-on-click hello-element ; Now we set a function to handle clicks (lambda (obj) ; In this case we use an anonymous function - (setf (color hello-element) "green"))) - - (run body))) ; Keep our thread alive until connection closes - ; and prevent garbage collection of our CLOG-Objects - ; until no longer needed. + (setf (color hello-element) "green")))))) ;; To see all the events one can set and the many properties and styles that ;; exist, refer to the CLOG manual or the file clog-element.lisp diff --git a/demos/03-demo.lisp b/demos/03-demo.lisp index 0c91b39..fc058d3 100644 --- a/demos/03-demo.lisp +++ b/demos/03-demo.lisp @@ -210,8 +210,7 @@ (set-on-before-unload (window body) (lambda(obj) (declare (ignore obj)) ;; return empty string to prevent nav off page - "")) - (run body)) + ""))) (defun start-demo () "Start demo." diff --git a/demos/04-demo.lisp b/demos/04-demo.lisp index 2d72d9a..44c087c 100644 --- a/demos/04-demo.lisp +++ b/demos/04-demo.lisp @@ -171,8 +171,7 @@ (clog-web-initialize body) (create-web-frame body app) (reset-menu app) - (route-content app "Home") - (run body))) + (route-content app "Home"))) (defun start-demo () "Start dynamic website demo." diff --git a/doc/clog-manual.html b/doc/clog-manual.html index 92e594e..cb189c6 100644 --- a/doc/clog-manual.html +++ b/doc/clog-manual.html @@ -4027,7 +4027,7 @@ CLOG-Builder. If not using builder use to connect:
[generic-function] DATABASE-CONNECTION CLOG-OBJ
+[generic-function] DATABASE-CONNECTION CLOG-DATABASE
Accessor to the database handle
[class] CLOG-ONE-ROW CLOG-ELEMENT
-Manipulate one row of a table.
Manipulate one row of a table at a time on panel.
+[generic-function] SET-ON-FETCH CLOG-ONE-ROW ON-FETCH-HANDLER
+ +Set the ON-FETCH-HANDLER for CLOG-ONE-ROW. If ON-FETCH-HANDLER
+is nil unbind the event. The on-fetch event is called after the row was fetched
+and stored in (last-fetch clog-one-row) or nil if no row was returned, and before
+data-load-plist is called that will use the value of (last-fetch clog-one-row).
+Calculated fields, transformations to field values, etc. can be done in on-fetch as
+new-row will block until on-fetch returns.
[generic-function] SET-MASTER-ONE-ROW CLOG-ONE-ROW MASTER-ONE-ROW SLOT-NAME
+ +Set CLOG-ONE-ROW to get-row setting a while-clause
+to follow slot-name of panel when MASTER-ONE-ROW calls next-row.
@@ -4047,15 +4071,18 @@ CLOG-Builder. If not using builder use to connect:
[generic-function] CREATE-ONE-ROW CLOG-OBJ &KEY CLOG-DATABASE HIDDEN CLASS HTML-ID AUTO-PLACE
-Create a new CLOG-One-Row element. A CLOG Database -must be a parent to CLOG-One-Row.
Create a new CLOG-One-Row element. If CLOG-OBJ is
+of type-of CLOG-DATABASE it is used as database source unless
+:CLOG-DATABASE is set.
[generic-function] CLOG-DATABASE CLOG-OBJ
+ +Access to the CLOG-DATABASE
@@ -4114,26 +4141,33 @@ must be a parent to CLOG-One-Row.
[generic-function] QUERY-ROW CLOG-OBJ PANEL SQL
+[generic-function] QUERY-ROW CLOG-ONE-ROW PANEL SQL
Ignore query related prperties and instead execute
SQL. row-id-name is required for updates. All PANEL items or custom
-rows on panel will be set using DATA-LOAD-PLIST.
DATA-LOAD-PLIST.
[generic-function] GET-ROW CLOG-OBJ PANEL
+[generic-function] GET-ROW CLOG-ONE-ROW PANEL
Get first row from a database table based on
-CLOG-OBJECT's table-name using where-clause and table-columns.
-row-id-name is required. All PANEL items or custom rows on panel will
+CLOG-ONE-ROW's table-name using where-clause and table-columns.
+row-id-name is required. All PANEL items or custom slots on panel will
be set using DATA-LOAD-PLIST.
[generic-function] NEXT-ROW CLOG-OBJ PANEL
+[generic-function] NEXT-ROW CLOG-ONE-ROW PANEL
Get next row from a database table based on query
-made for get-row. All PANEL items or custom rows on panel will be set
+made for get-row. All PANEL items or custom slots on panel will be set
using DATA-LOAD-PLIST.
[generic-function] INSERT-ROW CLOG-OBJ PANEL
+[generic-function] INSERT-ROW CLOG-ONE-ROW PANEL
Insert new row in to database table based on
-CLOG-OBJECT's table-name and table-columns. DATA-WRITE-PLIST is
-used to extract data from PANEL items and custom rows.
CLOG-ONE-ROW's table-name and table-columns. DATA-WRITE-PLIST is
+used to extract data from PANEL items and custom slots.
[generic-function] UPDATE-ROW CLOG-OBJ PANEL
+[generic-function] UPDATE-ROW CLOG-ONE-ROW PANEL
Update row in database table based on
-CLOG-OBJECT's table-name using current rowid and table-columns.
+CLOG-ONE-ROW's table-name using current rowid and table-columns.
row-id-name is required. All PANEL items or custom rows
on panel will be retrieved from PANEL using DATA-WRITE-PLIST.
PANEL using
[generic-function] CLEAR-ROW CLOG-OBJ PANEL
+[generic-function] CLEAR-ROW CLOG-ONE-ROW PANEL
Clear current rowid and all fields in PANEL
using DATA-WRITE-PLIST based on table-columns.
[generic-function] DELETE-ROW CLOG-OBJ
+[generic-function] DELETE-ROW CLOG-ONE-ROW PANEL
Delete a row from a database table based on -current rowid
CLEAR-ROW
+[class] CLOG-LOOKUP CLOG-ONE-ROW CLOG-SELECT
+ +CLOG Table Lookup Object
[generic-function] CREATE-LOOKUP CLOG-OBJ &KEY NAME MULTIPLE LABEL CLASS HTML-ID CLOG-DATABASE
+ +Create a new clog-lookup as child of CLOG-OBJ.
[class] CLOG-DB-TABLE CLOG-ONE-ROW CLOG-TABLE
+ +CLOG Database Table View Object
[generic-function] CREATE-DB-TABLE CLOG-OBJ &KEY CLOG-DATABASE HIDDEN CLASS HTML-ID AUTO-PLACE
+ +Create a new clog-db-table as child of CLOG-OBJ.
[generic-function] SET-ON-HEADER CLOG-DB-TABLE ON-HEADER-HANDLER
+ +Set the ON-HEADER-HANDLER for CLOG-DB-TABLE. If ON-HEADER-HANDLER
+is nil unbind the event. The on-header event is called before the first row is output
+after the table is cleared to all adding a header information to the table.
[generic-function] SET-ON-FOOTER CLOG-DB-TABLE ON-FOOTER-HANDLER
+ +Set the ON-FOOTER-HANDLER for CLOG-DB-TABLE. If ON-FOOTER-HANDLER
+is nil unbind the event. The on-footer event is called after all rows are output
+after the table is cleared for adding footer information to the table.
[generic-function] SET-ON-ROW CLOG-DB-TABLE ON-ROW-HANDLER
+ +Set the ON-ROW-HANDLER for CLOG-DB-TABLE. If ON-ROW-HANDLER
+is nil unbind the event. The on-row event is called for each row. The row handler
+is passed also the clog-table-row object before the columns are added in second parameter to
+handler.
[generic-function] SET-ON-COLUMN CLOG-DB-TABLE ON-COLUMN-HANDLER
+ +Set the ON-COLUMN-HANDLER for CLOG-DB-TABLE. If ON-COLUMN-HANDLER
+is nil unbind the event. The on-column event is called for each column as added to
+the current row being processsed. It is passed also the keyworld symbol name of
+the column and the clog-table-column object.
@@ -4992,7 +5122,7 @@ or CLOG Data-List objects.
[generic-function] ADD-SELECT-OPTION CLOG-SELECT VALUE CONTENT
+[generic-function] ADD-SELECT-OPTION CLOG-SELECT VALUE CONTENT &KEY SELECTED DISABLED
Add option VALUE to select.
CANCEL-TEXT is only displayed if m
[generic-function] RUN CLOG-BODY
-Keeps the connection thread alive to prevent garbage -collection of local objects when not using connection-data objects -or global objects.
Keeps a connection thread alive to allow post +user close of connection / browser.
diff --git a/source/clog-body.lisp b/source/clog-body.lisp index 981ba0d..37bdbec 100644 --- a/source/clog-body.lisp +++ b/source/clog-body.lisp @@ -47,15 +47,13 @@ ;;;;;;;;; (defgeneric run (clog-body) - (:documentation "Keeps the connection thread alive to prevent garbage -collection of local objects when not using connection-data objects -or global objects.")) - + (:documentation "Keeps a connection thread alive to allow post +user close of connection / browser.")) (defmethod run ((obj clog-body)) (loop - (if (validp obj) - (sleep 10) - (return)))) + (if (validp obj) + (sleep 10) + (return)))) ;;;;;;;;;;;;;;;;;;;;;;; ;; set-html-on-close ;; diff --git a/templates/projects/clog-gui/tmpl.lisp.lt b/templates/projects/clog-gui/tmpl.lisp.lt index 3bad8f2..e27cace 100644 --- a/templates/projects/clog-gui/tmpl.lisp.lt +++ b/templates/projects/clog-gui/tmpl.lisp.lt @@ -43,8 +43,7 @@ (help-item (create-gui-menu-drop-down menu-bar :content "Help")) (help-about (create-gui-menu-item help-item :content "About" :on-click 'on-help-about)) (full-screen (create-gui-menu-full-screen menu-bar))) - (declare (ignore icon-item file-new help-about full-screen)) - (run body)))) + (declare (ignore icon-item file-new help-about full-screen))))) (defun start-app () (initialize 'on-new-window diff --git a/templates/projects/clog-web/tmpl.lisp.lt b/templates/projects/clog-web/tmpl.lisp.lt index 2e29a7d..0bca3e2 100644 --- a/templates/projects/clog-web/tmpl.lisp.lt +++ b/templates/projects/clog-web/tmpl.lisp.lt @@ -11,8 +11,7 @@ ;; and vertically our div on the screen. (let* ((layout (create-panel-box-layout body))) (center-children (center-panel layout)) - (create-div (center-panel layout) :content "Hello") - (run body))) + (create-div (center-panel layout) :content "Hello"))) (defun start-app () (initialize 'on-new-window diff --git a/templates/projects/clog/tmpl.lisp.lt b/templates/projects/clog/tmpl.lisp.lt index 746f0a5..a799acc 100644 --- a/templates/projects/clog/tmpl.lisp.lt +++ b/templates/projects/clog/tmpl.lisp.lt @@ -9,8 +9,7 @@ ;; and vertically our div on the screen. (let* ((layout (create-panel-box-layout body))) (center-children (center-panel layout)) - (create-div (center-panel layout) :content "Hello") - (run body))) + (create-div (center-panel layout) :content "Hello"))) (defun start-app () (initialize 'on-new-window diff --git a/tools/clog-builder.lisp b/tools/clog-builder.lisp index 0414df1..10ec753 100644 --- a/tools/clog-builder.lisp +++ b/tools/clog-builder.lisp @@ -1518,8 +1518,7 @@ of controls and double click to select control." (set-on-before-unload (window body) (lambda(obj) (declare (ignore obj)) ;; return empty string to prevent nav off page - "")) - (run body))) + "")))) (defun clog-builder (&key static-root) "Start clog-builder." diff --git a/tutorial/01-tutorial.lisp b/tutorial/01-tutorial.lisp index 562d87a..1f15815 100644 --- a/tutorial/01-tutorial.lisp +++ b/tutorial/01-tutorial.lisp @@ -24,12 +24,8 @@ (set-on-click hello-element ; Now we set a function to handle clicks (lambda (obj) ; In this case we use an anonymous function (declare (ignore obj)) - (setf (color hello-element) :green))) + (setf (color hello-element) :green))))) - (run body))) ; Keep our thread alive until connection closes - ; and prevent garbage collection of our CLOG-Objects - ; until no longer needed. - ;;; To see all the events one can set and the many properties and styles that ;;; exist, take a look through the CLOG manual or the file clog-element.lisp diff --git a/tutorial/02-tutorial.lisp b/tutorial/02-tutorial.lisp index 39dd6c9..db69665 100644 --- a/tutorial/02-tutorial.lisp +++ b/tutorial/02-tutorial.lisp @@ -33,8 +33,7 @@ (dotimes (n x) (create-child body (format nil "
Clicked ~A times.
" x)) - (scroll-to (window body) 0 (height body)))))) - (run body))) + (scroll-to (window body) 0 (height body)))))))) (defun start-tutorial () "Start turtorial." diff --git a/tutorial/03-tutorial.lisp b/tutorial/03-tutorial.lisp index e7e4cc7..22f5009 100644 --- a/tutorial/03-tutorial.lisp +++ b/tutorial/03-tutorial.lisp @@ -19,8 +19,7 @@ (dotimes (n y) (create-p body :content (format nil "Clicked ~A times." y)) - (sleep y)))))) ;) - (run body))) + (sleep y)))))))) ;) ;;; 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_. diff --git a/tutorial/04-tutorial.lisp b/tutorial/04-tutorial.lisp index 7f57c82..bbe012d 100644 --- a/tutorial/04-tutorial.lisp +++ b/tutorial/04-tutorial.lisp @@ -14,8 +14,7 @@ (set-on-click (create-section body :h1 :content "Hello World! (click me!)") 'my-on-click) (set-on-click (create-section body :h3 :content "Click me too!") - 'my-on-click) - (run body)) + 'my-on-click)) (defun start-tutorial () "Start turtorial." diff --git a/tutorial/05-tutorial.lisp b/tutorial/05-tutorial.lisp index 0f552ed..08c351f 100644 --- a/tutorial/05-tutorial.lisp +++ b/tutorial/05-tutorial.lisp @@ -17,8 +17,7 @@ (set-on-click (create-section body :h1 :content "Hello World! (click me!)") 'my-on-click) (setf (connection-data-item body "changer") - (create-section body :h1 :content "I change")) - (run body)) + (create-section body :h1 :content "I change"))) (defun start-tutorial () "Start turtorial." diff --git a/tutorial/06-tutorial.lisp b/tutorial/06-tutorial.lisp index 6ba26e5..7adc752 100644 --- a/tutorial/06-tutorial.lisp +++ b/tutorial/06-tutorial.lisp @@ -28,8 +28,7 @@ "On-new-window handler." (setf (title (html-document body)) "Tutorial 6") (set-on-click (create-section body :h1 :content "(click me to start!)") - 'my-on-click) - (run body)) + 'my-on-click)) (defun start-tutorial () "Start turtorial." diff --git a/tutorial/07-tutorial.lisp b/tutorial/07-tutorial.lisp index b4b9100..765704d 100644 --- a/tutorial/07-tutorial.lisp +++ b/tutorial/07-tutorial.lisp @@ -75,8 +75,6 @@ (sleep .02)))) (error (c) (format t "Lost connection.~%~%~A" c)))) -;;; There is no reason to run (run body) here as we check for (validp body) -;;; and once the connection dies so does the on-new-window thread. (defun start-tutorial () "Start turtorial." diff --git a/tutorial/08-tutorial.lisp b/tutorial/08-tutorial.lisp index 96d6bfc..b409d34 100644 --- a/tutorial/08-tutorial.lisp +++ b/tutorial/08-tutorial.lisp @@ -93,8 +93,7 @@ (set-on-mouse-down div2 'on-mouse-down) (setf (positioning div3) :absolute) (set-on-touch-start div3 'on-mouse-down) - (set-on-mouse-down div3 'on-mouse-down) - (run body))) + (set-on-mouse-down div3 'on-mouse-down))) (defun start-tutorial () "Start turtorial." diff --git a/tutorial/09-tutorial.lisp b/tutorial/09-tutorial.lisp index 31fa697..684602b 100644 --- a/tutorial/09-tutorial.lisp +++ b/tutorial/09-tutorial.lisp @@ -153,8 +153,7 @@ (select-tab p2))) (set-on-click t3 (lambda (obj) (setf last-tab obj) - (select-tab p3)))) - (run body))) + (select-tab p3)))))) (defun start-tutorial () "Start turtorial." diff --git a/tutorial/10-tutorial.lisp b/tutorial/10-tutorial.lisp index 764193f..fa46a83 100644 --- a/tutorial/10-tutorial.lisp +++ b/tutorial/10-tutorial.lisp @@ -19,8 +19,7 @@ (begin-path cx) (ellipse cx 200 200 50 7 0.78 0 6.29) (path-stroke cx) - (path-fill cx) - (run body))) + (path-fill cx))) (defun start-tutorial () "Start turtorial." diff --git a/tutorial/11-tutorial.lisp b/tutorial/11-tutorial.lisp index 730865b..7ce63e5 100644 --- a/tutorial/11-tutorial.lisp +++ b/tutorial/11-tutorial.lisp @@ -67,8 +67,7 @@ ;; We need to override the boostrap default to submit the form html style (set-on-submit form (lambda (obj)(declare (ignore obj))())) (set-on-click good-button 'on-click-good) - (set-on-click scary-button 'on-click-scary)) - (run body))) + (set-on-click scary-button 'on-click-scary)))) (defun start-tutorial () "Start tutorial." diff --git a/tutorial/12-tutorial.lisp b/tutorial/12-tutorial.lisp index 886d6e2..cc4582b 100644 --- a/tutorial/12-tutorial.lisp +++ b/tutorial/12-tutorial.lisp @@ -39,25 +39,21 @@