improve image/rp

pull/27/head
Matthew Butterick 10 years ago
parent 4b6d67d68d
commit dba97e6fd1

@ -1,5 +1,5 @@
#lang racket/base
(require (for-syntax racket/base) scribble/core scribble/base scribble/manual racket/list scribble/private/manual-sprop scribble/decode scribble/html-properties racket/runtime-path racket/string)
(require (for-syntax racket/base racket/syntax) scribble/core scribble/base scribble/manual racket/list scribble/private/manual-sprop scribble/decode scribble/html-properties racket/runtime-path racket/string)
(provide (all-defined-out))
@ -47,7 +47,8 @@
(define-syntax (image/rp stx)
(syntax-case stx ()
[(_ name) #'(image/rp name 1.0)]
[(_ name scale) #'(begin
(define-runtime-path rp name)
(image rp #:scale scale))]))
[(_ name xs ...)
(with-syntax ([id (generate-temporary)])
#'(begin
(define-runtime-path id name)
(image id xs ...)))]))

@ -167,7 +167,7 @@ The border is too.
The project server is a web server built into Pollen. Just as DrRacket lets you run individual files and see if they work as you expect, the project server lets you preview and test your project as a real website. While working on your Pollen project, you may find it convenient to have DrRacket open on half your screen, and on the other half, a web browser pointing at the project server.
@image/rp["project-server.png" 0.7]
@image/rp["project-server.png" #:scale 0.7]
``Why can't I just open the HTML files directly in my browser?'' If you want to keep making web pages the way we did in 1996, go ahead. But that approach has several shortcomings. First, when you open files directly in your browser, you're cruising the local filesystem, and absolute URLs (the kind that start with a @litchar{/}) won't work. Second, if you want to test your website on devices other than your own machine — well, you can't. Third, you have to render your HTML files in advance, whereas the project server is clever about doing this dynamically.
@ -602,7 +602,7 @@ What do we expect to see? We expect that the @racketfont{padding} and @racketfon
And indeed, when you @link["http://localhost:8080/poem.html"]{reload the file} in the project server, you'll see exactly that:
@image/rp["result.png" 0.7]
@image/rp["result.png" #:scale 0.7]
As before, if you edit the values of the variables in the source file and reload in the project server, you'll see both the text and the layout change.

Loading…
Cancel
Save