Bundler
Ceramic applications can be compiled to native executables. This is done through the bundler, which compiles the app and its resources and external dependencies into a bundle. On Windows, the bundle is just a .zip file. On Unix, it's a tar file. The reason for this is that everyone on Windows can open a zip file, and zip files don't preserve executable permissions, which are rather important on Unix.
A bundle looks like this:
my-app.zip/
my-app ;; Executable
electron/
... ;; The Electron code required to manage browser windows
resources/
... ;; Application resources
API
bundle
(system-name &key bundle-pathname system-directory)
Resources
Every web application has external resources -- web assets like CSS and JavaScript. And most non-trivial applications also keep data (game maps, CAD files, etc.) in external files. In development, this data is usually stored along with the source code. When releasing an application, that data has to be bundled and released along with it.
Ceramic has tools for managing directories with resources: You map a symbol,
like web-assets
or game-data
to some directory relative to the
application (e.g. assets/build/
). You access that directory using a function
that maps the symbol to a directory: in development, it just returns the
pathname to the original directory. When you release an app, all the resources
are copied over to the release, and the function returns the path the copied
resource directory in the release.
For instance, assuming an application named my-app
:
(use-package :ceramic.resource)
(define-resources :my-app () ;; Name of the system
(web-assets #p"assets/build/")
(landsat-images #p"data/landsat/")
(icons #p"assets/icons/"))
Then, to access the direcotry for the web assets, you use the
resource-directory
function:
;;; In development
(resource-directory 'web-assets)
;; => /home/eudoxia/code/my-app/assets/build/
;;; In production
(resource-directory 'web-assets)
;; my-app/resources/web-assets/
To easily create a pathname relative to a resource directory, you have the
resource
function:
;;; In development
(resource 'web-assets #p"css/style.css")
;; => /home/eudoxia/code/my-app/assets/build/css/style.css
;;; In production
(resource 'web-assets #p"css/style.css")
;; my-app/resources/web-assets/css/style.css
API
define-resources
(system-name nil &rest pairs)
resource-directory
(resource-tag)
resource
(resource-tag pathname)