[Borges-users] Dynamically creating images with Borges

Eric Hodel drbrain at segment7.net
Mon May 3 18:29:30 EDT 2004


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.

> 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.

-- 
Eric Hodel - drbrain at segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/borges-users/attachments/20040503/1d78a071/attachment.bin


More information about the Borges-users mailing list