make sure world settables can start in the right place

pull/102/head
Matthew Butterick 9 years ago
parent f83ca11dee
commit efe3a51843

@ -144,9 +144,11 @@
(when (not (file-exists? path))
(error (format "cached-require: ~a does not exist" path)))
(define-values (path-dir path-name _) (split-path path))
(cond
[(world:current-compile-cache-active)
[(world:current-compile-cache-active path-dir)
(define key (paths->key path))
(hash-ref (hash-ref! ram-cache key (λ _
(cache-ref! key (λ _ (path->hash path))))) subkey)]

@ -105,6 +105,8 @@
(cond
[(not (file-exists? output-path)) 'file-missing]
[(mod-date-missing-or-changed? source-path template-path) 'mod-key-missing-or-changed]
[(let-values ([(source-dir source-name _) (split-path source-path)])
(not (world:current-render-cache-active source-dir))) 'render-cache-deactivated]
[else #f]))

@ -120,6 +120,8 @@ Default separators used in decoding. The first two are initialized to @racket["\
@defoverridable[paths-excluded-from-dashboard (listof path?)]{Paths not shown in the Pollen dashboard.}
@defoverridable[render-cache-active boolean?]{Whether the render cache, which speeds up interactive sessions by reusing rendered versions of Pollen output files, is active. Default is active (@racket[#t]).}
@defoverridable[compile-cache-active boolean?]{Whether the compile cache, which speeds up interactive sessions by saving compiled versions of Pollen source files, is active. Default is active (@racket[#t]).}
@defoverridable[compile-cache-max-size exact-positive-integer?]{Maximum size of the compile cache. Default is 10 megabytes.}

@ -8,14 +8,17 @@
(define directory-require "pollen.rkt")
(define (get-path-to-override)
(define (get-path-to-override [starting-dir (current-directory)])
;; for now, let `path->complete-path` flag any argument errors (test here is redundant)
#;(when (or (not (path? starting-dir)) (not (directory-exists? starting-dir)))
(error 'get-path-to-override (format "~a is not a directory" starting-dir)))
(define file-with-config-submodule directory-require)
(define (dirname path)
(let-values ([(dir name dir?) (split-path path)])
dir))
(let loop ([dir (current-directory)][path file-with-config-submodule])
(let loop ([dir starting-dir][path file-with-config-submodule])
(and dir ; dir is #f when it hits the top of the filesystem
(let ([completed-path (path->complete-path path)])
(let ([completed-path (path->complete-path path starting-dir)])
(if (file-exists? completed-path)
(simplify-path completed-path)
(loop (dirname dir) (build-path 'up path)))))))
@ -33,8 +36,10 @@
#'(begin
(define base-name default-value)
(define fail-thunk-name (λ _ base-name))
(define current-name (λ _ (with-handlers ([exn:fail? fail-thunk-name])
(dynamic-require `(submod ,(get-path-to-override) config-submodule) 'base-name fail-thunk-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) config-submodule) 'base-name fail-thunk-name))))))]))
(define-settable pollen-version "0.1508")
@ -96,6 +101,7 @@
(define-settable extension-escape-char #\_)
(define-settable compile-cache-active #t)
(define-settable render-cache-active #t)
(define-settable compile-cache-max-size (* 10 1024 1024)) ; = 10 megabytes
(define-settable unpublished-path? (λ(path) #f))

Loading…
Cancel
Save