builder in clogframe

This commit is contained in:
David Botton 2022-09-02 17:53:38 -04:00
parent 909e444b5f
commit fd0ddc55fa
9 changed files with 29 additions and 10 deletions

11
NATIVE.md vendored
View file

@ -1,6 +1,6 @@
# Creating Native Applications with CLOG # Creating Native Applications with CLOG
Simple solution: ## The Simple solution:
Common to all solutions is compiling you CLOG application to an executable. Common to all solutions is compiling you CLOG application to an executable.
See demos/make-snake and the source of the 01-demo.lisp file. See demos/make-snake and the source of the 01-demo.lisp file.
@ -8,11 +8,15 @@ See demos/make-snake and the source of the 01-demo.lisp file.
make-snake produces a native app that launches a browser. When snake game make-snake produces a native app that launches a browser. When snake game
exist the executable quits. exist the executable quits.
More advanced solutions: or better yet use CLOGFRAME - see clogframe/README.md and the built in
browser control on your OS.
## More advanced solutions:
1. Open app using chrome in app mode (not exactly native but looks it) 1. Open app using chrome in app mode (not exactly native but looks it)
2. Use MacGap on Mac (best native option for Mac) 2. Use MacGap on Mac
3. Native app using (ql:quickload :ceramic) (works well for Windows and Linux) 3. Native app using (ql:quickload :ceramic) (works well for Windows and Linux)
@ -123,3 +127,4 @@ https://cordova.apache.org/
https://github.com/webview/webview https://github.com/webview/webview
See clogframe for working external example

1
clogframe/make-builder vendored Executable file
View file

@ -0,0 +1 @@
sbcl --eval "(ql:quickload :clog/tools)" --eval "(sb-ext:save-lisp-and-die #P\"builder\" :toplevel (lambda () (clog-tools:clog-builder :port 0 :app t :start-browser nil :clogframe t)) :executable t :compression t)"

1
make-builder vendored Executable file
View file

@ -0,0 +1 @@
sbcl --eval "(ql:quickload :clog/tools)" --eval "(sb-ext:save-lisp-and-die #P\"builder\" :toplevel (lambda () (clog-tools:clog-builder :port 0 :app t :start-browser t)(loop (sleep 10))) :executable t :compression t)"

1
make-exe vendored
View file

@ -1 +0,0 @@
sbcl --eval "(ql:quickload :clog/tools)" --eval "(sb-ext:save-lisp-and-die #P\"./builder\" :toplevel (lambda () (clog-tools:clog-builder :port 0 :app t :start-browser t)(loop (sleep 10))) :executable t :compression t)"

View file

@ -106,7 +106,7 @@ set (logging to browser console), "
(clog-gui:clog-gui-initialize body)) (clog-gui:clog-gui-initialize body))
(setf clog-user::*body* body)) (setf clog-user::*body* body))
:path "/repl") :path "/repl")
(open-browser :url "http://127.0.0.1:8080/repl") (open-browser :url (format nil "http://127.0.0.1:~A/repl" *clog-port*))
(format t "Use clog-user:*body* to access the clog-repl window.")) (format t "Use clog-user:*body* to access the clog-repl window."))
;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -28,6 +28,9 @@ the same as the clog directy this overides the relative paths used in them.")
(defvar *extended-routing* nil (defvar *extended-routing* nil
"If true extended routing is done.") "If true extended routing is done.")
(defparameter *clog-port* 8080
"Port this instance of clog was started on")
;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;
;; initialize ;; ;; initialize ;;
;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;
@ -111,6 +114,7 @@ example."
(set-on-new-window on-new-window-handler :path "/" :boot-file boot-file)) (set-on-new-window on-new-window-handler :path "/" :boot-file boot-file))
(unless *clog-running* (unless *clog-running*
(setf *clog-running* t) (setf *clog-running* t)
(setf *clog-port* port)
(setf *static-root* (truename (or *overide-static-root* (setf *static-root* (truename (or *overide-static-root*
static-root))) static-root)))
(apply #'clog-connection:initialize (apply #'clog-connection:initialize
@ -163,7 +167,7 @@ BOOT-FILE will be used. If BOOT-FILE is nil path is removed."
;; open-browser ;; ;; open-browser ;;
;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;
(defun open-browser (&key (url "http://127.0.0.1:8080")) (defun open-browser (&key (url (format nil "http://127.0.0.1:~A" *clog-port*)))
"Launch on os a web browser on local machine to URL. See OPEN-WINDOW "Launch on os a web browser on local machine to URL. See OPEN-WINDOW
for openning windows on remote machines." for openning windows on remote machines."
(handler-case (handler-case

View file

@ -65,6 +65,7 @@ embedded in a native template application.)"
"CLOG Startup and Shutdown" "CLOG Startup and Shutdown"
(initialize function) (initialize function)
(*static-root* variable) (*static-root* variable)
(*clog-port* variable)
(set-on-new-window function) (set-on-new-window function)
(is-running-p function) (is-running-p function)
(shutdown function) (shutdown function)

View file

@ -41,4 +41,3 @@
(window-close (win panel)))))))) (window-close (win panel))))))))
(t (t
(window-close (win panel)))))))) (window-close (win panel))))))))

View file

@ -1273,7 +1273,10 @@ of controls and double click to select control."
(format nil ":boot-file \"~A\" " custom-boot) (format nil ":boot-file \"~A\" " custom-boot)
"")) ""))
:eval-in-package package))) :eval-in-package package)))
(open-window (window (connection-body obj)) "http://127.0.0.1:8080/test") (if *app-mode*
(open-browser :url (format nil "http://127.0.0.1:~A/test" *clog-port*))
(open-window (window (connection-body obj))
(format nil "http://127.0.0.1:~A/test" *clog-port*)))
(on-open-file obj :title-class "w3-yellow" :title "test eval" :text result))) (on-open-file obj :title-class "w3-yellow" :title "test eval" :text result)))
(defun on-show-control-properties-win (obj) (defun on-show-control-properties-win (obj)
@ -2599,7 +2602,8 @@ of controls and double click to select control."
(create-gui-menu-item tools :content "Thread Viewer" :on-click 'on-show-thread-viewer) (create-gui-menu-item tools :content "Thread Viewer" :on-click 'on-show-thread-viewer)
(create-gui-menu-item tools :content "CLOG Builder REPL" :on-click 'on-repl) (create-gui-menu-item tools :content "CLOG Builder REPL" :on-click 'on-repl)
(create-gui-menu-item tools :content "Copy/Cut History" :on-click 'on-show-copy-history-win) (create-gui-menu-item tools :content "Copy/Cut History" :on-click 'on-show-copy-history-win)
(create-gui-menu-item tools :content "Image to HTML Data" :on-click 'on-image-to-data) (unless *app-mode*
(create-gui-menu-item tools :content "Image to HTML Data" :on-click 'on-image-to-data))
(create-gui-menu-item tools :content "Launch DB Admin" :on-click (create-gui-menu-item tools :content "Launch DB Admin" :on-click
(lambda (obj) (lambda (obj)
(declare (ignore obj)) (declare (ignore obj))
@ -2656,7 +2660,7 @@ of controls and double click to select control."
clog-builder window.") clog-builder window.")
(defun clog-builder (&key (port 8080) (start-browser t) (defun clog-builder (&key (port 8080) (start-browser t)
app project static-root system) app project static-root system clogframe)
"Start clog-builder. When PORT is 0 choose a random port. When APP is "Start clog-builder. When PORT is 0 choose a random port. When APP is
t, shutdown applicatoin on termination of first window. If APP eq :BATCH then t, shutdown applicatoin on termination of first window. If APP eq :BATCH then
must specific default project :PROJECT and it will be batch rerendered must specific default project :PROJECT and it will be batch rerendered
@ -2679,6 +2683,11 @@ to use that asdf system's static root."
(set-on-new-window 'on-new-db-admin :path "/dbadmin") (set-on-new-window 'on-new-db-admin :path "/dbadmin")
(set-on-new-window 'on-attach-builder-page :path "/builder-page") (set-on-new-window 'on-attach-builder-page :path "/builder-page")
(set-on-new-window 'on-convert-image :path "/image-to-data") (set-on-new-window 'on-convert-image :path "/image-to-data")
(when clogframe
(uiop:run-program (list "./clogframe"
"CLOG Builder"
(format nil "~A/builder" port)
(format nil "~A" 1280) (format nil "~A" 840))))
(when start-browser (when start-browser
(format t "If browser does not start go to http://127.0.0.1:~A/builder" port) (format t "If browser does not start go to http://127.0.0.1:~A/builder" port)
(open-browser :url (format nil "http://127.0.0.1:~A/builder" port)))) (open-browser :url (format nil "http://127.0.0.1:~A/builder" port))))