add image/rp function to docs

pull/27/head
Matthew Butterick 10 years ago
parent db358117ab
commit 1cd8968a45

File diff suppressed because one or more lines are too long

@ -1,5 +1,5 @@
#lang racket/base
(require 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) 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))
@ -43,4 +43,11 @@
(define (noskip-note)
(nested #:style (style "noskip" (list (css-style-addition mb-css) (alt-tag "div")))
(margin-note "Dont skip this section! It explains a concept that's essential to understanding how Pollen works.")))
(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))]))

@ -167,8 +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.
@(define-runtime-path project-server "project-server.png")
@image[project-server #:scale 0.7]
@image/rp["project-server.png" 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.
@ -271,8 +270,7 @@ Then, in your web browser, visit @link["http://localhost:8080/index.ptree"]{@rac
You should see something like this:
@(define-runtime-path dashboard "dashboard.png")
@image[dashboard #:scale 1]
@image/rp["dashboard.png"]
The top line tells us that we're in the root directory of the project. We didn't make an explicit @racketfont{index.ptree} file, so the project server just shows us a directory listing.
@ -604,9 +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:
@(define-runtime-path result "result.png")
@image[result #:scale 0.7]
@image/rp["result.png" 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