On Monday, May 16, 2011 7:08:11 PM UTC-6, Ruby-Forum.com User wrote:
There doesn’t seem to be any reference for taking HTML snapshots from
within a Rails server. I wonder how one could implement Google’s
crawlable AJAX spec
(http://code.google.com/web/ajaxcrawling/docs/learn-more.html)on a Rails
As always, there are several ways…
with lots of AJAX. I need Google to index the AJAX content, hence need
to implement the above spec. Now, I can send an AJAX request to Rails
for a link that the crawler asks; I need Rails server to respond with
HTML snapshot. Can this be handled on a single Rails running on nginx?
Or do we need to send the link to a HTMLUnit headless browser to take a
of new HTML content? Or, is your AJAX the kind mostly manipulates the
getting new HTML document fragments via XHR requests?
As the Google docs on the subject itself mentions, if it is the former
then you may want to consider a server-side “browser” like HTMLUnit.
Otherwise, you might want to focus more on your actual rails code. Even
within the framework of rails conventions, there is so much latitude in
sites implement AJAX applications that there are lots of possible
For example, I’ve got a rails app (its an older rails 2 app) that has
amount of AJAX. I first developed it statically and used “progressive
enhancement” techniques to add AJAX functionality. The result is that in
many cases I have controller actions that when executed may “return”
(render) either a full HTML document or a document fragment, depending
whether the request is an XHR. If I were updating this site (quick and
dirty) to support this Google spec., I’d simply make it so that said
return a full HTML document when an AJAX request has the special
However, I can conceive of several different techniques (and have used
different ones to various degrees) that would require a different
This might be an area that would be good for some kind of rails (and/or
rack) gem built around a specific set of AJAX conventions and design
patterns, that integrates or is solely written to implement this Google
spec. If, indeed, such a beast doesn’t already exist. Such a solution
still only work for those who want to, are willing to, or already do
to the chosen conventions. But, then, rails users do the same for web
dev. in general.
Anyone else care to let their mind wander too?