rename pollen-source to decoder-source

pull/9/head
Matthew Butterick 11 years ago
parent af2209a0ba
commit f7f5a10694

@ -32,7 +32,7 @@ polcom [filename] (renders individual file)")]
(define (pollen-related-file? file) (define (pollen-related-file? file)
(ormap (λ(proc) (proc file)) (list (ormap (λ(proc) (proc file)) (list
pollen-source? decoder-source?
preproc-source? preproc-source?
template-source? template-source?
ptree-source? ptree-source?

@ -196,9 +196,9 @@
(any/c . -> . boolean?) (any/c . -> . boolean?)
(file-exists? (->preproc-source-path (->path x)))) (file-exists? (->preproc-source-path (->path x))))
(define/contract (has-pollen-source? x) (define/contract (has-decoder-source? x)
(any/c . -> . boolean?) (any/c . -> . boolean?)
(file-exists? (->pollen-source-path (->path x)))) (file-exists? (->decoder-source-path (->path x))))
(define/contract (needs-preproc? x) (define/contract (needs-preproc? x)
(any/c . -> . boolean?) (any/c . -> . boolean?)
@ -209,7 +209,7 @@
(any/c . -> . boolean?) (any/c . -> . boolean?)
; it's a pollen source file ; it's a pollen source file
; or a file (e.g., html) that has 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) (define/contract (ptree-source? x)
@ -222,13 +222,13 @@
(define/contract (pollen-source? x) (define/contract (decoder-source? x)
(any/c . -> . boolean?) (any/c . -> . boolean?)
(has-ext? x DECODER_SOURCE_EXT)) (has-ext? x DECODER_SOURCE_EXT))
(module+ test (module+ test
(check-true (pollen-source? "foo.pd")) (check-true (decoder-source? "foo.pd"))
(check-false (pollen-source? "foo.p"))) (check-false (decoder-source? "foo.p")))
(define/contract (template-source? x) (define/contract (template-source? x)
@ -271,7 +271,7 @@
(define/contract (->output-path x) (define/contract (->output-path x)
(pathish? . -> . path?) (pathish? . -> . path?)
(->path (->path
(if (or (pollen-source? x) (preproc-source? x)) (if (or (decoder-source? x) (preproc-source? x))
(remove-ext x) (remove-ext x)
x))) x)))
@ -287,17 +287,17 @@
;; does not, however, validate that new path exists ;; 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 ;; 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) ;; 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?) (pathish? . -> . path?)
(->path (if (pollen-source? x) (->path (if (decoder-source? x)
x x
(add-ext x DECODER_SOURCE_EXT)))) (add-ext x DECODER_SOURCE_EXT))))
(module+ test (module+ test
(check-equal? (->pollen-source-path (->path "foo.pd")) (->path "foo.pd")) (check-equal? (->decoder-source-path (->path "foo.pd")) (->path "foo.pd"))
(check-equal? (->pollen-source-path (->path "foo.html")) (->path "foo.html.pd")) (check-equal? (->decoder-source-path (->path "foo.html")) (->path "foo.html.pd"))
(check-equal? (->pollen-source-path "foo") (->path "foo.pd")) (check-equal? (->decoder-source-path "foo") (->path "foo.pd"))
(check-equal? (->pollen-source-path 'foo) (->path "foo.pd"))) (check-equal? (->decoder-source-path 'foo) (->path "foo.pd")))
(define/contract (project-files-with-ext ext) (define/contract (project-files-with-ext ext)
(symbol? . -> . (listof complete-path?)) (symbol? . -> . (listof complete-path?))

@ -1,7 +1,7 @@
#lang racket/base #lang racket/base
(require (only-in scribble/reader make-at-reader) (require (only-in scribble/reader make-at-reader)
(only-in "../world.rkt" EXPRESSION_DELIMITER) (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] (provide (rename-out [mb-read read]
[mb-read-syntax read-syntax]) [mb-read-syntax read-syntax])
@ -26,8 +26,8 @@
(define i (read-inner path-string p)) (define i (read-inner path-string p))
(datum->syntax i (datum->syntax i
;; select pollen dialect based on file type ;; select pollen dialect based on file type
`(module pollen-lang-module ,(if (or (preproc-source? path-string) (unsaved-source? path-string)) `(module pollen-lang-module ,(if (or (decoder-source? path-string) (ptree-source? path-string))
'pollen/main-preproc 'pollen/main
'pollen/main) 'pollen/main-preproc)
,@i) ,@i)
i)) i))

@ -212,18 +212,18 @@
;; this becomes the return value ;; this becomes the return value
(->boolean (> (len (get-output-string port-for-catching-file-info)) 0))) (->boolean (> (len (get-output-string port-for-catching-file-info)) 0)))
(define (complete-pollen-source-path x) (define (complete-decoder-source-path x)
(->complete-path (->pollen-source-path (->path x)))) (->complete-path (->decoder-source-path (->path x))))
;; apply template ;; apply template
(define/contract (render-with-template x [template-name #f] #:force [force #f]) (define/contract (render-with-template x [template-name #f] #:force [force #f])
(((and/c pathish? (((and/c pathish?
(flat-named-contract 'file-exists (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?) (path? #:force boolean?) . ->* . void?)
;; set up information about source ;; 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 ;; todo: this won't work with source files nested down one level
(define-values (source-dir ignored also-ignored) (split-path source-path)) (define-values (source-dir ignored also-ignored) (split-path source-path))

@ -163,7 +163,7 @@
(define possible-sources (define possible-sources
(if (directory-exists? fn) (if (directory-exists? fn)
empty ;; folders don't have source files 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)))) (define source (and (not (empty? possible-sources)) (->string (car possible-sources))))
`(tr ,@(map make-link-cell `(tr ,@(map make-link-cell
(append (list (append (list

@ -16,8 +16,8 @@
(define/contract (puttable-item? x) (define/contract (puttable-item? x)
(any/c . -> . boolean?) (any/c . -> . boolean?)
(or (tagged-xexpr? x) (or (tagged-xexpr? x)
(has-pollen-source? x) (has-decoder-source? x)
(and (pnode->url x) (has-pollen-source? (pnode->url x))))) (and (pnode->url x) (has-decoder-source? (pnode->url x)))))
(define/contract (query-key? x) (define/contract (query-key? x)
(any/c . -> . boolean?) (any/c . -> . boolean?)
@ -28,8 +28,8 @@
(cond (cond
;; Using put has no effect on tagged-xexprs. It's here to make the idiom smooth. ;; Using put has no effect on tagged-xexprs. It's here to make the idiom smooth.
[(tagged-xexpr? x) x] [(tagged-xexpr? x) x]
[(has-pollen-source? x) (dynamic-require (->pollen-source-path x) 'main)] [(has-decoder-source? x) (dynamic-require (->decoder-source-path x) 'main)]
[(has-pollen-source? (pnode->url x)) (dynamic-require (->pollen-source-path (pnode->url x)) 'main)])) [(has-decoder-source? (pnode->url x)) (dynamic-require (->decoder-source-path (pnode->url x)) 'main)]))
(module+ test (module+ test
(check-equal? (put '(foo "bar")) '(foo "bar")) (check-equal? (put '(foo "bar")) '(foo "bar"))
@ -51,15 +51,15 @@
(define/contract (find-in-metas px key) (define/contract (find-in-metas px key)
(puttable-item? query-key? . -> . (or/c xexpr-elements? false?)) (puttable-item? query-key? . -> . (or/c xexpr-elements? false?))
(and (has-pollen-source? px) (and (has-decoder-source? px)
(let ([metas (dynamic-require (->pollen-source-path px) 'metas)] (let ([metas (dynamic-require (->decoder-source-path px) 'metas)]
[key (->string key)]) [key (->string key)])
(and (key . in? . metas ) (->list (get metas key)))))) (and (key . in? . metas ) (->list (get metas key))))))
(module+ test (module+ test
(parameterize ([current-directory "tests/template"]) (parameterize ([current-directory "tests/template"])
(check-equal? (find-in-metas "put" "foo") (list "bar")) (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)]) [here (find-in-metas 'put 'here)])
(check-equal? here (list "tests/template/put"))))) (check-equal? here (list "tests/template/put")))))

Loading…
Cancel
Save