change naming convention for pollen source to source.html.p

pull/9/head
Matthew Butterick 11 years ago
parent 4e61ad85a5
commit 7022734a97

@ -180,15 +180,15 @@
(path? . -> . path?) (path? . -> . path?)
(remove-ext path)) (remove-ext path))
(define/contract (make-pollen-output-path thing ext) (define/contract (make-pollen-output-path thing)
(pathish? (or/c string? symbol?) . -> . path?) (pathish? . -> . path?)
(add-ext (remove-ext (->path thing)) ext)) (remove-ext (->path thing)))
(module+ test (module+ test
(check-equal? (make-pollen-output-path (->path "foo.p") 'html) (->path "foo.html")) (check-equal? (make-pollen-output-path (->path "foo.html.p")) (->path "foo.html"))
(check-equal? (make-pollen-output-path (->path "/Users/mb/git/foo.p") 'html) (->path "/Users/mb/git/foo.html")) (check-equal? (make-pollen-output-path (->path "/Users/mb/git/foo.html.p")) (->path "/Users/mb/git/foo.html"))
(check-equal? (make-pollen-output-path "foo" 'xml) (->path "foo.xml")) (check-equal? (make-pollen-output-path "foo.xml.p") (->path "foo.xml"))
(check-equal? (make-pollen-output-path 'foo 'barml) (->path "foo.barml"))) (check-equal? (make-pollen-output-path 'foo.barml.p) (->path "foo.barml")))
;; turns input into corresponding pollen source path ;; turns input into corresponding pollen source path
;; does not, however, validate that new path exists ;; does not, however, validate that new path exists
@ -196,10 +196,14 @@
;; 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 (make-pollen-source-path thing) (define/contract (make-pollen-source-path thing)
(pathish? . -> . path?) (pathish? . -> . path?)
(add-ext (remove-ext (->path thing)) POLLEN_SOURCE_EXT)) (define path (->path thing))
(if (pollen-source? path)
path
(add-ext path POLLEN_SOURCE_EXT)))
(module+ test (module+ test
(check-equal? (make-pollen-source-path (->path "foo.p")) (->path "foo.p")) (check-equal? (make-pollen-source-path (->path "foo.p")) (->path "foo.p"))
(check-equal? (make-pollen-source-path (->path "foo.html")) (->path "foo.html.p"))
(check-equal? (make-pollen-source-path "foo") (->path "foo.p")) (check-equal? (make-pollen-source-path "foo") (->path "foo.p"))
(check-equal? (make-pollen-source-path 'foo) (->path "foo.p"))) (check-equal? (make-pollen-source-path 'foo) (->path "foo.p")))

@ -27,10 +27,7 @@
[files (map remove-ext (filter (λ(x) (has-ext? x POLLEN_SOURCE_EXT)) files))]) [files (map remove-ext (filter (λ(x) (has-ext? x POLLEN_SOURCE_EXT)) files))])
;; make a POLLEN_TREE_ROOT_NAME structure and convert it to a full ptree ;; make a POLLEN_TREE_ROOT_NAME structure and convert it to a full ptree
(message "Generating ptree from file listing") (message "Generating ptree from file listing")
(ptree-root->ptree (cons POLLEN_TREE_ROOT_NAME (map path->string files)))))) (ptree-root->ptree (cons POLLEN_TREE_ROOT_NAME (map path->pnode files))))))
(define project-ptree (make-project-ptree))
;; remove parents from tree (i.e., just remove attrs) ;; remove parents from tree (i.e., just remove attrs)
;; is not the inverse of add-parents, i.e., you do not get back your original input. ;; is not the inverse of add-parents, i.e., you do not get back your original input.
@ -218,16 +215,17 @@
;; convert path to pnode ;; convert path to pnode
;; used for converting "here" values to pnodes ;; used for converting "here" values to pnodes
(define/contract (here->pnode x) (define/contract (path->pnode x)
(pathish? . -> . pnode?) (pathish? . -> . pnode?)
(->string (remove-all-ext (last (explode-path (->path x)))))) (->string (remove-all-ext (last (explode-path (->path x))))))
(module+ test (module+ test
(check-equal? (here->pnode "bar") "bar") (check-equal? (path->pnode "bar") "bar")
(check-equal? (here->pnode "foo/bar") "bar") (check-equal? (path->pnode "foo/bar") "bar")
(check-equal? (here->pnode "foo/bar.html") "bar") (check-equal? (path->pnode "foo/bar.html") "bar")
(check-equal? (here->pnode "/Users/this/that/foo/bar.html.pp") "bar")) (check-equal? (path->pnode "/Users/this/that/foo/bar.html.pp") "bar"))
(define here->pnode path->pnode)
;; convert key to URL ;; convert key to URL
;; = key name + suffix of template (or suffix of default template) ;; = key name + suffix of template (or suffix of default template)
@ -237,3 +235,7 @@
(pnode? . -> . string?) (pnode? . -> . string?)
(string-append key ".html")) (string-append key ".html"))
;; this project setup must follow definitions to prevent undefined errors
(define project-ptree (make-project-ptree))

@ -263,8 +263,8 @@
;; refresh template (it might have its own preprocessor file) ;; refresh template (it might have its own preprocessor file)
(regenerate template-path #:force force) (regenerate template-path #:force force)
;; calculate new path for generated file: base from source + ext from template ;; calculate new path for generated file
(define output-path (make-pollen-output-path source-path (get-ext template-path))) (define output-path (make-pollen-output-path source-path))
;; 2) Regenerate the source file with template, if needed. ;; 2) Regenerate the source file with template, if needed.
;; Regenerate is expensive, so we avoid it when we can. ;; Regenerate is expensive, so we avoid it when we can.

Loading…
Cancel
Save