change pollen/world to pollen/setup

pull/110/head
Matthew Butterick 8 years ago
parent e1f684f980
commit 4f146fd755

@ -3,18 +3,18 @@
sugar/define
"private/cache-utils.rkt"
"private/debug.rkt"
"world.rkt")
"setup.rkt")
;; The cache is a hash with paths as keys.
;; The cache values are also hashes, with key/value pairs for that path.
(define+provide (reset-cache [starting-dir (world:current-project-root)])
(define+provide (reset-cache [starting-dir (setup:current-project-root)])
(unless (and (path-string? starting-dir) (directory-exists? starting-dir))
(raise-argument-error 'reset-cache "path-string to existing directory" starting-dir))
(for ([path (in-directory starting-dir)]
#:when (and (directory-exists? path)
(equal? (path->string (car (reverse (explode-path path)))) (world:current-cache-dir-name))))
(equal? (path->string (car (reverse (explode-path path)))) (setup:cache-dir-name))))
(message (format "removing cache directory: ~a" path))
(delete-directory/files path)))
@ -31,11 +31,11 @@
(raise-argument-error caller-name "path to existing file" path-or-path-string))
(cond
[(world:current-compile-cache-active path)
[(setup:compile-cache-active path)
(define key (paths->key path))
(hash-ref (hash-ref! ram-cache key (λ _ (cache-ref! key (λ _ (path->hash path))))) subkey)]
[else (parameterize ([current-namespace (make-base-namespace)])
(namespace-attach-module (namespace-anchor->namespace cache-module-ns) 'pollen/world) ; brings in params
(namespace-attach-module (namespace-anchor->namespace cache-module-ns) 'pollen/setup) ; brings in params
(dynamic-require path subkey))]))))
@ -44,8 +44,8 @@
(define+provide (cached-doc path-string)
(cached-require-base path-string (world:current-main-export) 'cached-doc))
(cached-require-base path-string (setup:main-export) 'cached-doc))
(define+provide (cached-metas path-string)
(cached-require-base path-string (world:current-meta-export) 'cached-metas))
(cached-require-base path-string (setup:meta-export) 'cached-metas))

@ -1,8 +1,8 @@
#lang racket/base
(require (for-syntax racket/base "world.rkt" "private/splice.rkt"))
(require (for-syntax racket/base "setup.rkt" "private/splice.rkt"))
(require txexpr xml/path sugar/define sugar/coerce sugar/test racket/string)
(require "private/file-utils.rkt"
"world.rkt"
"setup.rkt"
"cache.rkt"
"pagetree.rkt"
"tag.rkt"
@ -86,7 +86,7 @@
(define (convert+validate-path pagenode-or-path caller)
(let ([path (get-source (if (pagenode? pagenode-or-path)
(build-path (world:current-project-root) (symbol->string pagenode-or-path))
(build-path (setup:current-project-root) (symbol->string pagenode-or-path))
pagenode-or-path))])
(unless path
(error (format "~a no source found for '~a' in directory ~a" caller path (current-directory))))
@ -116,7 +116,7 @@
(define-syntax (when/splice stx)
(syntax-case stx ()
[(_ COND BODY ...)
(with-syntax ([SPLICING-TAG (datum->syntax stx (world:current-splicing-tag))])
(with-syntax ([SPLICING-TAG (datum->syntax stx (setup:splicing-tag))])
#'(if COND
(with-handlers ([exn:fail? (λ(exn) (error (format "within when/splice, ~a" (exn-message exn))))])
(SPLICING-TAG BODY ...))

@ -1,6 +1,6 @@
#lang racket/base
(require xml txexpr racket/list sugar/list sugar/define sugar/test)
(require "world.rkt"
(require "setup.rkt"
"private/whitespace.rkt")
(require "unstable/mb.rkt")
@ -119,12 +119,12 @@
;; so rather than test for `txexpr?` at the beginning (which is potentially slow)
;; just look at the tag.
(and (pair? x)
(memq (get-tag x) (world:current-block-tags))
(memq (get-tag x) (setup:block-tags))
#t))
(define+provide/contract (decode-linebreaks elems [maybe-linebreak-proc '(br)]
#:separator [newline (world:current-linebreak-separator)])
#:separator [newline (setup:linebreak-separator)])
((txexpr-elements?) ((or/c txexpr-element? (txexpr-element? txexpr-element? . -> . txexpr-element?)) #:separator string?) . ->* . txexpr-elements?)
(define linebreak-proc (if (procedure? maybe-linebreak-proc)
maybe-linebreak-proc
@ -159,7 +159,7 @@
;; Ignore empty strings.
(define+provide/contract (merge-newlines x)
(txexpr-elements? . -> . txexpr-elements?)
(define newline-pat (regexp (format "^~a+$" (world:current-newline))))
(define newline-pat (regexp (format "^~a+$" (setup:newline))))
(define (newlines? x) (and (string? x) (regexp-match newline-pat x)))
(define (merge-if-newlines xs)
(if (newlines? (car xs))
@ -195,7 +195,7 @@
(linebreak-proc (merge-newlines (trimf elems whitespace?))))
(define (paragraph-break? x)
(define paragraph-separator (world:current-paragraph-separator))
(define paragraph-separator (setup:paragraph-separator))
(define paragraph-pattern (pregexp (format "^~a+$" paragraph-separator)))
(and (string? x) (regexp-match paragraph-pattern x)))

@ -7,7 +7,7 @@
;; do the tests here to verify that the right functions are available through file.rkt
(module-test-external
(require sugar/coerce pollen/world)
(require sugar/coerce pollen/setup)
(check-true (preproc-source? "foo.pp"))
(check-false (preproc-source? "foo.bar"))
(check-false (preproc-source? #f))
@ -16,8 +16,8 @@
(check-equal? (->preproc-source-path "foo") (->path "foo.pp"))
(check-equal? (->preproc-source-path 'foo) (->path "foo.pp"))
(check-true (pagetree-source? (format "foo.~a" (world:current-pagetree-source-ext))))
(check-false (pagetree-source? (format "~a.foo" (world:current-pagetree-source-ext))))
(check-true (pagetree-source? (format "foo.~a" (setup:pagetree-source-ext))))
(check-false (pagetree-source? (format "~a.foo" (setup:pagetree-source-ext))))
(check-false (pagetree-source? #f))
(check-true (markup-source? "foo.pm"))

@ -1,8 +1,8 @@
#lang racket/base
(require "private/main-base.rkt")
(define+provide-module-begin-in-mode world:mode-preproc) ; because default mode in submodule is preproc
(define+provide-module-begin-in-mode setup:default-mode-preproc) ; because default mode in submodule is preproc
(module reader racket/base
(require pollen/private/reader-base)
(define+provide-reader-in-mode world:mode-auto)) ; because default mode in file is auto
(define+provide-reader-in-mode setup:default-mode-auto)) ; because default mode in file is auto

@ -1,8 +1,8 @@
#lang racket/base
(require "private/main-base.rkt")
(define+provide-module-begin-in-mode world:mode-markdown)
(define+provide-module-begin-in-mode setup:default-mode-markdown)
(module reader racket/base
(require pollen/private/reader-base)
(define+provide-reader-in-mode world:mode-markdown))
(define+provide-reader-in-mode setup:default-mode-markdown))

@ -1,8 +1,8 @@
#lang racket/base
(require "private/main-base.rkt")
(define+provide-module-begin-in-mode world:mode-markup)
(define+provide-module-begin-in-mode setup:default-mode-markup)
(module reader racket/base
(require pollen/private/reader-base)
(define+provide-reader-in-mode world:mode-markup))
(define+provide-reader-in-mode setup:default-mode-markup))

@ -8,7 +8,7 @@ a) adapts the at-exp metalang from 6.2
b) incorporates the scribble/reader from 6.2
so that everything will work correctly in 6.0.
Note that pollen/mode uses world:command-char, NOT (world:current-command-char),
Note that pollen/mode uses setup:default-command-char, NOT (setup:command-char),
because doing so would create a loading loop if pollen/mode were used in "pollen.rkt"
(which is a likely place to use it)
Intractable problem, unavoiable limitation.
@ -59,7 +59,7 @@ Intractable problem, unavoiable limitation.
(λ args
(parameterize ([current-readtable (make-at-readtable #:datum-readtable 'dynamic
#:command-readtable 'dynamic
#:command-char (dynamic-require 'pollen/world 'world:command-char))])
#:command-char (dynamic-require 'pollen/setup 'setup:default-command-char))])
(apply p args))))
(define-values (at-read at-read-syntax at-get-info)

@ -1,6 +1,6 @@
#lang racket/base
(require racket/path racket/list sugar txexpr)
(require "world.rkt"
(require "setup.rkt"
"private/whitespace.rkt"
"private/file-utils.rkt"
"decode.rkt"
@ -39,7 +39,7 @@
(define+provide/contract (decode-pagetree xs)
(txexpr-elements? . -> . any/c) ; because pagetree is being explicitly validated
(define pt-root-tag (world:current-pagetree-root-node))
(define pt-root-tag (setup:pagetree-root-node))
(define (splice-nested-pagetree xs)
(apply append (for/list ([x (in-list xs)])
(if (and (txexpr? x) (eq? (get-tag x) pt-root-tag))
@ -93,7 +93,7 @@
;; certain files (leading dot) will be ignored by `directory-list` anyhow.
;; we will, however, ignore Pollen's cache files, because those shouldn't be project-manipulated.
(define (not-pollen-cache? path)
(not (member (->string path) world:cache-names)))
(not (member (->string path) setup:default-cache-names)))
(unless (directory-exists? dir)
(error 'directory->pagetree (format "directory ~v doesn't exist" dir)))
@ -112,7 +112,7 @@
(define+provide/contract (make-project-pagetree project-dir)
(pathish? . -> . pagetree?)
(with-handlers ([exn:fail? (λ(exn) (directory->pagetree project-dir))])
(define pagetree-source (build-path project-dir (world:current-default-pagetree)))
(define pagetree-source (build-path project-dir (setup:default-pagetree)))
(load-pagetree pagetree-source)))
@ -241,7 +241,7 @@
(check-false (next 'three test-pagetree)))
(define/contract+provide (path->pagenode path [starting-path (world:current-project-root)])
(define/contract+provide (path->pagenode path [starting-path (setup:current-project-root)])
((coerce/path?) (coerce/path?) . ->* . coerce/symbol?)
(define starting-dir
(if (directory-exists? starting-path)

@ -1,8 +1,8 @@
#lang racket/base
(require "private/main-base.rkt")
(define+provide-module-begin-in-mode world:mode-preproc)
(define+provide-module-begin-in-mode setup:default-mode-preproc)
(module reader racket/base
(require pollen/private/reader-base)
(define+provide-reader-in-mode world:mode-preproc))
(define+provide-reader-in-mode setup:default-mode-preproc))

@ -1,5 +1,5 @@
#lang racket/base
(require "file-utils.rkt" "../world.rkt" "project.rkt" file/cache racket/file sugar/coerce compiler/cm)
(require "file-utils.rkt" "../setup.rkt" "project.rkt" file/cache racket/file sugar/coerce compiler/cm)
(provide (all-defined-out))
(define (paths->key source-path [template-path #f])
@ -12,8 +12,8 @@
;; can't use relative paths for cache keys because source files include `here-path` which is absolute.
;; problem is that cache could appear valid on another filesystem (based on relative pathnames & mod dates)
;; but would actually be invalid (because the `here-path` names are wrong).
(define poly-flag (and (has-inner-poly-ext? source-path) (world:current-poly-target)))
(define pollen-env (getenv world:env-name))
(define poly-flag (and (has-inner-poly-ext? source-path) (setup:current-poly-target)))
(define pollen-env (getenv setup:default-env-name))
(define path+mod-time-pairs
(map (λ(ps) (and ps (let ([cp (->complete-path ps)])
(cons (path->string cp) (with-handlers ([exn:fail? (λ _ 0)])
@ -37,8 +37,8 @@
(for-each managed-compile-zo (or drfs null))
(define path-dir (dirname path))
(apply hash
(let ([doc-key (world:current-main-export)]
[meta-key (world:current-meta-export)])
(let ([doc-key (setup:main-export)]
[meta-key (setup:meta-export)])
(parameterize ([current-namespace (make-base-namespace)]
[current-directory path-dir])
;; I monkeyed around with using the metas submodule to pull out the metas (for speed)
@ -46,7 +46,7 @@
;; so it's just simpler to get both at once and be done with it.
;; the savings of avoiding two cache fetches at the outset outweighs
;; the benefit of not reloading doc when you just need metas.
(namespace-attach-module (namespace-anchor->namespace cache-utils-module-ns) 'pollen/world) ; brings in params
(namespace-attach-module (namespace-anchor->namespace cache-utils-module-ns) 'pollen/setup) ; brings in params
(list doc-key (dynamic-require path doc-key) meta-key (dynamic-require path meta-key))))))
(define (my-make-directory* dir)
@ -59,7 +59,7 @@
(define (make-cache-dirs path)
(define path-dir (dirname path))
(define cache-dir (build-path path-dir (world:current-cache-dir-name)))
(define cache-dir (build-path path-dir (setup:cache-dir-name)))
(define private-cache-dir (build-path cache-dir "private"))
(my-make-directory* private-cache-dir) ; will also make cache-dir, if needed
(values cache-dir private-cache-dir))
@ -75,5 +75,5 @@
private-cache-dir
(λ _
(write-to-file (path-hash-thunk) dest-file #:exists 'replace))
#:max-cache-size (world:current-compile-cache-max-size))
#:max-cache-size (setup:compile-cache-max-size))
(file->value dest-file))

@ -1,10 +1,10 @@
#lang racket/base
(require pollen/world pollen/render racket/file racket/path sugar/coerce "file-utils.rkt" pollen/pagetree racket/string racket/list racket/vector racket/cmdline)
(require pollen/setup pollen/render racket/file racket/path sugar/coerce "file-utils.rkt" pollen/pagetree racket/string racket/list racket/vector racket/cmdline)
;; The use of dynamic-require throughout this file is intentional:
;; this way, low-dependency raco commands (like "version") are faster.
;; Whereas with `require` or `local-require`, everything would have to be front-loaded.
;; but ... maybe most of the latency is due to pollen/world environment checking.
;; but ... maybe most of the latency is due to pollen/setup environment checking.
;; todo: investigate this
(module+ raco
@ -61,11 +61,11 @@ publish [dir] [dest] copy project in dir to dest without source files
(warning: overwrites existing dest dir)
setup preload cache
reset reset cache
version print the version (~a)" (world:current-server-port) world:version)))
version print the version (~a)" (setup:current-server-port) setup:default-version)))
(define (handle-version)
(displayln world:version))
(displayln setup:default-version))
(define (handle-reset directory-maybe)
@ -79,7 +79,7 @@ version print the version (~a)" (world:current-server-port) world
(define (handle-render)
(define render-target-wanted (make-parameter (world:current-poly-target)))
(define render-target-wanted (make-parameter (setup:current-poly-target)))
(define parsed-args (command-line #:program "raco pollen render"
#:argv (vector-drop (current-command-line-arguments) 1) ; snip the 'render' from the front
#:once-each
@ -90,13 +90,13 @@ version print the version (~a)" (world:current-server-port) world
(define path-args (if (empty? parsed-args)
(list (current-directory))
parsed-args))
(parameterize ([current-directory (world:current-project-root)]
[world:current-poly-target (render-target-wanted)])
(parameterize ([current-directory (setup:current-project-root)]
[setup:current-poly-target (render-target-wanted)])
(define first-arg (car path-args))
(if (directory-exists? first-arg)
(let ([dir first-arg]) ; now we know it's a dir
(parameterize ([current-directory dir]
[world:current-project-root dir])
[setup:current-project-root dir])
(define preprocs (filter preproc-source? (directory-list dir)))
(define static-pagetrees (filter pagetree-source? (directory-list dir)))
;; if there are no static pagetrees, use make-project-pagetree
@ -119,8 +119,8 @@ version print the version (~a)" (world:current-server-port) world
(define (handle-start directory-maybe [port #f])
(when (not (directory-exists? directory-maybe))
(error (format "~a is not a directory" directory-maybe)))
(parameterize ([world:current-project-root directory-maybe]
[world:current-server-port (or port world:default-port)])
(parameterize ([setup:current-project-root directory-maybe]
[setup:current-server-port (or port setup:default-default-port)])
(displayln "Starting project server ...")
((dynamic-require 'pollen/private/project-server 'start-server))))
@ -129,7 +129,7 @@ version print the version (~a)" (world:current-server-port) world
(define target-path
(or
(and rest-args (not (null? rest-args)) (path->complete-path (string->path (car rest-args))))
(build-path (find-system-path 'desk-dir) (string->path (if (equal? arg-command-name "clone") "clone" (world:current-publish-directory-name))))))
(build-path (find-system-path 'desk-dir) (string->path (if (equal? arg-command-name "clone") "clone" (setup:publish-directory-name))))))
(define (delete-it path)
(cond
@ -156,7 +156,7 @@ version print the version (~a)" (world:current-server-port) world
(when (directory-exists? target-dir)
(delete-directory/files target-dir))
(copy-directory/files source-dir target-dir)
(parameterize ([world:current-project-root (current-directory)])
(parameterize ([setup:current-project-root (current-directory)])
(for-each delete-it (find-files pollen-related-file? target-dir)))
(displayln (format "completed to ~a" target-dir)))

@ -1,4 +1,4 @@
#lang racket/base
(require "../world.rkt" sugar/file sugar/coerce sugar/test)
(require "../setup.rkt" sugar/file sugar/coerce sugar/test)
(provide (all-defined-out))

@ -1,7 +1,7 @@
#lang racket/base
(require (for-syntax racket/base racket/syntax))
(require racket/path)
(require "../world.rkt" sugar/define sugar/file sugar/string sugar/coerce sugar/test)
(require "../setup.rkt" sugar/define sugar/file sugar/string sugar/coerce sugar/test)
;; because it comes up all the time
@ -65,7 +65,7 @@
(directory-list dir #:build? #t))))))
(define+provide (escape-last-ext x [escape-char (world:current-extension-escape-char)])
(define+provide (escape-last-ext x [escape-char (setup:extension-escape-char)])
;((pathish?) (char?) . ->* . coerce/path?)
;; if x has a file extension, reattach it with the escape char
(define current-ext (get-ext x))
@ -83,7 +83,7 @@
(define second cadr)
(define third caddr)
(define (last x) (car (reverse x)))
(define+provide (unescape-ext x [escape-char (world:current-extension-escape-char)])
(define+provide (unescape-ext x [escape-char (setup:extension-escape-char)])
;((coerce/string?) (char?) . ->* . coerce/path?)
;; if x has an escaped extension, unescape it.
(define-values (base name dir?) (split-path x))
@ -121,7 +121,7 @@
(define+provide (ext-in-poly-targets? ext [x #f])
(member (->symbol ext) (apply world:current-poly-targets (if x (list x) null))))
(member (->symbol ext) (apply setup:poly-targets (if x (list x) null))))
(module-test-external
(check-equal? (ext-in-poly-targets? 'html) '(html))
@ -129,7 +129,7 @@
(define+provide (has-poly-ext? x)
(equal? (get-ext x) (->string (world:current-poly-source-ext))))
(equal? (get-ext x) (->string (setup:poly-source-ext))))
(module-test-external
(check-true (has-poly-ext? "foo.poly"))
@ -149,7 +149,7 @@
(define-syntax (make-source-utility-functions stx)
(syntax-case stx ()
[(_ stem)
(with-syntax ([world:current-stem-source-ext (format-id stx "world:current-~a-source-ext" #'stem)]
(with-syntax ([setup:stem-source-ext (format-id stx "setup:~a-source-ext" #'stem)]
[stem-source? (format-id stx "~a-source?" #'stem)]
[get-stem-source (format-id stx "get-~a-source" #'stem)]
[has/is-stem-source? (format-id stx "has/is-~a-source?" #'stem)]
@ -160,7 +160,7 @@
;; does file have particular extension
(define+provide/contract (stem-source? x)
(any/c . -> . boolean?)
(and (pathish? x) (has-ext? (->path x) (world:current-stem-source-ext)) #t))
(and (pathish? x) (has-ext? (->path x) (setup:stem-source-ext)) #t))
;; non-theoretical: want the first possible source that exists in the filesystem
(define+provide/contract (get-stem-source x)
@ -186,19 +186,19 @@
(list x) ; already has the source extension
#,(if (eq? (syntax->datum #'stem) 'scribble)
#'(if (x . has-ext? . 'html) ; different logic for scribble sources
(list (add-ext (remove-ext* x) (world:current-stem-source-ext)))
(list (add-ext (remove-ext* x) (setup:stem-source-ext)))
#f)
#'(let ([x-ext (get-ext x)]
[source-ext (world:current-stem-source-ext)])
[source-ext (setup:stem-source-ext)])
(append
(list (add-ext x source-ext)) ; standard
(if x-ext ; has existing ext, therefore needs escaped version
(append
(list (add-ext (escape-last-ext x) source-ext))
(if (ext-in-poly-targets? x-ext x) ; needs multi + escaped multi
(let ([x-multi (add-ext (remove-ext x) (world:current-poly-source-ext))])
(let ([x-multi (add-ext (remove-ext x) (setup:poly-source-ext))])
(list
(add-ext x-multi (world:current-stem-source-ext))
(add-ext x-multi (setup:stem-source-ext))
(add-ext (escape-last-ext x-multi) source-ext)))
null))
null))))))
@ -272,7 +272,7 @@
[(or (markup-source? x) (preproc-source? x) (null-source? x) (markdown-source? x))
(define output-path (unescape-ext (remove-ext x)))
(if (has-poly-ext? output-path)
(add-ext (remove-ext output-path) (or (world:current-poly-target) (car (world:current-poly-targets))))
(add-ext (remove-ext output-path) (or (setup:current-poly-target) (car (setup:poly-targets))))
output-path)]
[(scribble-source? x) (add-ext (remove-ext x) 'html)]
[else x]))
@ -280,7 +280,7 @@
(define+provide (project-files-with-ext ext)
;(coerce/symbol? . -> . complete-paths?)
(map ->complete-path (filter (λ(i) (has-ext? i (->symbol ext))) (directory-list (world:current-project-root)))))
(map ->complete-path (filter (λ(i) (has-ext? i (->symbol ext))) (directory-list (setup:current-project-root)))))
(define (racket-source? x)
@ -298,7 +298,7 @@
(define+provide (cache-file? path)
(ormap (λ(cache-name) (ends-with? (path->string path) cache-name)) world:cache-names))
(ormap (λ(cache-name) (ends-with? (path->string path) cache-name)) setup:default-cache-names))
(define+provide (pollen-related-file? file)
@ -312,4 +312,4 @@
racket-source?
magic-directory?
cache-file?
(world:current-unpublished-path?))))
(setup:unpublished-path?))))

@ -1,7 +1,8 @@
#lang racket/base
(require (for-syntax racket/base syntax/strip-context racket/syntax "../world.rkt" "split-metas.rkt")
"to-string.rkt" "../pagetree.rkt" "splice.rkt" "../world.rkt") ; need world here to resolve PARSER-MODE-ARG
(require (for-syntax racket/base syntax/strip-context racket/syntax "../setup.rkt" "split-metas.rkt")
"to-string.rkt" "../pagetree.rkt" "splice.rkt" "../setup.rkt") ; need world here to resolve PARSER-MODE-ARG
(provide (all-defined-out))
(require sugar/debug)
(define-syntax-rule (define+provide-module-begin-in-mode PARSER-MODE-ARG)
(begin
@ -10,18 +11,18 @@
(define-syntax (pollen-module-begin stx)
(syntax-case stx ()
[(_ EXPR (... ...))
(let-values ([(meta-hash expr-without-metas) (split-metas (syntax->datum #'(EXPR (... ...))) (world:current-define-meta-name))])
(let-values ([(meta-hash expr-without-metas) (split-metas (syntax->datum #'(EXPR (... ...))) (setup:define-meta-name))])
(with-syntax ([META-HASH (datum->syntax #'(EXPR (... ...)) meta-hash)]
[(EXPR-WITHOUT-METAS (... ...)) (datum->syntax #'(EXPR (... ...)) expr-without-metas)]
[METAS (format-id #'(EXPR (... ...)) "~a" (world:current-meta-export))]
[META-MOD (format-symbol "~a" (world:current-meta-export))]
[ROOT (format-id #'(EXPR (... ...)) "~a" (world:current-main-root-node))]
[NEWLINE (datum->syntax #'(EXPR (... ...)) (world:current-newline))]
[MODE-PAGETREE (datum->syntax #'(EXPR (... ...)) world:mode-pagetree)]
[MODE-MARKUP (datum->syntax #'(EXPR (... ...)) world:mode-markup)]
[MODE-MARKDOWN (datum->syntax #'(EXPR (... ...)) world:mode-markdown)]
[SPLICING_TAG (datum->syntax #'(EXPR (... ...)) (world:current-splicing-tag))]
[DOC (format-id #'(EXPR (... ...)) "~a" (world:current-main-export))]
[METAS (format-id #'(EXPR (... ...)) "~a" (setup:meta-export))]
[META-MOD (format-symbol "~a" (setup:meta-export))]
[ROOT (format-id #'(EXPR (... ...)) "~a" (setup:main-root-node))]
[NEWLINE (datum->syntax #'(EXPR (... ...)) (setup:newline))]
[MODE-PAGETREE (datum->syntax #'(EXPR (... ...)) setup:default-mode-pagetree)]
[MODE-MARKUP (datum->syntax #'(EXPR (... ...)) setup:default-mode-markup)]
[MODE-MARKDOWN (datum->syntax #'(EXPR (... ...)) setup:default-mode-markdown)]
[SPLICING_TAG (datum->syntax #'(EXPR (... ...)) (setup:splicing-tag))]
[DOC (format-id #'(EXPR (... ...)) "~a" (setup:main-export))]
[DOC-RAW (generate-temporary 'pollen-)]); prevents conflicts with other imported Pollen sources
(replace-context #'(EXPR (... ...))
#'(#%module-begin
@ -31,7 +32,7 @@
(module inner pollen/private/doclang-raw
DOC-RAW ; positional arg for doclang-raw that sets name of export.
(require pollen/top pollen/world pollen/core)
(require pollen/top pollen/setup pollen/core)
(require (submod ".." META-MOD))
(provide (all-defined-out) #%top (all-from-out (submod ".." META-MOD) pollen/core))
EXPR-WITHOUT-METAS (... ...))

@ -5,7 +5,7 @@
(require web-server/http/request-structs)
(require web-server/http/response-structs)
(require 2htdp/image)
(require "../world.rkt" "../render.rkt" sugar txexpr "file-utils.rkt" "debug.rkt" "../pagetree.rkt" "../cache.rkt")
(require "../setup.rkt" "../render.rkt" sugar txexpr "file-utils.rkt" "debug.rkt" "../pagetree.rkt" "../cache.rkt")
(module+ test (require rackunit))
@ -25,7 +25,7 @@
(meta ([charset "UTF-8"]))
(link ([rel "stylesheet"]
[type "text/css"]
[href ,(format "/~a" (world:current-dashboard-css))])))
[href ,(format "/~a" (setup:dashboard-css))])))
(body
,content-xexpr (div ((id "pollen-logo"))))))
@ -42,7 +42,7 @@
(define localhost-client "::1")
(define url-string (url->string (request-uri req)))
(when (not (ends-with? url-string "favicon.ico"))
(message "request:" (string-replace url-string (world:current-default-pagetree) " dashboard")
(message "request:" (string-replace url-string (setup:default-pagetree) " dashboard")
(if (not (equal? client localhost-client)) (format "from ~a" client) ""))))
;; pass string args to route, then
@ -53,7 +53,7 @@
(procedure? . -> . procedure?)
(λ(req . string-args)
(logger req)
(define path (apply build-path (world:current-project-root) (flatten string-args)))
(define path (apply build-path (setup:current-project-root) (flatten string-args)))
(response/xexpr+doctype (route-proc path))))
@ -78,7 +78,7 @@
(pathish? . -> . xexpr?)
(define path (->complete-path p))
(define img (bitmap/file path))
(define relative-path (->string (find-relative-path (world:current-project-root) path)))
(define relative-path (->string (find-relative-path (setup:current-project-root) path)))
(define img-url (format "/~a" relative-path))
`(div
(p "filename =" ,(->string relative-path))
@ -93,7 +93,7 @@
(define (handle-zip-path p)
(pathish? . -> . xexpr?)
(define path (->path p))
(define relative-path (->string (find-relative-path (world:current-project-root) path)))
(define relative-path (->string (find-relative-path (setup:current-project-root) path)))
(define ziplist (zip-directory-entries (read-zip-directory path)))
`(div
(p "filename =" ,(->string relative-path))
@ -134,7 +134,7 @@
(define (dashboard dashboard-ptree)
(define dashboard-dir (get-enclosing-dir dashboard-ptree))
(define (in-project-root?)
(directories-equal? dashboard-dir (world:current-project-root)))
(directories-equal? dashboard-dir (setup:current-project-root)))
(define parent-dir (and (not (in-project-root?)) (get-enclosing-dir dashboard-dir)))
(define empty-cell (cons #f #f))
(define (make-link-cell href+text)
@ -145,21 +145,21 @@
text)))))
(define (make-parent-row)
(define title (string-append "Project root" (if (equal? (world:current-project-root) dashboard-dir) (format " = ~a" dashboard-dir) "")))
(define dirs (cons title (if (not (equal? (world:current-project-root) dashboard-dir))
(explode-path (find-relative-path (world:current-project-root) dashboard-dir))
(define title (string-append "Project root" (if (equal? (setup:current-project-root) dashboard-dir) (format " = ~a" dashboard-dir) "")))
(define dirs (cons title (if (not (equal? (setup:current-project-root) dashboard-dir))
(explode-path (find-relative-path (setup:current-project-root) dashboard-dir))
null)))
(define dirlinks (cons "/" (map (λ(ps) (format "/~a/" (apply build-path ps)))
(for/list ([i (in-range (length (cdr dirs)))])
(take (cdr dirs) (add1 i))))))
`(tr (th ((colspan "3")) ,@(add-between (map (λ(dir dirlink) `(a ((href ,(format "~a~a" dirlink (world:current-default-pagetree)))) ,(->string dir))) dirs dirlinks) "/"))))
`(tr (th ((colspan "3")) ,@(add-between (map (λ(dir dirlink) `(a ((href ,(format "~a~a" dirlink (setup:default-pagetree)))) ,(->string dir))) dirs dirlinks) "/"))))
(define (make-path-row filename source indent-level)
`(tr ,@(map make-link-cell
(append (list
(let ([main-cell (cond ; main cell
[(directory-exists? (build-path dashboard-dir filename)) ; links subdir to its dashboard
(cons (format "~a/~a" filename (world:current-default-pagetree)) (format "~a/" filename))]
(cons (format "~a/~a" filename (setup:default-pagetree)) (format "~a/" filename))]
[(and source (equal? (get-ext source) "scrbl")) ; scribble source
(cons #f `(a ((href ,filename)) ,filename (span ((class "file-ext")) " (from " ,(->string (find-relative-path dashboard-dir source)) ")")))]
[source ; ordinary source. use remove-ext because source may have escaped extension in it
@ -167,9 +167,9 @@
(define source-minus-ext (unescape-ext (remove-ext source)))
(define source-second-ext (get-ext source-minus-ext))
(cond ; multi source. expand to multiple output files.
[(and source-second-ext (equal? source-second-ext (->string (world:current-poly-source-ext (->complete-path source)))))
[(and source-second-ext (equal? source-second-ext (->string (setup:poly-source-ext (->complete-path source)))))
(define source-base (remove-ext source-minus-ext))
(define output-names (map (λ(ext) (->string (add-ext source-base ext))) (world:current-poly-targets (->complete-path source))))
(define output-names (map (λ(ext) (->string (add-ext source-base ext))) (setup:poly-targets (->complete-path source))))
(cons #f `(span ,@(map (λ(on) `(a ((href ,on)) ,on (span ((class "file-ext")) "." ,source-first-ext ,(format " (from ~a)" (->string (find-relative-path dashboard-dir source)))))) output-names)))]
[else
(define extra-row-string
@ -201,7 +201,7 @@
[(pagetree-source? filename) empty-cell]
[else (cons (format "out/~a" filename) "out")]))))))
(define (ineligible-path? x) (member x (world:current-paths-excluded-from-dashboard)))
(define (ineligible-path? x) (member x (setup:paths-excluded-from-dashboard)))
(define directory-pagetree (with-handlers ([exn:fail:contract? (λ _ (directory->pagetree dashboard-dir))])
(cached-doc (->path dashboard-ptree))))
@ -256,7 +256,7 @@
(define/contract (req->path req)
(request? . -> . path?)
(define base (world:current-project-root))
(define base (setup:current-project-root))
(define file (url->path (request-uri req)))
(if (eq? (system-path-convention-type) 'windows)
(build-path base file) ; because url->path returns a relative path for 'windows

@ -5,7 +5,7 @@
web-server/dispatch)
(require "project-server-routes.rkt"
"debug.rkt"
"../world.rkt"
"../setup.rkt"
"../file.rkt"
"../cache.rkt")
@ -19,19 +19,19 @@
[((string-arg) ... "out" (string-arg)) route-out]
[else route-default]))
(message (format "Welcome to Pollen ~a" world:version) (format "(Racket ~a)" (version)))
(message (format "Project root is ~a" (world:current-project-root)))
(message (format "Welcome to Pollen ~a" setup:default-version) (format "(Racket ~a)" (version)))
(message (format "Project root is ~a" (setup:current-project-root)))
(define server-name (format "http://localhost:~a" (world:current-server-port)))
(define server-name (format "http://localhost:~a" (setup:current-server-port)))
(message (format "Project server is ~a" server-name) "(Ctrl-C to exit)")
(message (format "Project dashboard is ~a/~a" server-name (world:current-default-pagetree)))
(message (format "Project dashboard is ~a/~a" server-name (setup:default-pagetree)))
(message "Ready to rock")
(parameterize ([error-print-width 1000])
(serve/servlet pollen-servlet
#:port (world:current-server-port)
#:port (setup:current-server-port)
#:listen-ip #f
#:servlet-regexp #rx"" ; respond to top level
#:command-line? #t
#:file-not-found-responder route-404
#:extra-files-paths (list (world:current-server-extras-path) (world:current-project-root)))))
#:extra-files-paths (list (setup:current-server-extras-path) (setup:current-project-root)))))

@ -1,13 +1,13 @@
#lang racket/base
(require sugar/define
sugar/coerce
"../world.rkt"
"../setup.rkt"
"file-utils.rkt")
(define+provide/contract (get-directory-require-files source-arg)
(pathish? . -> . (or/c #f (λ(xs) (and (list? xs) (andmap complete-path? xs)))))
(define source-path (->path source-arg))
(define require-filenames (list world:directory-require))
(define require-filenames (list setup:default-directory-require))
(define identity (λ(x) x))
(define possible-requires (filter identity (map (λ(f) (find-upward-from source-path f)) require-filenames)))
(and (pair? possible-requires) possible-requires))

@ -1,7 +1,7 @@
#lang racket/base
(require racket/syntax syntax/strip-context racket/class)
(require (only-in scribble/reader make-at-reader) pollen/world "project.rkt" racket/list)
(provide define+provide-reader-in-mode (all-from-out pollen/world))
(require (only-in scribble/reader make-at-reader) pollen/setup "project.rkt" racket/list)
(provide define+provide-reader-in-mode (all-from-out pollen/setup))
(define (make-custom-read custom-read-syntax-proc)
@ -11,11 +11,11 @@
(define (make-custom-read-syntax reader-mode)
(λ (path-string p)
(define read-inner (make-at-reader
#:command-char (if (or (eq? reader-mode world:mode-template)
#:command-char (if (or (eq? reader-mode setup:default-mode-template)
(and (string? path-string)
(regexp-match (pregexp (format "\\.~a$" (world:current-template-source-ext))) path-string)))
(world:current-template-command-char)
(world:current-command-char))
(regexp-match (pregexp (format "\\.~a$" (setup:template-source-ext))) path-string)))
(setup:template-command-char)
(setup:command-char))
#:syntax? #t
#:inside? #t))
(define source-stx (read-inner path-string p))
@ -23,24 +23,24 @@
[(symbol? path-string) (symbol->string path-string)]
[(equal? path-string "unsaved editor") path-string]
[else (path->string path-string)]))
(define parser-mode (if (eq? reader-mode world:mode-auto)
(define parser-mode (if (eq? reader-mode setup:default-mode-auto)
(let* ([file-ext-pattern (pregexp "\\w+$")]
[here-ext (string->symbol (car (regexp-match file-ext-pattern reader-here-path)))]
[auto-computed-mode (cond
[(eq? here-ext (world:current-pagetree-source-ext)) world:mode-pagetree]
[(eq? here-ext (world:current-markup-source-ext)) world:mode-markup]
[(eq? here-ext (world:current-markdown-source-ext)) world:mode-markdown]
[else world:mode-preproc])])
[(eq? here-ext (setup:pagetree-source-ext)) setup:default-mode-pagetree]
[(eq? here-ext (setup:markup-source-ext)) setup:default-mode-markup]
[(eq? here-ext (setup:markdown-source-ext)) setup:default-mode-markdown]
[else setup:default-mode-preproc])])
auto-computed-mode)
reader-mode))
(define post-parser-syntax
(with-syntax ([HERE-KEY (format-id source-stx "~a" (world:current-here-path-key))]
(with-syntax ([HERE-KEY (format-id source-stx "~a" (setup:here-path-key))]
[HERE-PATH (datum->syntax source-stx reader-here-path)]
[POLLEN-MOD (format-symbol "~a" (gensym))] ; prevents conflicts with other imported Pollen sources
[PARSER-MODE-VALUE (format-symbol "~a" parser-mode)]
[DIRECTORY-REQUIRES (datum->syntax source-stx (require+provide-directory-require-files path-string))]
[(SOURCE-LINE ...) source-stx]
[DOC (format-id source-stx "~a" (world:current-main-export))])
[DOC (format-id source-stx "~a" (setup:main-export))])
(replace-context
source-stx
#'(module runtime-wrapper racket/base
@ -76,7 +76,7 @@
;; OTOH Scribble relies on it, so IMO it's highly unlikely to change.
(let ([maybe-definitions-frame (object-name in)])
(send maybe-definitions-frame get-filename)))) ; will be #f if unsaved file
(define my-command-char (hash-ref! command-char-cache maybe-source-path (λ _ (world:current-command-char maybe-source-path))))
(define my-command-char (hash-ref! command-char-cache maybe-source-path (λ _ (setup:command-char maybe-source-path))))
(case key
[(color-lexer)
(define my-make-scribble-inside-lexer

@ -2,7 +2,7 @@
(provide configure)
(module show racket/base
(require pollen/world)
(require pollen/setup)
(provide show show-enabled)
(define show-enabled (make-parameter #f))
@ -12,8 +12,8 @@
;; otherwise if a Pollen source imports others, they will all print their docs in sequence.
;; so only print if the current here-path is the top path, which is stored in the `show-enabled` parameter.
(when (and (show-enabled) (equal? here-path (show-enabled)))
(if (or (eq? parser-mode world:mode-preproc)
(eq? parser-mode world:mode-template))
(if (or (eq? parser-mode setup:default-mode-preproc)
(eq? parser-mode setup:default-mode-template))
(display doc)
;; OK to use dynamic-require because runtime-config itself is dynamic-required
(print (with-handlers ([exn:fail? (λ(exn) ((error '|pollen markup error| ((dynamic-require 'racket/string 'string-join) (cdr ((dynamic-require 'racket/string 'string-split) (exn-message exn) ": ")) ": "))))])

@ -1,3 +1,3 @@
#lang racket/base
(provide version)
(define version "1.0")
(provide default-version)
(define default-version "1.0")

@ -1,8 +1,8 @@
#lang racket/base
(require "private/main-base.rkt")
(define+provide-module-begin-in-mode world:mode-pagetree)
(define+provide-module-begin-in-mode setup:default-mode-pagetree)
(module reader racket/base
(require pollen/private/reader-base)
(define+provide-reader-in-mode world:mode-pagetree))
(define+provide-reader-in-mode setup:default-mode-pagetree))

@ -10,7 +10,7 @@
"template.rkt"
"core.rkt"
"private/rerequire.rkt"
"world.rkt")
"setup.rkt")
;; used to track renders according to modification dates of component files
(define mod-date-hash (make-hash))
@ -62,7 +62,7 @@
(define pagetree (if (pagetree? pagetree-or-path)
pagetree-or-path
(cached-doc pagetree-or-path)))
(parameterize ([current-directory (world:current-project-root)])
(parameterize ([current-directory (setup:current-project-root)])
(for-each render-from-source-or-output-path (map ->complete-path (pagetree->list pagetree)))))
@ -90,7 +90,7 @@
(cond
[(not (file-exists? output-path)) 'file-missing]
[(mod-date-missing-or-changed? source-path template-path) 'mod-key-missing-or-changed]
[(not (world:current-render-cache-active source-path)) 'render-cache-deactivated]
[(not (setup:render-cache-active source-path)) 'render-cache-deactivated]
[else #f]))
(when render-needed?
(render-to-file source-path template-path output-path)))
@ -117,9 +117,9 @@
(define output-path (or maybe-output-path (->output-path source-path)))
(define template-path (or maybe-template-path (get-template-for source-path output-path)))
(message (format "rendering: /~a as /~a" (find-relative-path (world:current-project-root) source-path)
(find-relative-path (world:current-project-root) output-path)))
(define render-result (parameterize ([world:current-poly-target (->symbol (get-ext output-path))])
(message (format "rendering: /~a as /~a" (find-relative-path (setup:current-project-root) source-path)
(find-relative-path (setup:current-project-root) output-path)))
(define render-result (parameterize ([setup:current-poly-target (->symbol (get-ext output-path))])
(apply render-proc (list source-path template-path output-path))))
;; wait till last possible moment to store mod dates, because render-proc may also trigger its own subrenders
;; e.g., of a template.
@ -178,18 +178,18 @@
(require (for-syntax racket/base))
(require pollen/private/include-template pollen/cache pollen/private/debug pollen/pagetree pollen/core)
,(require-directory-require-files source-path)
(parameterize ([current-pagetree (make-project-pagetree ,(world:current-project-root))])
(let ([,(world:current-main-export source-path) (cached-doc ,(path->string source-path))]
[,(world:current-meta-export source-path) (cached-metas ,(path->string source-path))]
[,(world:current-splicing-tag source-path) (λ xs xs)]) ; splice behavior is different in textual context
(parameterize ([current-pagetree (make-project-pagetree ,(setup:current-project-root))])
(let ([,(setup:main-export source-path) (cached-doc ,(path->string source-path))]
[,(setup:meta-export source-path) (cached-metas ,(path->string source-path))]
[,(setup:splicing-tag source-path) (λ xs xs)]) ; splice behavior is different in textual context
(local-require pollen/template pollen/top)
(define here (path->pagenode
(or (select-from-metas ',(world:current-here-path-key source-path) ,(world:current-meta-export source-path)) 'unknown)))
(or (select-from-metas ',(setup:here-path-key source-path) ,(setup:meta-export source-path)) 'unknown)))
(cond
[(bytes? ,(world:current-main-export source-path)) ,(world:current-main-export source-path)] ; if main export is binary, just pass it through
[(bytes? ,(setup:main-export source-path)) ,(setup:main-export source-path)] ; if main export is binary, just pass it through
[else
;; `include-template` is the slowest part of the operation (the eval itself is cheap)
(include-template #:command-char ,(world:current-command-char source-path) (file ,(->string (find-relative-path source-dir template-path))))])))))
(include-template #:command-char ,(setup:command-char source-path) (file ,(->string (find-relative-path source-dir template-path))))])))))
(time (parameterize ([current-directory (->complete-path source-dir)]) ; because include-template wants to work relative to source location
(render-through-eval expr-to-eval))))
@ -212,9 +212,9 @@
(define output-path-ext (get-ext output-path))
(define (get-template-from-metas)
(with-handlers ([exn:fail:contract? (λ _ #f)]) ; in case source-path doesn't work with cached-require
(parameterize ([current-directory (world:current-project-root)])
(parameterize ([current-directory (setup:current-project-root)])
(let* ([source-metas (cached-metas source-path)]
[template-name-or-names (select-from-metas (world:current-template-meta-key source-path) source-metas)] ; #f or atom or list
[template-name-or-names (select-from-metas (setup:template-meta-key source-path) source-metas)] ; #f or atom or list
[template-name (cond
[(list? template-name-or-names)
(define result
@ -225,13 +225,13 @@
(define (get-default-template)
(and output-path-ext
(let ([default-template-filename (add-ext (world:current-default-template-prefix source-path) output-path-ext)])
(let ([default-template-filename (add-ext (setup:default-template-prefix source-path) output-path-ext)])
(find-upward-from source-path default-template-filename file-exists-or-has-source?))))
(define (get-fallback-template)
(and output-path-ext
(build-path (world:current-server-extras-path)
(add-ext (world:current-fallback-template-prefix source-path) output-path-ext))))
(build-path (setup:current-server-extras-path)
(add-ext (setup:fallback-template-prefix source-path) output-path-ext))))
(or (file-exists-or-has-source? (get-template-from-metas))
(file-exists-or-has-source? (get-default-template))
@ -241,21 +241,21 @@
(module-test-external
(require pollen/world sugar/file sugar/coerce)
(define fallback.html (build-path (world:current-server-extras-path)
(add-ext (world:current-fallback-template-prefix) 'html)))
(require pollen/setup sugar/file sugar/coerce)
(define fallback.html (build-path (setup:current-server-extras-path)
(add-ext (setup:fallback-template-prefix) 'html)))
(check-equal? (get-template-for (->complete-path "foo.poly.pm")) fallback.html)
(check-equal? (get-template-for (->complete-path "foo.html.pm")) fallback.html)
(define fallback.svg (build-path (world:current-server-extras-path)
(add-ext (world:current-fallback-template-prefix) 'svg)))
(parameterize ([world:current-poly-target 'svg])
(define fallback.svg (build-path (setup:current-server-extras-path)
(add-ext (setup:fallback-template-prefix) 'svg)))
(parameterize ([setup:current-poly-target 'svg])
(check-equal? (get-template-for (->complete-path "foo.poly.pm")) fallback.svg)
(check-equal? (get-template-for (->complete-path "foo.html.pm")) fallback.html))
(define fallback.missing (build-path (world:current-server-extras-path)
(add-ext (world:current-fallback-template-prefix) 'missing)))
(parameterize ([world:current-poly-target 'missing])
(define fallback.missing (build-path (setup:current-server-extras-path)
(add-ext (setup:fallback-template-prefix) 'missing)))
(parameterize ([setup:current-poly-target 'missing])
(check-false (get-template-for (->complete-path "foo.poly.pm")))
(check-equal? (get-template-for (->complete-path "foo.html.pm")) fallback.html)))
@ -264,5 +264,5 @@
;(list? . -> . (or/c string? bytes?))
(parameterize ([current-namespace (make-base-namespace)]
[current-output-port (current-error-port)])
(namespace-attach-module (namespace-anchor->namespace render-module-ns) 'pollen/world) ; brings in params
(namespace-attach-module (namespace-anchor->namespace render-module-ns) 'pollen/setup) ; brings in params
(eval expr-to-eval)))

@ -75,7 +75,7 @@ As mentioned above, a Pollen source file is not code with text embedded in it, b
@item{@bold{If you can write text, you can program in Pollen.} Really. As you already found out in the @secref["quick-tour"], this is a valid Pollen program:
@codeblock{
#lang pollen
Hello world: how are you on this fine summer day?
Hello setup: how are you on this fine summer day?
}}
@item{@bold{Commands start with ◊.} A simple rule: if a piece of text starts with @litchar{◊}, it's treated as a command; otherwise it's treated as ordinary text.}

@ -1,6 +1,6 @@
#lang scribble/manual
@(require "mb-tools.rkt" scribble/eval pollen/cache pollen/world (for-label racket pollen/world pollen/render pollen/file sugar txexpr))
@(require "mb-tools.rkt" scribble/eval pollen/cache pollen/setup (for-label racket pollen/setup pollen/render pollen/file sugar txexpr))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen))
@ -9,7 +9,7 @@
@defmodule[pollen/cache]
The slowest part of a Pollen @racket[render] is compiling a source file. Because Pollen allows source files to be edited and previewed dynamically, these files get recompiled a lot. Therefore, Pollen stores copies of the exports of source files — namely, whatever is stored in @code[(format "~a" world:main-export)] and @code[(format "~a" world:meta-export)] — in a cache so they can be reused.
The slowest part of a Pollen @racket[render] is compiling a source file. Because Pollen allows source files to be edited and previewed dynamically, these files get recompiled a lot. Therefore, Pollen stores copies of the exports of source files — namely, whatever is stored in @code[(format "~a" setup:default-main-export)] and @code[(format "~a" setup:default-meta-export)] — in a cache so they can be reused.
In each directory of your project, Pollen creates a subdirectory called @filepath{pollen-cache}. The files are stored on disk so they can be reused between sessions. If you delete files within a cache directory (or the whole thing), don't worry — everything will get regenerated. (However, you should not read or write to any @filepath{pollen-cache} directory, as the implementation details are subject to change.)
@ -21,18 +21,18 @@ If you want to reset all the compile caches, use @exec{@seclink["raco_pollen_res
@section{Disabling the cache}
The compile cache is controlled by the @seclink["world-overrides"]{overridable value} @racket[world:current-compile-cache-active]. Thus, to disable the compile cache, add a @racket[world] submodule to your @filepath{pollen.rkt} like so:
The compile cache is controlled by the @seclink["setup-overrides"]{overridable value} @racket[setup:compile-cache-active]. Thus, to disable the compile cache, add a @racket[setup] submodule to your @filepath{pollen.rkt} like so:
@codeblock|{
(module world racket/base
(module setup racket/base
(provide (all-defined-out))
(define compile-cache-active #f))
}|
Pollen also caches rendered output files, so if you want to disable all caching — thus forcing everything to recompile, every time — you should also disable the render cache by overriding @racket[world:current-render-cache-active]:
Pollen also caches rendered output files, so if you want to disable all caching — thus forcing everything to recompile, every time — you should also disable the render cache by overriding @racket[setup:render-cache-active]:
@codeblock|{
(module world racket/base
(module setup racket/base
(provide (all-defined-out))
(define compile-cache-active #f)
(define render-cache-active #f))
@ -68,7 +68,7 @@ hash-eq?]
)]
Try to retrieve the requested value out of the cache. If it's not there, or out of date, @racket[dynamic-require] is used to update it from the source.
Despite their names, these functions actually rely on @racket[world:current-main-export] and @racket[world:current-meta-export] (which default to @id[world:main-export] and @id[world:meta-export]). Thus, if you override those names, everything will still work as expected.
Despite their names, these functions actually rely on @racket[setup:main-export] and @racket[setup:meta-export] (which default to @id[setup:default-main-export] and @id[setup:default-meta-export]). Thus, if you override those names, everything will still work as expected.
If you want the speed benefit of the cache, you should @bold{always} use @racket[cached-doc] and @racket[cached-metas] to get data from Pollen source files. That doesn't mean you can't also use functions like @racket[require], @racket[local-require], and @racket[dynamic-require]. They'll just be slower.

@ -1,7 +1,7 @@
#lang scribble/manual
@(require scribble/bnf scribble/eval "utils.rkt" "mb-tools.rkt"
(for-syntax racket/base)
(for-label rackunit pollen/core pollen/world pollen/render pollen/template (only-in scribble/reader
(for-label rackunit pollen/core pollen/setup pollen/render pollen/template (only-in scribble/reader
use-at-readtable)))
@(define read-eval (make-base-eval))
@ -29,7 +29,7 @@ Here's how you type it:
@bold{Ubuntu}: ctrl + shift + U, then 25CA
Still, if you don't want to use the lozenge as your command character, you can set Pollen's @racket[world:command-char] value to whatever character you want (see also @seclink["world-overrides"]).
Still, if you don't want to use the lozenge as your command character, you can set Pollen's @racket[setup:default-command-char] value to whatever character you want (see also @seclink["setup-overrides"]).
@margin-note{Scribble uses the @"@" sign as a delimiter. It's not a bad choice if you only work with Racket files. But as you use Pollen to work on other kinds of text-based files that commonly contain @"@" signs — HTML pages especially — it gets cumbersome. So I changed it.}

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval pollen/cache pollen/world (for-label racket (except-in pollen #%module-begin) pollen/render txexpr xml pollen/pagetree sugar/coerce pollen/core pollen/world))
@(require scribble/eval pollen/cache pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/render txexpr xml pollen/pagetree sugar/coerce pollen/core pollen/setup))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/core xml))
@ -23,7 +23,7 @@ You can retrieve a meta value — even in the same document where you define it
For an introduction to metas, see @secref["Inserting_metas"].
@defform[(\@ arg ...)]
Splicing tag: signals that a list should be merged into its containing expression. You can use something other than @racket[\@] by overriding @racket[world:current-splicing-tag].
Splicing tag: signals that a list should be merged into its containing expression. You can use something other than @racket[\@] by overriding @racket[setup:splicing-tag].
@examples[#:eval my-eval
(module splicer pollen/markup
@ -55,9 +55,9 @@ Functions for retrieving data out of Pollen source files. These are not the only
(or/c txexpr? string?)]
Retrieve the @racket[doc] export from @racket[_doc-source], which can be either a path, path string, or pagenode that can be resolved into a source path. If @racket[_doc-source] cannot be resolved, raise an error.
If @racket[_doc-source] is a relative path or pagenode, it is treated as being relative to @racket[world:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
If @racket[_doc-source] is a relative path or pagenode, it is treated as being relative to @racket[setup:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
If @racket[world:current-main-export] has been overridden with a project-specific value, then that is retrieved instead.
If @racket[setup:main-export] has been overridden with a project-specific value, then that is retrieved instead.
@defproc[
@ -66,9 +66,9 @@ If @racket[world:current-main-export] has been overridden with a project-specifi
hash?]
Retrieve the @racket[metas] export from @racket[_meta-source], which can be either a path, path string, or pagenode that can be resolved into a source path. If @racket[_meta-source] cannot be resolved, raise an error.
If @racket[_meta-source] is a relative path or pagenode, it is treated as being relative to @racket[world:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
If @racket[_meta-source] is a relative path or pagenode, it is treated as being relative to @racket[setup:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
If @racket[world:current-meta-export] has been overridden with a project-specific value, then that is retrieved instead.
If @racket[setup:meta-export] has been overridden with a project-specific value, then that is retrieved instead.
@deftogether[(
@ -92,7 +92,7 @@ With @racket[select], you get the first result; with @racket[select*], you get t
In both cases, you get @racket[#f] if there are no matches.
Note that if @racket[_value-source] is a relative path or pagenode, it is treated as being relative to @racket[world:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
Note that if @racket[_value-source] is a relative path or pagenode, it is treated as being relative to @racket[setup:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
@examples[#:eval my-eval
(module nut-butters pollen/markup
@ -115,7 +115,7 @@ Note that if @racket[_value-source] is a relative path or pagenode, it is treate
(or/c #f (listof xexpr?))]
Look up the value of @racket[_key] in @racket[_doc-source]. The @racket[_doc-source] argument can be either 1) a tagged X-expression representing a @racket[doc] or 2) a pagenode or source path that identifies a source file that provides @racket[doc]. If no value exists for @racket[_key], you get @racket[#f].
Note that if @racket[_doc-source] is a relative path or pagenode, it is treated as being relative to @racket[world:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
Note that if @racket[_doc-source] is a relative path or pagenode, it is treated as being relative to @racket[setup:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
@examples[#:eval my-eval
(module gelato pollen/markup
@ -137,7 +137,7 @@ Note that if @racket[_doc-source] is a relative path or pagenode, it is treated
(or/c #f xexpr?)]
Look up the value of @racket[_key] in @racket[_meta-source]. The @racket[_meta-source] argument can be either 1) a hashtable representing @racket[metas] or 2) a pagenode or source path that identifies a source file that provides @racket[metas]. If no value exists for @racket[_key], you get @racket[#f].
Note that if @racket[_meta-source] is a relative path or pagenode, it is treated as being relative to @racket[world:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
Note that if @racket[_meta-source] is a relative path or pagenode, it is treated as being relative to @racket[setup:current-project-root]. If that's not what you want, you'll need to convert it explicitly to a complete-path (e.g., with @racket[path->complete-path] or @racket[->complete-path]).
@examples[#:eval my-eval
(define metas (hash 'template "sub.xml.pp" 'target "print"))

@ -1,6 +1,6 @@
#lang scribble/manual
@(require "mb-tools.rkt" scribble/eval pollen/decode pollen/world txexpr racket/string (for-label racket(except-in pollen #%module-begin) pollen/world pollen/cache pollen/decode txexpr xml))
@(require "mb-tools.rkt" scribble/eval pollen/decode pollen/setup txexpr racket/string (for-label racket(except-in pollen #%module-begin) pollen/setup pollen/cache pollen/decode txexpr xml))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/decode xml racket/list txexpr))
@ -241,7 +241,7 @@ Identical to @racket[decode], but takes @racket[txexpr-elements?] as input rathe
(block-txexpr?
[v any/c])
boolean?]
Predicate that tests whether @racket[_v] has a tag that is among the @racket[world:current-block-tags]. If not, it is treated as inline.
Predicate that tests whether @racket[_v] has a tag that is among the @racket[setup:block-tags]. If not, it is treated as inline.
This predicate affects the behavior of other functions. For instance, @racket[decode-paragraphs] knows that block elements in the markup shouldn't be wrapped in a @racket[p] tag. So if you introduce a new block element called @racket[bloq] without configuring it as a block, misbehavior will follow:
@ -251,13 +251,13 @@ This predicate affects the behavior of other functions. For instance, @racket[de
(code:comment @#,t{Wrong: bloq should not be wrapped})
]
To change how this test works, use a @racket[world] submodule as described in @secref["world-overrides"]:
To change how this test works, use a @racket[setup] submodule as described in @secref["setup-overrides"]:
@racketblock[
(module world racket/base
(module setup racket/base
(provide (all-defined-out))
(require pollen/world)
(define block-tags (cons 'bloq world:block-tags)))]
(require pollen/setup)
(define block-tags (cons 'bloq setup:default-block-tags)))]
After that change, the result will be:
@ -265,14 +265,14 @@ After that change, the result will be:
The default block tags are:
@racketidfont{@(string-join (map symbol->string world:block-tags) " ")}
@racketidfont{@(string-join (map symbol->string setup:default-block-tags) " ")}
@defproc[
(merge-newlines
[elements (listof xexpr?)])
(listof xexpr?)]
Within @racket[_elements], merge sequential newline characters into a single element. The newline string is controlled by @racket[world:current-newline], and defaults to @val[world:newline].
Within @racket[_elements], merge sequential newline characters into a single element. The newline string is controlled by @racket[setup:newline], and defaults to @val[setup:default-newline].
@examples[#:eval my-eval
(merge-newlines '(p "\n" "\n" "foo" "\n" "\n\n" "bar"
@ -286,7 +286,7 @@ Within @racket[_elements], merge sequential newline characters into a single ele
(listof xexpr?)]
Within @racket[_elements], convert occurrences of the linebreak separator to @racket[_linebreaker], but only if the separator does not occur between blocks (see @racket[block-txexpr?]). Why? Because block-level elements automatically display on a new line, so adding @racket[_linebreaker] would be superfluous. In that case, the linebreak separator just disappears.
The linebreak separator is controlled by @racket[world:current-linebreak-separator], and defaults to @val[world:linebreak-separator].
The linebreak separator is controlled by @racket[setup:linebreak-separator], and defaults to @val[setup:default-linebreak-separator].
The @racket[_linebreaker] argument can either be an X-expression, or a function that takes two X-expressions and returns one. This function will receive the previous and next elements, to make contextual substitution possible.
@ -308,7 +308,7 @@ Find paragraphs within @racket[_elements] and wrap them with @racket[_paragraph-
What counts as a paragraph? Any @racket[_elements] that are either a) explicitly set apart with a paragraph separator, or b) adjacent to a @racket[block-txexpr?] (in which case the paragraph-ness is implied).
The paragraph separator is controlled by @racket[world:current-paragraph-separator], and defaults to @val[world:paragraph-separator].
The paragraph separator is controlled by @racket[setup:paragraph-separator], and defaults to @val[setup:default-paragraph-separator].
@examples[#:eval my-eval
(decode-paragraphs '("Explicit para" "\n\n" "Explicit para"))

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval "mb-tools.rkt" pollen/render pollen/world (for-label racket (except-in pollen #%module-begin) pollen/world sugar pollen/file))
@(require scribble/eval "mb-tools.rkt" pollen/render pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/setup sugar pollen/file))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/file))
@ -15,22 +15,22 @@ Pollen handles six kinds of source files:
@itemlist[
@item{@bold{Preprocessor}, with file extension @ext[world:preproc-source-ext]}
@item{@bold{Preprocessor}, with file extension @ext[setup:default-preproc-source-ext]}
@item{@bold{Markup}, with file extension @ext[world:markup-source-ext]}
@item{@bold{Markup}, with file extension @ext[setup:default-markup-source-ext]}
@item{@bold{Markdown}, with file extension @ext[world:markdown-source-ext]}
@item{@bold{Markdown}, with file extension @ext[setup:default-markdown-source-ext]}
@item{@bold{Null}, with file extension @ext[world:null-source-ext]}
@item{@bold{Null}, with file extension @ext[setup:default-null-source-ext]}
@item{@bold{Scribble}, with file extension @ext[world:scribble-source-ext]}
@item{@bold{Scribble}, with file extension @ext[setup:default-scribble-source-ext]}
@item{@bold{Pagetree}, with file extension @ext[world:pagetree-source-ext]. This is the only source type that does not produce an output file.}
@item{@bold{Pagetree}, with file extension @ext[setup:default-pagetree-source-ext]. This is the only source type that does not produce an output file.}
]
The functions in this module rely on file extensions specified in @racketmodname[pollen/world]. These extensions can be overridden within a project — see @secref["world-overrides"].
The functions in this module rely on file extensions specified in @racketmodname[pollen/setup]. These extensions can be overridden within a project — see @secref["setup-overrides"].
For each kind of Pollen source file, the corresponding output file name is derived by removing the extension from the name of the source file. So the preprocessor source file @filepath{default.css.pp} would become @filepath{default.css}. (See
@secref["Saving___naming_your_source_file"] if this rings no bells.)
@ -170,7 +170,7 @@ In all cases, if there is no corresponding source, return @racket[#f].
path?]
Convert a source path @racket[_p] into its corresponding output path. This function simply generates a path for a file — it does not ask whether the file exists.
If @racket[_p] has a @seclink["The_poly_output_type"]{@id[world:poly-source-ext] output type}, then @racket[->output-path] uses @racket[world:current-poly-target] as the output-path extension.
If @racket[_p] has a @seclink["The_poly_output_type"]{@id[setup:default-poly-source-ext] output type}, then @racket[->output-path] uses @racket[setup:current-poly-target] as the output-path extension.
Otherwise, there are no type-specific variants for this function because the output path of a Pollen source file is @seclink["Saving___naming_your_source_file"]{determined by its name}.

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval pollen/render pollen/world (for-label racket (except-in pollen #%module-begin) pollen/world sugar pollen/pagetree))
@(require scribble/eval pollen/render pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/setup sugar pollen/pagetree))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/file))
@ -46,7 +46,7 @@ The second export, @racket[metas], is a hashtable of keyvalue pairs with extr
Pollen source files also make the @racket[metas] hashtable available through a submodule, also called @racket[metas]. So rather than importing a source file with @racket[(require "source.html.pm")], you would @racket[(require (submod "source.html.pm" metas))]. Accessing the metas this way avoids fully compiling the source file, and thus will usually be faster.
The names @racket[doc] and @racket[metas] can be changed for a project by overriding @racket[world:main-export] and @racket[world:meta-export].
The names @racket[doc] and @racket[metas] can be changed for a project by overriding @racket[setup:default-main-export] and @racket[setup:default-meta-export].
@margin-note{The Pollen rendering system relies on these two identifiers, but otherwise doesn't care how they're generated. Meaning, the code inside your Pollen source file could be @tt{#lang racket} or @tt{#lang whatever}. As long as you manually @racket[provide] those two identifiers and follow the usual file-naming convention, your source file will be usable.}
@ -65,9 +65,9 @@ If a file called @filepath{pollen.rkt} exists in the same directory with a sourc
@bold{How is this different from Racket?} In Racket, you must explicitly import files using @racket[require].
@subsection{Preprocessor (@(format ".~a" world:preproc-source-ext) extension)}
@subsection{Preprocessor (@(format ".~a" setup:default-preproc-source-ext) extension)}
Invoke the preprocessor dialect by using @code{#lang pollen/pre} as the first line of your source file, or by using @code{#lang pollen} with a file extension of @code{@(format ".~a" world:preproc-source-ext)}. These forms are equivalent:
Invoke the preprocessor dialect by using @code{#lang pollen/pre} as the first line of your source file, or by using @code{#lang pollen} with a file extension of @code{@(format ".~a" setup:default-preproc-source-ext)}. These forms are equivalent:
@racketmod[#:file "sample.css.pp" pollen
@ -90,9 +90,9 @@ The output of the preprocessor dialect, provided by @racket['doc], is plain text
@subsection{Markdown (@(format ".~a" world:markdown-source-ext) extension)}
@subsection{Markdown (@(format ".~a" setup:default-markdown-source-ext) extension)}
Invoke the Markdown dialect by using @code{#lang pollen/markdown} as the first line of your source file, or by using @code{#lang pollen} with a file extension of @code{@(format ".~a" world:markdown-source-ext)}. These forms are equivalent:
Invoke the Markdown dialect by using @code{#lang pollen/markdown} as the first line of your source file, or by using @code{#lang pollen} with a file extension of @code{@(format ".~a" setup:default-markdown-source-ext)}. These forms are equivalent:
@racketmod[#:file "sample.txt.pmd" pollen
@ -106,9 +106,9 @@ _...source...
The output of the Markdown dialect, provided by @racket[doc], is a tagged X-expression.
@subsection{Markup (@(format ".~a" world:markup-source-ext) extension)}
@subsection{Markup (@(format ".~a" setup:default-markup-source-ext) extension)}
Invoke the Pollen markup dialect by using @code{#lang pollen/markup} as the first line of your source file, or by using @code{#lang pollen} with a file extension of @code{@(format ".~a" world:markup-source-ext)}. These forms are equivalent:
Invoke the Pollen markup dialect by using @code{#lang pollen/markup} as the first line of your source file, or by using @code{#lang pollen} with a file extension of @code{@(format ".~a" setup:default-markup-source-ext)}. These forms are equivalent:
@racketmod[#:file "about.html.pm" pollen
@ -121,10 +121,10 @@ _...source...
The output of the Pollen markup dialect, provided by @racket[doc], is a tagged X-expression.
@subsection{Pagetree (@(format ".~a" world:pagetree-source-ext) extension)}
@subsection{Pagetree (@(format ".~a" setup:default-pagetree-source-ext) extension)}
Invoke the pagetree dialect by using @code{#lang pollen/ptree} as the first line of your source file, or by using @code{#lang pollen} with a file extension of @code{@(format ".~a" world:pagetree-source-ext)}. These forms are equivalent:
Invoke the pagetree dialect by using @code{#lang pollen/ptree} as the first line of your source file, or by using @code{#lang pollen} with a file extension of @code{@(format ".~a" setup:default-pagetree-source-ext)}. These forms are equivalent:
@racketmod[#:file "main.ptree" pollen
@ -148,12 +148,12 @@ These aren't source formats because they don't contain a @tt{#lang pollen} line.
@subsection{Scribble (@(format ".~a" world:scribble-source-ext) extension)}
@subsection{Scribble (@(format ".~a" setup:default-scribble-source-ext) extension)}
Scribble files are recognized by the project server and can be compiled and previewed in single-page mode.
@subsection{Null (@(format ".~a" world:null-source-ext) extension)}
@subsection{Null (@(format ".~a" setup:default-null-source-ext) extension)}
Files with the null extension are simply rendered as a copy of the file without the extension, so @filepath{index.html.p} becomes @filepath{index.html}.
@ -165,8 +165,8 @@ This can be useful you're managing your project with git. Most likely you'll wan
Pollen relies extensively on the convention of naming source files by adding a source extension to an output-file name. So the Pollen markup source for @filepath{index.html} would be @filepath{index.html.pm}.
This convention occasionally flummoxes other programs that assume a file can only have one extension. If you run into such a situation, you can @italic{escape} the output-file extension using the @racket[world:extension-escape-char], which defaults to the underscore @litchar{_}.
This convention occasionally flummoxes other programs that assume a file can only have one extension. If you run into such a situation, you can @italic{escape} the output-file extension using the @racket[setup:default-extension-escape-char], which defaults to the underscore @litchar{_}.
So instead of @filepath{index.html.pm}, your source-file name would be @filepath{index_html.pm}. When this source file is rendered, it will automatically be converted into @filepath{index.html} (meaning, the escaped extension will be converted into a normal file extension).
This alternative-naming scheme is automatically enabled in every project. You can also set the escape character on a per-project basis (see @racket[world:current-extension-escape-char]). Pollen will let you choose any character, but of course it would be unwise to pick one with special meaning in your filesystem (for instance, @litchar{/}).
This alternative-naming scheme is automatically enabled in every project. You can also set the escape character on a per-project basis (see @racket[setup:extension-escape-char]). Pollen will let you choose any character, but of course it would be unwise to pick one with special meaning in your filesystem (for instance, @litchar{/}).

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval pollen/render pollen/world (for-label racket (except-in pollen #%module-begin) pollen/world sugar))
@(require scribble/eval pollen/render pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/setup sugar))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/file))

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval pollen/render pollen/world (for-label racket (except-in pollen #%module-begin) pollen/world sugar))
@(require scribble/eval pollen/render pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/setup sugar))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/file))

@ -63,10 +63,11 @@
(define-syntax (defoverridable stx)
(syntax-case stx ()
[(_ name predicate? desc ...)
(with-syntax ([world:name (format-id stx "world:~a" #'name)]
[world:current-name (format-id stx "world:current-~a" #'name)])
#'(deftogether ((defthing world:name predicate?)
(defproc (world:current-name) predicate?))
(with-syntax ([setup:default-name (format-id stx "setup:default-~a" #'name)]
[setup:name (format-id stx "setup:~a" #'name)])
#'(deftogether ((defproc (setup:name) predicate?)
(defthing setup:default-name predicate?)
)
desc ...))]))
(define (val . args)

@ -10,7 +10,7 @@
@include-section["file.scrbl"]
@include-section["pagetree.scrbl"]
@include-section["render.scrbl"]
@include-section["setup.scrbl"]
@include-section["tag.scrbl"]
@include-section["template.scrbl"]
@include-section["top.scrbl"]
@include-section["world.scrbl"]

@ -1,6 +1,6 @@
#lang scribble/manual
@(require "mb-tools.rkt" scribble/eval pollen/cache pollen/world (for-label racket (except-in pollen #%module-begin) pollen/world txexpr pollen/decode pollen/file sugar pollen/pagetree))
@(require "mb-tools.rkt" scribble/eval pollen/cache pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/setup txexpr pollen/decode pollen/file sugar pollen/pagetree))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/pagetree txexpr))
@ -24,7 +24,7 @@ Pagetrees surface throughout the Pollen system. They're primarily used for navig
@section{Making pagetrees with a source file}
A pagetree source file either starts with @code{#lang pollen} and uses the @racketfont{@(format ".~a" world:pagetree-source-ext)} extension, or starts with @code{#lang pollen/ptree} and then can have any file extension.
A pagetree source file either starts with @code{#lang pollen} and uses the @racketfont{@(format ".~a" setup:default-pagetree-source-ext)} extension, or starts with @code{#lang pollen/ptree} and then can have any file extension.
Unlike other Pollen source files, since the pagetree source is not rendered into an output format, the rest of the filename is up to you.
@ -422,7 +422,7 @@ Return the pagenode immediately after @racket[_p]. For @racket[next*], return al
[pagetree-source pathish?])
pagetree?
]
Get a pagetree from a @ext[world:pagetree-source-ext] source file, namely @racket[_pagetree-source].
Get a pagetree from a @ext[setup:default-pagetree-source-ext] source file, namely @racket[_pagetree-source].
@defproc[
@ -456,7 +456,7 @@ Report whether @racket[_pagenode] is in @racket[_pagetree].
@defproc[
(path->pagenode
[p pathish?]
[starting-path pathish? (world:current-project-root)])
[starting-path pathish? (setup:current-project-root)])
pagenode?
]
Convert path @racket[_p] to a pagenode — meaning, make it relative to @racket[_starting-path], run it through @racket[->output-path], and convert it to a symbol. Does not tell you whether the resulting pagenode actually exists in the current pagetree (for that, use @racket[in-pagetree?]).

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval pollen/world (for-label racket (except-in pollen #%module-begin) pollen/world))
@(require scribble/eval pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/setup))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen))

@ -1,5 +1,5 @@
#lang scribble/manual
@(require scribble/eval (for-label pollen/unstable/pygments pollen/decode plot pollen/world pollen/tag racket/base pollen/template txexpr racket/list racket/string))
@(require scribble/eval (for-label pollen/unstable/pygments pollen/decode plot pollen/setup pollen/tag racket/base pollen/template txexpr racket/list racket/string))
@(require "mb-tools.rkt")
@(define my-eval (make-base-eval))

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval pollen/decode pollen/world txexpr (for-label txexpr racket (except-in pollen #%module-begin)))
@(require scribble/eval pollen/decode pollen/setup txexpr (for-label txexpr racket (except-in pollen #%module-begin)))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/unstable/pygments))

@ -1,6 +1,6 @@
#lang scribble/manual
@(require "mb-tools.rkt" scribble/eval pollen/world (for-label (except-in racket ...) pollen/world))
@(require "mb-tools.rkt" scribble/eval pollen/setup (for-label (except-in racket ...) pollen/setup))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/file))
@ -47,7 +47,7 @@ Displays a list of available commands.
@section{@exec{raco pollen start}}
Start the project server from the current directory using the default port, which is the value of the parameter @racket[world:current-server-port] (by default, port @(format "~a" world:default-port)).
Start the project server from the current directory using the default port, which is the value of the parameter @racket[setup:current-server-port] (by default, port @(format "~a" setup:default-default-port)).
This command can be invoked with two optional arguments.
@ -56,7 +56,7 @@ This command can be invoked with two optional arguments.
@terminal{
> raco pollen start ~/path/to/project/}
@racket[raco pollen start _path _port] will start the project server in @racket[_path] using @racket[_port] rather than @racket[world:current-server-port]. This is useful if you want to have multiple project servers running simultaneously.
@racket[raco pollen start _path _port] will start the project server in @racket[_path] using @racket[_port] rather than @racket[setup:current-server-port]. This is useful if you want to have multiple project servers running simultaneously.
@terminal{
> raco pollen start ~/path/to/project/
@ -88,7 +88,7 @@ Paths can also be specified as output rather than input paths, and the correspon
> raco pollen render foo.html
> raco pollen render foo.html bar.html zam.css}
The optional @exec{-t} or @exec{--target} switch specifies the render target for multi-output source files. If the target is omitted, the renderer will use whatever target appears first in @racket[(world:current-poly-targets)].
The optional @exec{-t} or @exec{--target} switch specifies the render target for multi-output source files. If the target is omitted, the renderer will use whatever target appears first in @racket[(setup:poly-targets)].
@terminal{
> raco pollen render -t pdf foo.poly.pm}
@ -107,7 +107,7 @@ Make a copy of the project directory on the desktop, but without any source file
If you're already in your project directory and want to publish somewhere other than the desktop, use @racket[raco pollen publish _. _dest-dir].
You can determine the files that get filtered out in a particular project by using @racket[world:current-unpublished-path?].
You can determine the files that get filtered out in a particular project by using @racket[setup:unpublished-path?].
@section{@exec{raco pollen setup}}

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval pollen/render pollen/world (for-label racket (except-in pollen #%module-begin) pollen/world pollen/core web-server/templates pollen/file sugar pollen/render))
@(require scribble/eval pollen/render pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/setup pollen/core web-server/templates pollen/file sugar pollen/render))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen))
@ -75,7 +75,7 @@ Note that @racket[_pt-or-pt-source] is used strictly as a list of files to rende
Find a template file for @racket[_source-path], with the following priority:
@itemlist[#:style 'ordered
@item{If the @racket[metas] for @racket[_source-path] have a key for @code[(format "~a" world:template-meta-key)], then use the value of this key, e.g. —
@item{If the @racket[metas] for @racket[_source-path] have a key for @code[(format "~a" setup:default-template-meta-key)], then use the value of this key, e.g. —
@code{◊(define-meta template "my-template.html")}
@ -88,7 +88,7 @@ If your project has @seclink["fourth-tutorial"]{multiple output targets}, you ca
}
@item{If this key doesn't exist, or refers to a nonexistent file, look for a default template with the name @code[(format "~a.[output extension]" world:default-template-prefix)]. Meaning, if @racket[_source-path] is @code[(format "intro.html.~a" world:markup-source-ext)], the output path would be @code["intro.html"], so the default template would be @code[(format "~a.html" world:default-template-prefix)]. Look for this default template in the same directory as the source file, and then search upwards within successive parent directories. (Corollary: a default template in the project root will apply to all files in the project unless overridden within a subdirectory.)}
@item{If this key doesn't exist, or refers to a nonexistent file, look for a default template with the name @code[(format "~a.[output extension]" setup:default-default-template-prefix)]. Meaning, if @racket[_source-path] is @code[(format "intro.html.~a" setup:default-markup-source-ext)], the output path would be @code["intro.html"], so the default template would be @code[(format "~a.html" setup:default-default-template-prefix)]. Look for this default template in the same directory as the source file, and then search upwards within successive parent directories. (Corollary: a default template in the project root will apply to all files in the project unless overridden within a subdirectory.)}
@item{If this file doesn't exist, use the fallback template as a last resort. (See @secref["Templates"
#:tag-prefixes '("tutorial-2")

@ -1,13 +1,13 @@
#lang scribble/manual
@(require "mb-tools.rkt")
@(require scribble/eval pollen/world racket/string (for-label racket (except-in pollen #%module-begin) pollen/world))
@(require scribble/eval pollen/setup racket/string (for-label racket (except-in pollen #%module-begin) pollen/setup))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/world))
@(my-eval `(require pollen pollen/setup))
@title{World}
@title{Setup}
@defmodule[pollen/world]
@defmodule[pollen/setup]
Global values that are used throughout the Pollen system.
@ -15,36 +15,36 @@ Global values that are used throughout the Pollen system.
I mean @italic{parameters} in the Racket sense, i.e. values that can be fed to @racket[parameterize].
@defparam[world:current-server-port port integer?]{
A parameter that sets the HTTP port for the project server. Initialized to @racket[world:default-port].}
@defparam[setup:current-server-port port integer?]{
A parameter that sets the HTTP port for the project server. Initialized to @racket[setup:default-default-port].}
@defparam[world:current-project-root port path?]{
@defparam[setup:current-project-root port path?]{
A parameter that holds the root directory of the current project (e.g., the directory where you launched @code{raco pollen start}).}
@defparam[world:current-server-extras-path dir path?]{
@defparam[setup:current-server-extras-path dir path?]{
A parameter that reports the path to the directory of support files for the project server. Initialized to @racket[#f], but set to a proper value when the server runs.}
@defparam[world:current-poly-target target symbol?]{
@defparam[setup:current-poly-target target symbol?]{
A parameter that reports the current rendering target for @racket[poly] source files. Initialized to @racket['html].}
@section[#:tag "world-overrides"]{World overrides}
@section[#:tag "setup-overrides"]{Setup overrides}
These values can be changed by overriding them in your @racket["pollen.rkt"] source file:
@itemlist[#:style 'ordered
@item{Within this file, @seclink["submodules" #:doc '(lib "scribblings/guide/guide.scrbl")]{create a submodule} called @racket[world].}
@item{Within this file, @seclink["submodules" #:doc '(lib "scribblings/guide/guide.scrbl")]{create a submodule} called @racket[setup].}
@item{Within this submodule, use @racket[define] to make a variable with the same name as the one in @racket[pollen/world], but without the @racket[world:] prefix.}
@item{Within this submodule, use @racket[define] to make a variable with the same name as the one in @racket[pollen/setup], but without the @racket[setup:] prefix.}
@item{Assign it whatever value you like.}
@item{Repeat as needed.}
]
When Pollen runs, these definitions will supersede those in @racket[pollen/world].
When Pollen runs, these definitions will supersede those in @racket[pollen/setup].
For instance, suppose you wanted the main export of every Pollen source file to be called @racket[van-halen] rather than @racket[doc], the extension of Pollen markup files to be @racket[.rock] rather than @racket[.pm], and the command character to be @litchar{🎸} instead of @litchar{◊}. Your @racket["pollen.rkt"] would look like this:
@ -54,18 +54,18 @@ For instance, suppose you wanted the main export of every Pollen source file to
;; ... the usual definitions and tag functions ...
(module world racket/base
(module setup racket/base
(provide (all-defined-out))
(define main-export 'van-halen)
(define markup-source-ext 'rock)
(define command-char #\🎸))
}]
Though any of the values below can be overridden, it may not always be wise to do so. For instance, if you redefined @racket[world:fallback-template-prefix], you would simply break the fallback-template mechanism, because it would look for files that don't exist. But we don't live in a nanny state, so you are entrusted to say what you mean and accept the consequences.
Though any of the values below can be overridden, it may not always be wise to do so. For instance, if you redefined @racket[setup:default-fallback-template-prefix], you would simply break the fallback-template mechanism, because it would look for files that don't exist. But we don't live in a nanny state, so you are entrusted to say what you mean and accept the consequences.
Of course, you can restore the defaults simply by removing these defined values from @racket["pollen.rkt"].
These values are each equipped with a corresponding @racket[world:current-]@racket[_name] function that will return the value loaded from the @racket[world] submodule (if @racket[_name] was defined there), otherwise it returns the original value for @racket[world:]@racket[_name]. For instance, @racket[world:command-char] will always be @litchar{◊}, but in the example above, @racket[world:current-command-char] would return @litchar{🎸}.
These values are each equipped with a corresponding @racket[setup:]@racket[_name] function that will return the value loaded from the @racket[setup] submodule (if @racket[_name] was defined there), otherwise it returns the original value for @racket[setup:]@racket[_name]. For instance, @racket[setup:default-command-char] will always be @litchar{◊}, but in the example above, @racket[setup:command-char] would return @litchar{🎸}.
@defoverridable[default-port integer?]{
@ -94,13 +94,13 @@ Determines the default HTTP port for the project server. Initialized to @racket[
)]
File extensions for Pollen source files, initialized to the following values:
@racket[world:preproc-source-ext] = @code[(format "'~a" world:preproc-source-ext)]
@(linebreak)@racket[world:markup-source-ext] = @code[(format "'~a" world:markup-source-ext)]
@(linebreak)@racket[world:markdown-source-ext] = @code[(format "'~a" world:markdown-source-ext)]
@(linebreak)@racket[world:null-source-ext] = @code[(format "'~a" world:null-source-ext)]
@(linebreak)@racket[world:pagetree-source-ext] = @code[(format "'~a" world:pagetree-source-ext)]
@(linebreak)@racket[world:template-source-ext] = @code[(format "'~a" world:template-source-ext)]
@(linebreak)@racket[world:scribble-source-ext] = @code[(format "'~a" world:scribble-source-ext)]
@racket[setup:default-preproc-source-ext] = @code[(format "'~a" setup:default-preproc-source-ext)]
@(linebreak)@racket[setup:default-markup-source-ext] = @code[(format "'~a" setup:default-markup-source-ext)]
@(linebreak)@racket[setup:default-markdown-source-ext] = @code[(format "'~a" setup:default-markdown-source-ext)]
@(linebreak)@racket[setup:default-null-source-ext] = @code[(format "'~a" setup:default-null-source-ext)]
@(linebreak)@racket[setup:default-pagetree-source-ext] = @code[(format "'~a" setup:default-pagetree-source-ext)]
@(linebreak)@racket[setup:default-template-source-ext] = @code[(format "'~a" setup:default-template-source-ext)]
@(linebreak)@racket[setup:default-scribble-source-ext] = @code[(format "'~a" setup:default-scribble-source-ext)]
@defoverridable[decodable-extensions (listof symbol?)]{File extensions that are eligible for decoding.}
@ -116,9 +116,9 @@ File extensions for Pollen source files, initialized to the following values:
@defoverridable[block-tags (listof symbol?)]{Tags that are treated as blocks by @racket[block-txexpr?]. Initialized to the @link["https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements"]{block-level elements in HTML5}, namely:
@racketidfont{@(string-join (map symbol->string (cdr world:block-tags)) " ")}
@racketidfont{@(string-join (map symbol->string (cdr setup:default-block-tags)) " ")}
... plus @racket[world:current-main-root-node].}
... plus @racket[setup:main-root-node].}
@ -153,7 +153,7 @@ Default separators used in decoding. The first two are initialized to @racket["\
@defoverridable[here-path-key symbol?]{Key used to store the absolute path of the current source file in its @racket[metas] hashtable. Default is @racket['here-path].}
@defoverridable[splicing-tag symbol?]{Key used to signal that an X-expression should be spliced into its containing X-expression. Default is @val[world:splicing-tag].}
@defoverridable[splicing-tag symbol?]{Key used to signal that an X-expression should be spliced into its containing X-expression. Default is @val[setup:default-splicing-tag].}
@defoverridable[poly-source-ext symbol?]{Extension that indicates a source file can target multiple output types. Default is @racket['poly].}

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval pollen/cache pollen/world (for-label racket (except-in pollen #%module-begin) txexpr pollen/tag pollen/render xml pollen/pagetree))
@(require scribble/eval pollen/cache pollen/setup (for-label racket (except-in pollen #%module-begin) txexpr pollen/tag pollen/render xml pollen/pagetree))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/template xml))

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval pollen/cache pollen/world (for-label racket (except-in pollen #%module-begin) pollen/render txexpr xml pollen/pagetree sugar/coerce pollen/template pollen/template/html pollen/world))
@(require scribble/eval pollen/cache pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/render txexpr xml pollen/pagetree sugar/coerce pollen/template pollen/template/html pollen/setup))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/template pollen/template/html xml))

@ -1,9 +1,9 @@
#lang scribble/manual
@(require scribble/eval pollen/cache pollen/world (for-label racket (except-in pollen #%module-begin) pollen/world pollen/tag))
@(require scribble/eval pollen/cache pollen/setup (for-label racket (except-in pollen #%module-begin) pollen/setup pollen/tag))
@(define my-eval (make-base-eval))
@(my-eval `(require pollen pollen/world))
@(my-eval `(require pollen pollen/setup))
@title{Top}

@ -1,6 +1,6 @@
#lang scribble/manual
@(require (for-label pollen/world racket) "mb-tools.rkt")
@(require (for-label pollen/setup racket) "mb-tools.rkt")
@title[#:tag "first-tutorial"]{First tutorial: the project server & preprocessor}
@ -234,7 +234,7 @@ Though port @tt{8080} is the default, you can start the project server on any po
> raco pollen start /path/to/tutorial 8088
}
@margin-note{You can also change the default port by altering @racket[world:default-port], or parameterizing it with @racket[world:current-server-port].}
@margin-note{You can also change the default port by altering @racket[setup:default-default-port], or parameterizing it with @racket[setup:current-server-port].}
Note that when you pass a port argument, you also have to pass a path argument. (Without it, you'll get an error, as illustrated below.) If you want the project server to start in the current directory, you can use the usual @litchar{.} shorthand:

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval racket/date (for-label pollen/core racket/file racket/system pollen/decode plot pollen/world pollen/tag racket/base pollen/template txexpr racket/list racket/string pollen/render))
@(require scribble/eval racket/date (for-label pollen/core racket/file racket/system pollen/decode plot pollen/setup pollen/tag racket/base pollen/template txexpr racket/list racket/string pollen/render))
@(require "mb-tools.rkt")
@(define my-eval (make-base-eval))
@ -16,7 +16,7 @@ In previous tutorial projects, we've maintained a one-to-one relationship betwee
@item{Setting up & using @tt{poly} source files}
@item{The @tt{world} submodule}
@item{The @tt{setup} submodule}
@item{Branching tag functions}
@ -83,7 +83,7 @@ In the previous tutorials, you saw how Pollen source files correspond to certain
In a multiple-output project, a source file no longer has a one-to-one correspondence with a specific output type. To indicate this, we'll instead use the special @tt{poly} extension. So our @filepath{document.html.pm} will become @filepath{document.poly.pm}.
@margin-note{The @tt{poly} extension is the default, but can be changed for a project by using the @racket[world:current-poly-source-ext] setting.}
@margin-note{The @tt{poly} extension is the default, but can be changed for a project by using the @racket[setup:poly-source-ext] setting.}
Let's set up a new multi-output project for a résumé. Find a convenient directory and create a new @tt{poly} source file as follows:
@ -142,11 +142,11 @@ Today is @(date->string (current-date)). I @bold{really} want this job.
Though Pollen imputes HTML as a target for poly sources by default, if you only wanted HTML, you wouldn't be using a poly source. So our next step will be to explicitly define the output targets that we want to associate with poly sources.
@subsubsection{Using the @tt{world} submodule}
@subsubsection{Using the @tt{setup} submodule}
We'll do this by setting the @racket[world:current-poly-targets] value in our @filepath{pollen.rkt}. If you haven't investigated it yet, the @racket[pollen/world] module offers @seclink["world-overrides"] that allow you to configure certain Pollen characteristics from within a @filepath{pollen.rkt} file. The example on that page, for instance, shows how to change the markup source extension and the Pollen command character.
We'll do this by setting the @racket[setup:poly-targets] value in our @filepath{pollen.rkt}. If you haven't investigated it yet, the @racket[pollen/setup] module offers @seclink["setup-overrides"] that allow you to configure certain Pollen characteristics from within a @filepath{pollen.rkt} file. The example on that page, for instance, shows how to change the markup source extension and the Pollen command character.
The idea is that you add a @racket[world] submodule to your @filepath{pollen.rkt} file with a @racket[define] statement for the value. Because we're defining the local value, we drop the @racket[world:current-] prefix and just call it @racket[poly-targets]. Our value will be a list of file extensions denoting the targets. To start, let's set our output formats to HTML and plain text, which we'll denote with the list of extensions @racket['(html txt)].
The idea is that you add a @racket[setup] submodule to your @filepath{pollen.rkt} file with a @racket[define] statement for the value. Because we're defining the local value, we drop the @racket[setup:] prefix and just call it @racket[poly-targets]. Our value will be a list of file extensions denoting the targets. To start, let's set our output formats to HTML and plain text, which we'll denote with the list of extensions @racket['(html txt)].
@margin-note{I'm glossing over the details of @seclink["submodules" #:doc '(lib "scribblings/guide/guide.scrbl")], but they're one of the best-considered features of the Racket language. What makes submodules so handy is that they are truly independent: you can load a submodule from a source file without running the main body of the file. Thus, tasks like this — setting configuration values — that might require separate files in other languages can be handled as submodules in Racket.}
@ -155,7 +155,7 @@ The idea is that you add a @racket[world] submodule to your @filepath{pollen.rkt
(require racket/date)
(provide (all-defined-out))
(module config racket/base
(module setup racket/base
(provide (all-defined-out))
(define poly-targets '(html txt)))
@ -173,7 +173,7 @@ Though you ordinarily don't have to restart the project server to see changes in
@image/rp["poly-ps-html-txt.png" #:scale 0.45]
What's happened is that @racket[world:current-poly-targets] now reflects the settings in @filepath{pollen.rkt}. The project server sees that we want to associate poly files with HTML and plain-text targets, and accordingly shows us two entries in the project-server listing: @filepath{cv.html.pm} and @filepath{cv.txt.pm}. As the adjacent message indicates, these are not new source files on disk, but rather implied by @filepath{cv.poly.pm}.
What's happened is that @racket[setup:poly-targets] now reflects the settings in @filepath{pollen.rkt}. The project server sees that we want to associate poly files with HTML and plain-text targets, and accordingly shows us two entries in the project-server listing: @filepath{cv.html.pm} and @filepath{cv.txt.pm}. As the adjacent message indicates, these are not new source files on disk, but rather implied by @filepath{cv.poly.pm}.
If you click on @filepath{cv.html.pm}, you'll see the same HTML output that you saw before. If you click on @filepath{cv.txt.pm}, however, you'll see this:
@ -221,14 +221,14 @@ But plain text doesn't have @racket[h2] or @racket[strong]. So how about this: w
``So how do we make our tags mean one thing for HTML and a different thing for plain text?'' We make @italic{branching tag functions} that do different things depending on what the current rendering target for poly sources is.
That value, in fact, is stored in a Pollen @seclink["parameterize" #:doc '(lib "scribblings/guide/guide.scrbl")]{parameter} called @racket[(world:current-poly-target)]. What we're going to do is rewrite our tag functions to behave differently based on the value of this parameter. Update your @filepath{pollen.rkt} as follows:
That value, in fact, is stored in a Pollen @seclink["parameterize" #:doc '(lib "scribblings/guide/guide.scrbl")]{parameter} called @racket[(setup:current-poly-target)]. What we're going to do is rewrite our tag functions to behave differently based on the value of this parameter. Update your @filepath{pollen.rkt} as follows:
@fileblock["pollen.rkt" @codeblock|{
#lang racket/base
(require racket/date pollen/world)
(require racket/date pollen/setup)
(provide (all-defined-out))
(module config racket/base
(module setup racket/base
(provide (all-defined-out))
(define poly-targets '(html txt)))
@ -236,12 +236,12 @@ That value, in fact, is stored in a Pollen @seclink["parameterize" #:doc '(lib "
(date->string (current-date)))
(define (heading . xs)
(case (world:current-poly-target)
(case (setup:current-poly-target)
[(txt) (map string-upcase xs)]
[else `(h2 ,@xs)]))
(define (emph . xs)
(case (world:current-poly-target)
(case (setup:current-poly-target)
[(txt) `("**" ,@xs "**")]
[else `(strong ,@xs)]))
}|]
@ -269,10 +269,10 @@ Let's see how fast we can add support for LaTeX output. Here's the updated @file
@fileblock["pollen.rkt" @codeblock|{
#lang racket/base
(require racket/date pollen/world)
(require racket/date pollen/setup)
(provide (all-defined-out))
(module config racket/base
(module setup racket/base
(provide (all-defined-out))
(define poly-targets '(html txt ltx)))
@ -280,13 +280,13 @@ Let's see how fast we can add support for LaTeX output. Here's the updated @file
(date->string (current-date)))
(define (heading . xs)
(case (world:current-poly-target)
(case (setup:current-poly-target)
[(ltx) (apply string-append `("{\\huge " ,@xs "}"))]
[(txt) (map string-upcase xs)]
[else `(h2 ,@xs)]))
(define (emph . xs)
(case (world:current-poly-target)
(case (setup:current-poly-target)
[(ltx) (apply string-append `("{\\bf " ,@xs "}"))]
[(txt) `("**" ,@xs "**")]
[else `(strong ,@xs)]))
@ -332,10 +332,10 @@ First, we update @filepath{pollen.rkt}:
@fileblock["pollen.rkt" @codeblock|{
#lang racket/base
(require racket/date pollen/world)
(require racket/date pollen/setup)
(provide (all-defined-out))
(module config racket/base
(module setup racket/base
(provide (all-defined-out))
(define poly-targets '(html txt ltx pdf)))
@ -343,13 +343,13 @@ First, we update @filepath{pollen.rkt}:
(date->string (current-date)))
(define (heading . xs)
(case (world:current-poly-target)
(case (setup:current-poly-target)
[(ltx pdf) (apply string-append `("{\\huge " ,@xs "}"))]
[(txt) (map string-upcase xs)]
[else `(h2 ,@xs)]))
(define (emph . xs)
(case (world:current-poly-target)
(case (setup:current-poly-target)
[(ltx pdf) (apply string-append `("{\\bf " ,@xs "}"))]
[(txt) `("**" ,@xs "**")]
[else `(strong ,@xs)]))

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval (for-label pollen/unstable/pygments pollen/decode plot pollen/world pollen/tag racket/base pollen/template txexpr racket/list racket/string))
@(require scribble/eval (for-label pollen/unstable/pygments pollen/decode plot pollen/setup pollen/tag racket/base pollen/template txexpr racket/list racket/string))
@(require "mb-tools.rkt")
@(define my-eval (make-base-eval))

@ -1,6 +1,6 @@
#lang scribble/manual
@(require (for-label racket/base pollen/world pollen/template pollen/pagetree sugar))
@(require (for-label racket/base pollen/setup pollen/template pollen/pagetree sugar))
@(require "mb-tools.rkt")
@ -165,7 +165,7 @@ Skipping past a few boring details, that's basically all there is to it.
So why is it called an X-expression? Lisp languages are built out of units called S-expressions, which look like this:
@terminal{(and (txexpr? x) (memq (get-tag x) (world:current-block-tags)) #t))}
@terminal{(and (txexpr? x) (memq (get-tag x) (setup:block-tags)) #t))}
S-expressions use prefix notation, where each pair of parentheses contains a list. The first element in the list names a function, and the other elements are the arguments to that function. (This is a review of @secref["Racket_basics__if_you_re_not_familiar_"].) X-expressions are just a minor adaptation of S-expression notation to represent markup, hence the name (the @defterm{X} is short for @defterm{XML-like}).
@ -336,7 +336,7 @@ But within a template, we need to tell Pollen how we want to convert the X-expre
Third, we need to include the content from our source file. By convention, every Pollen source file makes its output available through an exported variable named @code{doc}. A source file in preprocessor mode puts its text result in @code{doc}. And a source file in authoring mode puts its X-expression result in @code{doc}. So we put the variable @code{doc} inside the @code{body} tag.
@margin-note{You can change the name to something other than @code{doc} by changing @racket[world:main-export].}
@margin-note{You can change the name to something other than @code{doc} by changing @racket[setup:default-main-export].}
@codeblock[#:keep-lang-line? #f]{
#lang pollen

@ -1,6 +1,6 @@
#lang scribble/manual
@(require scribble/eval (for-label pollen/decode plot pollen/world pollen/tag racket/base pollen/template txexpr racket/list racket/string))
@(require scribble/eval (for-label pollen/decode plot pollen/setup pollen/tag racket/base pollen/template txexpr racket/list racket/string))
@(require "mb-tools.rkt")
@(define my-eval (make-base-eval))

File diff suppressed because one or more lines are too long

@ -2,15 +2,15 @@
(require (for-syntax racket/base racket/syntax) "private/version.rkt")
(require racket/runtime-path)
(provide (prefix-out world: (combine-out (all-defined-out) (all-from-out "private/version.rkt"))))
(provide (prefix-out setup: (combine-out (all-defined-out) (all-from-out "private/version.rkt"))))
(define current-project-root (make-parameter (current-directory)))
(define directory-require "pollen.rkt")
(define env-name "POLLEN")
(define default-directory-require "pollen.rkt")
(define default-env-name "POLLEN")
(define (get-path-to-override [file-or-dir (current-directory)])
(define file-with-config-submodule directory-require)
(define file-with-config-submodule default-directory-require)
(define (dirname path)
(let-values ([(dir name dir?) (split-path path)])
dir))
@ -24,21 +24,21 @@
;; parameters should not be made settable.
(define-for-syntax world-submodule-name 'world)
(define-for-syntax world-submodule-name 'setup)
(define-syntax (define-settable stx)
(syntax-case stx ()
[(_ name default-value)
(with-syntax ([base-name (format-id stx "~a" #'name)]
[current-name (format-id stx "current-~a" #'name)]
(with-syntax ([default-name (format-id stx "default-~a" #'name)]
[name-thunked (format-id stx "~a" #'name)]
[world-submodule (format-id stx "~a" world-submodule-name)]
[fail-thunk-name (format-id stx "fail-thunk-~a" #'name)] )
[name-fail-thunked (format-id stx "fail-thunk-~a" #'name)] )
#'(begin
(define base-name default-value)
(define fail-thunk-name (λ _ base-name))
(define default-name default-value)
(define name-fail-thunked (λ _ default-name))
;; can take a dir argument that sets start point for (get-path-to-override) search.
(define current-name (λ get-path-args
(with-handlers ([exn:fail? fail-thunk-name])
(dynamic-require `(submod ,(apply get-path-to-override get-path-args) world-submodule) 'base-name fail-thunk-name))))))]))
(define name-thunked (λ get-path-args
(with-handlers ([exn:fail? name-fail-thunked])
(dynamic-require `(submod ,(apply get-path-to-override get-path-args) world-submodule) 'name name-fail-thunked))))))]))
(define-settable preproc-source-ext 'pp)
(define-settable markup-source-ext 'pm)
@ -49,20 +49,20 @@
(define-settable scribble-source-ext 'scrbl)
;; these are deliberately not settable because they're just internal signalers, no effect on external interface
(define mode-auto 'auto)
(define mode-preproc 'pre)
(define mode-markup 'markup)
(define mode-markdown 'markdown)
(define mode-pagetree 'ptree)
(define mode-template 'template)
(define default-mode-auto 'auto)
(define default-mode-preproc 'pre)
(define default-mode-markup 'markup)
(define default-mode-markdown 'markdown)
(define default-mode-pagetree 'ptree)
(define default-mode-template 'template)
(define-settable cache-filename "pollen.cache")
(define-settable cache-dir-name "pollen-cache")
(define cache-names (list (current-cache-filename) (current-cache-dir-name)))
(define default-cache-names (list (cache-filename) (cache-dir-name)))
(define-settable decodable-extensions (list (current-markup-source-ext) (current-pagetree-source-ext)))
(define-settable decodable-extensions (list (markup-source-ext) (pagetree-source-ext)))
(define-settable default-pagetree (format "index.~a" (current-pagetree-source-ext)))
(define-settable default-pagetree (format "index.~a" (pagetree-source-ext)))
(define-settable pagetree-root-node 'pagetree-root)
(define-settable main-root-node 'root)
@ -79,10 +79,10 @@
(define-settable define-meta-name 'define-meta)
;; tags from https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
(define-settable block-tags (cons (current-main-root-node) '(address article aside blockquote body canvas dd div dl fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hgroup hr li main nav noscript ol output p pre section table tfoot ul video)))
(define-settable block-tags (cons (main-root-node) '(address article aside blockquote body canvas dd div dl fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hgroup hr li main nav noscript ol output p pre section table tfoot ul video)))
(define-settable newline "\n")
(define-settable linebreak-separator (current-newline))
(define-settable linebreak-separator (newline))
(define-settable paragraph-separator "\n\n")
(define-settable paths-excluded-from-dashboard (map string->path (list "poldash.css" "compiled")))
@ -90,7 +90,7 @@
(define-settable default-port 8080)
(define current-server-port (make-parameter (current-default-port)))
(define current-server-port (make-parameter (default-port)))
(define-settable dashboard-css "poldash.css")
@ -113,4 +113,4 @@
(define-settable poly-source-ext 'poly) ; extension that signals source can be used for multiple output targets
(define-settable poly-targets '(html)) ; current target applied to multi-output source files
(define current-poly-target (make-parameter (car (current-poly-targets))))
(define current-poly-target (make-parameter (car (poly-targets))))

@ -1,7 +1,7 @@
#lang racket/base
(provide (all-defined-out))
(module world racket/base
(module setup racket/base
(provide (all-defined-out))
(define compile-cache-active #f)
(define extension-escape-char #\$))

@ -4,7 +4,7 @@
(define (root . xs)
`(rootover ,@xs))
(module world racket/base
(module setup racket/base
(provide (all-defined-out))
(define preproc-source-ext 'ppover)

@ -1,5 +1,5 @@
#lang racket/base
(module world racket/base
(module setup racket/base
(provide (all-defined-out))
(define command-char #\∆))

@ -1,18 +1,18 @@
#lang racket/base
(require pollen/world)
(require pollen/setup)
(provide (all-defined-out))
(module world racket/base
(module setup racket/base
(provide (all-defined-out))
(define poly-targets '(html txt))
(define compile-cache-active #f))
(define (heading . xs)
(case (world:current-poly-target)
(case (setup:current-poly-target)
[(txt) (map string-upcase xs)]
[else `(h2 ,@xs)]))
(define (emph . xs)
(case (world:current-poly-target)
(case (setup:current-poly-target)
[(txt) `("**" ,@xs "**")]
[else `(strong ,@xs)]))

@ -1,8 +1,8 @@
#lang racket/base
(require pollen/world)
(require pollen/setup)
(provide (all-defined-out))
(module world racket/base
(module setup racket/base
(provide (all-defined-out))
(define poly-targets '(html txt))
(define compile-cache-active #f))

@ -1,5 +1,5 @@
#lang at-exp racket/base
(require rackunit racket/port racket/system racket/runtime-path compiler/find-exe pollen/world)
(require rackunit racket/port racket/system racket/runtime-path compiler/find-exe pollen/setup)
;; define-runtime-path only allowed at top level
(define-runtime-path override-dir "data/override")
@ -21,7 +21,7 @@
(define racket-path (find-exe))
;; parameterize needed to pick up override file
(parameterize ([current-directory override-dir]
[world:current-project-root override-dir])
[setup:current-project-root override-dir])
(when racket-path
(define (run path)
(define cmd-string (format "'~a' ~a" racket-path path))

@ -1,10 +1,10 @@
#lang at-exp racket/base
(require rackunit pollen/world racket/runtime-path)
(require rackunit pollen/setup racket/runtime-path)
;; define-runtime-path only allowed at top level
(define-runtime-path test-dir "data/pollen-mode")
(define-runtime-path test-source "data/pollen-mode/test-pollen-mode.foo")
(parameterize ([current-directory test-dir]
[world:current-project-root test-dir])
[setup:current-project-root test-dir])
(check-equal? ((dynamic-require test-source 'proc)) "fooXbarXzam"))

@ -1,14 +1,14 @@
#lang at-exp racket/base
(require rackunit pollen/world racket/runtime-path pollen/render)
(require rackunit pollen/setup racket/runtime-path pollen/render)
;; define-runtime-path only allowed at top level
(define-runtime-path poly-dir "data/poly")
(define-runtime-path poly-source "data/poly/test.poly.pm")
(parameterize ([current-directory poly-dir]
[world:current-project-root poly-dir]
[setup:current-project-root poly-dir]
[current-output-port (open-output-string)])
(parameterize ([world:current-poly-target 'txt])
(parameterize ([setup:current-poly-target 'txt])
(check-equal? (render poly-source) "TITLE is **big**"))
(parameterize ([world:current-poly-target 'html])
(parameterize ([setup:current-poly-target 'html])
(check-equal? (render poly-source) (format "~v" '(root (h2 "title") " is " (strong "big"))))))

@ -1,5 +1,5 @@
#lang at-exp racket/base
(require rackunit racket/runtime-path pollen/render racket/file pollen/world)
(require rackunit racket/runtime-path pollen/render racket/file pollen/setup)
;; define-runtime-path only allowed at top level
(define-runtime-path quick-tour-dir "data/quick-tour/")
@ -20,7 +20,7 @@
;; test makes sure that quick tour files work
(parameterize ([current-output-port (open-output-string)]
[current-directory quick-tour-dir]
[world:current-project-root quick-tour-dir])
[setup:current-project-root quick-tour-dir])
(check-not-exn (λ _ (render-to-file-if-needed hello.txt.pp)))
(check-not-exn (λ _ (render-to-file-if-needed margin.html.pp)))
(check-not-exn (λ _ (render-to-file-if-needed downtown.html.pmd)))

@ -1,5 +1,5 @@
#lang at-exp racket/base
(require rackunit racket/runtime-path pollen/render racket/file racket/system pollen/world)
(require rackunit racket/runtime-path pollen/render racket/file racket/system pollen/setup)
;; define-runtime-path only allowed at top level
(define-runtime-path rerequire-dir "data/rerequire")
@ -16,7 +16,7 @@
;; test makes sure that file render changes after pollen.rkt changes
(parameterize ([current-output-port (open-output-string)]
[current-directory rerequire-dir]
[world:current-project-root rerequire-dir])
[setup:current-project-root rerequire-dir])
(display-to-file @string-append{#lang racket/base
(provide id)

@ -1,5 +1,5 @@
#lang at-exp racket/base
(require rackunit pollen/world racket/runtime-path pollen/render)
(require rackunit pollen/setup racket/runtime-path pollen/render)
;; define-runtime-path only allowed at top level
(define-runtime-path subtemplate-dir "data/subtemplate")
@ -8,7 +8,7 @@
(define-runtime-path three-source "data/subtemplate/subdir/subsubdir/three.txt.pm")
(parameterize ([current-directory subtemplate-dir]
[world:current-project-root subtemplate-dir]
[setup:current-project-root subtemplate-dir]
[current-output-port (open-output-string)])
(check-equal? (render one-source) "one in main template")
(check-equal? (render two-source) "two in main template")

@ -1,5 +1,5 @@
#lang racket/base
(require sugar txexpr racket/list racket/string pollen/world xml html racket/file racket/match "html.rkt" net/url racket/port)
(require sugar txexpr racket/list racket/string pollen/setup xml html racket/file racket/match "html.rkt" net/url racket/port)
(define (attrs->pollen attrs)
(string-join (flatten (map (λ(pair) (list (format "'~a:" (car pair)) (format "\"~a\"" (cadr pair)))) attrs)) " "))
@ -12,7 +12,7 @@
(cond
[(and p-breaks (txexpr? x) (equal? (car x) 'p) (apply string-append `("\n" ,@(map ->string (map loop (get-elements x))) "\n")))]
[(txexpr? x) (apply string-append
(map ->string `(,(world:current-command-char) ,(get-tag x)
(map ->string `(,(setup:command-char) ,(get-tag x)
,@(if (not (null? (get-attrs x))) `("[" ,(attrs->pollen (get-attrs x)) "]") null)
,@(if (not (null? (get-elements x))) `("{" ,@(map loop (get-elements x)) "}" ) null))))]
[(symbol? x) (loop (entity->integer x))]

@ -1,5 +1,5 @@
#lang racket/base
(require (for-syntax racket/base "../world.rkt"))
(require (for-syntax racket/base "../setup.rkt"))
(require racket/list sugar/define sugar/test txexpr racket/match sugar/container sugar/coerce sugar/len racket/string "../private/to-string.rkt" )
(define (make-replacer query+replacement)

Loading…
Cancel
Save