From fd0ddc55fa0ed1e037e4bf4645e4b9314f688e5e Mon Sep 17 00:00:00 2001 From: David Botton Date: Fri, 2 Sep 2022 17:53:38 -0400 Subject: [PATCH] builder in clogframe --- NATIVE.md | 11 ++++++++--- clogframe/make-builder | 1 + make-builder | 1 + make-exe | 1 - source/clog-helpers.lisp | 2 +- source/clog-system.lisp | 6 +++++- source/clog.lisp | 1 + tools/clog-builder-templates.lisp | 1 - tools/clog-builder.lisp | 15 ++++++++++++--- 9 files changed, 29 insertions(+), 10 deletions(-) create mode 100755 clogframe/make-builder create mode 100755 make-builder delete mode 100755 make-exe diff --git a/NATIVE.md b/NATIVE.md index d9ce79b..e8f774f 100644 --- a/NATIVE.md +++ b/NATIVE.md @@ -1,6 +1,6 @@ # Creating Native Applications with CLOG -Simple solution: +## The Simple solution: 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. @@ -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 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) -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) @@ -123,3 +127,4 @@ https://cordova.apache.org/ https://github.com/webview/webview +See clogframe for working external example \ No newline at end of file diff --git a/clogframe/make-builder b/clogframe/make-builder new file mode 100755 index 0000000..4feda27 --- /dev/null +++ b/clogframe/make-builder @@ -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)" diff --git a/make-builder b/make-builder new file mode 100755 index 0000000..5a26999 --- /dev/null +++ b/make-builder @@ -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)" diff --git a/make-exe b/make-exe deleted file mode 100755 index 833297e..0000000 --- a/make-exe +++ /dev/null @@ -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)" diff --git a/source/clog-helpers.lisp b/source/clog-helpers.lisp index 31462e2..c436a87 100644 --- a/source/clog-helpers.lisp +++ b/source/clog-helpers.lisp @@ -106,7 +106,7 @@ set (logging to browser console), " (clog-gui:clog-gui-initialize body)) (setf clog-user::*body* body)) :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.")) ;;;;;;;;;;;;;;;;;;;;;;; diff --git a/source/clog-system.lisp b/source/clog-system.lisp index d8857a3..e99a1d6 100644 --- a/source/clog-system.lisp +++ b/source/clog-system.lisp @@ -28,6 +28,9 @@ the same as the clog directy this overides the relative paths used in them.") (defvar *extended-routing* nil "If true extended routing is done.") +(defparameter *clog-port* 8080 + "Port this instance of clog was started on") + ;;;;;;;;;;;;;;;; ;; initialize ;; ;;;;;;;;;;;;;;;; @@ -111,6 +114,7 @@ example." (set-on-new-window on-new-window-handler :path "/" :boot-file boot-file)) (unless *clog-running* (setf *clog-running* t) + (setf *clog-port* port) (setf *static-root* (truename (or *overide-static-root* static-root))) (apply #'clog-connection:initialize @@ -163,7 +167,7 @@ BOOT-FILE will be used. If BOOT-FILE is nil path is removed." ;; 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 for openning windows on remote machines." (handler-case diff --git a/source/clog.lisp b/source/clog.lisp index 79ea73b..74059e2 100644 --- a/source/clog.lisp +++ b/source/clog.lisp @@ -65,6 +65,7 @@ embedded in a native template application.)" "CLOG Startup and Shutdown" (initialize function) (*static-root* variable) + (*clog-port* variable) (set-on-new-window function) (is-running-p function) (shutdown function) diff --git a/tools/clog-builder-templates.lisp b/tools/clog-builder-templates.lisp index 2ccef7a..d2eddf6 100644 --- a/tools/clog-builder-templates.lisp +++ b/tools/clog-builder-templates.lisp @@ -41,4 +41,3 @@ (window-close (win panel)))))))) (t (window-close (win panel)))))))) - diff --git a/tools/clog-builder.lisp b/tools/clog-builder.lisp index e1a3941..a9cdcc9 100644 --- a/tools/clog-builder.lisp +++ b/tools/clog-builder.lisp @@ -1273,7 +1273,10 @@ of controls and double click to select control." (format nil ":boot-file \"~A\" " custom-boot) "")) :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))) (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 "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 "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 (lambda (obj) (declare (ignore obj)) @@ -2656,7 +2660,7 @@ of controls and double click to select control." clog-builder window.") (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 t, shutdown applicatoin on termination of first window. If APP eq :BATCH then 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-attach-builder-page :path "/builder-page") (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 (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))))