[racket] normalize-response (in the context of web server)
What's wrong with that output? Is that you want display and not write?
On Tue, Apr 30, 2013 at 12:00 PM, J G Cho <gcho at fundingmatters.com> wrote:
> It seems like pages are built and saved to a table which looks like
>
> '#hasheq((#<procedure:static-page>
> .
> (html
> (head (title "My CV"))
> (body (p (a ((href "index.html")) "Dave Herman")))))
> (#<procedure:static-page>
> .
> (html
> (head (title "My Web Site"))
> (body (p "Check out my " (a ((href "cv.html")) "CV."))))))
>
> Then the values of the above are written out.
>
> Except in the code seems to "normalize" (html ...) and do a conditional to
> see full? vs incremental?.
>
> (define (write-page site page [out (current-output-port)])
> (let ([data (normalize-response #t (hash-ref (site-table site) page))])
> (cond
> [(response/full? data)
> (for ([bytes (response/full-body data)])
> (write-bytes bytes out))]
> [(response/incremental? data)
> (error 'write-page "incremental responses unsupported")])))
>
> I changed to
>
> (define (write-page site page [out (current-output-port)])
> (let ([data (hash-ref (site-table site) page)])
> (cond
> [(xexpr? data)
> (write (xexpr->string data) out)]
> [else
> (error 'write-page "incremental responses unsupported")])))
>
> Almost, but output is not quite right:
>
> "<html><head><title>My Web Site</title></head><body><p>Check out my <a
> href=\"cv.html\">CV.</a></p></body></html>"
>
>
> Any advice on how to do it correctly?
>
>
>
>
>
>
>
>
>
>
>
> On Tue, Apr 30, 2013 at 1:15 PM, Jay McCarthy <jay.mccarthy at gmail.com>
> wrote:
>>
>> That package is incredibly old and used internal functions of the Web
>> server. You'll have to look into what it was doing and update it to
>> the modern documented server.
>>
>> Jay
>>
>> On Tue, Apr 30, 2013 at 11:12 AM, J G Cho <gcho at fundingmatters.com> wrote:
>> > While trying out dherman's site generator (from
>> >
>> > planet.racket-lang.oracketg/package-source/dherman/static-page.plt/1/0/main.ss),
>> > the following error is thrown:
>> >
>> > normalize-response: unbound identifier
>> >
>> > This procedure does not turn up in Search Manuals. Is there way to
>> > fix/work
>> > around this?
>> >
>> > jGc
>> >
>> > ____________________
>> > Racket Users list:
>> > http://lists.racket-lang.org/users
>> >
>>
>>
>>
>> --
>> Jay McCarthy <jay at cs.byu.edu>
>> Assistant Professor / Brigham Young University
>> http://faculty.cs.byu.edu/~jay
>>
>> "The glory of God is Intelligence" - D&C 93
>
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93