[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Problem with Rails and embedded SVG?

Williams, Chris

12/3/2004 2:52:00 PM

> -----Original Message-----
> From: Florian Gross [mailto:flgr@ccan.de]
> Sent: Thursday, December 02, 2004 4:53 PM
> To: ruby-talk@ruby-lang.org
> Subject: Re: Problem with Rails and embedded SVG?
>
> Williams, Chris wrote:
>
> > How can I easily [view http headers]? I'm not sure how to check...
>
> http://livehttpheaders.m... if you use Firefox. Or just do a HTTP
> request with telnet or dump the HTTP headers with wget -s.

Well, after some googling I found a suitable hack to embed the SVG.

I took a look at the way Tobias Reif is serving his SVG on
http://www.pinkjuice.com/howt...

The only hack that works well (for me) is to write a ruby file which when
executed forces the content-type to "image/svg+xml" and writes out the SVG
graph. So I dynamically create this ruby file and then point to it as the
data source for the object tag.

<object type="image/svg+xml" data="/rails/chart_svg.cgi?IEHack=.svg"
width="800" height="600"></object>

In my case, with rails and my setup, I had to make the ruby file have a .cgi
extension to make it executable.

This works very well, and is much more palatable compared to my previous
hack of keeping a static html page pointing at the SVG file.

Chris


1 Answer

Jeremy Kemper

12/3/2004 5:32:00 PM

0

Williams, Chris wrote:
> Well, after some googling I found a suitable hack to embed the SVG.

This might help.

In public/.htaccess:
# Strip .svg extension to mollify IE (put above other rules)
RewriteRule ^(.*)\.svg$ $1

In app/controllers/foo_controller.rb:
class FooController < AbstractApplicationController
def index; end
def chart
send_data generate_svg_chart, :type => 'image/svg+xml'
end
end

In app/views/foo/index.rhtml:
<object type="image/svg+xml" data="<%= url_for :action => 'chart'
%>.svg" width="800" height="600"></object>

Best,
jeremy