Revert "wtf"

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

@ -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" "debug.rkt")
(require "world.rkt" "readability.rkt" "file-tools.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
[(ptree-source? path) (let ([ptree (dynamic-require path 'main)])
[(report (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,8 +345,9 @@
;; Therefore no way to arbitrarily invoke template at run-time.
;; This routine creates a new namespace and compiles the template within it.
(define string-to-eval
`(begin
(render-through-eval
source-dir
`(begin
;; for include-template (used below)
(require web-server/templates)
;; for ptree navigation functions, and template commands
@ -355,16 +356,14 @@
(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)))))
(render-through-eval source-dir string-to-eval))
(include-template #:command-char ,TEMPLATE_FIELD_DELIMITER ,(->string template-name))))))
;; 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 i #:force force))
(for-each (λ(i) (render (report 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,10 +35,9 @@
(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")
(if (not (equal? client localhost-client)) (format "from ~a" client) "")))
"from" (if (equal? client "::1") "localhost" client)))
;; pass string args to route, then
;; package route into right format for web server

Loading…
Cancel
Save