From 8b0de591429242a3985ccaf5cd98d9eb49d7f707 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 6 Feb 2014 17:47:34 -0800 Subject: [PATCH] Revert "Revert "wtf"" This reverts commit 7f6afa4c57ef6caa021bcac6aa6a8882efd01bc4. --- predicates.rkt | 2 +- ptree.rkt | 2 +- render.rkt | 13 +++++++------ server-routes.rkt | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/predicates.rkt b/predicates.rkt index 31a9f5c..930ad6e 100644 --- a/predicates.rkt +++ b/predicates.rkt @@ -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)) diff --git a/ptree.rkt b/ptree.rkt index 471ab9a..83aacc1 100644 --- a/ptree.rkt +++ b/ptree.rkt @@ -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)) diff --git a/render.rkt b/render.rkt index fc96907..04e6d12 100644 --- a/render.rkt +++ b/render.rkt @@ -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))) diff --git a/server-routes.rkt b/server-routes.rkt index 25a61d1..536fd5b 100644 --- a/server-routes.rkt +++ b/server-routes.rkt @@ -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