[Borges-users] Dynamically creating images with Borges

Michael Neumann mneumann at ntecs.de
Mon May 3 17:32:35 EDT 2004


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

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

Thanks!


Regards,

  Michael


More information about the Borges-users mailing list