I am developing a website that does not use AJAX. What I would like to be able to do on the server side is find the point in RoR (assuming it exists) where the HTML is "rendered" and capture that string so that I can manipulate it for my purposes. To be a little clearer, the user at their browser can do a View Page Source and then save that HTML to a file. I would like to generate (i.e. capture) exactly the contents of that string/file on the server side so that I can save it on the SERVER. I am not asking for the client to send back the contents of the View Page Source back to the server. I do not wish to interfere with the sending of the HTML to the client. I just want to get a copy of that HTML so that I can save it to a file on the server and have that file have exactly the same contents as a View Page Source and then Save File as that file would be on the client. Is this possible and/or easy to do? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Nov 20, 4:19 pm, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I am developing a website that does not use AJAX. > > What I would like to be able to do on the server side is find the point > in RoR (assuming it exists) where the HTML is "rendered" and capture > that string so that I can manipulate it for my purposes. > > To be a little clearer, the user at their browser can do a View Page > Source and then save that HTML to a file. I would like to generate > (i.e. capture) exactly the contents of that string/file on the server > side so that I can save it on the SERVER. > > Is this possible and/or easy to do? >You could probably do that from an after_filter - you should be able to play around with response.body. Fred> -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Perhaps try to override the content-type: @headers["Content-Type"] = "text/plain; charset=utf-8" Let us know if it works. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
"José Mota" <josemota.net-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote in post #962911:> Perhaps try to override the content-type: > > @headers["Content-Type"] = "text/plain; charset=utf-8" > > Let us know if it works.I''m sorry, Jose, I do not understand this at all. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung wrote in post #962809:> On Nov 20, 4:19pm, Ralph Shnelvar <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> Is this possible and/or easy to do? >> > > You could probably do that from an after_filter - you should be able > to play around with response.body. > > FredFred, this is _exactly_ what I wanted! Thanks. - - - For information about after_filer, see page 485 in *Agile Web Development in Rails* by Dave Thomas. For the clueless (me), here''s a code snippet that works for me class MarketingController < ApplicationController include ApplicationHelper after_filter :write_response_body . . . protected @@prefix = ''f:/xxx/'' def write_response_body puts "#{__FILE__} @ #{__LINE__}" # puts response.body.length html_file_name_to_save @@prefix + params[''controller''] + ''/'' + params[''action''] + ''.html'' File.open(html_file_name_to_save,"w") { |f| f << response.body } end end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ralph Shnelvar wrote in post #962803:> I am developing a website that does not use AJAX. > > What I would like to be able to do on the server side is find the point > in RoR (assuming it exists) where the HTML is "rendered" and capture > that string so that I can manipulate it for my purposes. > > To be a little clearer, the user at their browser can do a View Page > Source and then save that HTML to a file. I would like to generate > (i.e. capture) exactly the contents of that string/file on the server > side so that I can save it on the SERVER. > > I am not asking for the client to send back the contents of the View > Page Source back to the server. I do not wish to interfere with the > sending of the HTML to the client. I just want to get a copy of that > HTML so that I can save it to a file on the server and have that file > have exactly the same contents as a View Page Source and then Save File > as that file would be on the client. > > Is this possible and/or easy to do?Sure. Use render_to_string. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.