mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
2.1 KiB
2.1 KiB
Creating Native Applications with CLOG
- Open app using chrome in app mode
- Native app using :ceramic
1 Open app using chrome in app mode
To open a chrome window in app mode use -app="URL" for example to start the builder as an app:
On Mac:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome -app="http://127.0.0.1:8080/builder"
On Linux:
google-chrome-stable --new-window --app="http://127.0.0.1:8080/builder"
On WindowsL
chrome --new-window --app="http://127.0.0.1:8080/builder"
2 Using Ceramic Mac/Windows/Linux
The documentation for ceramic is at: http://ceramic.github.io/
- (ql:quickload :ceramic)
- (ceramic:setup)
Now that ceramic is installed. We create a new project using CLOG Builder:
- (ql:quickload :clog/tools)
- (clog-tools:clog-builder)
In CLOG Builder:
- Choose Builder->New Application Template
- Choose a template for your project - I will use CLOG-GUI
- Give the new project a name - I am using elect as the project name
- Choose the default directory ~/common-lisp or another that works for you
In the REPL let's load the new project:
- Let's open ~/common-lisp/elect/elect.asd
- Add to depends-on #:ceramic
- Let's open ~/common-lisp/elect/elect.lisp
- Replace start-app with:
(defvar *window* nil)
(defun start-app (&key (port 8080))
(ceramic:start)
(initialize 'on-new-window
:port port
:static-root (ceramic:resource-directory 'www))
(setf *window*
(ceramic:make-window :url (format nil "http://127.0.0.1:~D/" port)))
(ceramic:show *window*))
(ceramic:define-resources :elect ()
(www #p"www/"))
(ceramic:define-entry-point :elect ()
(start-app))
- We need to add to the botton of on-new-window code to shutdown app.
(clog:run body) ; wait while body is running
(ceramic:quit) ; quit ceramic/electron
(clog:shutdown) ; shutdown clog
- I suggest starting from scratch at this point: M-x slime-restart-inferior-lisp
- (ql:quickload :elect)
- (elect:start-app)
That should start up a native application with your CLOG app
To package you applicaton use:
- (ceramic:bundle :elect)