Dynamic text highlighting

Hi,

consider following situation:

I want to load an external site A.html in an iframe. As far, no problem.

But now, I want to load it with words hightlighted on it, like Google’s
cache result pages. Unfortunately, the decision, which words should
highlighted is done on run time.

Is it possible to replace the original content with my content on the
fly?

Thanks.

Best regards,
Tomas

On 28 Apr 2007, at 13:51, Tomas F. wrote:

I want to load an external site A.html in an iframe. As far, no
problem.

But now, I want to load it with words hightlighted on it, like
Google’s
cache result pages. Unfortunately, the decision, which words should
highlighted is done on run time.

Is it possible to replace the original content with my content on the
fly?

Yes, you can do that if you route the request/response through your
Rails app.

E.g. in your index action, make a Net::HTTP request to your external
site, gsub the response’s body to your heart’s content, then send the
end result to the browser.

If you want the user to be able to navigate around the external site,
you’ll have to rewrite all the hyperlinks so that they point back to
your own action, with the real path stored in a param somewhere, so
your action can make another HTTP request to the appropriate part of
the external site, gsub the response’s body (including hyperlinks)
and send the result to the browser.

Regards,
Andy S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs