Revert "prevent caching of ptrees used as dashbaords"

This reverts commit 5bb2e5bc19.
pull/9/head
Matthew Butterick 10 years ago
parent 7f6afa4c57
commit b972f262d0

@ -211,6 +211,13 @@
; or a file (e.g., html) that has a pollen source file
(ormap (λ(proc) (proc (->path x))) (list pollen-source? has-pollen-source?)))
(define/contract (ptree-source? x)
(any/c . -> . boolean?)
(has-ext? x PTREE_SOURCE_EXT))
(module+ test
(check-true (ptree-source? "foo.ptree"))
(check-false (ptree-source? "ptree.bar")))
(define/contract (pollen-source? x)

@ -1,18 +1,10 @@
#lang racket/base
(require racket/contract racket/match xml/path racket/bool racket/rerequire)
(require racket/contract racket/match xml/path racket/bool)
(require "tools.rkt" "world.rkt" "debug.rkt" "decode.rkt")
(module+ test (require rackunit))
(provide pnode? ptree? ptree-source? parent children previous next pnode->url ptree-source-decode path->pnode ptree->list file->ptree make-project-ptree current-ptree current-url-context)
(define/contract (ptree-source? x)
(any/c . -> . boolean?)
((->path x) . has-ext? . PTREE_SOURCE_EXT))
(module+ test
(check-true (ptree-source? (format "foo.~a" PTREE_SOURCE_EXT)))
(check-false (ptree-source? (format "~a.foo" PTREE_SOURCE_EXT))))
(provide pnode? ptree? parent children previous next pnode->url ptree-source-decode path->pnode ptree->list file->ptree make-project-ptree current-ptree current-url-context)
(define/contract (pnode? x)
(any/c . -> . boolean?)
@ -56,7 +48,6 @@
(pathish? . -> . ptree?)
(define path (->path p))
(message "Loading ptree file" (->string (file-name-from-path path)))
(dynamic-rerequire path)
(dynamic-require path MAIN_POLLEN_EXPORT))
(define/contract (directory->ptree dir)

@ -116,7 +116,7 @@
;; and files without extension that correspond to p files
[(needs-template? path) (render-with-template path #:force force)]
;; this will catch ptree files
[(report (ptree-source? path)) (let ([ptree (dynamic-require path 'main)])
[(ptree-source? path) (let ([ptree (dynamic-require path 'main)])
(render-files-in-ptree ptree #:force force))]
[(equal? FALLBACK_TEMPLATE (->string (file-name-from-path path)))
(message "Render: using fallback template")]
@ -363,7 +363,7 @@
(define/contract (render-files-in-ptree ptree #:force [force #f])
((ptree?) (#:force boolean?) . ->* . void?)
;; pass force parameter through
(for-each (λ(i) (render (report i) #:force force))
(for-each (λ(i) (render i #:force force))
;; use dynamic-require to avoid requiring ptree.rkt every time render.rkt is required
((dynamic-require "ptree.rkt" 'all-pages) ptree)))

@ -18,10 +18,10 @@
(define (body-wrapper content-xexpr)
`(html
(head
(meta ([charset "UTF-8"]))
(link ([rel "stylesheet"]
[type "text/css"]
[href ,(format "/~a" DASHBOARD_CSS)])))
(meta ((charset "UTF-8")))
(link ((rel "stylesheet")
(type "text/css")
(href ,(format "/~a" DASHBOARD_CSS)))))
(body
,content-xexpr (div ((id "pollen-logo"))))))
@ -174,12 +174,12 @@
(cond ; in cell
[source (cons (format "in/~a" source) "in")]
[(or (ptree-source? filename) (sourceish? filename)) (cons (format "in/~a" filename) "in")]
[(or (has-ext? filename PTREE_SOURCE_EXT) (sourceish? filename)) (cons (format "in/~a" filename) "in")]
[else empty-cell])
(cond ; out cell
[(directory-exists? (build-path dir filename)) (cons #f #f)]
[(ptree-source? filename) empty-cell]
[(has-ext? filename PTREE_SOURCE_EXT) empty-cell]
[else (cons (format "out/~a" filename) "out")]))))))
(define (ineligible-path? x) (or (not (visible? x)) (member x RESERVED_PATHS)))
@ -188,14 +188,12 @@
(define output-paths (map ->output-path xs))
(define (unique-members xs) (set->list (list->set xs)))
(define all-paths (unique-members output-paths))
(define path-is-directory? (λ(f) (directory-exists? (build-path dir f))))
(define subdirectories (filter path-is-directory? all-paths))
(define files (filter-not path-is-directory? all-paths))
(define ptree-sources (filter ptree-source? files))
(define other-files (filter-not ptree-source? files))
(define built-directory-exists? (λ(f) (directory-exists? (build-path dir f))))
(define subdirectories (filter built-directory-exists? all-paths))
(define files (filter-not built-directory-exists? all-paths))
(define (sort-names xs) (sort xs #:key ->string string<?))
;; put subdirs in list ahead of files (so they appear at the top)
(append (sort-names subdirectories) (sort-names ptree-sources) (sort-names other-files)))
(append (sort-names subdirectories) (sort-names files)))
(define project-paths (filter-not ineligible-path? (if (file-exists? dashfile)
(map ->path (ptree->list (file->ptree dashfile)))

Loading…
Cancel
Save