From efe3a51843bda5e3cf006c4a97d547cebeb645e7 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 27 Aug 2015 13:45:52 -0700 Subject: [PATCH] make sure world settables can start in the right place --- cache.rkt | 4 +++- render.rkt | 2 ++ scribblings/world.scrbl | 2 ++ world.rkt | 16 +++++++++++----- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cache.rkt b/cache.rkt index 3677e18..02c0ac2 100644 --- a/cache.rkt +++ b/cache.rkt @@ -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)] diff --git a/render.rkt b/render.rkt index 6c31bd8..9f95c81 100644 --- a/render.rkt +++ b/render.rkt @@ -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])) diff --git a/scribblings/world.scrbl b/scribblings/world.scrbl index 823ee94..cd462b3 100644 --- a/scribblings/world.scrbl +++ b/scribblings/world.scrbl @@ -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.} diff --git a/world.rkt b/world.rkt index f51e260..c6efbb1 100644 --- a/world.rkt +++ b/world.rkt @@ -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))