Revert "Revert "wtf""

This reverts commit 7f6afa4c57.
pull/9/head
Matthew Butterick 11 years ago
parent c6a0a7c41d
commit 8b0de59142

@ -1,7 +1,7 @@
#lang racket/base
(require racket/contract racket/match racket/list xml racket/set)
(require (prefix-in html: "library/html.rkt"))
(require "world.rkt" "readability.rkt" "file-tools.rkt")
(require "world.rkt" "readability.rkt" "file-tools.rkt" "debug.rkt")
(module+ test (require rackunit))

@ -55,7 +55,7 @@
(define/contract (file->ptree p)
(pathish? . -> . ptree?)
(define path (->path p))
(message "Loading ptree file" (->string (file-name-from-path path)))
;; (message "Loading ptree file" (->string (file-name-from-path path)))
(dynamic-rerequire path)
(dynamic-require path MAIN_POLLEN_EXPORT))

@ -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")]
@ -345,9 +345,8 @@
;; Therefore no way to arbitrarily invoke template at run-time.
;; This routine creates a new namespace and compiles the template within it.
(render-through-eval
source-dir
`(begin
(define string-to-eval
`(begin
;; for include-template (used below)
(require web-server/templates)
;; for ptree navigation functions, and template commands
@ -356,14 +355,16 @@
(require ,(->string source-name))
(parameterize ([current-ptree (make-project-ptree ,PROJECT_ROOT)]
[current-url-context ,PROJECT_ROOT])
(include-template #:command-char ,TEMPLATE_FIELD_DELIMITER ,(->string template-name))))))
(include-template #:command-char ,TEMPLATE_FIELD_DELIMITER ,(->string template-name)))))
(render-through-eval source-dir string-to-eval))
;; render files listed in a ptree file
(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)))

@ -35,9 +35,10 @@
(define/contract (logger req)
(request? . -> . void?)
(define client (request-client-ip req))
(define localhost-client "::1")
(define url-string (url->string (request-uri req)))
(message "Request:" (string-replace url-string DASHBOARD_NAME " dashboard")
"from" (if (equal? client "::1") "localhost" client)))
(if (not (equal? client localhost-client)) (format "from ~a" client) "")))
;; pass string args to route, then
;; package route into right format for web server

Loading…
Cancel
Save