9.7 Low-Level API
9.7.1 Collecting and Building
| (require camp/build) | package: camp-lib |
The camp/build module provides the two-pass build system for Camp sites.
procedure
(collect site) → site-info?
site : site?
Source documents are loaded in a way that picks up changes between calls within the same process: if a source file (or a module it depends on) has been modified since a previous collect, the new version is used. This is what makes rebuilds in the GUI app and raco camp serve reflect edits without restarting.
Changed in version 1.1 of package camp-lib: Parses the date and updated metas of every page (see page-link). A value that cannot be parsed, or an updated earlier than the date, raises an exception here, for pages in and out of feeds.
procedure
(collect/call-with-page site slug proc) → any
site : site? slug : string? proc : (-> document? context? any)
This is useful for rendering or processing a single page with full site context without performing a complete build!. The slug is matched case-insensitively. Raises an error if no page with the given slug exists.
(collect/call-with-page my-site "my-post" my-render-function)
procedure
site : site? info : site-info?
Returns a table of the static files that were fingerprinted by static-url during the build. Keys and values are paths relative to the static and output folders respectively, with "/" as the separator: for example, "css/style.css" maps to "css/style-a4a3b627.css".
Changed in version 1.1 of package camp-lib: Copies static files after rendering, not before, and returns the table of fingerprinted files instead of #<void>. A static file now replaces a page that has the same output path; before, the page replaced the static file.
struct
(struct site-info (pages term-index page-index taxonomy-index) #:extra-constructor-name make-site-info #:transparent) pages : (listof page?) term-index : hash? page-index : hash? taxonomy-index : hash?
parameter
(current-site-info) → (or/c site-info? #f)
(current-site-info info) → void? info : (or/c site-info? #f)
struct
(struct page (source-path output-path doc slug collection-name) #:extra-constructor-name make-page #:transparent) source-path : path? output-path : path? doc : any/c slug : string? collection-name : string?
9.7.2 Development Server
| (require camp/serve) | package: camp-lib |
The camp/serve module provides a development server for local testing.
procedure
(start-server output-folder [ #:port port #:log-format log-format]) → (-> void?) output-folder : path-string? port : exact-nonnegative-integer? = 8000 log-format : (or/c 'modern 'apache) = 'modern
The log-format parameter controls request logging: 'modern produces a clean HH:MM:SS METHOD PATH STATUS format suitable for colorized terminal output, while 'apache produces traditional Apache combined log format.
Note: This function only starts a static server. File watching and automatic rebuilds are provided by the raco camp serve command, which uses this function internally.
9.7.3 Logging
| (require camp/log) | package: camp-lib |
The camp/log module provides structured logging for Camp operations.
value
syntax
(log-camp-fatal string-expr arg ...)
syntax
(log-camp-error string-expr arg ...)
syntax
(log-camp-warning string-expr arg ...)
syntax
(log-camp-info string-expr arg ...)
syntax
(log-camp-debug string-expr arg ...)