[Borges-users] Dynamically creating images with Borges
Michael Neumann
mneumann at ntecs.de
Mon May 3 19:00:52 EDT 2004
On Mon, May 03, 2004 at 03:29:30PM -0700, Eric Hodel wrote:
> Michael Neumann (mneumann at ntecs.de) wrote:
>
> > On Tue, May 04, 2004 at 12:24:34AM +0400, ??????? ???????? wrote:
> > > >>data = File.open('plasm.jpg') {|f| f.binmode; f.read} # we have some
> > > >>binary data
> > > >>r.image r.url_for_document(data,"image/jpeg") # we make the image's URL
> > > >>point to this data, with a mime-type
> > > >
> > > >Hm, this way the image is the same for all sessions, isn't it? And the
> > > >URL will not be reclaimed (it will stay forever).
> > >
> > > Instead of opening a file, you can fill 'data' with binary data for
> > > the image in some other way. (Capture the output from an SVG renderer,
> > > for example.) The image will be different between different calls to
> > > Controller#render_on (i.e. between different page renders). You can
> > > use some session-specific data to build the image from it, etc. Isn't
> > > this what you want? (This way, you don't really need the proc - you
> > > generate the image data when the page loads, and store it for later
> > > retrieval with #url_for_document.)
> >
> > Yes, that's exactly what I want.
> >
> > Is there an easy way to access any extra arguments given at the end of
> > the URL?
> >
> > For now I've solved it this way:
> >
> > class Borges::Session
> > attr_reader :request
> > alias old_handle_request handle_request
> > def handle_request(req)
> > @request = req
> > old_handle_request(req)
> > end
> > end
> >
> >
> > and then inside render_on, I access it via "session.request.fields".
>
> Would client-side image maps work for you? These can be easily
> added to the Renderer.
Not really, as I want the x,y positions of a mouse click. But it's
working now (I can now "draw" images within a webbrowser :-).
> > But I noticed that Request#fields seems to be wrong. In my case it
> > contains "?4?x,y". The "?4" is part of the anchor link (the ?x,y is the
> > x and y coordinates of the mouse click).
>
> What browser are you using? I wonder if it is not joining the
> portions of the GET args correctly.
I tried Konqueror and Mozilla. Both show the same.
Regards,
Michael
More information about the Borges-users
mailing list