From f7f5a1069499d5959bd48bb771717bb6d2c1dba9 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Fri, 7 Feb 2014 18:16:52 -0800 Subject: [PATCH] rename pollen-source to decoder-source --- command.rkt | 2 +- file-tools.rkt | 26 +++++++++++++------------- lang/reader.rkt | 8 ++++---- render.rkt | 8 ++++---- server-routes.rkt | 2 +- template.rkt | 14 +++++++------- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/command.rkt b/command.rkt index 6704790..4118aae 100644 --- a/command.rkt +++ b/command.rkt @@ -32,7 +32,7 @@ polcom [filename] (renders individual file)")] (define (pollen-related-file? file) (ormap (λ(proc) (proc file)) (list - pollen-source? + decoder-source? preproc-source? template-source? ptree-source? diff --git a/file-tools.rkt b/file-tools.rkt index e07f4c9..67c50a4 100644 --- a/file-tools.rkt +++ b/file-tools.rkt @@ -196,9 +196,9 @@ (any/c . -> . boolean?) (file-exists? (->preproc-source-path (->path x)))) -(define/contract (has-pollen-source? x) +(define/contract (has-decoder-source? x) (any/c . -> . boolean?) - (file-exists? (->pollen-source-path (->path x)))) + (file-exists? (->decoder-source-path (->path x)))) (define/contract (needs-preproc? x) (any/c . -> . boolean?) @@ -209,7 +209,7 @@ (any/c . -> . boolean?) ; it's a pollen source file ; or a file (e.g., html) that has a pollen source file - (ormap (λ(proc) (proc (->path x))) (list pollen-source? has-pollen-source?))) + (ormap (λ(proc) (proc (->path x))) (list decoder-source? has-decoder-source?))) (define/contract (ptree-source? x) @@ -222,13 +222,13 @@ -(define/contract (pollen-source? x) +(define/contract (decoder-source? x) (any/c . -> . boolean?) (has-ext? x DECODER_SOURCE_EXT)) (module+ test - (check-true (pollen-source? "foo.pd")) - (check-false (pollen-source? "foo.p"))) + (check-true (decoder-source? "foo.pd")) + (check-false (decoder-source? "foo.p"))) (define/contract (template-source? x) @@ -271,7 +271,7 @@ (define/contract (->output-path x) (pathish? . -> . path?) (->path - (if (or (pollen-source? x) (preproc-source? x)) + (if (or (decoder-source? x) (preproc-source? x)) (remove-ext x) x))) @@ -287,17 +287,17 @@ ;; does not, however, validate that new path exists ;; todo: should it? I don't think so, sometimes handy to make the name for later use ;; OK to use pollen source as input (comes out the same way) -(define/contract (->pollen-source-path x) +(define/contract (->decoder-source-path x) (pathish? . -> . path?) - (->path (if (pollen-source? x) + (->path (if (decoder-source? x) x (add-ext x DECODER_SOURCE_EXT)))) (module+ test - (check-equal? (->pollen-source-path (->path "foo.pd")) (->path "foo.pd")) - (check-equal? (->pollen-source-path (->path "foo.html")) (->path "foo.html.pd")) - (check-equal? (->pollen-source-path "foo") (->path "foo.pd")) - (check-equal? (->pollen-source-path 'foo) (->path "foo.pd"))) + (check-equal? (->decoder-source-path (->path "foo.pd")) (->path "foo.pd")) + (check-equal? (->decoder-source-path (->path "foo.html")) (->path "foo.html.pd")) + (check-equal? (->decoder-source-path "foo") (->path "foo.pd")) + (check-equal? (->decoder-source-path 'foo) (->path "foo.pd"))) (define/contract (project-files-with-ext ext) (symbol? . -> . (listof complete-path?)) diff --git a/lang/reader.rkt b/lang/reader.rkt index 9c866b4..00209c5 100644 --- a/lang/reader.rkt +++ b/lang/reader.rkt @@ -1,7 +1,7 @@ #lang racket/base (require (only-in scribble/reader make-at-reader) (only-in "../world.rkt" EXPRESSION_DELIMITER) - (only-in "../file-tools.rkt" preproc-source? unsaved-source?)) + (only-in "../file-tools.rkt" decoder-source? ptree-source?)) (provide (rename-out [mb-read read] [mb-read-syntax read-syntax]) @@ -26,8 +26,8 @@ (define i (read-inner path-string p)) (datum->syntax i ;; select pollen dialect based on file type - `(module pollen-lang-module ,(if (or (preproc-source? path-string) (unsaved-source? path-string)) - 'pollen/main-preproc - 'pollen/main) + `(module pollen-lang-module ,(if (or (decoder-source? path-string) (ptree-source? path-string)) + 'pollen/main + 'pollen/main-preproc) ,@i) i)) diff --git a/render.rkt b/render.rkt index f17102a..cddacc8 100644 --- a/render.rkt +++ b/render.rkt @@ -212,18 +212,18 @@ ;; this becomes the return value (->boolean (> (len (get-output-string port-for-catching-file-info)) 0))) -(define (complete-pollen-source-path x) - (->complete-path (->pollen-source-path (->path x)))) +(define (complete-decoder-source-path x) + (->complete-path (->decoder-source-path (->path x)))) ;; apply template (define/contract (render-with-template x [template-name #f] #:force [force #f]) (((and/c pathish? (flat-named-contract 'file-exists - (λ(x) (file-exists? (complete-pollen-source-path x)))))) + (λ(x) (file-exists? (complete-decoder-source-path x)))))) (path? #:force boolean?) . ->* . void?) ;; set up information about source - (define source-path (complete-pollen-source-path x)) + (define source-path (complete-decoder-source-path x)) ;; todo: this won't work with source files nested down one level (define-values (source-dir ignored also-ignored) (split-path source-path)) diff --git a/server-routes.rkt b/server-routes.rkt index 536fd5b..1c99484 100644 --- a/server-routes.rkt +++ b/server-routes.rkt @@ -163,7 +163,7 @@ (define possible-sources (if (directory-exists? fn) empty ;; folders don't have source files - (filter file-in-dir? (list (->preproc-source-path filename) (->pollen-source-path filename))))) + (filter file-in-dir? (list (->preproc-source-path filename) (->decoder-source-path filename))))) (define source (and (not (empty? possible-sources)) (->string (car possible-sources)))) `(tr ,@(map make-link-cell (append (list diff --git a/template.rkt b/template.rkt index 41a91f5..df7183f 100644 --- a/template.rkt +++ b/template.rkt @@ -16,8 +16,8 @@ (define/contract (puttable-item? x) (any/c . -> . boolean?) (or (tagged-xexpr? x) - (has-pollen-source? x) - (and (pnode->url x) (has-pollen-source? (pnode->url x))))) + (has-decoder-source? x) + (and (pnode->url x) (has-decoder-source? (pnode->url x))))) (define/contract (query-key? x) (any/c . -> . boolean?) @@ -28,8 +28,8 @@ (cond ;; Using put has no effect on tagged-xexprs. It's here to make the idiom smooth. [(tagged-xexpr? x) x] - [(has-pollen-source? x) (dynamic-require (->pollen-source-path x) 'main)] - [(has-pollen-source? (pnode->url x)) (dynamic-require (->pollen-source-path (pnode->url x)) 'main)])) + [(has-decoder-source? x) (dynamic-require (->decoder-source-path x) 'main)] + [(has-decoder-source? (pnode->url x)) (dynamic-require (->decoder-source-path (pnode->url x)) 'main)])) (module+ test (check-equal? (put '(foo "bar")) '(foo "bar")) @@ -51,15 +51,15 @@ (define/contract (find-in-metas px key) (puttable-item? query-key? . -> . (or/c xexpr-elements? false?)) - (and (has-pollen-source? px) - (let ([metas (dynamic-require (->pollen-source-path px) 'metas)] + (and (has-decoder-source? px) + (let ([metas (dynamic-require (->decoder-source-path px) 'metas)] [key (->string key)]) (and (key . in? . metas ) (->list (get metas key)))))) (module+ test (parameterize ([current-directory "tests/template"]) (check-equal? (find-in-metas "put" "foo") (list "bar")) - (let* ([metas (dynamic-require (->pollen-source-path 'put) 'metas)] + (let* ([metas (dynamic-require (->decoder-source-path 'put) 'metas)] [here (find-in-metas 'put 'here)]) (check-equal? here (list "tests/template/put")))))