Calling a ruby script from javascript

Here’s the situation: I need to call in an RSS feed to display on a
page, and am using the jfeed plugin for jquery to parse the feed and
display it, however, it will only parse a local feed, so in order to
parse a remote one, you need a proxy.

jfeed itself comes with an example proxy written in PHP, fine, but I’m
developing a rails-based website.

So here is my question: is there a way I can call the ruby script, in
a similar way to how you can call a php script, passing a parameter to
it and then using the result?

The example given by jfeed is: url: ‘proxy.php?url=http://
jfhovinne

(normally this should be the url of the feed, but if it’s external you
need the proxy)

If there is no way of doing this, is there a similar way to do it?
Perhaps using AJAX?

Any help would be gratefully appreciated, I’m a bit stumped.

Thanks,

Mark

On 13 Aug 2008, at 14:13, Mark wrote:

a similar way to how you can call a php script, passing a parameter to

Any help would be gratefully appreciated, I’m a bit stumped.

That should work fine. Just add an appropriate controller & action
that load the specified url for you
You might find that rails is a bit heavy-weight for that, a mongrel
handler or something similar might be a better match. Be careful not
to turn yourself into an open relay.

Fred

On 13 Aug 2008, at 14:28, Mark wrote:

you
handler or something similar might be a better match. Be careful not
saying I should code it into the rails app? How would I go about
calling that via javascript?

If you’ve got it setup so that apache (or whatever) will execute your
ruby script when you hit it at the right url then you don’t need to
put it in the app.

If it were in your app then you’d just tell your javascript to hit
proxy/?url=http://www.hovinne.com/feed/
assuming your controller is called proxy and that the index action
does the proxying,

Fred

it and then using the result?
Any help would be gratefully appreciated, I’m a bit stumped.

That should work fine. Just add an appropriate controller & action
that load the specified url for you
You might find that rails is a bit heavy-weight for that, a mongrel
handler or something similar might be a better match. Be careful not
to turn yourself into an open relay.

Fred

Sorry Fred I’m not sure what you mean, maybe I should explain a bit
more about where I am: I’ve got a ruby script that will load the feed
and output the xml code, and I want to have that returned xml parsed
by jfeed.

At the moment this ruby script lives in my public folder, are you
saying I should code it into the rails app? How would I go about
calling that via javascript?

Thanks for your help.